Commit 7d2761e2 by 连敬荣

代码重构

parent 31073433
......@@ -16,6 +16,7 @@ use App\Http\Controllers\Controller;
class DataController extends Controller
{
private $STATUS_CLOSED = 4;
public function createInquiryItemsDetail(Request $request){
$userInfo = $this->user();
$input = $request->input();
......@@ -54,7 +55,7 @@ class DataController extends Controller
#插入明细
$brandInfo = json_decode($input["brand_s"],true);
$check = $inquiryItemsModel->where(["inquiry_id"=>$input["inquiry_id"],"goods_name"=>$input["goods_name"],"brand_name"=>$brandInfo[0]["name"]])->count();
$check = $inquiryItemsModel->checkUniqueInquiryItemsDetail($input);//检查是否存在相同的明细
if ($check >0){
throw new Exception("已存在重复此型号品牌!");
}
......@@ -107,7 +108,8 @@ class DataController extends Controller
(new InquiryItemsAssignModel())->insert($assignInsert);
}
$inquiryItemsModel->where('id', $inquiryItemsId)->update(['status' => 4]); // 存在指定采购,则标记状态为已领取
// $inquiryItemsModel->where('id', $inquiryItemsId)->update(['status' => 4]); // 存在指定采购,则标记状态为已领取
$inquiryItemsModel->updateInquiryItemsStatus($inquiryItemsId,$this->STATUS_CLOSED);
}
#日志
......
......@@ -6,3 +6,4 @@ Route::Get('/ApiBrandList','SearchController@getBrandList');//新增询价查询
Route::Post('/ApiCheckGoods','SearchController@checkUniqueGoods');//检查是否已经存在询价单;
Route::Post('/ApiCreateOneItems','DataController@createInquiryItemsDetail');//创建一条询价明细;
Route::Post('/api/ApiDeleteInquiryItems','DataController@deleteInquiryItemsDetail');//删除询价明细;
//Route::Post('/api/ApiEditInquiry','DataController@ApiEditInquiry');//新增询价;
\ No newline at end of file
......@@ -656,4 +656,13 @@ class InquiryItemsModel extends Model
return [0,"通过"];
}
public function checkUniqueInquiryItemsDetail($input){//检查是否存在相同品牌信息的明细
$brandInfo = json_decode($input["brand_s"],true);
$check = $this->where(["inquiry_id"=>$input["inquiry_id"],"goods_name"=>$input["goods_name"],"brand_name"=>$brandInfo[0]["name"]])->count();
return $check;
}
public function updateInquiryItemsStatus($inquiryItemsId,$status){
$this->where('id', $inquiryItemsId)->update(['status' => $status]); // 存在指定采购,则标记状态为已领取
}
}
\ 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 sign in to comment