档案详情接口增加id_card字段

This commit is contained in:
luofei 2023-08-01 16:31:48 +08:00
parent aa8fa7c139
commit 3b86db5d96
12 changed files with 127 additions and 623 deletions

View File

@ -1,108 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\informationg;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\informationg\UserInformationgLists;
use app\adminapi\logic\informationg\UserInformationgLogic;
use app\adminapi\validate\informationg\UserInformationgValidate;
/**
* UserInformationg控制器
* Class UserInformationgController
* @package app\adminapi\controller\informationg
*/
class UserInformationgController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function lists()
{
return $this->dataLists(new UserInformationgLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function add()
{
$params = (new UserInformationgValidate())->post()->goCheck('add');
$result = UserInformationgLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(UserInformationgLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function edit()
{
$params = (new UserInformationgValidate())->post()->goCheck('edit');
$result = UserInformationgLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(UserInformationgLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function delete()
{
$params = (new UserInformationgValidate())->post()->goCheck('delete');
UserInformationgLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function detail()
{
$params = (new UserInformationgValidate())->goCheck('detail');
$result = UserInformationgLogic::detail($params);
return $this->data($result);
}
}

View File

@ -105,7 +105,6 @@ class UserController extends BaseAdminController
{
$params = Request::param();
$result = UserLogic::detail($params['id']);
halt($result);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
$data = [
'name' => $result['nickname'] . '的合同',

View File

@ -56,6 +56,7 @@ class CategoryBusinessLists extends BaseAdminDataLists implements ListsSearchInt
{
$lists=CategoryBusiness::where($this->searchWhere)
->field(['id', 'name', 'pid', 'sort', 'status'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();

View File

@ -1,77 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\informationg;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\informationg\UserInformationg;
use app\common\lists\ListsSearchInterface;
/**
* UserInformationg列表
* Class UserInformationgLists
* @package app\adminapi\listsinformationg
*/
class UserInformationgLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function setSearch(): array
{
return [
'=' => ['create_user_id', 'user_id', 'area_id', 'street_id', 'village_id', 'brigade_id', 'address', 'name', 'phone', 'sex', 'age', 'wechat', 'family', 'child', 'child_arr', 'highway', 'smart_phone', 'status'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function lists(): array
{
$lists = UserInformationg::where($this->searchWhere)
->field(['id', 'area_id','area_id area_name','street_id','street_id street_name','village_id','village_id village_name', 'brigade_id','brigade_id brigade_name', 'address', 'name', 'phone', 'sex', 'age', 'status'])
->order(['id' => 'desc'])
->select()
->toArray();
return $lists;
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function count(): int
{
return UserInformationg::where($this->searchWhere)->count();
}
}

View File

@ -1,162 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\informationg;
use app\common\model\informationg\UserInformationg;
use app\common\logic\BaseLogic;
use app\common\model\informationg\UserInformationgDemand;
use think\facade\Db;
/**
* UserInformationg逻辑
* Class UserInformationgLogic
* @package app\adminapi\logic\informationg
*/
class UserInformationgLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/08/01 15:00
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
UserInformationg::create([
'create_user_id' => $params['create_user_id'],
'user_id' => $params['user_id'],
'area_id' => $params['area_id'],
'street_id' => $params['street_id'],
'village_id' => $params['village_id'],
'brigade_id' => $params['brigade_id'],
'address' => $params['address'],
'name' => $params['name'],
'phone' => $params['phone'],
'sex' => $params['sex'],
'age' => $params['age'],
'wechat' => $params['wechat'],
'family' => $params['family'],
'child' => $params['child'],
'child_arr' => $params['child_arr'],
'highway' => $params['highway'],
'smart_phone' => $params['smart_phone'],
'status' => $params['status']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/08/01 15:00
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
UserInformationg::where('id', $params['id'])->update([
'create_user_id' => $params['create_user_id'],
'user_id' => $params['user_id'],
'area_id' => $params['area_id'],
'street_id' => $params['street_id'],
'village_id' => $params['village_id'],
'brigade_id' => $params['brigade_id'],
'address' => $params['address'],
'name' => $params['name'],
'phone' => $params['phone'],
'sex' => $params['sex'],
'age' => $params['age'],
'wechat' => $params['wechat'],
'family' => $params['family'],
'child' => $params['child'],
'child_arr' => $params['child_arr'],
'highway' => $params['highway'],
'smart_phone' => $params['smart_phone'],
'status' => $params['status']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/08/01 15:00
*/
public static function delete(array $params): bool
{
return UserInformationg::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/08/01 15:00
*/
public static function detail($params): array
{
$item = UserInformationg::where('id', $params['id'])->field('*,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->find();
$item['family'] = json_decode($item['family'], true);
$item['child_arr'] = json_decode($item['child_arr'], true);
$data = UserInformationgDemand::where('information_id', $params['id'])->order('id', 'desc')->select();
$item['datas'] = [];
$datas = [];
if ($data) {
foreach ($data as $k => $v) {
$a = json_decode($v['data'], true);
$arr = [
'id' => $v['id'],
'category_id' => $v['category_id'],
'category_child' => $v['category_child'],
'datas' => $a
];
if ($a) {
array_push($datas, $arr);
}
}
$item['datas'] = $datas;
}
return $item->toArray();
}
}

View File

@ -52,7 +52,7 @@ class UserLogic extends BaseLogic
// $user->sex = $user->getData('sex');
$user['qualification']=json_decode($user->qualification,true);
if($user->is_contract==1){
$user['contract']=Contract::where(['type'=>2,'party_b'=>$userId])->with(['partyA','contractType'])->find();
$user['contract']=Contract::where(['type'=>2,'party_b'=>$userId])->with('party_a,contractType')->find();
}
return $user->toArray();
}

View File

@ -1,102 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\informationg;
use app\common\validate\BaseValidate;
/**
* UserInformationg验证器
* Class UserInformationgValidate
* @package app\adminapi\validate\informationg
*/
class UserInformationgValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'user_id' => 'require',
'name' => 'require',
'phone' => 'require',
'wechat' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'user_id' => '用户id',
'name' => '姓名',
'phone' => '联系电话',
'wechat' => '微信',
];
/**
* @notes 添加场景
* @return UserInformationgValidate
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function sceneAdd()
{
return $this->only(['user_id','name','phone','wechat']);
}
/**
* @notes 编辑场景
* @return UserInformationgValidate
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function sceneEdit()
{
return $this->only(['id','user_id','name','phone','wechat']);
}
/**
* @notes 删除场景
* @return UserInformationgValidate
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return UserInformationgValidate
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace app\api\controller;
use app\common\model\category_business\CategoryBusiness;
/**
* 商机分类
* Class SmsController
* @package app\api\controller
*/
class CategoryBusinessController extends BaseApiController
{
public array $notNeedLogin = ['list'];
/**
*/
public function list()
{
$lists = CategoryBusiness::field(['id', 'name', 'pid', 'sort', 'status'])
->order(['id' => 'desc'])
->select()
->toArray();
return $this->success('操作成功',linear_to_tree($lists, 'children'));
}
}

View File

@ -2,7 +2,7 @@
namespace app\api\controller;
use app\common\model\informationg\UserInformationg;
use app\common\model\information\UserInformationg;
use app\common\logic\BaseLogic;
class InformationController extends BaseApiController

View File

@ -0,0 +1,123 @@
<?php
namespace app\common\model\information;
use app\common\model\BaseModel;
use app\common\model\user\User;
use think\facade\Db;
use think\facade\Log;
use app\common\logic\BaseLogic;
use app\common\model\Company;
class UserInformationg extends BaseModel
{
public static function list($param,$page=1,$size=10){
return self::where($param)->with('company')
->field('id,area_id,area_id as area_name,street_id,street_id as street_name,village_id,village_id as village_name, street_id as street_name,brigade_id,brigade_id as brigade_name,name,phone,age,address,create_time,update_time')
->page($page)->limit($size)->select();
}
public static function add($param)
{
$family_json = json_encode($param['family']);
$child_arr_json = json_encode($param['child_arr']);
// 插入数据
$data = [
'create_user_id'=>$param['admin_id'],
'name' => $param['name'],
'phone' => $param['phone'],
'age' => $param['age'],
'wechat' => $param['wechat'],
'area_id' => $param['area_id'],
'street_id' => $param['street_id'],
'village_id' => $param['village_id'],
'brigade_id' => $param['brigade_id'],
'address' => $param['address'],
'family' => $family_json,
'child' => $param['child'],
'child_arr' => $child_arr_json,
];
Db::startTrans();
try{
$result = self::create($data);
foreach($param['datas'] as $k=>$v){
self::informationg_demand($v,$result['id'],$param['admin_id']);
}
// switch($param['data_type']){
// case 1:
// self::informationg_demand($param,$result['id']);
// break;
// }
Db::commit();
}catch(\Exception $e){
Db::rollback();
BaseLogic::setError($e->getMessage());
return false;
}
return true;
}
public static function informationg_demand($param,$id,$admin_id){
$data=[
'create_user_id'=>$admin_id,
'category_id'=>$param['category_id']??0,
'category_child'=>$param['category_child']??0,
'data'=>json_encode($param['datas']),
'create_time'=>time(),
'update_time'=>time(),
'status'=>1,
'information_id'=>$id,
];
UserInformationgDemand::create($data);
}
public static function details($id){
$item=self::where('id',$id)->find();
$userInfo = User::where('id',$item['create_user_id'])->find();
$item['id_card'] = $userInfo['id_card'];
$item['family'] = json_decode($item['family'],true);
$item['child_arr'] = json_decode($item['child_arr'],true);
$data=UserInformationgDemand::where('create_user_id',$item['create_user_id'])->select();
$item['datas']=[];
if($data){
foreach($data as $k=>$v){
$datas=[];
$a=json_decode($v['data'],true);
$arr=[
'category_id'=>$v['category_id'],
'category_child'=>$v['category_child'],
'datas'=>$a
];
if($a){
array_push($datas,$arr);
}
$item['datas']=$datas;
}
}
return $item;
}
public function company()
{
return $this->hasOne(Company::class, 'id', 'company_id')->field(['id','company_name','admin_id']);
}
public function getCityNameAttr($value)
{
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
}
public function getAreaNameAttr($value)
{
return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name');
}
public function getStreetNameAttr($value)
{
return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name');
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace app\common\model\informationg;
namespace app\common\model\information;
use app\common\model\BaseModel;

View File

@ -1,142 +0,0 @@
<?php
namespace app\common\model\informationg;
use app\common\model\BaseModel;
use think\facade\Db;
use think\facade\Log;
use app\common\logic\BaseLogic;
use app\common\model\Company;
class UserInformationg extends BaseModel
{
/**
* @notes 关联商机信息
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/08/01 15:00
*/
public function informationInfo()
{
return $this->hasOne(\app\common\model\informationg\UserInformationgDemand::class, 'information_id', 'id');
}
public static function list($param, $page = 1, $size = 10)
{
return self::where($param)->with('company')
->field('id,area_id,area_id as area_name,street_id,street_id as street_name,village_id,village_id as village_name, street_id as street_name,brigade_id,brigade_id as brigade_name,name,phone,age,address,create_time,update_time')
->order('id','desc')
->page($page)->limit($size)->select();
}
public static function add($param)
{
$family_json = json_encode($param['family']);
$child_arr_json = json_encode($param['child_arr']);
// 插入数据
$data = [
'create_user_id' => $param['admin_id'],
'name' => $param['name'],
'phone' => $param['phone'],
'age' => $param['age'],
'wechat' => $param['wechat'],
'area_id' => $param['area_id'],
'street_id' => $param['street_id'],
'village_id' => $param['village_id'],
'brigade_id' => $param['brigade_id'],
'address' => $param['address'],
'family' => $family_json,
'child' => $param['child'],
'child_arr' => $child_arr_json,
];
Db::startTrans();
try {
$result = self::create($data);
foreach ($param['datas'] as $k => $v) {
self::informationg_demand($v, $result['id'], $param['admin_id']);
}
// switch($param['data_type']){
// case 1:
// self::informationg_demand($param,$result['id']);
// break;
// }
Db::commit();
} catch (\Exception $e) {
Db::rollback();
BaseLogic::setError($e->getMessage());
return false;
}
return true;
}
public static function informationg_demand($param, $id, $admin_id)
{
$data = [
'create_user_id' => $admin_id,
'category_id' => $param['category_id'] ?? 0,
'category_child' => $param['category_child'] ?? 0,
'data' => json_encode($param['datas']),
'create_time' => time(),
'update_time' => time(),
'status' => 1,
'information_id' => $id,
];
UserInformationgDemand::create($data);
}
public static function details($id)
{
$item = self::where('id', $id)->field('*,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->find();
$item['family'] = json_decode($item['family'], true);
$item['child_arr'] = json_decode($item['child_arr'], true);
$data = UserInformationgDemand::where('information_id', $id)->order('id', 'desc')->select();
$item['datas'] = [];
$datas = [];
if ($data) {
foreach ($data as $k => $v) {
$a = json_decode($v['data'], true);
$arr = [
'id' => $v['id'],
'category_id' => $v['category_id'],
'category_child' => $v['category_child'],
'datas' => $a
];
if ($a) {
array_push($datas, $arr);
}
}
$item['datas'] = $datas;
}
return $item;
}
public function company()
{
return $this->hasOne(Company::class, 'id', 'company_id')->field(['id', 'company_name', 'admin_id']);
}
public function getCityNameAttr($value)
{
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
}
public function getAreaNameAttr($value)
{
return Db::name('geo_area')->where(['area_code' => $this->area_id])->value('area_name');
}
public function getStreetNameAttr($value)
{
return Db::name('geo_street')->where(['street_code' => $this->street_id])->value('street_name');
}
public function getVillageNameAttr($value)
{
return Db::name('geo_village')->where(['village_code' => $this->village_id])->value('village_name');
}
public function getBrigadeNameAttr($value)
{
return Db::name('geo_brigade')->where(['id' => $this->brigade_id])->value('brigade_name');
}
}