Commit 17d4adeb by hcy001

1

parent 143a8bfc
...@@ -32,6 +32,7 @@ class InquiryItemsReportModel extends Model ...@@ -32,6 +32,7 @@ class InquiryItemsReportModel extends Model
try{ try{
$con = DB::connection('rfq'); $con = DB::connection('rfq');
$con->beginTransaction(); $con->beginTransaction();
$InquiryUsersModel = new InquiryUsersModel();
#更新客户资料 #更新客户资料
$user = [ $user = [
...@@ -40,13 +41,25 @@ class InquiryItemsReportModel extends Model ...@@ -40,13 +41,25 @@ class InquiryItemsReportModel extends Model
"fax"=>$input["fax"], "fax"=>$input["fax"],
"tel"=>$input["tel"], "tel"=>$input["tel"],
]; ];
$InquiryUsersModel->where("id",$input["com_id"])->update($user);
(new InquiryUsersModel())->where("id",$input["com_id"])->update($user);
#添加销售资料
$user2 = [
"types"=>2,
"user_name"=>$input["sale_user_name"],
"contact"=>$input["sale_contact"],
"fax"=>$input["sale_fax"],
"tel"=>$input["sale_tel"],
];
$sale_user_id = $InquiryUsersModel->where($user2)->value("id");
if (!$sale_user_id){
$sale_user_id = $InquiryUsersModel->insertGetId($user2);
}
#更新报价明细 #更新报价明细
foreach ($input["items"] as $k=>$inquiry_items_id){ foreach ($input["items"] as $k=>$inquiry_items_id){
$temp = [ $temp = [
"inquiry_id"=>$inquiry_id , "inquiry_id"=>$inquiry_id ,
"sale_user_id"=>$sale_user_id ,
"inquiry_items_id"=>$inquiry_items_id, "inquiry_items_id"=>$inquiry_items_id,
"goods_name"=>@$input["goods_name"][$k] ? $input["goods_name"][$k] : "" , "goods_name"=>@$input["goods_name"][$k] ? $input["goods_name"][$k] : "" ,
"goods_name_pro"=>@$input["goods_name_pro"][$k] ? $input["goods_name_pro"][$k] : "" , "goods_name_pro"=>@$input["goods_name_pro"][$k] ? $input["goods_name_pro"][$k] : "" ,
...@@ -82,18 +95,19 @@ class InquiryItemsReportModel extends Model ...@@ -82,18 +95,19 @@ class InquiryItemsReportModel extends Model
if($inquiry_id == ""){ if($inquiry_id == ""){
return [1001,"询价单号不得为空!"]; return [1001,"询价单号不得为空!"];
} }
$InquiryUsersModel = new InquiryUsersModel();
#主表信息 #主表信息
$mainArr = (new InquiryModel())->where("id",$inquiry_id)->first()->toArray(); $mainArr = (new InquiryModel())->where("id",$inquiry_id)->first()->toArray();
#本公司信息
$company_info_origin = Config("website.company_info_origin");
$data["company"] = $company_info_origin[$mainArr["delivery_place"]]; #公司信息
#客户信息 #客户信息
$data["user"] = (new InquiryUsersModel())->where("id",$mainArr["user_id"])->first()->toArray(); $data["user"] = $InquiryUsersModel->where("id",$mainArr["user_id"])->first()->toArray();
#询价明细 #报表明细
$itemsArr = $this->whereIn("inquiry_items_id",explode(",",$inquiry_items_ids))->get()->toArray(); $itemsArr = $this->whereIn("inquiry_items_id",explode(",",$inquiry_items_ids))->get()->toArray();
#查询销售资料
$data["company"] = $InquiryUsersModel->where("id",$itemsArr[0]["sale_user_id"])->first()->toArray();
$quote_price_count = 0; $quote_price_count = 0;
foreach ($itemsArr as $k=>&$v){ foreach ($itemsArr as $k=>&$v){
$v["quote_account"] = $v["price_rmb"] > 0 ? $v["price_rmb"]*$v["inquiry_number"] : $v["price_origin"]*$v["inquiry_number"]; $v["quote_account"] = $v["price_rmb"] > 0 ? $v["price_rmb"]*$v["inquiry_number"] : $v["price_origin"]*$v["inquiry_number"];
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
<td><b>Tel</b>: {{ @$user["tel"] }}</td> <td><b>Tel</b>: {{ @$user["tel"] }}</td>
</tr> </tr>
<tr> <tr>
<td><b>From</b>:{{ @$company["name"] }}</td> <td><b>From</b>:{{ @$company["user_name"] }}</td>
<td><b>C.C</b>:{{ @$company["cc"] }}</td> <td><b>C.C</b>:{{ @$company["contact"] }}</td>
<td><b>Fax</b>:{{ @$company["fax"] }}</td> <td><b>Fax</b>:{{ @$company["fax"] }}</td>
<td><b>Tel</b>: {{ @$company["tel"] }}</td> <td><b>Tel</b>: {{ @$company["tel"] }}</td>
</tr> </tr>
......
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