396 lines
13 KiB
PHP
396 lines
13 KiB
PHP
<?php
|
|
/**
|
|
* 易优CMS
|
|
* ============================================================================
|
|
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
|
* 网站地址: http://www.eyoucms.com
|
|
* ----------------------------------------------------------------------------
|
|
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
|
* ============================================================================
|
|
* Author: 陈风任 <491085389@qq.com>
|
|
* Date: 2019-2-12
|
|
*/
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use think\Page;
|
|
use think\Db;
|
|
use think\Config;
|
|
use app\admin\logic\MemberLogic;
|
|
|
|
class Project extends Base {
|
|
|
|
public $userConfig = [];
|
|
|
|
/**
|
|
* 构造方法
|
|
*/
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->language_access(); // 多语言功能操作权限
|
|
/*会员中心数据表*/
|
|
$this->project_db = Db::name('project'); //
|
|
$this->service_db = Db::name('service'); //
|
|
|
|
// 是否开启支付功能设置
|
|
$this->userConfig = getUsersConfigData('all');
|
|
$this->assign('userConfig',$this->userConfig);
|
|
|
|
// 模型是否开启
|
|
$channeltype_row = \think\Cache::get('extra_global_channeltype');
|
|
$this->assign('channeltype_row',$channeltype_row);
|
|
}
|
|
|
|
|
|
// 会员列表
|
|
public function users_index()
|
|
{
|
|
$list = array();
|
|
|
|
$param = input('param.');
|
|
$condition = array();
|
|
// 应用搜索条件
|
|
foreach (['keywords','origin_type'] as $key) {
|
|
if (isset($param[$key]) && $param[$key] !== '') {
|
|
if ($key == 'keywords') {
|
|
$condition['a.enterprise|a.name'] = array('LIKE', "%{$param[$key]}%");
|
|
} else {
|
|
$condition['a.'.$key] = array('eq', $param[$key]);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $condition['a.is_del'] = 0;
|
|
// 多语言
|
|
//$condition['a.lang'] = array('eq', $this->admin_lang);
|
|
|
|
/**
|
|
* 数据查询
|
|
*/
|
|
$count = $this->project_db->alias('a')->where($condition)->count();// 查询满足要求的总记录数
|
|
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
|
|
$list = $this->project_db->field('a.*')
|
|
->alias('a')
|
|
// ->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
|
|
->where($condition)
|
|
->order('a.id desc')
|
|
->limit($Page->firstRow.','.$Page->listRows)
|
|
->select();
|
|
|
|
$show = $Page->show();// 分页显示输出
|
|
$this->assign('page',$show);// 赋值分页输出
|
|
$this->assign('list',$list);// 赋值数据集
|
|
$this->assign('pager',$Page);// 赋值分页集
|
|
|
|
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
//新增项目
|
|
public function add()
|
|
{
|
|
//防止php超时
|
|
function_exists('set_time_limit') && set_time_limit(0);
|
|
$id = input('id',0);
|
|
if($id){
|
|
$item = $this->project_db->where([
|
|
'id' => $id
|
|
])->find();
|
|
$this->assign('item',$item);
|
|
}
|
|
$this->assign('id',$id);
|
|
if (IS_POST) {
|
|
$post = input('post.');
|
|
|
|
// 添加表信息
|
|
$data = array(
|
|
'name' => $post['name'],
|
|
'pwd' => $post['pwd'],
|
|
'enterprise' => $post['enterprise'],
|
|
'filing' => $post['filing'],
|
|
'sid' =>$post['sid'],
|
|
'limitationdate' => $post['limitationdate'],
|
|
);
|
|
if($id >0){
|
|
$this->project_db->where(array('id'=>$id))->update($data);
|
|
$insertID = $id;
|
|
}else{
|
|
$data['createtime'] = getTime();
|
|
$insertID = M('project')->insertGetId($data);
|
|
}
|
|
$data['id'] = $insertID;
|
|
$datas['qrcode'] = $this->book($data);
|
|
$this->project_db->where(array('id'=>$insertID))->update($datas);
|
|
|
|
if (!empty($insertID)) {
|
|
// adminLog('新增项目:'.$post['name']);
|
|
$this->success("操作成功", url('Project/users_index'));
|
|
} else {
|
|
$this->error("操作失败", url('Project/users_index'));
|
|
}
|
|
}
|
|
|
|
return $this->fetch();
|
|
}
|
|
//新增服务商
|
|
public function edit()
|
|
{
|
|
//防止php超时
|
|
function_exists('set_time_limit') && set_time_limit(0);
|
|
$id = input('id',0);
|
|
if($id){
|
|
$item = $this->service_db->where([
|
|
'id' => $id
|
|
])->find();
|
|
$this->assign('item',$item);
|
|
}
|
|
$this->assign('id',$id);
|
|
if (IS_POST) {
|
|
$post = input('post.');
|
|
|
|
// 添加表信息
|
|
$data = array(
|
|
'name' => $post['name'],
|
|
'centre' => $post['centre']
|
|
);
|
|
|
|
if($id >0){
|
|
$this->service_db->where(array('id'=>$id))->update($data);
|
|
$insertID = $id;
|
|
}else{
|
|
$data['createtime'] = getTime();
|
|
$insertID = M('service')->insertGetId($data);
|
|
}
|
|
$data['id'] = $insertID;
|
|
$datas['qrcode'] = $this->service($data);
|
|
$this->service_db->where(array('id'=>$insertID))->update($datas);
|
|
if (!empty($insertID)) {
|
|
// adminLog('新增项目:'.$post['name']);
|
|
$this->success("操作成功", url('Project/users_index'));
|
|
} else {
|
|
$this->error("操作失败", url('Project/users_index'));
|
|
}
|
|
}
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
|
|
// 项目删除
|
|
public function users_del()
|
|
{
|
|
$users_id = input('del_id/a');
|
|
$users_id = eyIntval($users_id);
|
|
if (IS_AJAX_POST && !empty($users_id)) {
|
|
// 删除统一条件
|
|
$Where = [
|
|
'id' => ['IN', $users_id],
|
|
];
|
|
|
|
$result = $this->project_db->field('name')->where($Where)->select();
|
|
$username_list = get_arr_column($result, 'name');
|
|
|
|
$return = $this->project_db->where($Where)->delete();
|
|
if (false !== $return) {
|
|
$this->success('删除成功');
|
|
}else{
|
|
$this->error('删除失败');
|
|
}
|
|
}
|
|
$this->error('参数有误');
|
|
}
|
|
|
|
// 级别列表
|
|
public function level_index()
|
|
{
|
|
|
|
$list = array();
|
|
|
|
$param = input('param.');
|
|
$condition = array();
|
|
// 应用搜索条件
|
|
foreach (['keywords','origin_type'] as $key) {
|
|
if (isset($param[$key]) && $param[$key] !== '') {
|
|
if ($key == 'keywords') {
|
|
$condition['a.name|a.centre'] = array('LIKE', "%{$param[$key]}%");
|
|
} else {
|
|
$condition['a.'.$key] = array('eq', $param[$key]);
|
|
}
|
|
}
|
|
}
|
|
|
|
// $condition['a.is_del'] = 0;
|
|
// 多语言
|
|
//$condition['a.lang'] = array('eq', $this->admin_lang);
|
|
|
|
/**
|
|
* 数据查询
|
|
*/
|
|
$count = $this->service_db->alias('a')->where($condition)->count();// 查询满足要求的总记录数
|
|
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
|
|
$list = $this->service_db->field('a.*')
|
|
->alias('a')
|
|
// ->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
|
|
->where($condition)
|
|
->order('a.id desc')
|
|
->limit($Page->firstRow.','.$Page->listRows)
|
|
->select();
|
|
|
|
$show = $Page->show();// 分页显示输出
|
|
$this->assign('page',$show);// 赋值分页输出
|
|
$this->assign('list',$list);// 赋值数据集
|
|
$this->assign('pager',$Page);// 赋值分页集
|
|
|
|
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
// 服务商删除
|
|
public function del()
|
|
{
|
|
$users_id = input('del_id/a');
|
|
$users_id = eyIntval($users_id);
|
|
if (IS_AJAX_POST && !empty($users_id)) {
|
|
// 删除统一条件
|
|
$Where = [
|
|
'id' => ['IN', $users_id],
|
|
];
|
|
|
|
$result = $this->service_db->field('name')->where($Where)->select();
|
|
$username_list = get_arr_column($result, 'name');
|
|
|
|
$return = $this->service_db->where($Where)->delete();
|
|
if (false !== $return) {
|
|
$this->success('删除成功');
|
|
}else{
|
|
$this->error('删除失败');
|
|
}
|
|
}
|
|
$this->error('参数有误');
|
|
}
|
|
|
|
/**
|
|
* 项目
|
|
* @return string
|
|
*/
|
|
public function book($data)
|
|
{
|
|
// $data = array(
|
|
// 'title'=>'防爆电器',
|
|
// 'enterprise'=>'新黎明科技股份有限公司',
|
|
// 'filing'=>'G-20230525',
|
|
// 'sid'=>'91320500582331116Y',
|
|
// 'limitationdate'=>'2023-05-25',
|
|
// );
|
|
$path = "uploads/imgs/";
|
|
// file_put_contents(__DIR__ . '/debug.txt', var_export($data,true));
|
|
$file = $data['id'].'.jpg';
|
|
$font = "uploads/msyh.ttf";
|
|
$target = imagecreatetruecolor(1657, 1105);
|
|
$bc = imagecolorallocate($target, 0, 0, 0);
|
|
$cc = imagecolorallocate($target, 255, 51, 0);
|
|
$wc = imagecolorallocate($target, 255, 255, 255);
|
|
$yc = imagecolorallocate($target, 255, 255, 0);
|
|
//背景
|
|
$bg = imagecreatefromjpeg("uploads/imgs/b.jpg");
|
|
imagecopy($target, $bg, 0, 0, 0, 0, 1657, 1105);
|
|
imagedestroy($bg);
|
|
|
|
//名称
|
|
imagettftext($target, 23, 0, 600, 589, $bc, $font, $data['name']);
|
|
//个人/企业
|
|
imagettftext($target, 23, 0, 600, 652, $bc, $font, $data['enterprise']);
|
|
//备案号
|
|
imagettftext($target, 23, 0, 600, 718, $bc, $font, $data['filing']);
|
|
//证件号码
|
|
imagettftext($target, 23, 0, 600, 786, $bc, $font, $data['sid']);
|
|
//有效期
|
|
imagettftext($target, 23, 0, 600, 850, $bc, $font, $data['limitationdate']);
|
|
imagejpeg($target, $path . $file);
|
|
imagedestroy($target);
|
|
// echo '<img src="../../uploads/imgs/'.$data['id'].'.jpg">';
|
|
return '/uploads/imgs/'.$data['id'].'.jpg';
|
|
}
|
|
|
|
/**
|
|
* 服务商
|
|
* @return string
|
|
*/
|
|
public function service($data)
|
|
{
|
|
|
|
// $id = 1;
|
|
/* $data = array(
|
|
'name'=>'上 海 聚 上 网 络 科 技 有 限 公 司',
|
|
'centre'=>'华 东 服 务 中 心',
|
|
);*/
|
|
$path = "uploads/imgs/";
|
|
$me =array();
|
|
$file = $data['id'].'.jpg';
|
|
$font = "uploads/msyh.ttf";
|
|
$target = imagecreatetruecolor(800, 1111);
|
|
$bc = imagecolorallocate($target, 0, 0, 0);
|
|
$cc = imagecolorallocate($target, 255, 51, 0);
|
|
// $wc = imagecolorallocate($target, 255, 255, 255);
|
|
// $yc = imagecolorallocate($target, 255, 255, 0);
|
|
//背景
|
|
$bg = imagecreatefromjpeg("uploads/imgs/a.jpg");
|
|
|
|
imagecopy($target, $bg, 0, 0, 0, 0, 800, 1111);
|
|
imagedestroy($bg);
|
|
|
|
imagettftext($target, 23, 0, 160, 625, $bc, $font, $data['name']);
|
|
imagettftext($target, 21, 0, 300, 690, $cc, $font, $data['centre']);
|
|
imagejpeg($target, $path . $file);
|
|
imagedestroy($target);
|
|
// echo '<img src="../../uploads/imgs/'.$id.'.jpg">';
|
|
return '/uploads/imgs/'.$data['id'].'.jpg';
|
|
}
|
|
|
|
|
|
/**
|
|
* 测试
|
|
* @return string
|
|
*/
|
|
public function createShopImage()
|
|
{
|
|
$data = array(
|
|
'title'=>'防爆电器',
|
|
'enterprise'=>'新黎明科技股份有限公司',
|
|
'filing'=>'G-20230525',
|
|
'sid'=>'91320500582331116Y',
|
|
'limitationdate'=>'2023-05-25',
|
|
);
|
|
$id = 1;
|
|
$path = "uploads/imgs/";
|
|
$mid = 1;
|
|
$me =array();
|
|
$file = $id.'.jpg';
|
|
$font = "uploads/msyh.ttf";
|
|
$target = imagecreatetruecolor(1657, 1105);
|
|
$bc = imagecolorallocate($target, 0, 0, 0);
|
|
$cc = imagecolorallocate($target, 255, 51, 0);
|
|
$wc = imagecolorallocate($target, 255, 255, 255);
|
|
$yc = imagecolorallocate($target, 255, 255, 0);
|
|
//背景
|
|
$bg = imagecreatefromjpeg("uploads/imgs/b.jpg");
|
|
imagecopy($target, $bg, 0, 0, 0, 0, 1657, 1105);
|
|
imagedestroy($bg);
|
|
|
|
//名称
|
|
imagettftext($target, 23, 0, 600, 589, $bc, $font, $data['title']);
|
|
//个人/企业
|
|
imagettftext($target, 23, 0, 600, 652, $bc, $font, $data['enterprise']);
|
|
//备案号
|
|
imagettftext($target, 23, 0, 600, 718, $bc, $font, $data['filing']);
|
|
//证件号码
|
|
imagettftext($target, 23, 0, 600, 786, $bc, $font, $data['sid']);
|
|
//有效期
|
|
imagettftext($target, 23, 0, 600, 850, $bc, $font, $data['limitationdate']);
|
|
imagejpeg($target, $path . $file);
|
|
imagedestroy($target);
|
|
echo '<img src="../../uploads/imgs/'.$id.'.jpg">';
|
|
}
|
|
} |