Commit 48da1000 by 连敬荣

代码重构

parent b1a4cf1d
......@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Model\InquiryItemsModel;
use App\Model\LieBrandModel;
use Illuminate\Http\Request;
......@@ -37,4 +38,9 @@ class SearchController extends Controller
$lieBrandModel = new LieBrandModel();
$lieBrandModel->getBrandList($k,$types);
}
public function checkUniqueGoods(Request $request )
{ var_dump($request->input());exit();
$InquiryItemsModel = new InquiryItemsModel();
$InquiryItemsModel->checkGoods($request->input());
}
}
\ No newline at end of file
......@@ -11,4 +11,5 @@ interface ApiCode
const API_CODE_UNLOGINED = 1001;//未登陆
const API_CODE_DATA_EMPTY = 1003;//数据为空
}
\ No newline at end of file
......@@ -2,4 +2,7 @@
Route::Get('/ApiSkuList','SearchController@getSkuList');//新增询价查询sku接口;
Route::Get('/ApiBrandList','SearchController@getBrandList');//新增询价查询品牌接口;
\ No newline at end of file
Route::Get('/ApiBrandList','SearchController@getBrandList');//新增询价查询品牌接口;
Route::Post('/ApiCheckGoods','SearchController@checkUniqueGoods');//检查是否已经存在询价单;
Route::Post('/ApiCreateOneItems','DataController@createInquiryItemsDetail');//创建一条询价明细;
//Route::Post('/api/ApiDeleteInquiryItems','DataController@deleteInquiryItemsDetail');//删除一条明细;
\ No newline at end of file
<?php
namespace App\Model;
use App\Http\Utils\ApiCode;
use App\map\InquiryMap;
use App\map\QuoteMap;
use App\Model\InquiryItemsAssignModel;
......@@ -211,16 +212,16 @@ class InquiryItemsModel extends Model
* 创建单个创建明细
* @param $data 批量
*/
public function addItems($b){
public function addItems($b,$userInfo){
if (count($b) == 0 || $b == ""){
return [1001,"插入数据不得为空"];
}
if (empty($b["goods_name"])) return [1003, "请选择型号名称"];
if (empty($b["inquiry_id"])) return [1003, "询价单ID不得为空"];
if (empty($b["brand_s"])) return [1003, "请选择品牌名称"];
if (empty($b["inquiry_number"])) return [1003, "请输入询价数量"];
if (empty($b["batch"])) return [1003, "请输入批次要求"];
if (empty($b["delivery_time"])) return [1003, "请选择交货日期"];
if (empty($b["goods_name"])) return [ApiCode::API_CODE_DATA_EMPTY, "请选择型号名称"];
if (empty($b["inquiry_id"])) return [ApiCode::API_CODE_DATA_EMPTY, "询价单ID不得为空"];
if (empty($b["brand_s"])) return [ApiCode::API_CODE_DATA_EMPTY, "请选择品牌名称"];
if (empty($b["inquiry_number"])) return [ApiCode::API_CODE_DATA_EMPTY, "请输入询价数量"];
if (empty($b["batch"])) return [ApiCode::API_CODE_DATA_EMPTY, "请输入批次要求"];
if (empty($b["delivery_time"])) return [ApiCode::API_CODE_DATA_EMPTY, "请选择交货日期"];
try{
$con = DB::connection('rfq');
......@@ -290,15 +291,15 @@ class InquiryItemsModel extends Model
'relation_id'=>$inquiryItemsId, #明细id
'relation_sn'=>(new InquiryModel())->FindInquirySn($b["inquiry_id"]),
'content'=>'单个添加询价',
'create_uid'=>$b['user_id'],
'create_name'=>$b["user_name"],
'create_uid'=>$userInfo['user_id'],
'create_name'=>$userInfo["user_name"],
]);
$con->commit();
return [0,"添加成功"];
return [ApiCode::API_CODE_SUCCESS,"添加成功"];
}catch (\Exception $e) {
$con->rollBack();
return [1001,"添加失败:".$e->getMessage()];
return [ApiCode::API_CODE_ERROR,"添加失败:".$e->getMessage()];
}
}
......@@ -654,5 +655,4 @@ class InquiryItemsModel extends Model
return [0,"通过"];
}
}
\ 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