附件上传增加用户属性

This commit is contained in:
15090180611 2024-12-19 17:30:50 +08:00
parent 15ec3f60c9
commit 525d204e35
18 changed files with 259 additions and 32 deletions

View File

@ -59,7 +59,7 @@ class Attachment extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
$list = $this->model->with(["user"])
->where($mimetypeQuery)
->where($where)
->whereRaw("`filename` NOT REGEXP '^[0-9A-Fa-f]{32}'")
@ -67,12 +67,19 @@ class Attachment extends Backend
->paginate($limit);
// var_dump($this->model->getLastSql());
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname', 'realname', 'mobile', 'avatar']);
}
$rows = $list->items();
$cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
foreach ($list as $k => &$v) {
foreach ($rows as $k => &$v) {
$v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
}
unset($v);
$result = array("total" => $list->total(), "rows" => $list->items());
$result = array("total" => $list->total(), "rows" => $rows);
return json($result);
}

View File

@ -706,7 +706,12 @@ class ClassesLib extends Backend
//主键值
$primaryvalue = $this->request->request("keyValue");
//搜索字段
$searchfield = (array)$this->request->request("searchField/a");
// $searchfield = (array)$this->request->request("searchField/a");
$searchfield = [
'id','title', 'address', 'address_detail'
];
//自定义搜索条件
$custom = (array)$this->request->request("custom/a");
//是否返回树形结构

View File

@ -137,7 +137,11 @@ class User extends Backend
//主键值
$primaryvalue = $this->request->request("keyValue");
//搜索字段
$searchfield = (array)$this->request->request("searchField/a");
// $searchfield = (array)$this->request->request("searchField/a");
$searchfield = [
'id','realname','nickname','mobile'
];
//自定义搜索条件
$custom = (array)$this->request->request("custom/a");
//是否返回树形结构

View File

@ -37,5 +37,9 @@ return [
'Please enter a new name' => '请输入新的类别名称',
'Please select category' => '请选择一个类别',
'Category not found' => '指定的类别未找到',
'Upload from editor' => '从编辑器上传'
'Upload from editor' => '从编辑器上传',
'User.nickname' => '上传用户昵称',
'User.realname' => '上传用户真实姓名',
'User.mobile' => '上传用户手机号',
'User.avatar' => '上传用户头像',
];

View File

@ -21,15 +21,21 @@ class Index extends Api
/**
* 执行sql脚本
*
* @ApiMethod(GET)
* @ApiParams(name = "page", type = "int",required=false,description = "页数")
* @ApiParams(name = "limit", type = "int",required=false,description = "每页条数")
*/
public function index()
{
$limit = $this->request->param('limit/d', 1000);
$page = $this->request->param('page/d', 1);
Db::startTrans();
try {
// $da = ServiceOrder::getCost("dgadasdasdsds12343","2024121214396382520","aaaaa",$param=[],true);
// var_dump($da);
Sqlscript::importClasses(1,1000);
// Sqlscript::deleteClasses(1,1000);
Sqlscript::importClasses($page,$limit);
Sqlscript::importUser($page,$limit);
Db::commit();
} catch (PDOException|\Exception $e) {
Db::rollback();

View File

@ -6,6 +6,10 @@ use app\common\model\school\Area;
use app\common\model\school\classes\Cate;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\ClassesSpec;
use app\common\model\school\classes\Evaluate;
use app\common\model\school\classes\Order;
use app\common\model\school\classes\order\OrderDetail;
use app\common\model\school\classes\order\ServiceOrder;
use app\common\model\school\classes\Type;
use app\common\model\school\classes\VirtualHead;
use app\common\model\school\classes\VirtualUser;
@ -85,6 +89,12 @@ $address_type = "2";
$v["start_time"] = substr($v["start_time"],0,10);
$v["end_time"] = substr($v["end_time"],0,10);
//如果是非过期课程则不添加
if($v["end_time"] >= time()){
continue;
}
$spec = [
"classes_lib_id"=>0,
"name"=>"单课时默认课时",
@ -121,4 +131,118 @@ $address_type = "2";
public static function deleteClasses($page=1,$limit=1000){
$kechengs = Db::table("kecheng")
->page($page,$limit)->select();
//默认机构id
$manystore_id = 1;
$shop_id = 1;
$user_id = 72;
$teacher_id = 15;
foreach ($kechengs as $k=>$v){
$classes_cate_ids = Cate::where( "name",$v["gongyi"])->value("id");
if(!$classes_cate_ids)$classes_cate_ids="";
$classes_label_ids = "";
$classes_type = Type::where( "name",$v["kecheng_type"])->value("id");
$add_type = "2";
$add_id = 0;
$title = $v["name"];
$headimage = $v["img"];
if(!$headimage)continue;
$images = Db::table("kecheng_img")->where("ke_id",$v["id"])->column("path");
$images = implode(",",$images);
$type = "in";
$classes_num = 1;
$address_type = "2";
// "address_city": "河南省/洛阳市",
// "province": "河南省",
// "city": "洛阳市",
// "area": null,
// "province_code": 410000,
// "city_code": 410300,
// "area_code": 0
$address_city = "河南省/洛阳市"."/".$v["district"];
$address = $v["district"];
$address_detail = $v["shangkedidian"];
$province = 410000;
$city = 410300;
$district = Area::where( "name","like","%".$v["district"]."%")
->where("level",3)
->where("pid",$city)
->value("id");
$longitude = $v["longitude"];
$latitude = $v["latitude"];
//html解码
$content = html_entity_decode($v["blurb"]);
$notice = html_entity_decode($v["experience"]);
$price = 0;
$status = "1";
$weigh = 0;
$recommend = ''.($v["por"] ?:0);
$hot = ''.($v["hot"] ?:0);
$new = ''.($v["top"] ?:0);
$auth_status = 1;
$feel = "1";
//如果不存在开始和结束时间
//随机生成个至少过去一个月的开始和结束时间, 结束时间至少过去一个月
if(!$v["start_time"]||!$v["end_time"]){
$v["start_time"] = time()-rand(2592000,2592000*10);
$v["end_time"] = rand($v["start_time"]+24536,$v["start_time"] + time()-$v["start_time"]);
}
//开始时间和结束时间如果是毫秒级时间戳,截取成秒级
$v["start_time"] = substr($v["start_time"],0,10);
$v["end_time"] = substr($v["end_time"],0,10);
$classes_lib = ClassesLib::where("title",$title)->find();
if($classes_lib){
ClassesLib::deleteAllByClassesId($classes_lib["id"]);
}
}
}
public static function importUser($page=1,$limit=1000){
$userwxs = Db::table("userwx")
->page($page,$limit)->select();
//默认机构id
$manystore_id = 1;
$shop_id = 1;
$user_id = 72;
$teacher_id = 15;
foreach ($userwxs as $k=>$userwx){
$nickname = $userwx["user"] ?: $userwx["name"];
$mobile = $userwx["phone"];
//创建用户
$user = \app\common\model\User::where("mobile",$mobile)->find();
//检测更新教练下单学员账号创建状态 2022/8/27 new
if(!$user)$user = (new \app\common\model\User)->addUserByMobile($mobile,$nickname,false);
//更新附加信息
$user['nickname'] = $userwx["name"];
$user['realname'] = $userwx["user"];
if(!$userwx['sex'] || $userwx['sex'] == "" || $userwx['sex'] == "1"){
$user['gender'] = 1;
}else{
$user['gender'] = 0;
}
$user['avatar'] = $userwx['head_img'] ?: "/old/static/common/images/tou2.png";
$user['birthday'] = $userwx['birthday'];
$user['work'] = $userwx['career'];
$user['createtime'] = strtotime($userwx["uptime"]);
$user['updatetime'] = strtotime($userwx["uptime"]);
$user->save();
}
}
}

View File

@ -4,7 +4,7 @@ namespace app\common\model;
use think\Model;
class Attachment extends Model
class Attachment extends BaseModel
{
// 开启自动写入时间戳字段
@ -95,4 +95,10 @@ class Attachment extends Model
$data['unclassed'] = __('Unclassed');
return $data;
}
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}

View File

@ -4,7 +4,7 @@ namespace app\common\model;
use think\Model;
class ManystoreAttachment extends Model
class ManystoreAttachment extends BaseModel
{
// 开启自动写入时间戳字段
@ -62,4 +62,10 @@ class ManystoreAttachment extends Model
}
});
}
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}

View File

@ -260,12 +260,12 @@ class User extends BaseModel
* @param $nickname
*/
public function addUserByMobile($mobile,$nickname,$check=true){
//去除空格
$nickname = trim($nickname);
$mobile = trim($mobile);
if(!is_numeric($mobile))throw new \Exception("不是合法手机号!");
if(strlen($mobile)!=11)throw new \Exception("请输入11位手机号");
if($check){
//去除空格
$nickname = trim($nickname);
$mobile = trim($mobile);
if(!is_numeric($mobile))throw new \Exception("不是合法手机号!");
if(strlen($mobile)!=11)throw new \Exception("请输入11位手机号");
if (!preg_match("/[\x7f-\xff]/", $nickname)) throw new \Exception("名称必须是汉字,请去除空格和其他特殊符号!");
preg_match_all("/[\x{4e00}-\x{9fa5}]/u","$nickname",$result);
if(!$result || join('',$result[0])!=$nickname)throw new \Exception("名称必须是汉字,请去除空格和其他特殊符号!");

View File

@ -219,12 +219,12 @@ class ManystoreShop extends BaseModel
<span>必要展示信息为: </span><br><br><br>
<span>1:地址信息:包括详细地址、所在城市、所在省、所在市、所在县、经纬度</span><br>
<span>2店铺名称</span><br>
<span>3店铺logo</span><br>
<span>4店铺封面图</span><br>
<span>5店铺环境照</span><br>
<span>2申请人姓名|机构名称</span><br>
<span>3logo</span><br>
<span>4封面图</span><br>
<span>5环境图片</span><br>
<span>6:服务电话</span><br>
<span>7店铺详情</span><br><br><br>
<span>7详情</span><br><br><br>
<b>请您确保上述信息均已完善后才能正常上架课程。 </b><br><br>
<b>若已完善请您刷新页面。 </b><br><br>
</div>

View File

@ -10,6 +10,8 @@ use app\common\model\manystore\Shop;
use app\common\model\manystore\UserAuth;
use app\common\model\school\Area;
use app\common\model\school\classes\lib\Spec;
use app\common\model\school\classes\order\OrderDetail;
use app\common\model\school\classes\order\ServiceOrder;
use app\common\model\User;
use app\manystore\model\Manystore;
use think\Model;
@ -1816,6 +1818,23 @@ $user_unpaid_order = $user_paid_order =null;
}
public static function deleteAllByClassesId($classesId){
$classes_lib = ClassesLib::where("id",$classesId)->find();
if($classes_lib){
Order::where(array('classes_lib_id'=>$classes_lib['id']))->delete();
OrderDetail::where(array('classes_lib_id'=>$classes_lib['id']))->delete();
\app\admin\model\school\classes\hour\Order::where(array('classes_lib_id'=>$classes_lib['id']))->delete();
ServiceOrder::where(array('classes_lib_id'=>$classes_lib['id']))->delete();
Evaluate::where(array('classes_lib_id'=>$classes_lib['id']))->delete();
$specs = $classes_lib->specs;
foreach ($specs as $spec){
$spec->delete();
}
$classes_lib->delete();
}
}
}

View File

@ -60,19 +60,24 @@ class Attachment extends ManystoreBase
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
$list = $this->model->with(["user"])
->where($mimetypeQuery)
->whereRaw("`filename` NOT REGEXP '^[0-9A-Fa-f]{32}'")
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname', 'realname', 'mobile', 'avatar']);
}
$rows = $list->items();
$cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
foreach ($list as $k => &$v) {
foreach ($rows as $k => &$v) {
$v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
}
unset($v);
$result = array("total" => $list->total(), "rows" => $list->items());
$result = array("total" => $list->total(), "rows" => $rows);
return json($result);
}

View File

@ -105,7 +105,12 @@ class User extends ManystoreBase
//主键值
$primaryvalue = $this->request->request("keyValue");
//搜索字段
$searchfield = (array)$this->request->request("searchField/a");
// $searchfield = (array)$this->request->request("searchField/a");
$searchfield = [
'id','realname', 'username', 'nickname', 'mobile'
];
//自定义搜索条件
$custom = (array)$this->request->request("custom/a");
//是否返回树形结构

View File

@ -37,5 +37,9 @@ return [
'Please enter a new name' => '请输入新的类别名称',
'Please select category' => '请选择一个类别',
'Category not found' => '指定的类别未找到',
'Upload from editor' => '从编辑器上传'
'Upload from editor' => '从编辑器上传',
'User.nickname' => '上传用户昵称',
'User.realname' => '上传用户真实姓名',
'User.mobile' => '上传用户手机号',
'User.avatar' => '上传用户头像',
];

View File

@ -25,8 +25,8 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
{field: 'state', checkbox: true},
{field: 'id', title: __('Id')},
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
{field: 'admin_id', title: __('Admin_id'), visible: false, addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
{field: 'user_id', title: __('User_id'), visible: false, addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
{field: 'admin_id', title: __('Admin_id'), addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
{field: 'user_id', title: __('User_id'), addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
{field: 'preview', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
{field: 'url', title: __('Url'), formatter: Controller.api.formatter.url, visible: false},
{field: 'filename', title: __('Filename'), sortable: true, formatter: Controller.api.formatter.filename, operate: 'like'},
@ -37,6 +37,13 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
return (size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
}
},
{field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
{field: 'user.realname', title: __('User.realname'),visible:false, operate: 'LIKE'},
{field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
{field: 'user.avatar', title: __('User.avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'imagewidth', title: __('Imagewidth'), sortable: true},
{field: 'imageheight', title: __('Imageheight'), sortable: true},
{field: 'imagetype', title: __('Imagetype'), sortable: true, formatter: Table.api.formatter.search, operate: 'like'},

View File

@ -33,9 +33,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'messageevent.logo_image', title: __('Logo_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
{field: 'status', title: __('Status'), searchList: {"system":__('Status system'),"classes":__('Status classes'),"order":__('Status order')}, formatter: Table.api.formatter.status},
{field: 'status', title: __('Status'), searchList: {"system":__('Status system'),"classes":__('Status classes'),"order":__('Status order')}, formatter: Table.api.formatter.status},
{field: 'mini_type', title: __('Mini_type'), searchList: {"order_notice":__('Mini_type order_notice'),"classes_auth":__('Mini_type classes_auth'),"classes_apply":__('Mini_type classes_apply'),"shop_apply":__('Mini_type shop_apply'),"classes_order_notice":__('Mini_type classes_order_notice'),"user_auth":__('Mini_type user_auth'),"aftercare":__('Mini_type aftercare'),"other":__('Mini_type other')}, formatter: Table.api.formatter.normal},
{field: 'event', title: __('Event'),visible:false, operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'event', title: __('Event'),visible:false, operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},

View File

@ -55,7 +55,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
text: __('设置成机构认证'),
title: __('设置成机构认证'),
classname: 'btn btn-dialog',
icon: 'fa fa-list',
icon: 'fa fa-bank',
dropdown : '更多',
url: manystore_url,
callback: function (data) {
@ -70,7 +70,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
text: __('设置成机构授权'),
title: __('设置成机构授权'),
classname: 'btn btn-dialog',
icon: 'fa fa-list',
icon: 'fa fa-bitbucket',
dropdown : '更多',
url: user_auth_url,
callback: function (data) {
@ -181,6 +181,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// return row.classes_evaluate_id;
// }
},
{
name: 'attachment',
text: __('查看用户上传图片'),
title: __('查看用户上传图片'),
classname: 'btn btn-dialog',
icon: 'fa fa-file-picture-o',
dropdown : '更多',
url: attachment_url,
callback: function (data) {
},
// visible: function (row) {
// return row.classes_evaluate_id;
// }
},
], events: Table.api.events.operate, formatter: Table.api.formatter.operate},
@ -270,6 +285,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
return 'school/classes/evaluate/index?user_id='+row.id;
}
var attachment_url = function (row,dom) {
return 'general/attachment/index?user_id='+row.id;
}
return Controller;
});

View File

@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
{field: 'user_id', title: __('User_id'), visible: false, addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
{field: 'user_id', title: __('User_id'), addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
{field: 'preview', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
{field: 'url', title: __('Url'), formatter: Controller.api.formatter.url, visible: false},
@ -38,6 +38,12 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
return (size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
}
},
{field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
{field: 'user.realname', title: __('User.realname'),visible:false, operate: 'LIKE'},
{field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
{field: 'user.avatar', title: __('User.avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'imagewidth', title: __('Imagewidth'), sortable: true},
{field: 'imageheight', title: __('Imageheight'), sortable: true},
{field: 'imagetype', title: __('Imagetype'), formatter: Table.api.formatter.search, operate: 'like'},