Commit e37431ea authored by wuxiaoli's avatar wuxiaoli

族谱简介

parent 6a1fa1e4
......@@ -10,6 +10,7 @@ use app\api\model\PaymentLogModel;
use app\api\model\RechargeModel;
use app\api\model\UsersModel;
use app\common\controller\Api;
use app\lib\model\AgentModel;
use app\lib\model\FamilyModel;
use app\lib\model\FamilyPeopleModel;
use app\lib\model\FamilyTreeMateModel;
......@@ -186,6 +187,19 @@ class Family extends Api
}
$data=FamilyModel::dataInfo(['id'=>$id]);
$data['family_name'] = AgentModel::dataValue(['family_id'=>$id,'status'=>1,'type'=>1]);
$data['inheritor'] = AgentModel::dataList(['family_id'=>$id,'status'=>1,'type'=>2]);
if($data['village_id']){
$addr=Db::name('addr_village')->where(['village_code'=>$data['village_id']])->find();
$data['addr']=$addr?$addr['province'].$addr['city'].$addr['county'].$addr['town'].$addr['village']:'';
}else if($data['town_id']){
$addr=Db::name('addr_village')->where(['town_code'=>$data['town_id']])->find();
$data['addr']=$addr?$addr['province'].$addr['city'].$addr['county'].$addr['town']:'';
}else if($data['area_id']){
$addr=Db::name("addr")->where(['ID'=>$data['area_id']])->field('ID as value,Name as name, ParentId,MergerName')->find();
$data['addr']= $addr['MergerName'];
}
$this->success("",$data);
}
......
<?php
namespace app\lib\model;
use think\Db;
use think\Model;
class AgentModel extends Model
{
// 表名
protected $name = 'agent';
// 追加属性
protected $append = [
'type_text',
'status_text'
];
public function getTypeList()
{
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4'), '5' => __('Type 5')];
}
public function getStatusList()
{
return ['1' => __('Status 1'), '2' => __('Status 2')];
}
public function getTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
$list = $this->getTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
/**
* @功能说明:
*/
public static function dataList($where,$field="*",$orderby="createtime desc"){
return self::where($where)->field($field)->order($orderby)->select();
}
/**
* @功能说明:
*/
public static function dataInfo($where,$orderby="createtime desc"){
return self::where($where)->order($orderby)->find();
}
/**
* @功能说明:取某个字段
*/
public static function dataValue($where,$field='id',$orderby="createtime desc"){
return self::where($where)->order($orderby)->value($field);
}
}
\ No newline at end of file
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