Commit a988d490120f23a46d0106dfb5aae2522d59c53d

Authored by teemitop
2 parents 06caa555 797d4639

Merge branch 'master' of http://123.56.79.57/najixian/xt_dc_admin

<?php
namespace app\admin\controller;
use think\Db;
use think\facade\Request;
class Area extends Common
{
/**
***代理商管理
***
**/
/**
* 商家list
*/
public function Seller(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$channel = @$key['channel'] ? @$key['channel'] : 1;
$address = @$key['address'] ? @$key['address'] : '';
$prov = @$key['prov'] ? @$key['prov'] : '';
$city = @$key['city'] ? @$key['city'] : '';
$area = @$key['area'] ? @$key['area'] : '';
$limit = '&x='.$data["page"].'&y='.$data["limit"].'&areaid=61&channel=4&address='.$address.'&prov='.$prov.'&city='.$city.'&area='.$area;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Agent.getSellerList'.$limit);
$array = json_decode($list,TRUE);
foreach ($array['data']['data'] as $key => $value) {
$array['data']['data'][$key]['cdate'] = date("Y-m-d H:i:s",$value['cdate']);
if($value['status']==1)
$array['data']['data'][$key]['statusVal'] = "启用";
else
$array['data']['data'][$key]['statusVal'] = "停用";
$c_name = array();
$t_name = array();
//2019-03-05 增加菜系配置、商家类型配置
if(is_array($value['cuisine'])){
foreach ($value['cuisine'] as $k => $v) {
$c_name[] = $v['name'];
}
}
if(is_array($value['type'])){
foreach ($value['type'] as $k => $v) {
$t_name[] = $v['type_name'];
}
}
if(!empty($c_name))
$array['data']['data'][$key]['cuisine'] = implode(',', $c_name);
if(!empty($t_name))
$array['data']['data'][$key]['type'] = implode(',', $t_name);
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['data'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'title','区域内商户维护');
return $this->fetch();
}
public function addagent(){
if(Request::isAjax()){
$data = Request::except('file');
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Agent.addAgent&areaid='.$data['areaid'].'&agent_name='.$data['agent_name'].'&agent_phone='.$data['agent_phone']);
$array = json_decode($list,TRUE);
return $result = ['code'=>0,'msg'=>'添加成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
}
$this->assign ( 'title','代理商管理');
return $this->fetch();
}
/**
* 商家list
*/
public function agent(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$channel = @$key['channel'] ? @$key['channel'] : 1;
$address = @$key['address'] ? @$key['address'] : '';
$prov = @$key['prov'] ? @$key['prov'] : '';
$city = @$key['city'] ? @$key['city'] : '';
$area = @$key['area'] ? @$key['area'] : '';
$limit = '';#'&x='.$data["page"].'&y='.$data["limit"];
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Agent.getAgentList'.$limit);
$array = json_decode($list,TRUE);
/*foreach ($array['data'][0]['data'] as $key => $value) {
$array['data'][0]['data'][$key]['cdate'] = date("Y-m-d H:i:s",$value['cdate']);
}*/
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
}
$this->assign ( 'title','代理商管理');
return $this->fetch();
}
/**
* 代理商运营list
*/
public function operate(){
if(Request::isAjax()){
$data = Request::except('file');
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Agent.getAgentOperate&areaid=2');
$array = json_decode($list,TRUE);
foreach ($array['data'] as $key => $value) {
$array['data'][$key]['cdate'] = date("Y-m-d H:i:s",$value['cdate']);
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
}
$this->assign ( 'title','代理商管理');
return $this->fetch();
}
/**
* 禁用运营
*/
public function setAgentOperate(){
if(Request::isAjax()){
$data = Request::except('file');
$list= file_get_contents(ON_LINE.'App.Agent.getAgentOperate&id='.$data['id']);
$array = json_decode($list,TRUE);
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
}
$this->assign ( 'title','代理商管理');
return $this->fetch();
}
//增加运营管理人员
public function operateAdd(){
//缓存60秒 不请求。
/*$arr = cache('qrcod_url');
if(!$arr){
$arr= file_get_contents("http://xt.colorcun.com/WechatApi/WechatApi/CreateOperateQrcode/");
$arr = json_decode($arr,TRUE);
cache('qrcod_url',$arr, 50);
}*/
$this->assign('qrcode_path','https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGx8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyTHVYdVF0QmZlR2oxMDAwMDAwN2oAAgQ84vpdAwQAAAAA');
return view();
}
/**
* 停用商家
*/
public function configStop(){
if(Request::isAjax()){
$data = Request::except('file');
$data['status'] = $data['status'] ? 0 : 1;
$list= file_get_contents(ON_LINE.'App.Seller.SetStopBySeller&sellerid='.$data['sellerid'].'&status='.$data['status']);
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请求错误!';
}
return $result;
}
return view();
}
/**
* 从商家维度统计:订单、短信等情况
*/
public function getStatistics(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$sid = $data['sid'] ? implode(',', $data['sid']) : '';
$sellername = $data['key'] ? $data['key'] : '';
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$stime = $time ? strtotime(date($time[0],time())) : '';
$etime = $time ? strtotime(date($time[1],time())) : '';
$data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;
$data['channel'] = $data['channel'] ? $data['channel'] : 1;
$parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Report.GetReserveData'.$parame);
$array = json_decode($list,TRUE);
$new_array = array();
foreach ($array['data'] as $key => $value) {
if(is_array($value)){
$new_array[$key]['id'] = $value['id'];
$new_array[$key]['sellername'] = $value['sellername'];
$new_array[$key]['contacts_total'] = $value['contacts_total'];
$new_array[$key]['inviting'] = $value['inviting'];
$new_array[$key]['reserve_count'] = $value['appReserveCount'] .'/'. $value['AndroidReserveCount'].'/'. $value['CReserveCount'];
$new_array[$key]['reserve_count_sort'] = $value['appReserveCount'] + $value['AndroidReserveCount'] + $value['CReserveCount'];
$new_array[$key]['sms_send_count'] = $value['appSmsCount'] .'/'. $value['AndroidSmsCount'];
$new_array[$key]['sms_send_count_sort'] = $value['appSmsCount'] + $value['AndroidSmsCount'];
$new_array[$key]['table_room_total'] = $value['table_total'] .'/'. $value['room_total'];
$new_array[$key]['address_component'] = $value['address_component']['province'] && $value['address_component']['city'] ? $value['address_component']['province'] .'-'. $value['address_component']['city'] : '无法获取地区,请检查经纬度是否正确!';
}
}
return $result = [
'code'=>0,'msg'=>'获取成功!',
'data'=>$new_array,
'count'=>$array['data']['total'],
'countReserve'=>$array['data']['appReserveCount']+$array['data']['AndroidReserveCount']+$array['data']['CReserveCount'],
'countSms'=>$array['data']['appSmsCount']+$array['data']['AndroidSmsCount'],
'inviteeCount'=>$array['data']['inviteeCount'],
'appReserveCount'=>$array['data']['appReserveCount'],
'AndroidReserveCount'=>$array['data']['AndroidReserveCount'],
'CReserveCount'=>$array['data']['CReserveCount'],
'appSmsCount'=>$array['data']['appSmsCount'],
'AndroidSmsCount'=>$array['data']['AndroidSmsCount'],
'Contacts'=>$array['data']['Contacts'],
'rel'=>1
];
}
$this->assign ( 'title','预定订单统计');
return $this->fetch();
}
/**
* 从设备(电话机)维度统计:订单、短信等情况
*/
public function getEquipment(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$sid = $data['sid'] ? implode(',', $data['sid']) : '';
$sellername = $data['key'] ? $data['key'] : '';
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$stime = $time ? strtotime(date($time[0],time())) : '';
$etime = $time ? strtotime(date($time[1],time())) : '';
$data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;
$data['channel'] = $data['channel'] ? $data['channel'] : 1;
$parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Report.GetReserveDataBydev'.$parame);
$array = json_decode($list,TRUE);
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'title','设备维度统计预定订单');
return $this->fetch();
}
/**
* 商家菜系、类型配置
*/
public function sellerconfig(){
$data = Request::except('file');
if(Request::isAjax()){
$cuisine = !empty($data['cuisine']) ? implode(',', array_keys($data['cuisine'])) : '';
$type = !empty($data['type']) ? implode(',', array_keys($data['type'])) : '';
$mode = !empty($data['mode']) ? implode(',', array_keys($data['mode'])) : '';
$sms_code = !empty($data['sms_code']) ? $data['sms_code'] : '';
$label = !empty($data['label']) ? implode(',', array_keys($data['label'])) : '';
$brand = !empty($data['brand']) ? implode(',', array_keys($data['brand'])) : '';
$label_1_ = !empty($data['label_1_']) ? implode(',', array_keys($data['label_1_'])) : '';
$label_2_ = !empty($data['label_2_']) ? implode(',', array_keys($data['label_2_'])) : '';
$label_3_ = !empty($data['label_3_']) ? implode(',', array_keys($data['label_3_'])) : '';
if($sms_code)
$res_sms_code= file_get_contents(ON_LINE.'App.SendSMS.SetSellerSmsTemplate&sid='.$data['sellerid'].'&sms_id='.$sms_code);
if($cuisine)
$res_cuisine= file_get_contents(ON_LINE.'App.Seller.SetSellerCuisine&sellerid='.$data['sellerid'].'&cid='.$cuisine);
//$res_cuisine = json_decode($res_cuisine,TRUE);
if($type)
$res_type= file_get_contents(ON_LINE.'App.Seller.SetSellerType&sellerid='.$data['sellerid'].'&typeid='.$type);
//$res_type = json_decode($res_type,TRUE);
if($mode)
$res_mode= file_get_contents(ON_LINE.'App.Seller.setSellerMode&sellerid='.$data['sellerid'].'&modeid='.$mode);
//$res_mode = json_decode($res_mode,TRUE);
if($label)
$res_label= file_get_contents(ON_LINE.'App.Seller.setSellerLabel&sid='.$data['sellerid'].'&field='.$label);
if($brand){
$del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel WHERE sid =".$data['sellerid']);
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel VALUES(".$data['sellerid'].",".$brand.")");
}
if($label_1_){
$del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel WHERE sid = ".$data['sellerid']." AND lcid in (SELECT id FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c WHERE pid = 1)");
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_1_.")");
}
if($label_2_){
$del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel WHERE sid = ".$data['sellerid']." AND lcid in (SELECT id FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c WHERE pid = 2)");
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_2_.")");
}
if($label_3_){
$del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel WHERE sid = ".$data['sellerid']." AND lcid in (SELECT id FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c WHERE pid = 3)");
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_3_.")");
}
if(isset($data['edition'])){
$up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_online_reserve = ".$data['edition']." where id = ".$data['sellerid']);
}
if(isset($data['is_tele'])){
$up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_tele = ".$data['is_tele']." where id = ".$data['sellerid']);
}
$result['code'] = 1;
$result['msg'] = "配置成功!";
return $result;
}
//获取商家已有菜系
$cuisine_list= file_get_contents(ON_LINE.'App.Seller.getSellerCuisine&sellerid='.$data['id']);
$cuisine_list = json_decode($cuisine_list,TRUE);
//获取所有菜系
$list= file_get_contents(ON_LINE.'App.Reserve.GetCustomerConfig');
$array = json_decode($list,TRUE);
//组装数据
foreach ($cuisine_list['data'] as $key => $value) {
foreach ($array['data']['cate'] as $k => $v) {
if($value['cid']==$v['id']){
$array['data']['cate'][$k]['checked'] = 1;
}
}
}
$this->assign('list',$array['data']['cate']);//获取所有菜系
//获取商家已有来源
$type_list= file_get_contents(ON_LINE.'App.Seller.GetSellerType&sellerid='.$data['id']);
$type_list = json_decode($type_list,TRUE);
//获取来源
$channel = array(array('id'=>1,'name'=>'合作'),array('id'=>2,'name'=>'推广'),array('id'=>3,'name'=>'测试'));
//组装数据
foreach ($type_list['data'] as $key => $value) {
foreach ($channel as $k => $v) {
if($value['type_id']==$v['id']){
$channel[$k]['checked'] = 1;
}
}
}
$this->assign('channel',$channel);//获取所有来源
//获取商家已有地图显示方式
$mode_list= file_get_contents(ON_LINE.'App.Seller.getSellerMode&sellerid='.$data['id']);
$mode_list = json_decode($mode_list,TRUE);
//获取所有地图显示方式
$mode= array(array('id'=>1,'name'=>'地图上大图标'),array('id'=>2,'name'=>'地图上文字'));
//组装数据
foreach ($mode_list['data'] as $key => $value) {
foreach ($mode as $k => $v) {
if($value['sm_id']==$v['id']){
$mode[$k]['checked'] = 1;
}
}
}
$this->assign('mode',$mode);//获取所有菜系
//获取商家已选短信模板
$template = file_get_contents(ON_LINE.'App.Reserve.SellerInfo&seller_id='.$data['id']);
$template = json_decode($template,TRUE);
//获取短信模板列表
$template_list = file_get_contents(ON_LINE.'App.SendSMS.GetSmsTemplate');
$template_list = json_decode($template_list,TRUE);
//组装数据
foreach ($template_list['data'] as $key => $value) {
if($value['template_code']==$template['data']['setting']['template_code']){
$template_list['data'][$key]['checked'] = 1;
}
switch ($value['template_code']) {
case 'SMS_163050401':
$vowels = array(
'周到安排演示店' => '${seller_name}',
'11月25日晚上18:00' => '${date}',
'金台夕照、卢沟晓月' =>'${region_room_name}',
'西电路447号南湖金地西门南100米' =>'${seller_addr}',
'18792581193' =>'${seller_phone}',
'毛毛' =>'${cusman}',
);
break;
case 'SMS_162733710':
$vowels = array(
'4月6日中午' => '${reserve_date}',
'周到1店西电路447号金台夕照' => '${seller_name_addr_room}',
'毛毛' =>'${cusman}',
);
break;
case 'SMS_154587043':
$vowels = array(
'侯先生' => '${guest}',
'周到安排演示店' => '${seller_name}',
'11月25日晚上18:00' =>'${date}',
'包间(金台夕照)' =>'${region_room_name}',
'西电路447号南湖金地西门南100米' =>'${seller_addr}',
'18792581193' =>'${seller_phone}\n',
'毛毛' =>'${cusman}',
);
break;
case 'SMS_164277855':
$vowels = array(
'周到1店西电路447号' => '${seller_name}',
'11月7日晚上18:30' => '${date}',
'包间(金台夕照)' =>'${region_room_name}',
'1879258119' =>'${seller_phone}',
);
break;
case 'SMS_164268239':
$vowels = array(
'周到安排演示店' => '${seller_name}',
'11月7日晚上18:30' => '${date}',
'包间(金台夕照)' =>'${region_room_name}',
'西电路447号南湖金地西门南100米' =>'${seller_addr}',
'1879258119' =>'${seller_phone}',
);
break;
default:
# code...
break;
}
$template_list['data'][$key]['content'] = str_replace($vowels, array_keys($vowels),$value['content']);
}
$this->assign('template_list',$template_list['data']);//获取短信模板列表
//获取商家拥有哪些标签
$label_list= file_get_contents(ON_LINE.'App.Seller.GetSellerLabel&sid='.$data['id']);
$label_list = json_decode($label_list,TRUE);
$this->assign('label_list',$label_list['data']);
//商家标签
//原生:
//$label_c=Db::query("SELECT * from xt-member-two-LINE.xt_dc_dz_seller_label_c");
$label_c=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c")->select();
$label_c_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c_rel")->where(array('sid'=>$data['id']))->select();
//组装数据
foreach ($label_c as $key => $value) {
foreach ($label_c_rel as $k => $v) {
if($value['id']==$v['lcid']){
$label_c[$key]['checked'] = 1;
}
}
}
$this->assign('label_c',$label_c);
//商家品牌
$brand=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand")->select();
$brand_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand_rel")->where(array('sid'=>$data['id']))->select();
//组装数据
foreach ($brand as $key => $value) {
foreach ($brand_rel as $k => $v) {
if($value['id']==$v['bid']){
$brand[$key]['checked'] = 1;
}
}
}
$this->assign('brand',$brand);
$is_online_reserve=Db::table("xt-member-two-LINE.xt_seller")->where(array('id'=>$data['id']))->select();
//获取商家在线预定版本情况
$this->assign('is_online_reserve',$is_online_reserve[0]['is_online_reserve']);
//是否安装电话机
$this->assign('is_tele',$is_online_reserve[0]['is_tele']);
//商户信息
$this->assign ('data',$data);
$this->assign ( 'title','商户信息配置' );
return $this->fetch();
}
/**
* 商家基础信息配置
*/
public function setsellerconfig(){
if(Request::isAjax()){
$data = Request::except('file');
$data['status'] = $data['status'] ? 0 : 1;
$list= file_get_contents(ON_LINE.'App.Seller.SetSellerConfigByPC&sid='.$data['sellerid'].'&field='.$data['field'].'&value='.$data['value']);
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请求错误!';
}
return $result;
}
return view();
}
/**
* 商家详情
*/
public function sellerdetail(){
//print_r(Request::except('file'));die;
$data = Request::except('file');
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Seller.GetSellerById&sellerid='.$data['sid']);
$array = json_decode($list,TRUE);
if($array['data']['data']){
$array['data']['data']['daily'] = json_decode($array['data']['data']['daily'],TRUE);
$array['data']['data']['daily_time'] = json_decode($array['data']['data']['daily_time'],TRUE);
$array['data']['data']['cdate'] = date("Y年m月d日 H时i分s秒",$array['data']['data']['cdate']);
}
//获取短信流水
$sms= file_get_contents(ON_LINE.'App.SendSMS.GetSellerSmsFlowing&sid='.$data['sid']);
$sms_data = json_decode($sms,TRUE);
$sms_data_list = $sms_data['data'] ? $sms_data['data'] : array();
$this->assign ( 'smslist',$sms_data_list);
$this->assign ( 'data',$array['data']['data']);
$this->assign ( 'title','商家详情页面');
return $this->fetch();
}
//商家列表 用于配置商家活动
public function seller_activity_list(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$channel = @$key['channel'] ? @$key['channel'] : 1;
$limit = '&x='.$data["page"].'&y='.$data["limit"].'&keywords='.@$key['id'].'&channel='.$channel;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Seller.GetSellerListByActivity'.$limit);
$array = json_decode($list,TRUE);
foreach($array['data'][0]['data'] as $key=>$value){
if(!empty($value['activity'])){
foreach ($value['activity'] as $k => $v) {
$str[$key][] = ($k+1).'、'.$v['title'];
}
$array['data'][0]['data'][$key]['activity'] = implode('<br/>', $str[$key]);
//$array['data'][0]['data'][$key]['activity'] = implode('<br/>', array_column($value['activity'], 'title'));
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'][0]['data'],'count'=>$array['data'][0]['total'],'rel'=>1];
}
$this->assign ( 'title','商家活动配置');
return $this->fetch();
}
/**
* 商家活动列表页
*/
public function seller_activity(){
$data = Request::except('file');
//获取商家现有活动
$seller_activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivity&sid='.$data['id']);
$seller_activity = json_decode($seller_activity,TRUE);
//活动列表
$this->assign('sid',$data['id']);
$this->assign ( 'seller_activity',$seller_activity['data']);
$this->assign ( 'title','商家活动配置页面');
return $this->fetch();
}
//添加活动
public function add_activity(){
$data = Request::except('file');
if(Request::isAjax()){
switch ($data['type']) {
case '1':
if($data['max_num']==0){
$data['title'] = '立减'.$data['min_num'];break;
}else{
$data['title'] = '满'.$data['max_num'].'立减'.$data['min_num'];break;
}
case '2':
$data['title'] = '满赠';
break;
case '3':
if($data['max_num']==0){
$data['title'] = $data['min_num'].'折';break;
}else{
$data['title'] = '满'.$data['max_num'].'立享'.$data['min_num'].'折';break;
}
case '4':
$data['title'] = $data['max_num'].'元代金券';
break;
case '5':
$data['title'] = '会员价';
break;
default:
# code...
break;
}
//字段空值过滤
//添加活动
$res= file_get_contents(ON_LINE.'App.Seller.SetActivity&str='.serialize($data));
$res = json_decode($res,TRUE);
if($data['aid']){
if($res['data']){
$result = ['code'=>1,'msg'=>'修改成功!','rel'=>1];
}else{
$result = ['code'=>0,'msg'=>'修改失败!','rel'=>1];
}
}else{
if($res['data']){
$result = ['code'=>1,'msg'=>'添加成功!','rel'=>1];
}else{
$result = ['code'=>0,'msg'=>'添加失败!','rel'=>1];
}
}
return $result;
}
if($data['id']){
//修改---需要获取对应的数据
$activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivityById&id='.$data['id']);
$activity = json_decode($activity,TRUE);
$this->assign ('data',$activity['data']);
$this->assign ( 'title','修改活动');
}
$this->assign ( 'hid',$data['sid']);
$this->assign ( 'title','添加活动');
return $this->fetch();
}
//删除活动
public function del_activity(){
$data = Request::except('file');
$res= file_get_contents(ON_LINE.'App.Seller.DelSellerActivity&sid='.$data['sid'].'&aid='.$data['aid']);
$res = json_decode($res,TRUE);
$this->redirect('Seller/seller_activity', ['id' => $data['sid']]);
//return $this->fetch('seller_activity',['id' => $data['sid']]);
}
//商家设备列表
public function device_list(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
if(Request::isAjax()){
$data = Request::except('file');
$channel = @$data['channel'] ? @$data['channel'] : 1;
$manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
$limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit); //GetSellerDevice
$array = json_decode($list,TRUE);
foreach ($array['data']['list'] as $key => $value) {
switch ($value['type']) {
case '0':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '1':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['type'] = 'error: '.$value['type'];
break;
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'facturer',$facturer);
$this->assign ( 'title','商家设备列表');
return $this->fetch();
}
//商家设备列表
public function add_gray_user(){
if(Request::isAjax()){
$data = Request::except('file');
$list= file_get_contents(ON_LINE.'App.Device.SetGrayUser&ids='.serialize($data['id']));
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '服务器错误,请勿重复将设备号添加到灰度用户!';
}
return $result;
}
return view();
}
//灰度用户列表
public function gray_user_list(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
$this->assign ( 'facturer',$facturer);
if(Request::isAjax()){
$data = Request::except('file');
$channel = @$data['channel'] ? @$data['channel'] : 1;
$manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
$limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
$list= file_get_contents(ON_LINE.'App.Device.GetGrayUserList'.$limit);
$array = json_decode($list,TRUE);
foreach ($array['data']['list'] as $key => $value) {
switch ($value['type']) {
case '1':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['type'] = 'error';
break;
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
$this->assign ( 'facturer',$facturer);
$this->assign ( 'title','灰度用户列表');
return $this->fetch();
}
//删除灰度用户
public function del_gray_user(){
if(Request::isAjax()){
$data = Request::except('file');
$list= file_get_contents(ON_LINE.'App.Device.DelGrayUser&jsstr='.serialize($data['id']));
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请刷新页面重新尝试!';
}
return $result;
}
return view();
}
//获取在线设备情况
public function get_device_online_status(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
if(Request::isAjax()){
$data = Request::except('file');
$channel = @$data['channel'] ? @$data['channel'] : 1;
$manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
$limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
$list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit);
$array = json_decode($list,TRUE);
foreach ($array['data']['list'] as $key => $value) {
switch ($value['type']) {
case '0':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '1':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['type'] = $value['type'];
break;
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'facturer',$facturer);
$this->assign ( 'title','商家话机在线设备列表');
return $this->fetch();
}
/**
* 从商家维度统计:订单、短信等情况
*/
public function GetReserveList(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$nokey= input('post.nokey') ? input('post.nokey') : "";
$sellername = $data['key'] ? $data['key'] : ''; //商家名称
$id = $data['nokey'] ? $data['nokey'] : ''; //订单ID
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$stime = $time ? strtotime(date($time[0],time())) : strtotime(date('Y-m-d 00:00:00',time()));
$etime = $time ? strtotime(date($time[1],time())) : strtotime(date('Y-m-d 23:59:59',time()));
$dtime = $data['dtime'] ? explode(' - ', $data['dtime']) : '';
$sdtime = $dtime ? strtotime(date($dtime[0],time())) : '';
$edtime = $dtime ? strtotime(date($dtime[1],time())) : '';
$data['status'] = $data['status'] ? $data['status'] : 2;
$data['channel'] = $data['channel'] ? $data['channel'] : 1;
$parame = '&offset='.$data["page"].'&limit='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&id='.$id.'&status='.@$data['status'].'&sdtime='.$sdtime.'&edtime='.$edtime;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Customer.GetReserveList'.$parame);
$array = json_decode($list,TRUE);
$new_array = array();
foreach ($array['data']['list'] as $key => $value) {
//有无设备
if($value['is_tele']==1){
switch ($value['type']) {
case '1':
$array['data']['list'][$key]['dv'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['dv'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['dv'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['dv'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['dv'] = '无';
break;
}
}else{
$array['data']['list'][$key]['dv'] = '无';
}
//订单接受时间段
switch ($value['ddate_solt']) {
//'未设置/早市/午市/晚市/夜宵 0/1/2/3/4',
case 0:
$value['ddate_solt'] = '未设置';
break;
case 1:
$value['ddate_solt'] = '早市';
break;
case 2:
$value['ddate_solt'] = '午市';
break;
case 3:
$value['ddate_solt'] = '晚市';
break;
case 4:
$value['ddate_solt'] = '夜宵';
break;
default:
# code...
break;
}
$array['data']['list'][$key]['ddate'] = date('Y-m-d H:i:s',$value['ddate']).'['.$value['ddate_solt'].']';
$array['data']['list'][$key]['cdate'] = date('Y-m-d H:i:s',$value['cdate']);
$array['data']['list'][$key]['handle_time'] = $value['handle_time'] ? date('Y-m-d H:i:s',$value['handle_time']) : '';
$array['data']['list'][$key]['rec_date'] = $value['rec_date'] ? date('Y-m-d H:i:s',$value['rec_date']) : '';
switch ($value['status']) {
case 0:
$array['data']['list'][$key]['sta'] = '待确认';
break;
case 1:
$array['data']['list'][$key]['sta'] = '已定座';
break;
case 2:
$array['data']['list'][$key]['sta'] = '到店';
break;
case 3:
$array['data']['list'][$key]['sta'] = '离店';
break;
case 4:
$array['data']['list'][$key]['sta'] = '已取消';
break;
case 5:
$array['data']['list'][$key]['sta'] = '已分配';
break;
case 6:
$array['data']['list'][$key]['sta'] = '拒单';
break;
default:
# code...
break;
}
switch ($value['sex']) {
case 1:
$array['data']['list'][$key]['rname'] = $value['rname'].'先生'.'('.$value['phone'].')';
break;
case 2:
$array['data']['list'][$key]['rname'] = $value['rname'].'女士'.'('.$value['phone'].')';
break;
case 3:
$array['data']['list'][$key]['rname'] = $value['rname'].'公司'.'('.$value['phone'].')';
break;
default:
# code...
break;
}
if($value['room_demand']){
$array['data']['list'][$key]['room_demand'] = implode(',',array_column(json_decode($value['room_demand'],true), 'name'));
}
$array['data']['list'][$key]['sta'] = $value['is_tele']==1 ? $array['data']['list'][$key]['sta'] : $array['data']['list'][$key]['sta'].'无话机';
//根据操作人识别操作终端
if(isset($template['operator_openid'])){
if(strstr($template['operator_openid'],'_',-4)=='tele'){ //话机操作
$array['data']['list'][$key]['operator_openid'] = '电话机';
}
if(strstr($template['operator_openid'],'_',-4)=='wind'){ //PC操作
$array['data']['list'][$key]['operator_openid'] = 'PC';
}
if(strstr($template['operator_openid'],'_',-4)=='chat'){ //PC操作
$array['data']['list'][$key]['operator_openid'] = '小程序';
}
}
}
//print_r($array['data']['list']);die;
return $result = [
'code'=>0,'msg'=>'获取成功!',
'data'=>$array['data']['list'],
'count'=>$array['data']['total'],
'rel'=>1
];
}
$this->assign ( 'title','C端预定订单管理');
return $this->fetch();
}
/**
* 状态设置
*/
public function setReserveStatus(){
if(Request::isAjax()){
$data = Request::except('file');
$data['cause'] = json_encode(array('uid'=>-1,'uname'=>session('username'),'desc'=>$data['cause']));
$list= file_get_contents(ON_LINE.'App.Reserve.SetReserveStatus&rid='.$data['id'].'&status='.$data['status'].'&cause='.$data['cause']);
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请求错误!';
}
return $result;
}
return view();
}
}
... ...
{include file="common/head"/}
<div class="admin-main fadeInUp animated" ng-app="hd" ng-controller="ctrl">
<fieldset class="layui-elem-field layui-field-title">
<legend>绑定代理商</legend>
</fieldset>
<form class="layui-form layui-form-pane">
<div class="layui-form-item">
<label class="layui-form-label">代理商名称</label>
<div class="layui-input-4">
<input type="text" name="agent_name" ng-model="field.title" lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">代理商手机号</label>
<div class="layui-input-4">
<input type="text" name="agent_phone" ng-model="field.title" lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
<a href="{:url('addagent')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
</div>
</div>
</form>
</div>
{include file="common/foot"/}
<script src="/static/common/js/angular.min.js"></script>
<script>
var m = angular.module('hd',[]);
m.controller('ctrl',['$scope',function($scope) {
$scope.field = '{$info|raw}'!='null'?{$info|raw}:{title:''};
layui.use(['form', 'layer'], function () {
var form = layui.form, layer = layui.layer,$= layui.jquery;
form.on('submit(submit)', function (data) {
loading = layer.load(1,{shade:[0.1,'#fff']});
// 提交到方法 默认为本身
data.field.group_id = $scope.field.group_id;
$.post("", data.field, function (res) {
layer.close(loading);
if (res.code > 0) {
layer.msg(res.msg, {time: 1800, icon: 1}, function () {
location.href = res.url;
});
} else {
layer.msg(res.msg, {time: 1800, icon: 2});
}
});
})
});
}]);
</script>
\ No newline at end of file
... ...
{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
<fieldset class="layui-elem-field layui-field-title">
<legend>{:$title}</legend>
</fieldset>
<div class="demoTable">
区域名称:<div class="layui-inline">
<input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}区域名称" autocomplete="off">
</div>
<button class="layui-btn" id="search" data-type="reload">搜索</button>
<!-- 备注: 人均消费(130)、店铺评分(4.9,最高5分)、停车场(0/1 无/有)开启单元格编辑 -->
</div>
<table class="layui-table" id="list" lay-filter="list"></table>
</div>
{include file="common/foot"/}
<script src="/static/common/js/jquery.2.1.1.min.js"></script>
<script type="text/javascript" src="/static/city/data.js"></script>
<script type="text/javascript" src="/static/city/province.js"></script>
<script type="text/javascript">
var defaults = {
s1: 'provid',
s2: 'cityid',
s3: 'areaid',
v1: null,
v2: null,
v3: null
};
</script>
<script type="text/html" id="action">
<a class="layui-btn {{ 0==d.status?'':'layui-btn-danger'}} layui-btn-xs" lay-event="stop">{{ 0==d.status?'启用':'停用'}}</a>
{{#if(d.is_exist==0){}}
<a href="{:url('Area/addagent')}?areaid={{d.areaid}}" class="layui-btn layui-btn-xs">添加代理商</a>
{{#}}}
<!--<a href="{:url('Template/configMer')}?id={{d.id}}&name={{d.sellername}}" class="layui-btn layui-btn-xs">配置菜品</a>-->
<!--<a href="{:url('Basicinfo/smsRecharge')}?id={{d.id}}&name={{d.sellername}}" class="layui-btn layui-btn-xs">短信充值</a>-->
</script>
<script>
layui.use(['table','form'], function() {
var table = layui.table,$ = layui.jquery;
var tableIn = table.render({
elem: '#list',
url: '{:url("agent")}',
method: 'post',
title: '代理商区域列表',
toolbar: '#toolbarDemo',
page:true,
cols: [[
{field: 'areaid', width:60, fixed: true},
{field: 'areaname', edit: 'text', title: '区域名称'},
{field: 'agent_name', edit: 'text', title: '代理商名称'},
{align: 'center', width:200,title: '操作', toolbar: '#action'}
]]
,id: 'testReload'
,page: true
});
//监听行双击事件
table.on('rowDouble(list)', function(obj){
//table.on('row(list)', function(obj){ 双击事件
//console.log(obj.tr) //得到当前行元素对象
console.log(obj.data) //得到当前行数据
layer.open({
type: 2,
title: obj.data.sellername,
shadeClose: true,
shade: 0.8,
area: ['90%', '90%'],
content: '{:url("sellerdetail")}?sid='+obj.data.id //iframe的url
/*success:function(dom){
let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
$iframeDom.find("#test").html("我是从父级传来的值哟……")
}*/
});
});
//搜索
$('#search').on('click', function() {
var key = $('#key').val();
/*if($.trim(key)==='') {
layer.msg('{:lang("pleaseEnter")}店铺名称!',{icon:0});
return;
}*/
tableIn.reload({
page:{page: 1},
where:{
key: key,
address: $('#address').val(),
channel: $('#channel').val(),
prov: $("#provid").find("option:selected").text(),
city: $("#cityid").find("option:selected").text(),
area: $("#areaid").find("option:selected").text()
}
});
});
var $ = layui.$, active = {
reload: function(){
var key = $('#key');
var channel = $('#channel');
var address = $('#address');
var prov = $("#provid").find("option:selected").text();
var city = $("#cityid").find("option:selected").text();
var area = $("#areaid").find("option:selected").text()
//执行重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
key: {
id: key.val(),
channel: channel.val(),
address: address.val(),
prov: prov,
city: city,
area: area
}
}
});
}
};
$('.demoTable .layui-btn').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
//启用、停用
table.on('tool(list)', function(obj){
var data = obj.data;
if(obj.event === 'stop'){
var statusVal = data.status==1 ? '停用' : '启用';
layer.confirm('请确定要 '+statusVal+" 该商家!", function(index){
$.post("{:url('configStop')}",{sellerid:data.id,status:data.status},function(res){
if(res.code==1){
layer.msg(res.msg,{time:1000,icon:1});
location.reload();
}else{
layer.msg(res.msg,{time:1000,icon:2});
}
});
layer.close(index);
});
}
});
})
</script>
\ No newline at end of file
... ...
{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
<fieldset class="layui-elem-field layui-field-title">
<legend>代理商运营人员列表</legend>
</fieldset>
<blockquote class="layui-elem-quote">
<a href="{:url('operateAdd')}" class="layui-btn layui-btn-sm">添加运营人员</a>
</blockquote>
<table class="layui-table" id="list" lay-filter="list"></table>
</div>
{include file="common/foot"/}
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
</script>
<script>
layui.use(['table','form'], function() {
var table = layui.table,form = layui.form,$ = layui.jquery;
var tableIn = table.render({
elem: '#list',
url: '{:url("operate")}',
method:'post',
cols: [[
,{field:'sub_openid', title: '运营公众号ID', width:280,fixed: true}
,{field:'openid', title: '一键订商户ID', width:270}
,{field:'account', title: '运营账号', width:120}
,{field:'cdate', title: '加入时间',width:180}
,{width:160,title: '操作', align:'center', toolbar: '#barDemo'}
]]
});
//删除运营人员
table.on('tool(list)', function(obj){
var data = obj.data;
if(obj.event === 'del'){
layer.confirm('{:lang("确认禁用?")}', function(index){
$.post("{:url('setAgentOperate')}",{id:data.id},function(res){
if(res.code==1){
layer.msg(res.msg,{time:1000,icon:1});
obj.del();
}else{
layer.msg(res.msg,{time:1000,icon:2});
}
});
layer.close(index);
});
}
});
});
</script>
</body>
</html>
\ No newline at end of file
... ...
{include file="common/head"/}
<div class="admin-main fadeInUp animated" ng-app="hd" ng-controller="ctrl">
<fieldset class="layui-elem-field layui-field-title">
<legend>请扫描二维码完成添加代理商运营人员操作</legend>
</fieldset>
<form class="layui-form layui-form-pane">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 465px;width: 500px;"><img style="margin: 20px;height: 400px;width: 400px;" src="{$qrcode_path}"/></label>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<a href="{:url('operateList')}" style="margin-left: 95px" class="layui-btn">{:lang('back')}</a>
</div>
</div>
</form>
</div>
{include file="common/foot"/}
\ No newline at end of file
... ...
{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
<fieldset class="layui-elem-field layui-field-title">
<legend>{:$title}</legend>
</fieldset>
<blockquote class="layui-elem-quote">
<a href="{:url('Seller/sellerList')}" class="layui-btn layui-btn-sm layui-btn-danger">
<i class="fa fa-file-image-o"></i> 商家信息列表
</a>
<a href="{:url('Template/uploadFile')}" class="layui-btn layui-btn-sm">
<i class="fa fa-file-image-o"></i> GIF图片、短视频上传
</a>
<a href="{:url('Template/Vegetable')}" class="layui-btn layui-btn-sm">
<i class="fa fa-file-image-o"></i> 菜品库管理
</a>
</blockquote>
<div class="demoTable">
商家名称:<div class="layui-inline">
<input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}店铺名称" autocomplete="off">
</div>
商家地址:<div class="layui-inline">
<input class="layui-input" name="address" id="address" placeholder="{:lang('pleaseEnter')}店铺地址" autocomplete="off">
</div>
商家来源:
<div class="layui-input-inline layui-form">
<div class="layui-input-8">
<select name="class" id="channel" lay-filter="myselect">
<option value="4">全部</option>
<option value="1" selected>合作</option>
<option value="2">推广</option>
<option value="3">测试</option>
</select>
</div>
</div>
选择地区:
<div class="layui-input-inline">
<form class="layui-form">
<div class="layui-input-inline">
<select name="provid" id="provid" lay-filter="provid">
<option value="">请选择省</option>
</select>
</div>
<div class="layui-input-inline">
<select name="cityid" id="cityid" lay-filter="cityid">
<option value="">请选择市</option>
</select>
</div>
<div class="layui-input-inline">
<select name="areaid" id="areaid" lay-filter="areaid">
<option value="">请选择县/区</option>
</select>
</div>
</form>
</div>
<button class="layui-btn" id="search" data-type="reload">搜索</button>
<!-- 备注: 人均消费(130)、店铺评分(4.9,最高5分)、停车场(0/1 无/有)开启单元格编辑 -->
</div>
<table class="layui-table" id="list" lay-filter="list"></table>
</div>
{include file="common/foot"/}
<script src="/static/common/js/jquery.2.1.1.min.js"></script>
<script type="text/javascript" src="/static/city/data.js"></script>
<script type="text/javascript" src="/static/city/province.js"></script>
<script type="text/javascript">
var defaults = {
s1: 'provid',
s2: 'cityid',
s3: 'areaid',
v1: null,
v2: null,
v3: null
};
</script>
<script type="text/html" id="action">
<a class="layui-btn {{ 0==d.status?'':'layui-btn-danger'}} layui-btn-xs" lay-event="stop">{{ 0==d.status?'启用':'停用'}}</a>
<a href="{:url('Seller/sellerconfig')}?id={{d.id}}&name={{d.sellername}}" class="layui-btn layui-btn-xs">配置</a>
<!--<a href="{:url('Template/configMer')}?id={{d.id}}&name={{d.sellername}}" class="layui-btn layui-btn-xs">配置菜品</a>-->
<a href="{:url('Basicinfo/smsRecharge')}?id={{d.id}}&name={{d.sellername}}" class="layui-btn layui-btn-xs">短信充值</a>
</script>
<script>
layui.use(['table','form'], function() {
var table = layui.table,$ = layui.jquery;
var tableIn = table.render({
elem: '#list',
url: '{:url("Seller")}',
method: 'post',
title: '商家列表',
toolbar: '#toolbarDemo',
page:true,
cols: [[
{field: 'id', title: '{:lang("id")}', width:60, fixed: true},
{field: 'sellername', edit: 'text', title: '商家名称'},
{field: 'selleralias', edit: 'text', title: '短店名+地址'},
{field: 'last_num', align: 'center',title: '短信余量'},
{field: 'average', align: 'center', edit: 'text', title: '人均消费'},
{field: 'score', align: 'center', edit: 'text', title: '店铺评分'},
{field: 'is_parking', align: 'center', edit: 'text',title: '是否有停车场'},
{field: 'is_meal_fee', align: 'center', edit: 'text',title: '有无餐位费'},
{field: 'is_unsubscribe', align: 'center', edit: 'text',title: '是否可随时退'},
{field: 'is_minimum_consumption', align: 'center', edit: 'text',title: '有无最低消费'},
{field: 'is_belt_wine', align: 'center', edit: 'text',title: '是否可自带酒水'},
{field: 'slogan', align: 'center', edit: 'text',title: '商家短标语'},
{field: 'scale', align: 'center', edit: 'text', sort: true,title: '比例尺'},
{field: 'is_auth', align: 'center', edit: 'text', sort: true,title: '订座读写权限'},
{field: 'user_name', align: 'center',title: '创建人'},
//{field: 'dz_version', align: 'center',title: 'APP版本'},
{align: 'center', width:200,title: '操作', toolbar: '#action'}
]]
,id: 'testReload'
,page: true
});
//监听单元格编辑
table.on('edit(list)', function(obj){
var value = obj.value, //得到修改后的值
data = obj.data, //得到所在行所有键值
field = obj.field; //得到字段
switch(field){
case 'average':
var new_field = '人均消费';
break;
case 'is_parking':
var new_field = '停车场';
break;
case 'score':
var new_field = '店铺评分';
break;
case 'slogan':
var new_field = '标语';
break;
case 'selleralias':
var new_field = '短店名';
break;
case 'is_meal_fee':
var new_field = '有无餐位费';
break;
case 'is_unsubscribe':
var new_field = '是否可随时退';
break;
case 'is_minimum_consumption':
var new_field = '有无最低消费';
break;
case 'is_belt_wine':
var new_field = '是否自带酒水';
break;
case 'scale':
var new_field = '比例尺';
break;
case 'sellername':
var new_field = '商家名字';
case 'is_auth':
var new_field = '是否开始订座读写权限';
}
if(field=='slogan' && value.length>15){
layer.msg('标语不能超过15个字符!',{time:1500,icon:2});return;
}
if(field=='scale' && value>20){
layer.msg('比例尺最高可设置为20',{time:1500,icon:2});return;
}
if(field=='scale' && value<3){
layer.msg('比例尺最低可设置为3',{time:1500,icon:2});return;
}
if(field=='is_auth' && value>1 || value<0){
layer.msg('请输入正确的参数,0为只读,1为读写',{time:1500,icon:2});return;
}
//layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为:'+ value);
layer.confirm('请确认将 '+ data.sellername +'商家的 ' + new_field + ' 更改为:'+ value, function(index){
$.post("{:url('setsellerconfig')}",{sellerid:data.id,field:field,value:value},function(res){
if(res.code==1){
layer.msg(res.msg,{time:1500,icon:1});
}else{
layer.msg(res.msg,{time:1500,icon:2});
}
});
layer.close(index);
});
});
//监听行双击事件
table.on('rowDouble(list)', function(obj){
//table.on('row(list)', function(obj){ 双击事件
//console.log(obj.tr) //得到当前行元素对象
console.log(obj.data) //得到当前行数据
layer.open({
type: 2,
title: obj.data.sellername,
shadeClose: true,
shade: 0.8,
area: ['90%', '90%'],
content: '{:url("sellerdetail")}?sid='+obj.data.id //iframe的url
/*success:function(dom){
let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
$iframeDom.find("#test").html("我是从父级传来的值哟……")
}*/
});
});
//搜索
$('#search').on('click', function() {
var key = $('#key').val();
/*if($.trim(key)==='') {
layer.msg('{:lang("pleaseEnter")}店铺名称!',{icon:0});
return;
}*/
tableIn.reload({
page:{page: 1},
where:{
key: key,
address: $('#address').val(),
channel: $('#channel').val(),
prov: $("#provid").find("option:selected").text(),
city: $("#cityid").find("option:selected").text(),
area: $("#areaid").find("option:selected").text()
}
});
});
var $ = layui.$, active = {
reload: function(){
var key = $('#key');
var channel = $('#channel');
var address = $('#address');
var prov = $("#provid").find("option:selected").text();
var city = $("#cityid").find("option:selected").text();
var area = $("#areaid").find("option:selected").text()
//执行重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
key: {
id: key.val(),
channel: channel.val(),
address: address.val(),
prov: prov,
city: city,
area: area
}
}
});
}
};
$('.demoTable .layui-btn').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
//启用、停用
table.on('tool(list)', function(obj){
var data = obj.data;
if(obj.event === 'stop'){
var statusVal = data.status==1 ? '停用' : '启用';
layer.confirm('请确定要 '+statusVal+" 该商家!", function(index){
$.post("{:url('configStop')}",{sellerid:data.id,status:data.status},function(res){
if(res.code==1){
layer.msg(res.msg,{time:1000,icon:1});
location.reload();
}else{
layer.msg(res.msg,{time:1000,icon:2});
}
});
layer.close(index);
});
}
});
})
</script>
\ No newline at end of file
... ...