档案
This commit is contained in:
parent
2706ab1455
commit
2076c7e535
32
app/api/controller/InformationController.php
Normal file
32
app/api/controller/InformationController.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\model\information\UserInformationg;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
|
||||||
|
class InformationController extends BaseApiController
|
||||||
|
{
|
||||||
|
public function list()
|
||||||
|
{
|
||||||
|
$param = Request()->param();
|
||||||
|
[$page, $limit] = $this->getPage();
|
||||||
|
$data['create_user_id'] = $this->userId;
|
||||||
|
$res = UserInformationg::list($data,$page,$limit);
|
||||||
|
if ($res != true) {
|
||||||
|
return $this->fail( BaseLogic::getError());
|
||||||
|
}
|
||||||
|
return $this->success('成功', $res->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$param = Request()->param();
|
||||||
|
$param['admin_id'] = $this->userId;
|
||||||
|
$res = UserInformationg::add($param);
|
||||||
|
if ($res != true) {
|
||||||
|
return $this->fail( BaseLogic::getError());
|
||||||
|
}
|
||||||
|
return $this->success('成功');
|
||||||
|
}
|
||||||
|
}
|
84
app/common/model/information/UserInformationg.php
Normal file
84
app/common/model/information/UserInformationg.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\information;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Log;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
|
||||||
|
class UserInformationg extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public static function list($param,$page=1,$size=10){
|
||||||
|
return self::where($param)->page($page)->limit($size)->select()->each(function($item, $key){
|
||||||
|
$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);
|
||||||
|
if($a){
|
||||||
|
array_push($datas,$a);
|
||||||
|
}
|
||||||
|
$item['datas']=$datas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
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){
|
||||||
|
|
||||||
|
$data=[
|
||||||
|
'create_user_id'=>$param['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);
|
||||||
|
}
|
||||||
|
}
|
10
app/common/model/information/UserInformationgDemand.php
Normal file
10
app/common/model/information/UserInformationgDemand.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\information;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class UserInformationgDemand extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user