191 lines
3.4 KiB
PHP
191 lines
3.4 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\Source;
|
|
use app\farm\server\Land;
|
|
use think\App;
|
|
use think\facade\Db;
|
|
|
|
|
|
class AdminSource 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-14 17:04
|
|
* @功能说明:溯源列表
|
|
*/
|
|
public function sourceList(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$source_model = new Source();
|
|
|
|
$dis[] = ['uniacid','=',$this->_uniacid];
|
|
|
|
$dis[] = ['status','>',-1];
|
|
|
|
if(!empty($input['title'])){
|
|
|
|
$dis[] = ['title','like','%'.$input['title'].'%'];
|
|
}
|
|
|
|
if(!empty($input['farmer_id'])){
|
|
|
|
$dis[] = ['farmer_id','=',$input['farmer_id']];
|
|
}
|
|
|
|
$data = $source_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-14 17:04
|
|
* @功能说明:溯源下拉框
|
|
*/
|
|
public function sourceSelect(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$source_model = new Source();
|
|
|
|
$dis[] = ['uniacid','=',$this->_uniacid];
|
|
|
|
$dis[] = ['status','=',1];
|
|
|
|
if(!empty($input['title'])){
|
|
|
|
$dis[] = ['title','like','%'.$input['title'].'%'];
|
|
}
|
|
|
|
if(!empty($input['farmer_id'])){
|
|
|
|
$dis[] = ['farmer_id','=',$input['farmer_id']];
|
|
}
|
|
|
|
$data = $source_model->where($dis)->select()->toArray();
|
|
|
|
return $this->success($data);
|
|
}
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-14 17:10
|
|
* @功能说明:添加溯源
|
|
*/
|
|
public function sourceAdd(){
|
|
|
|
$input = $this->_input;
|
|
|
|
$source_model = new Source();
|
|
|
|
$input['uniacid'] = $this->_uniacid;
|
|
|
|
$res = $source_model->dataAdd($input);
|
|
|
|
return $this->success($res);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-14 17:12
|
|
* @功能说明:编辑溯源
|
|
*/
|
|
public function sourceUpdate(){
|
|
|
|
$input = $this->_input;
|
|
|
|
$source_model = new Source();
|
|
|
|
$input['uniacid'] = $this->_uniacid;
|
|
|
|
$dis = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
//删除
|
|
if(isset($input['status'])&&$input['status']==-1){
|
|
|
|
$find = $this->land_model->landSomeFind($input['id'],3);
|
|
|
|
if($find==1){
|
|
|
|
$this->errorMsg('该溯源正在被使用');
|
|
}
|
|
|
|
}
|
|
|
|
$res = $source_model->dataUpdate($dis,$input);
|
|
|
|
return $this->success($res);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2021-12-14 17:12
|
|
* @功能说明:编辑溯源
|
|
*/
|
|
public function sourceInfo(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$source_model = new Source();
|
|
|
|
$dis = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
|
|
$res = $source_model->dataInfo($dis);
|
|
|
|
return $this->success($res);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|