提交 053745aa authored 作者: 李大见's avatar 李大见

提交版本0623

上级 02ca8072
# tongnan
## Laravel PHP Framework
[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework)
[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework)
[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework)
[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework)
[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework)
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.
Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked.
## Official Documentation
Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs).
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
### License
The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
}
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
\Symfony\Component\HttpKernel\Exception\HttpException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
}
<?php
/**
* [uploadBase64Img 上传base64图片]
* @param [type] $stream [base64数据]
* @return [type] [上传成功返回图片路径,失败返回false]
*/
function uploadBase64Img($stream)
{
if(stristr($stream,'data:image')){
$stream = $stream;
}else{
$stream="data:image/png;base64,".$stream;
}
//获取扩展名和文件名
if (preg_match('/(?<=\/)[^\/]+(?=\;)/', $stream, $pregR)) $streamFileType = '.' . $pregR[0];
$streamFileRand = time() . rand(11111,99999);//产生一个随机文件名(因为你base64上来肯定没有文件名,这里你可以自己设置一个也行)
// $pathName = "/public/image/" ;
$pathName = storage_path()."/image/";//获取上传图片路径
// 创建文件夹
if (!file_exists($pathName)) {
mkdir($pathName,0775,true);
chmod($pathName,0775);
}
$streamFilename = $pathName . $streamFileRand . $streamFileType;//上传到服务器图片路径
//处理base64文本,用正则把第一个base64,之前的部分砍掉
preg_match('/(?<=base64,)[\S|\s]+/', $stream, $streamForW);
if (file_put_contents($streamFilename, base64_decode($streamForW[0])) === false) {
return false;
} else {
// 返回路径
$filePath = "storage/image/". $streamFileRand . $streamFileType;
return $filePath;
}
}
/**
* [wherebutton 获取当前列表下的按钮]
* @param [type] $api_token [用户token]
* @param [type] $pri_id [当前列表的id]
* @return [type] [description]
*/
function wherebutton($api_token,$pri_id)
{
if(empty($pri_id))
{
return response()->json(["code"=>500,'msg'=>'error','data'=>'参数错误']);
}
try{
$api_token = Crypt::decrypt($api_token);
}catch (\Exception $e){
return response()->json(["code"=>500,'msg'=>'error','data'=>'非法api_token']);
}
$role_info = DB::table('login_temporary')
->where('api_token','=',$api_token)
->select('role_auth')
->first();
// 对象转数组
$role_info = object_array(json_decode($role_info['role_auth']));
// 获取到当前列表下的按钮
$wherebutton = [];
foreach($role_info as $key=>$value)
{
if($value['pri_fid'] == $pri_id)
{
$wherebutton[] = $value;
}
}
if(!$wherebutton)
{
return false;
}
return $wherebutton;
}
// 对象转数组
function object_array($array) {
if(is_object($array)) {
$array = (array)$array;
} if(is_array($array)) {
foreach($array as $key=>$value) {
$array[$key] = object_array($value);
}
}
return $array;
}
// 发送短信验证码
function sendSmsCode($mobile, $content)
{
$username = "lksy";
$pwd = "19r1rt22";
$password = md5($username . "" . md5($pwd));
$url = "http://www1.jc-chn.cn/smsSend.do?";
$param = http_build_query(
array(
'username' => $username,
'password' => $password,
'mobile' => $mobile,
// 'content'=>iconv("GB2312","UTF-8",$content)
'content' => $content
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
/**
* [webCreateToken 移动web端生成token]
* @param [type] $userid [技师账号id]
* @return [type] [description]
*/
function webCreateToken($userid)
{
$token_str = $userid.date('Y-m-d').'jidjld465afd2134ds65f4';
$api_token = sha1($token_str); //加密
return Crypt::encrypt($api_token);
}
/**
* [webVerifyToken 移动web端验证token]
* @param [type] $userid [技师账号id]
* @param [type] $api_token [api_token]
* @return [type] [description]
*/
function webVerifyToken($userid, $api_token)
{
$token_str = $userid.date('Y-m-d').'jidjld465afd2134ds65f4';
$token = sha1($token_str); //加密
try{
$api_token = Crypt::decrypt($api_token);
}catch (\Exception $e){
return ['code'=>500,'msg'=>'error','data'=>'非法api_token'];
}
if ($token == $api_token) {
return ['code'=>200,'msg'=>'success','data'=>''];
}else{
return ['code'=>500,'msg'=>'error','data'=>'api_token错误'];
}
}
// 分解二维码
function splitCode($code)
{
// 50004 1908 00000005 823
// 50004 1909 00000005 823
// 50004190800001719 - 50004190800010933
// 20
// 50004 1908 6922266440090 00000030 667
// 33
$code_len = strlen($code);
$data['company_symbol'] = substr($code, 0, 5);//公司标识
$data['yemo'] = substr($code, 5, 4);//年月
if ($code_len == 33) {
$data['bar_code'] = substr($code, 9, 13);//条形码
$data['number'] = substr($code, 22, 8);//码号
}else{
$data['bar_code'] = '';//条形码
$data['number'] = substr($code, 9, 8);//码号
}
return $data;
}
// 日志记录,记录操作数据
function logRecord($data, $file_name = 'log', $type = 1)
{
// $file_path = "./Uploads/".$file_name.".txt";
$file_path = storage_path() . "/logs/" . $file_name . ".txt";
$myfile = fopen($file_path, "a");
if ($type == 1) {
$txt = json_encode($data) . "\r\n\r\n";
}else{
$txt = json_encode($data, JSON_UNESCAPED_UNICODE) . "\r\n\r\n";
}
fwrite($myfile, $txt);
fclose($myfile);
}
/**
* curl 请求 CURLOPT_POSTFIELDS
* @param [type] $url 路径
* @param [type] $data 参数
* @param [type] $headers headers头
* @param integer $timeout [description]
* @param string $method [description]
* @return [type] [description]
*/
function curlRequest($url, $data = [], $headers = [], $timeout = 10, $method = 'GET')
{
$curl = curl_init();
if (!empty($headers)) {
$headers = array(
'Content-type: application/json',
'Authorization: '.$headers['Authorization'].'',
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data) && 'GET' == $method) $method = 'POST';
switch ($method) {
case 'POST':
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case 'PUT':
curl_setopt($curl, CURLOPT_PUT, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "DELETE":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
if (curl_errno($curl)) {
return 'Curl error: ' . curl_error($curl);
}
curl_close($curl);
return $output;
}
差异被折叠。
差异被折叠。
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use \Exception;
use App\Http\Models\CommenModel;
use Illuminate\Support\Facades\Crypt;
use App\Http\Models\AnticounterModel;
use App\Http\Models\Coperationa;
class AnticounterController extends Controller
{
/**
防伪设置
*/
public function antiset(Request $request)
{
// $token="d34f105ddbb0fbe052ad69f430c57e15a6d19e60";
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$initial=Db::table('note')->where(['not_cid'=>0])->select('note_content as content','note_number as number')->first();
$enterprise=Db::table('note')->where(['not_cid'=>$user['adm_cid']])->select('note_content as content','note_number as number')->first();
$initial['content']=stripslashes($initial['content']);
if(empty($enterprise)){
$enterprise=$initial;
}
$enterprise['content']=stripslashes($enterprise['content']);
// var_dump($enterprise['content']);exit;
$show_data=$enterprise;
$old_data=$initial;
$show_data['content']=$this->replace_str($show_data['content']);
$old_data['content'] =$this->replace_str($old_data['content']);
$res=['code'=>200,'msg'=>'success','data'=>['old_data'=>$initial,'new_data'=>$enterprise,'show_data'=>$show_data,'old_show'=>$old_data]];
$res['button_data'] = wherebutton($request['api_token'],$request['pri_id']);
return response()->json($res);
}
public function replace_str($data){
$data=str_replace('{goods}',"满天星窗帘",$data);
$data=str_replace('{code}',"500011810015498",$data);
$data=str_replace('{num}','1',$data);
$data=str_replace('{nums}','1',$data);
$data=str_replace('{time}',"2019-07-22 12:00:00",$data);
$data=str_replace('{pros}',"天津 武清区",$data);
return $data;
}
//更改 访问预警设置数据
public function judge(Request $request){
$arr=[1=>'{goods}',2=>'{code}',3=>'{num}',4=>'{time}',5=>'{pros}','6'=>'{nums}'];
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$type=(int)$request->input('type',0);
$content=$request->input('content');
if($type!=0){
if(strpos('.'.$content,$arr[$type])){
return response()->json(['code'=>500,'msg'=>'error','data'=>'请勿重复添加!']);
}
$new_data=$show_data=$content."<p>".$arr[$type]."</p>";
}else{
$new_data=$show_data=$content;
}
$show_data=stripslashes(stripslashes($this->replace_str($show_data)));
$new_data=stripslashes(stripslashes($new_data));
return response()->json(['code'=>200,'msg'=>'success','data'=>['content'=>$new_data,'show_data'=>$show_data]]);
// if()
}
//防伪设置 提交
public function editantiset(Request $request){
// $token="d34f105ddbb0fbe052ad69f430c57e15a6d19e60";
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$data['note_number']=(int)$request->input('number',1);
if($data['note_number']<0){
return response()->json(['code'=>500,'msg'=>'error','data'=>'预警次数最少0次']);
}
$data['note_content']=$request->input('content',null);
if(empty($data['note_content'])){
return response()->json(['code'=>500,'msg'=>'error','data'=>'防伪设置不能为空']);
}
$data['update_user'] =$user['admin_id'];
$data['created_at']=date('Y-m-d H:i:s');
$obj=new AnticounterModel();
$res=$obj->Set_Anti_Style($data,$user);
return response()->json($res);
}
/**
防伪预警列表
*/
public function antilist(Request $request)
{
// $token="d34f105ddbb0fbe052ad69f430c57e15a6d19e60";
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$where['stase'] =(int)$request->input('state',null);
if (!empty($request['time'])) {
$time_start = $request['time'][0];
$time_end = $request['time'][1];
$where['time_start'] =$time_start;
$where['time_end'] =$time_end.' 23:59:59';
}
// $where['time_start'] =$request->input('time_start',null);
// $where['time_end'] =$request->input('time_end',null);
$where['code_number']=$request->input('code_number',null);
$where['goods_name'] =$request->input('goods_name',null);
$where['number'] =(int)$request->input('number',null);
$where['page'] =(int)$request->input('page',1);
if($where['number']<0){
$where['number']=0;
}
$where['pagesize'] =(int)$request->input('page_size',10);
if($where['pagesize']>100 || $where['pagesize'] < 1){
$where['pagesize']=10;
}
$obj=new AnticounterModel();
$res=$obj->Anti_List($where,$user);
$res['button_data'] = wherebutton($request['api_token'],$request['pri_id']);
return response()->json($res);
}
/**
防伪处理
*/
public function antihandle(Request $request)
{
// $token="d34f105ddbb0fbe052ad69f430c57e15a6d19e60";
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$id=$request->input('id',null);
if(empty($id)){
return response()->json(['code'=>500,'msg'=>'error','data'=>'id不能为空']);
}
$remarks=$request->input('remarks',null);
$obj=new AnticounterModel();
$res=$obj->Update_state($id,$user,$remarks);
return response()->json($res);
}
/**
防伪编辑
*/
public function editanti(Request $request)
{
// $token="d34f105ddbb0fbe052ad69f430c57e15a6d19e60";
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$id=$request->input('id',null);
if(empty($id)){
return response()->json(['code'=>500,'msg'=>'error','data'=>'id不能为空']);
}
$remarks=$request->input('remarks',null);
$obj=new AnticounterModel();
$res=$obj->Edit_Anti($id,$user,$remarks);
return response()->json($res);
}
// 开启查询
public function openQuery(Request $request)
{
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$total_id = $request['total_id'];
if (empty($total_id)) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'参数错误']);
}
$total_status = 1;
$total_code = DB::table('info_total')->whereIn('total_id',$total_id)->select('total_code')->get();
foreach($total_code as $k=>$v)
{
$name[] = $v['total_code'];
}
$name = implode($name,',');
$res = DB::table('info_total')->whereIn('total_id',$total_id)->update(['total_status'=>$total_status]);
if ($res) {
Coperationa::add($user['admin_id'],$request->getClientIp(),'开启查询','开启',"开启(".$name.")溯源码号");
return response()->json(["code"=>200,'msg'=>'success','data'=>'操作成功']);
}else{
return response()->json(["code"=>500,'msg'=>'error','data'=>'操作失败']);
}
}
// 关闭查询
public function closeQuery(Request $request)
{
$token=Crypt::decrypt($request->input("api_token"));
$user=CommenModel::getUserToken($token);
if(!$user){
return response()->json(['code'=>500,'msg'=>'error','data'=>'token错误']);
}
$total_id = $request['total_id'];
if (empty($total_id)) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'参数错误']);
}
$total_status = 2;
$total_code = DB::table('info_total')->whereIn('total_id',$total_id)->select('total_code')->get();
foreach($total_code as $k=>$v)
{
$name[] = $v['total_code'];
}
$name = implode($name,',');
$res = DB::table('info_total')->whereIn('total_id',$total_id)->update(['total_status'=>$total_status]);
if ($res) {
Coperationa::add($user['admin_id'],$request->getClientIp(),'关闭查询','关闭',"关闭(".$name.")溯源码号");
return response()->json(["code"=>200,'msg'=>'success','data'=>'操作成功']);
}else{
return response()->json(["code"=>500,'msg'=>'error','data'=>'操作失败']);
}
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Create a new password controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
<?php
namespace App\Http\Controllers\Channels;
use App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use DB;
use Crypt;
use Illuminate\Support\Facades\Storage;
use Session;
use App\Http\Models\Coperationa;
class ChannelsLabelController extends Controller
{
// 列表每页显示数据个数
protected $show_count = 10;
// 标签列表
public function index(Request $request)
{
// 获取操作人
$find_adm = Coperationa::getUserInfo($request->input('api_token'));
$label_info = $request->all();
$userinfo = DB::table('channels_label')
->where(function($query) use($label_info) {
if (!empty($label_info['label_name'])) {
$query->where('label_name', 'like' , '%'.$label_info['label_name'].'%' );
}
})
->where(function($query) use($label_info) {
if (!empty($label_info['label_state'])) {
$query->where('label_state','=',$label_info['label_state']);
}
})
->where('label_cid',$find_adm['adm_cid'])
->select('label_id','label_name','label_state','label_addtime','label_total')
->orderBy('label_id','desc')
->paginate($this->show_count);
$data_info['current_page'] = $userinfo->currentPage(); //当前页面页码
$data_info['last_page'] = $userinfo->lastPage(); //表示最后一页的页码
$data_info['total'] = $userinfo->total(); //总数据个数
$data_info['current_number'] = $this->show_count; //一页显示多少个
$data_info['data'] = $userinfo->items(); //返回数据
// 获取当前列表下的按钮
$button = wherebutton($request['api_token'],$request['pri_id']);
if($data_info) {
return response()->json(['code'=> 200,'msg'=>'success','data'=>$data_info,'button'=>$button]);
}else{
return response()->json(['code'=> 500,'msg'=>'error','data'=>'暂无数据']);
}
}
// 新增渠道标签
public function add(Request $request)
{
// 获取当前操作账号
$adm_info = Coperationa::getUserInfo($request->input('api_token'));
$input = $request->all();
// 验证数据
if ( empty($input['label_name']) || !in_array($input['label_state'], [1,2]) ) {
return response()->json(['code'=>500,'msg'=>'error','data'=>'参数错误']);
}
// 判断渠道标签名称是否重复
$channels_label = DB::table('channels_label');
$label_name = $channels_label->
where('label_cid',$adm_info['adm_cid'])->
where('label_name',$input['label_name'])->first();
if ($label_name) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'渠道标签名称已存在']);
}
$add_data = [
'label_cid'=>$adm_info['adm_cid'],
'label_name'=>$input['label_name'],
'label_state'=>$input['label_state']
];
// 新增渠道标签
$res = $channels_label->insert($add_data);
if (!$res) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'新增渠道标签失败']);
}
Coperationa::add($adm_info['adm_id'],$request->getClientIp(),'渠道标签','添加','添加'.$input['label_name']);
return response()->json(["code"=>200,'msg'=>'success','data'=>'新增渠道标签成功']);
}
// 编辑渠道标签
public function edit(Request $request)
{
$input = $request->only('label_name','label_state','edit_id');
// 验证数据
if ( empty($input['label_name']) || !in_array($input['label_state'], [1,2]) || !is_numeric($input['edit_id']) ) {
return response()->json(['code'=>500,'msg'=>'error','data'=>'参数错误']);
}
// 获取当前操作账号
$adm_info = Coperationa::getUserInfo($request->input('api_token'));
$save_data['label_name'] = $input['label_name'];
$save_data['label_state'] = $input['label_state'];
$save_data['label_edittime'] = date('Y-m-d H:i:s');
$res = DB::table('channels_label')->where('label_id', '=', $input['edit_id'])->update($save_data);
if (!$res) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'编辑渠道标签失败']);
}
Coperationa::add($adm_info['adm_id'],$request->getClientIp(),'渠道标签','编辑','编辑'.$input['label_name']);
return response()->json(["code"=>200,'msg'=>'success','data'=>'编辑渠道标签成功']);
}
// 启用标签
public function start(Request $request)
{
$label_id = $request['edit_id'];
if(empty($label_id) || !is_array($label_id)) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'参数错误']);
}
// 获取当前操作账号
$adm_info = Coperationa::getUserInfo($request->input('api_token'));
// 查询渠道标签名称
$label_data = DB::table('channels_label')->whereIn('label_id',$label_id)->select('label_name')->get();
$label_name = '';
foreach ($label_data as $key => $value) {
$label_name .= $value['label_name'].',';
}
$update_data['label_state'] = 1;//状态:1启用2停用
$update_data['label_edittime'] = date('Y-m-d H:i:s');
$res = DB::table('channels_label')->whereIn('label_id',$label_id)->update($update_data);
if(!$res) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'启用渠道标签失败']);
}
Coperationa::add($adm_info['adm_id'],$request->getClientIp(),'渠道标签','启用','启用('.trim($label_name,',').')渠道标签');
return response()->json(["code"=>200,'msg'=>'success','data'=>'启用渠道标签成功']);
}
// 停用标签
public function stop(Request $request)
{
$label_id = $request['edit_id'];
if(empty($label_id) || !is_array($label_id)) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'参数错误']);
}
// 获取当前操作账号
$adm_info = Coperationa::getUserInfo($request->input('api_token'));
// 查询渠道标签名称
$label_data = DB::table('channels_label')->whereIn('label_id',$label_id)->select('label_name')->get();
$label_name = '';
foreach ($label_data as $key => $value) {
$label_name .= $value['label_name'].',';
}
$update_data['label_state'] = 2;//状态:1启用2停用
$update_data['label_edittime'] = date('Y-m-d H:i:s');
$res = DB::table('channels_label')->whereIn('label_id',$label_id)->update($update_data);
if(!$res) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'停用渠道标签失败']);
}
Coperationa::add($adm_info['adm_id'],$request->getClientIp(),'渠道标签','停用','停用('.trim($label_name,',').')渠道标签');
return response()->json(["code"=>200,'msg'=>'success','data'=>'停用渠道标签成功']);
}
// 删除标签
public function delete(Request $request)
{
$label_id = $request['del_id'];
if(empty($label_id) || !is_array($label_id)) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'参数错误']);
}
// 获取当前操作账号
$adm_info = Coperationa::getUserInfo($request->input('api_token'));
// 查询渠道标签名称
$label_data = DB::table('channels_label')->whereIn('label_id',$label_id)->select('label_name','label_total')->get();
$label_name = '';
foreach ($label_data as $key => $value) {
if ($value['label_total'] > 0) {
return response()->json(["code"=>500,'msg'=>'error','data'=>'下属渠道商数量不为0,不允许删除']);
}
$label_name .= $value['label_name'].',';
}
$res = DB::table('channels_label')->whereIn('label_id',$label_id)->delete();
if(!$res){
return response()->json(["code"=>500,'msg'=>'error','data'=>'删除渠道标签失败']);
}
Coperationa::add($adm_info['adm_id'],$request->getClientIp(),'渠道标签','删除','删除('.$label_name.')渠道标签');
return response()->json(["code"=>200,'msg'=>'success','data'=>'删除渠道标签成功']);
}
}
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论