Commit 758697a6 by 朱继来

调整

parents b4bf615d 5b05f6ca
......@@ -58,16 +58,24 @@ class ApiController extends Controller
}
//关闭整个询价单
private function ApiInquiryClose($request, $id){
Export((new InquiryModel())->inquiryClose($request->input('inquiry_id')));
private function ApiInquiryClose($input, $id){
Export((new InquiryModel())->inquiryClose($input));
}
//关闭单条询价明细
public function ApiInquiryItemsClose($request, $id){
Export((new InquiryItemsModel())->inquiryItemsClose($request->input('inquiry_items_id')));
public function ApiInquiryItemsClose($input, $id){
Export((new InquiryItemsModel())->inquiryItemsClose($input));
}
//关闭整个询价单
private function ApiUrgePrice($request, $id){
Export((new InquiryModel())->inquiryClose($request->input('inquiry_id')));
//吹报价
private function ApiUrgePrice($input, $id){
Export((new InquiryItemsModel())->urgePrice($input));
}
//创建询价明细
private function ApiCreateOneItems($input, $id){
Export((new InquiryItemsModel())->addItems(1,[$input]));
}
//更新询价明细
private function ApiUpdateOneItems($input, $id){
Export((new InquiryItemsModel())->updateItems($input));
}
//询价列表
private function ApiInquiryList($input, $id){
......
......@@ -3,8 +3,9 @@ namespace App\Model;
use App\map\InquiryMap;
use App\map\QuoteMap;
use Illuminate\Database\Eloquent\Model;
use App\Model\InquiryItemsAssignModel;
use Dompdf\Exception;
use Illuminate\Database\Eloquent\Model;
use App\Model\OplogModel;
use App\Model\UserModel;
use DB;
......@@ -137,22 +138,182 @@ class InquiryItemsModel extends Model
/*
* 关闭询价
*/
public function inquiryItemsClose($inquiry_items_id){
if (!intval($inquiry_items_id)){
return [1001,"询价明细id不得为空!"];
public function inquiryItemsClose($input){
if (empty(@$input["inquiry_items_id"])){
return [1001,"询价单ID不得为空"];
}
$this->where("id",$inquiry_items_id)->update(["status"=>-1,"update_time"=>time()]);
$this->where("id",$input["inquiry_items_id"])->update(["status"=>-1,"remark"=>@$input["remark"] ? $input["remark"] : "","update_time"=>time()]);
return [0,"关闭询价单明细成功"];
}
/*
* 吹报价
redis 集合:
询价 吹 报价: frq_inquiry_items_urge 内容:“询价明细id- 领取人id”
新报价通知询价人: frq_quote_urge 内容:“询价明细id”
*/
public function urgePrice(){
public function urgePrice($input){
$inquiry_items_id = @$input['inquiry_items_id'];
if (!intval(@$input['inquiry_items_id'])){
return [1001,"询价明细id不得为空!"];
}
#查询所有领取人
$res = (new InquiryItemsAssignModel())->select("assign_uid")->where("inquiry_items_id",$inquiry_items_id)->get();
if ($res){ //存在 领取人才要写入吹询价表
$Redis= \RedisDB::connection();
$res = $res->toArray();
foreach ($res as $k=>$v){
$Redis->sadd("frq_inquiry_items_urge",$inquiry_items_id."-".$v["assign_uid"]);
}
$indata = ["inquiry_items_id"=>$inquiry_items_id,"remark"=>$input["remark"],"create_uid"=>$input["user_id"],"create_name"=>$input["user_name"],"create_time"=>time(),"update_time"=>time()];
(new InquiryItemsUrgeModel())->insert($indata);
}
return [0,"催价成功"];
}
/*
* 创建询价明细,支持单个批量创建明细
* @param $types 插入类型: 1 单个添加 2 批量添加
* @param $data 批量
*/
public function addItems($types,$data){
if (count($data) == 0 || $data == ""){
return [1001,"插入数据不得为空"];
}
try{
$con = DB::connection('rfq');
$con->beginTransaction();
$assignInsert = []; #指定领取人
foreach ($data as $k=>&$b){
if ($b["inquiry_id"] == "" ){
throw new Exception("询价单ID不得为空",10001);
}
if ($types == 1){ #单个添加
if (empty($b["brand_s"])) throw new Exception("请选择型号名称",1002);
$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"],true);
}else{
$purArr = $b["purArr"];
}
if (empty($b["goods_name"])) throw new Exception("请选择型号名称",1002);
if (empty($b["inquiry_number"])) throw new Exception("请输入询价数量",1004);
if (empty($b["batch"])) throw new Exception("请输入批次要求",1005);
if (empty($b["delivery_time"])) throw new Exception("请选择交货日期",1006);
if (empty($b["brand_name"])) throw new Exception("请选择品牌名称",1003);
$insertArr= [
"inquiry_id"=>$b["inquiry_id"] ,
"goods_name"=>@$b["goods_name"] ? $b["goods_name"] : "" ,
"brand_id"=>@$b["brand_id"] ? $b["brand_id"] : 0,
"brand_name"=>@$b["brand_name"] ? $b["brand_name"] : "",
"class_id2"=>@$b["class_id2"] ? $b["class_id2"] : 0 ,
"class_id2_name"=>@$b["class_id2_name"] ? $b["class_id2_name"] : "" ,
"inquiry_number"=>@$b["inquiry_number"] ? $b["inquiry_number"] :0 ,
"target_price"=>@$b["target_price"] ? $b["target_price"] : 0,
"delivery_time"=>@$b["delivery_time"] ? $b["delivery_time"] : "",
"batch"=>@$b["batch"] ? $b["batch"] : "" ,
"assign_type"=>@$b["assign_type"] ? $b["assign_type"] : 2,
"remark"=>@$b["remark"] ? $b["remark"] : "",
"create_time"=>time() ,
"update_time"=>time() ,
];
#插入明细
$inquiryItemsId = $this->insertGetId($insertArr);
if (count($purArr) > 0){
foreach ($purArr as $b=>$c){
array_push($assignInsert,[
"inquiry_items_id"=>$inquiryItemsId,
"assign_uid"=>$c["uid"],
"assign_name"=>$c["user_name"],
"create_time"=>time(),
]);
}
}
}
if(count($assignInsert) >0){ #插入指定人
(new InquiryItemsAssignModel())->insert($assignInsert);
}
$con->commit();
return [0,"添加成功"];
}catch (\Exception $e) {
$con->rollBack();
return [1001,"添加失败:".$e->getMessage()];
}
}
/*
* 修改单个明细
* @param $data 数据
*/
public function updateItems($b){
$inquiry_items_id = @$b["inquiry_items_id"] ? $b["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"]);
$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,
"brand_name"=>@$b["brand_name"] ? $b["brand_name"] : "",
"class_id2"=>@$b["class_id2"] ? $b["class_id2"] : 0 ,
"class_id2_name"=>@$b["class_id2_name"] ? $b["class_id2_name"] : "" ,
"inquiry_number"=>@$b["inquiry_number"] ? $b["inquiry_number"] :0 ,
"target_price"=>@$b["target_price"] ? $b["target_price"] : 0,
"delivery_time"=>@$b["delivery_time"] ? $b["delivery_time"] : "",
"batch"=>@$b["batch"] ? $b["batch"] : "" ,
"assign_type"=>@$b["assign_type"] ? $b["assign_type"] : 2,
"remark"=>@$b["remark"] ? $b["remark"] : "",
"create_time"=>time() ,
"update_time"=>time() ,
];
$this->where("id",$inquiry_items_id)->update($updateArr);
#清空指定人
$InquiryItemsAssignModel->where("inquiry_items_id",$inquiry_items_id)->delete();
#插入采购
if (count($purArr) > 0){
foreach ($purArr as $b=>$c){
array_push($assignInsert,[
"inquiry_items_id"=>$inquiry_items_id,
"assign_uid"=>$c["uid"],
"assign_name"=>$c["user_name"],
"create_time"=>time(),
]);
}
}
if(count($assignInsert) >0){ #插入指定人
$InquiryItemsAssignModel->insert($assignInsert);
}
$con->commit();
return [0,"修改成功"];
}catch (\Exception $e) {
$con->rollBack();
return [1001,"修改失败".$e->getMessage()];
}
}
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ class InquiryModel extends Model
public function getList($input = [])
{
$user_id = @$input["user_id"];
$user_name = @$input["email"];
$user_name = @$input["user_name"];
$rqpConn = DB::connection('rfq');
......@@ -134,8 +134,11 @@ class InquiryModel extends Model
/*
* 关闭询价
*/
public function inquiryClose($inquiry_id){
$this->where("id",$inquiry_id)->update(["status"=>-1,"update_time"=>time()]);
public function inquiryClose($input){
if (empty(@$input["inquiry_id"])){
return [1001,"询价单ID不得为空"];
}
$this->where("id",$input["inquiry_id"])->update(["status"=>-1,"remark"=>@$input["remark"] ? $input["remark"] : "","update_time"=>time()]);
return [0,"关闭整个询价单成功"];
}
......
......@@ -29,7 +29,7 @@ class LoginModel extends Model
$source = $request->header("source"); //来源端:内部后台:pc 云芯系统:yunxin App: app 小程序:h5_app
$token = $request->header("token");
if ($token == ""){
Export(1001,"参数 frq_token 不得为空");
Export(1001,"参数 token 不得为空");
}
$userInfoKey = $Redis->keys('frq_login_'.$token."*");
$userInfo = count($userInfoKey) ? $Redis->get($userInfoKey[0]) : "";
......
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