update
This commit is contained in:
parent
eda6481f7c
commit
ea91ea167c
|
@ -231,18 +231,33 @@
|
|||
//添加饲养动物操作记录
|
||||
public function addAnimalRecord(): Json
|
||||
{
|
||||
$params = $this->request->post(['user_id','action_id','action_content']);
|
||||
$params = $this->request->post(['user_id','action_id','action_content','action_extends']);
|
||||
if(empty($params['user_id']) || empty($params['action_id']) || empty($params['action_content'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if(empty(json_decode($params['action_content']))) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//写入数据
|
||||
$params['create_time'] = time();
|
||||
$result = Db::name('farmer_animal_record')->insert($params);
|
||||
Db::transaction(function () use($params) {
|
||||
//写入数据
|
||||
$params['create_time'] = time();
|
||||
Db::name('farmer_animal_record')->insert($params);
|
||||
if(!empty($params['action_extends'])){
|
||||
$extends = json_decode($params['action_extends'],true);
|
||||
if($extends && !empty($extends['animal_id'])){
|
||||
foreach($extends['animal_id'] as $v){
|
||||
Db::name('farmer_animal_status')->insert([
|
||||
'animal_id' => $v,
|
||||
'action_name' => '疫苗注射记录',
|
||||
'action_content' => $params['action_content'],
|
||||
'create_time' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//返回
|
||||
return $result ? $this->success('添加成功') : $this->fail('添加失败');
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
//删除饲养动物操作记录
|
||||
|
|
|
@ -231,18 +231,33 @@
|
|||
//添加饲养家禽操作记录
|
||||
public function addPoultryRecord(): Json
|
||||
{
|
||||
$params = $this->request->post(['user_id','action_id','action_content']);
|
||||
$params = $this->request->post(['user_id','action_id','action_content','action_extends']);
|
||||
if(empty($params['user_id']) || empty($params['action_id']) || empty($params['action_content'])){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if(empty(json_decode($params['action_content']))) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//写入数据
|
||||
$params['create_time'] = time();
|
||||
$result = Db::name('farmer_poultry_record')->insert($params);
|
||||
Db::transaction(function () use($params) {
|
||||
//写入数据
|
||||
$params['create_time'] = time();
|
||||
Db::name('farmer_poultry_record')->insert($params);
|
||||
if(!empty($params['action_extends'])){
|
||||
$extends = json_decode($params['action_extends'],true);
|
||||
if($extends && !empty($extends['poultry_id'])){
|
||||
foreach($extends['poultry_id'] as $v){
|
||||
Db::name('farmer_poultry_status')->insert([
|
||||
'poultry_id' => $v,
|
||||
'action_name' => '疫苗注射记录',
|
||||
'action_content' => $params['action_content'],
|
||||
'create_time' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//返回
|
||||
return $result ? $this->success('添加成功') : $this->fail('添加失败');
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
//删除饲养家禽操作记录
|
||||
|
|
Loading…
Reference in New Issue