Commit ff292939 by hcy001

1

parent d7438df8
......@@ -110,16 +110,16 @@ class ApiController extends Controller
}
//添加询价
private function ApiAddInquiry($request, $id){
(new CommonModel())->UserList($request->input('k'));
private function ApiAddInquiry($input, $id){
Export((new InquiryModel())->addInquiry($input));
}
//生成报价/销售 询价单
private function ApiAddInquiryReport($request, $id){
(new InquiryItemsReportModel())->addOffer();
}
//清空询价列表
private function ApiDeleteInquiryItems($request, $id){
Export((new InquiryItemsModel())->DeleteInquiryItems($request->input('inquiry_id'), $this->user_id));
//删除询价列表
private function ApiDeleteInquiryItems($input, $id){
Export((new InquiryItemsModel())->DeleteInquiryItems($input));
}
//导出询价
......
......@@ -126,14 +126,14 @@ class InquiryItemsModel extends Model
}
//清空列表
public function DeleteInquiryItems($inquiry_id,$create_uid){
$check = (new InquiryModel())->where(["inquiry_id"=>$inquiry_id,"create_uid"=>$create_uid])->first();
if (!$check){
return [1001,"不存在数据"];
}else{
$del = $this->where(["inquiry_id"=>$inquiry_id])->delete();
return [0,"删除成功"];
public function DeleteInquiryItems($input){
if (@$input["inquiry_id"]){
$del = $this->where(["inquiry_id"=>$input["inquiry_id"]])->delete();
}
if (@$input["inquiry_items_id"]){
$del = $this->where(["id"=>$input["inquiry_items_id"]])->delete();
}
return [0,"删除成功"];
}
/*
......@@ -254,21 +254,18 @@ class InquiryItemsModel extends Model
*/
public function updateItems($b){
$inquiry_items_id = @$b["inquiry_items_id"] ? $b["inquiry_items_id"] : "" ;
if ($inquiry_items_id){
if (!$inquiry_items_id){
return [1001,"修改明细ID不得为空"];
}
try{
$con = DB::connection('rfq');
$con->beginTransaction();
$InquiryItemsAssignModel = (new InquiryItemsAssignModel());
#更新明细
$assignInsert = []; #指定领取人
$brandInfo = json_decode($b["brand_s"]);
$brandInfo = json_decode($b["brand_s"],true);
$b["brand_id"] = $brandInfo[0]["brand_id"];
$b["brand_name"] = $brandInfo[0]["brand_name"];
$purArr = json_decode($b["pur_s"]); #指定采购
$updateArr= [
"goods_name"=>@$b["goods_name"] ? $b["goods_name"] : "" ,
"brand_id"=>@$b["brand_id"] ? $b["brand_id"] : 0,
......@@ -290,7 +287,9 @@ class InquiryItemsModel extends Model
$InquiryItemsAssignModel->where("inquiry_items_id",$inquiry_items_id)->delete();
#插入采购
if (count($purArr) > 0){
if (@$b["pur_s"] != ""){
$purArr = json_decode($b["pur_s"],true); #指定采购
$assignInsert = []; #指定领取人
foreach ($purArr as $b=>$c){
array_push($assignInsert,[
"inquiry_items_id"=>$inquiry_items_id,
......@@ -299,10 +298,9 @@ class InquiryItemsModel extends Model
"create_time"=>time(),
]);
}
}
if(count($assignInsert) >0){ #插入指定人
$InquiryItemsAssignModel->insert($assignInsert);
if(count($assignInsert) >0){ #插入指定人
$InquiryItemsAssignModel->insert($assignInsert);
}
}
$con->commit();
......
......@@ -304,6 +304,24 @@ class InquiryModel extends Model
}
}
//从草稿生成正式询价单
public function addInquiry($input){
if (empty($input["inquiry_id"])) return [1001,"缺少询价单号"];
if (empty($input["customer_name"])) return [1001,"请选择询价客户名称"];
if (empty($input["delivery_place"])) return [1002,"请选择交货地"];
$data = [
"status"=>1, #启用
"delivery_place"=>$input["delivery_place"],
"customer_uid"=>$input["customer_uid"],
"customer_name"=>$input["customer_name"],
"create_time"=>time(),
"update_time"=>time(),
];
$check = $inqueryId=$this->where("id",$input["inquiry_id"])->update($data);
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