219 lines
3.8 KiB
PHP
219 lines
3.8 KiB
PHP
<?php
|
|
namespace app\farm\controller;
|
|
use app\AdminRest;
|
|
use app\farm\model\BalanceCard;
|
|
use app\farm\model\BalanceOrder;
|
|
|
|
|
|
use app\farm\model\LandList;
|
|
use app\farm\model\Massif;
|
|
use app\farm\model\Seed;
|
|
use app\farm\server\Land;
|
|
use think\App;
|
|
use think\facade\Db;
|
|
|
|
|
|
class AdminSeed extends AdminRest
|
|
{
|
|
|
|
|
|
protected $model;
|
|
|
|
protected $massif_model;
|
|
|
|
protected $land_model;
|
|
|
|
|
|
public function __construct(App $app) {
|
|
|
|
parent::__construct($app);
|
|
|
|
$this->model = new BalanceCard();
|
|
|
|
$this->massif_model = new Massif();
|
|
|
|
$this->land_model = new LandList();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-20 16:54
|
|
* @功能说明:种子列表
|
|
*/
|
|
public function seedList(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$dis[] = ['uniacid','=',$this->_uniacid];
|
|
|
|
$dis[] = ['status','>',-1];
|
|
|
|
if(!empty($input['farmer_id'])){
|
|
|
|
$dis[] = ['farmer_id','=',$input['farmer_id']];
|
|
}
|
|
|
|
if(!empty($input['title'])){
|
|
|
|
$dis[] = ['title','like','%'.$input['title'].'%'];
|
|
}
|
|
|
|
$seed_model = new Seed();
|
|
|
|
$data = $seed_model->dataList($dis,$input['limit']);
|
|
|
|
if(!empty($data['data'])){
|
|
|
|
foreach ($data['data'] as &$v){
|
|
|
|
// $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
|
}
|
|
}
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-20 16:54
|
|
* @功能说明:种子列表
|
|
*/
|
|
public function seedSelect(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$dis[] = ['uniacid','=',$this->_uniacid];
|
|
|
|
$dis[] = ['status','=',1];
|
|
|
|
if(!empty($input['farmer_id'])){
|
|
|
|
$dis[] = ['farmer_id','=',$input['farmer_id']];
|
|
}
|
|
|
|
if(!empty($input['title'])){
|
|
|
|
$dis[] = ['title','like','%'.$input['title'].'%'];
|
|
}
|
|
|
|
$seed_model = new Seed();
|
|
|
|
$data = $seed_model->where($dis)->select()->toArray();
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-20 16:57
|
|
* @功能说明:添加种子
|
|
*/
|
|
public function seedAdd(){
|
|
|
|
$input = $this->_input;
|
|
|
|
$input['uniacid'] = $this->_uniacid;
|
|
|
|
$seed_model = new Seed();
|
|
|
|
$data = $seed_model->dataAdd($input);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-14 14:50
|
|
* @功能说明:编辑种子
|
|
*/
|
|
public function seedUpdate(){
|
|
|
|
$input = $this->_input;
|
|
|
|
$dis = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
|
|
$input['uniacid'] = $this->_uniacid;
|
|
|
|
$seed_model = new Seed();
|
|
//删除
|
|
if(isset($input['status'])&&in_array($input['status'],[-1,0])){
|
|
|
|
$find = $this->land_model->landSomeFind($input['id'],2);
|
|
|
|
if($find==1){
|
|
|
|
$this->errorMsg('该种子正在被使用');
|
|
}
|
|
|
|
}
|
|
|
|
$data = $seed_model->dataUpdate($dis,$input);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-14 14:50
|
|
* @功能说明:编辑种子
|
|
*/
|
|
public function seedInfo(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$dis = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
|
|
$seed_model = new Seed();
|
|
|
|
$data = $seed_model->dataInfo($dis);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-14 14:50
|
|
* @功能说明:编辑种子
|
|
*/
|
|
public function seedStatusUpdate(){
|
|
|
|
$input = $this->_input;
|
|
|
|
$dis = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
|
|
$seed_model = new Seed();
|
|
|
|
$data = $seed_model->where($dis)->update($input);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|