Commit e270b40c by wenyi.chen

线上

parent b29b3d81
......@@ -232,4 +232,15 @@ class AdminUser extends AuthBase
exception($e,'UserInfo.resetPassword');
}
}
public function userList()
{
$adminModel = new AdminModel();
$result = $adminModel->where('status',1)->select();
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.deletion_failed"),[]);
}
}
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ namespace app\api\controller;
use app\common\model\redis\RedisModel;
use app\common\model\mysql\EnterpriseInfo as EnterpriseInfoModel;
use app\common\model\mysql\Product as ProductsModel;
use app\common\model\mysql\ProductAllocation as ProductAllocationModel;
use app\common\model\mysql\Admin as AdminModel;
use think\facade\Db;
class Product extends AuthBase
......@@ -49,6 +51,27 @@ class Product extends AuthBase
]);
if($result){
$result = $result->toArray();
}
$ProductAllocationModel =new ProductAllocationModel();
$AdminModel =new AdminModel();
$list = [];
foreach ($result['data'] as $val){
$verify_user = $ProductAllocationModel->where('product_id',$val['id'])->find();
if ($verify_user){
$res = $AdminModel->where('id',$verify_user['user_id'])->find();
$val['verify_user'] = $res['name'];
$val['verify_time'] = $verify_user['inspect_time'];
$val['distribute_time'] = $verify_user['distribute_time'];
}else{
$val['verify_user'] = '';
$val['verify_time'] = '';
$val['distribute_time'] ='';
}
array_push($list,$val);
}
$result['data'] = $list;
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),$result);
......@@ -149,4 +172,34 @@ class Product extends AuthBase
exception($e,self::$name.'delete');
}
}
/**
* 未分配的产品列表
* @return \josn
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function unallocatedProducts()
{
$productsModel =new ProductsModel();
$ProductAllocationModel =new ProductAllocationModel();
$result = $productsModel->select();
$list = [];
foreach ($result as $val){
$res = $ProductAllocationModel->where('product_id',$val['id'])->find();
if (empty($res)){
$arr = [
'key'=>$val['id'],
'label'=>$val['product_name']
];
array_push($list,$arr);
}
}
if($list){
return returnResult(config("config.code.success"),config("config.describe.success"),$list);
}else{
return returnResult(config("config.code.success"),config("config.describe.deletion_failed"),[]);
}
}
}
\ No newline at end of file
<?php
/**
* Create by wenyi
* E-mail: wesley_prc@163.com
* Description: data-collect-api
* Date: 2024/2/27 23:37
* Update: 2024/2/27 23:37
* 数据管理
*/
namespace app\api\controller;
use app\common\model\redis\RedisModel;
use app\common\model\mysql\Product as ProductModel;
use app\common\model\mysql\EnterpriseInfo as EnterpriseInfoModel;
use app\common\model\mysql\ProductAllocation as ProductAllocationModel;
use app\common\model\mysql\Admin as AdminModel;
use think\facade\Db;
class ProductAllocation extends AuthBase
{ public static $name = 'controller.ProductAllocation';
/**
* 列表
* @return \josn|void
*/
public function list()
{
try{
// 数据接收
$page = input("param.page",0,"intval");
$limit = input("param.limit",10,"intval");
$ProductAllocationModel =new ProductAllocationModel();
$result = $ProductAllocationModel->with([
'productInfo' => function($query){
},
'adminInfo' => function($query){
$query->where('status',1)->field("id,name");
},
])->where('user_id',$this->userId)
->paginate([
'list_rows'=>$limit,
'page'=>$page
]);
if($result){
$result = $result->toArray();
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),$result);
}
}catch (\Exception $e){
exception($e,self::$name.'.list');
}
}
/**
* 产品人员分配
* @return \josn|void
*/
public function add()
{
$data = array();
// 数据接收
$data['product_id'] = input("param.product_id");
$data['user_id'] = input("param.user_id");
$list = $data['product_id'];
$ProductAllocationModel =new ProductAllocationModel();
foreach ($list as $val){
$info = [
'user_id'=>$data['user_id'],
'product_id'=>$val,
'distribute_time'=>date('Y-m-d H:i:s'),
];
$result = $ProductAllocationModel->insert($info);
}
return returnResult(config("config.code.success"),config("config.describe.success"),[]);
}
/**
* 查看信息
* @return \josn
*/
public function see()
{
$id = input("id");
if(empty($id)){
return returnResult(config("config.code.error"),'ID错误!');
}
$ProductAllocationModel =new ProductAllocationModel();
$ProductModel =new ProductModel();
$EnterpriseInfoModel =new EnterpriseInfoModel();
$AdminModel =new AdminModel();
$productAllocationInfo = $ProductAllocationModel->where('id',$id)->find();
$productInfo = $ProductModel->where('id',$productAllocationInfo['product_id'])->find();
$enterpriseInfo = $EnterpriseInfoModel->where('id',$productInfo['enterprise_id'])->find();
$adminInfo = $AdminModel->where('id',$productAllocationInfo['user_id'])->find();
$result = [
'userInfo'=>$adminInfo,
'enterpriseInfo'=>$enterpriseInfo,
'productInfo'=>$productInfo,
'productAllocationInfo'=>$productAllocationInfo,
'number' =>'',
];
if($result){
$info = $ProductAllocationModel->where('user_id',$productAllocationInfo['user_id'])->select();
$num = [];
foreach ($info as $val){
array_push($num,$val['id']);
}
$index = array_search($val['id'], $num);
$front =$index-1;
$after = $index+1;
if ($front<0) {
$front = $index;
}
if ($after>=count($num)) {
$after = $index;
}
$result['number'] = ['front'=>$num[$front],'after'=>$num[$after]];
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),[]);
}
}
/**
* 保存编辑信息
* @return \josn|void
*/
public function save()
{
try{
$id = input("id");
$product_id = input("product_id");
$product_name = input("product_name");
$product_categ_name = input("product_categ_name");
$page_url = input("page_url");
$product_model = input("product_model");
$describe = input("describe");
$parameter = input("parameter");
$inspect_remarks = input("inspect_remarks");
$ProductAllocationModel =new ProductAllocationModel();
$ProductModel =new ProductModel();
$result = $ProductAllocationModel->where('id',$id)->update(['inspect_time'=>date('Y-m-d H:i:s'),'status'=>1]);
if($result){
$ProductModel
->where('id',$product_id)
->update(
[
'product_name'=>$product_name,
'product_categ_name'=>$product_categ_name,
'page_url'=>$page_url,
'product_model'=>$product_model,
'describe'=>$describe,
'parameter'=>$parameter,
'inspect_remarks'=>$inspect_remarks,
'inspect_status'=>1
]
);
}
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),[]);
}
}catch (\Exception $e){
exception($e,self::$name.'.edit');
}
}
/**
* 数据异常
* @return \josn
*/
public function abnormal()
{
$id = input("id");
$is = input("is");
$product_id = input("product_id");
$inspect_remarks = input("inspect_remarks");
$ProductAllocationModel =new ProductAllocationModel();
$ProductModel =new ProductModel();
$result = $ProductAllocationModel->where('id',$id)->update(['inspect_time'=>date('Y-m-d H:i:s'),'status'=>1]);
if($result){
$ProductModel
->where('id',$product_id)
->update(
[
'inspect_remarks'=>$inspect_remarks,
'inspect_status'=>$is
]
);
}
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),[]);
}
}
}
\ No newline at end of file
......@@ -42,6 +42,8 @@ Route::rule("admin/delete","AdminUser/delete"); //删除信息
Route::rule("admin/changeStatus","AdminUser/changeStatus"); //修改状态
Route::rule("admin/resetPassword","AdminUser/resetPassword"); //修改状态
Route::rule("admin/userList","AdminUser/userList"); // 产品检查人员列表
/***************************操作日志 */
Route::rule("adminLog/list","AdminLog/list"); // 列表
......@@ -86,6 +88,14 @@ Route::rule("product/save","Product/save");
Route::rule("product/delete","Product/delete");
Route::rule("product/add","Product/add");
Route::rule("product/unallocatedProducts","product/unallocatedProducts");
Route::rule("productAllocation/add","productAllocation/add");
Route::rule("productAllocation/list","productAllocation/list");
Route::rule("productAllocation/see","productAllocation/see");
Route::rule("productAllocation/save","productAllocation/save");
Route::rule("productAllocation/abnormal","productAllocation/abnormal");
Route::rule("service/product","Service/product");
Route::rule("service/product1","Service/product1");
Route::rule("service/enterpriseName","Service/enterpriseName");
......
<?php
/**
*
*/
namespace app\common\model\mysql;
use think\Model;
class ProductAllocation extends Model
{
protected $name = 'product_allocation';
// protected $createTime = 'create_at';
// protected $updateTime = 'update_at';
// // 定义更新的时间戳字段名
//// protected $autoWriteTimestamp = ['update_time'];
/**
* 关联权限组信息
* @return \think\model\relation\HasMany
*/
public function enterpriseInfo()
{
try{
return $this->hasOne('EnterpriseInfo','id','enterprise_id');
}catch (\Exception $e){
exception($e,'mysql.'.$this->name.'.enterpriseInfo');
}
}
/**
* 关联权限组信息
* @return \think\model\relation\HasMany
*/
public function productInfo()
{
try{
return $this->hasOne('Product','id','product_id');
}catch (\Exception $e){
exception($e,'mysql.'.$this->name.'.enterpriseInfo');
}
}
/**
* 关联权限组信息
* @return \think\model\relation\HasMany
*/
public function adminInfo()
{
try{
return $this->hasOne('Admin','id','user_id');
}catch (\Exception $e){
exception($e,'mysql.'.$this->name.'.adminInfo');
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment