更新后台管理系统细节
This commit is contained in:
parent
0c780d19c6
commit
4e3353eacd
|
@ -104,5 +104,21 @@ class LandPlantController extends BaseAdminController
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/11/23 11:32
|
||||||
|
*/
|
||||||
|
public function suyuan()
|
||||||
|
{
|
||||||
|
$params = (new LandPlantValidate())->goCheck('suyuan');
|
||||||
|
$result = LandPlantLogic::suyuan($params);
|
||||||
|
if (false === $result) {
|
||||||
|
return $this->fail(LandPlantLogic::getError());
|
||||||
|
}
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,8 +15,11 @@
|
||||||
namespace app\adminapi\logic\land;
|
namespace app\adminapi\logic\land;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\land\LandPlant;
|
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\land\LandPlant;
|
||||||
|
use app\common\model\action\Action;
|
||||||
|
use app\common\model\land\Land;
|
||||||
|
use app\common\model\plant\Plant;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,4 +128,38 @@ class LandPlantLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
return LandPlant::findOrEmpty($params['id'])->toArray();
|
return LandPlant::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function suyuan($params): array|bool
|
||||||
|
{
|
||||||
|
if(empty($params['id'])){
|
||||||
|
self::setError('参数错误');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$plantInfo = Plant::where('id',$params['id'])->findOrEmpty();
|
||||||
|
if($plantInfo->isEmpty()){
|
||||||
|
self::setError('种植信息错误');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if($plantInfo['status'] != 2){
|
||||||
|
self::setError('种植信息状态错误');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$landInfo = Land::where('id',$plantInfo['land_id'])->findOrEmpty();
|
||||||
|
if($landInfo->isEmpty()){
|
||||||
|
self::setError('土地信息错误');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$plantInfo['pic'] = json_decode($plantInfo['pic'],true);
|
||||||
|
$plantInfo['plant_date'] = date('Y-m-d',$plantInfo['plant_date']);
|
||||||
|
$plantInfo['land_name'] = $landInfo['title'];
|
||||||
|
$plantInfo['land_area'] = $landInfo['total_area'];
|
||||||
|
$plantInfo['land_address'] = $landInfo['province_name'].$landInfo['city_name'].$landInfo['county_name'].$landInfo['town_name'].$landInfo['village_name'].$landInfo['group_name'];
|
||||||
|
//获取操作
|
||||||
|
$action = Action::field('type,type_text,detail,create_time')->where('plant_id',$params['id'])->select()->each(function($item){
|
||||||
|
$item['detail'] = json_decode($item['detail'],true);
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
|
$plantInfo['actions'] = $action;
|
||||||
|
return $plantInfo->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -109,4 +109,15 @@ class LandPlantValidate extends BaseValidate
|
||||||
return $this->only(['id']);
|
return $this->only(['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 溯源场景
|
||||||
|
* @return LandPlantValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2023/11/23 11:32
|
||||||
|
*/
|
||||||
|
public function sceneSuyuan()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue