post=$this->request->post(); // $token = isset($this->post['token']) ? trim($this->post['token']) : ""; // if($token==""){ // return error_show(101,'token不能为空'); // } // $effetc = VerifyTokens($token); // if(!empty($effetc) && $effetc['code']!=0) { // return error_show($effetc['code'], $effetc['message']); // } } // public function list(){ // $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1"; // $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10"; // $where=[['is_del',"=",0],["cat_id","<>",0]]; // $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : ""; // if ($zxNo !== "") { // $where[] = ['zxNo','=',$zxNo]; // } // $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : ""; // if ($sequenceNo !== "") { // $where[] = ['sequenceNo','like',"%$sequenceNo%"]; // } // $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : ""; // if ($salesman !== "") { // //$where["salesman"] =Db::Raw("like '%$salesman%'"); // $where[]= ["salesman",'like',"%$salesman%"]; // } // $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : ""; // if ($cpName !== "") { // //$where["cpName"]= Db::Raw("like '%$cpName%'"); // $where[]= ["cpName",'like',"%$cpName%"]; // } // $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : ""; // if ($khNo !== "") { // // $where['khNo'] = $khNo; // $where[]= ["khNo",'like',"%$khNo%"]; // } // $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:""; // if ($start !="") { // //$where = ["zxtime"=>Db::raw(">= '{$start}'")]; // $where[]= ["zxtime",'>=',$start]; // } // $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :""; // if($end !=""){ // $where[]= ["zxtime",'<=',$end]; // } // $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : ""; // if ($status !== "") { // $where[]= ["status",'=',$status]; // } // $count = Db::name('consult')->where($where)->count(); // $total = ceil($count / $size); // $page = $page >= $total ? $total : $page; // $list = Db::name('consult')->where($where)->page($page,$size) // ->select(); // $data=[]; // foreach ($list as $value){ // $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[]; // $data[]=$value; // } // return app_show(0,"获取成功",['count'=>$count,'list'=>$data]); // } public function conlist(){ $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1"; $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10"; $where=[['a.is_del',"=",0],['b.is_del',"=",0]]; $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : ""; if ($zxNo !== "") { $where[] = ['a.zxNo','=',$zxNo]; } // $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : ""; // if ($sequenceNo !== "") { // $where[] = ['sequenceNo','like',"%$sequenceNo%"]; // } $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : ""; if ($salesman !== "") { //$where["salesman"] =Db::Raw("like '%$salesman%'"); $where[]= ["b.salesman",'like',"%$salesman%"]; } $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : ""; if ($cpName !== "") { //$where["cpName"]= Db::Raw("like '%$cpName%'"); $where[]= ["a.good_Name",'like',"%$cpName%"]; } $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : ""; if ($khNo !== "") { // $where['khNo'] = $khNo; $where[]= ["b.khNo",'like',"%$khNo%"]; } $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:""; if ($start !="") { //$where = ["zxtime"=>Db::raw(">= '{$start}'")]; $where[]= ["a.addtime",'>=',$start]; } $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :""; if($end !=""){ $where[]= ["a.addtime",'<=',$end]; } $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : ""; if ($status !== "") { $where[]= ["a.status",'=',$status]; } $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where) ->count(); $total = ceil($count / $size); $page = $page >= $total ? $total : $page; $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size) ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->select(); $data=[]; foreach ($list as $value){ $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[]; $value['khname']=""; if($value['khNo']!==""){ $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find(); $value['khname']= isset($kh['companyName'])?$kh['companyName']:""; } $data[]=$value; } return app_show(0,"获取成功",['count'=>$count,'list'=>$data]); } public function info(){ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : ""; if($id==""){ return error_show(1002,"咨询单编号不能为空"); } $fo = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find(); $in= isset($fo['cat_id']) && $fo['cat_id'] !=0 ? made($fo['cat_id']):[]; $fo['can']=$in; if(empty($fo)){ return error_show(1002,"未找到咨询单编号"); }else{ return app_show(0,"获取成功",$fo); } } public function del(){ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : ""; $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find(); if($de==false){ return error_show(1002,'咨询单信息未找到'); } $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]); if($dell){ return error_show(0,"删除成功"); }else return error_show(1002,"删除失败"); } public function create(){ $is_project= isset($this->post['is_project']) && $this->post['is_project'] !=="" ? intval($this->post['is_project']) : ""; if($is_project===""){ return error_show(1002,"参数is_project不能为空"); } if($is_project==1){ $projectNo= isset($this->post['projectNo']) && $this->post['projectNo'] !=="" ? trim($this->post['projectNo']) : ""; if($projectNo===""){ return error_show(1002,"参数projectNo不能为空"); } } $khNo = isset($this->post['khNo']) && $this->post['khNo'] !=="" ? trim($this->post['khNo']) : ""; if($khNo===""){ return error_show(1002,"参数khNo不能为空"); } $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) : ""; if($companyNo===""){ return error_show(1002,"参数companyNo不能为空"); } $endtime = isset($this->post['endtime']) && $this->post['endtime'] !=="" ? $this->post['endtime'] : ""; if($endtime===""){ return error_show(1002,"参数endtime不能为空"); } // $saleid = isset($this->post['saleid']) && $this->post['saleid'] !=="" ? intval($this->post['saleid']) : ""; // if($saleid===""){ // return error_show(1002,"参数saleid不能为空"); // } // $depart = isset($this->post['depart']) && $this->post['depart'] !=="" ? intval($this->post['depart']) : ""; // if($depart===""){ // return error_show(1002,"参数depart不能为空"); // } $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) : ""; if($platform_code===""){ return error_show(1002,"参数platform_code不能为空"); } $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder']) ? $this->post['ladder']:""; if($ladder==""){ return error_show(1005,"参数ladder不能为空"); } $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):""; if($token==''){ return error_show(1005,"参数token不能为空"); } $user =GetUserInfo($token); if(empty($user)||$user['code']!=0){ return error_show(1002,"用户数据不存在"); } $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : ""; $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : ""; $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find(); $zxNo=makeNo("ZX"); $data=[ "zxNo"=>$zxNo, "createrid"=>$createrid, "creater"=>$creater, "is_project"=>$is_project, "projectNo"=>isset($projectNo) ? $projectNo:"", "khNo"=>$khNo, "companyNo"=>$companyNo, "endtime"=>$endtime, "salesman"=>$creater, "platform_code"=>$platform_code, "saleid"=>$createrid, "depart"=>isset($depart['itemid'])?$depart['itemid']:0, "status"=>0, "is_del"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s"), ]; $zx = Db::name("consult_order")->insert($data); if($zx){ foreach ($ladder as $value){ $infoNo=isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):makeNo("INF"); $info=[ "infoNo"=>$infoNo, "zxNo"=>$zxNo, "spuCode"=>"", "good_name"=>$value['good_name'], "good_img"=>$value['good_img'], "cat_id"=>$value['cat_id'], "unit"=>$value['unit'], "brand_id"=>$value['brand_id'], "arrival_time"=>$value['arrival_time'], "model"=>$value['model'], "color"=>$value['color'], "material"=>$value['material'], "cost_desc"=>$value['cost_desc'], "is_addrs"=>$value['is_addrs'], "is_custom"=>$value['is_custom'], "metal_id"=>$value['metal_id'], "config"=>isset($value['config'])?$value['config']:"", "other_config"=>isset($value['other_config'])?$value['other_config']:"", "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0", "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0", "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0", "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0", "budget_price"=>$value['budget_price'], "num"=>$value['num'], "use_desc"=>$value['use_desc'], "remark"=>$value['remark'], "status"=>1, "is_del"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $up = Db::name("consult_info")->insert($info); if(!$up){ Db::rollback(); return error_show(1004,'添加失败'); } } return app_show(0,"新建成功",["zxNo"=>$zxNo]); }else{ return error_show(1004,"新建失败"); } } // public function zxadd(){ // $good_name = isset($this->post['good_name'])&&$this->post['good_name']!==""?trim($this->post['good_name']):""; // if($good_name===""){ // return error_show(1004,"参数good_name不能为空"); // } // $zxNo = isset($this->post['zxNo'])&&$this->post['zxNo']!==""?trim($this->post['zxNo']):""; // if($zxNo===""){ // return error_show(1004,"参数zxNo不能为空"); // } // // $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):""; // if($cat_id===""){ // return error_show(1004,"参数cat_id不能为空"); // } // $arrival_time = isset($this->post['arrival_time'])&&$this->post['arrival_time']!==""?$this->post['arrival_time'] // :""; // if($arrival_time===""){ // return error_show(1004,"参数arrival_time不能为空"); // } // $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""?trim($this->post['good_img']):""; // if($good_img===""){ // return error_show(1004,"参数good_img不能为空"); // } // $is_custom = isset($this->post['is_custom'])&&$this->post['is_custom']!==""?intval($this->post['is_custom']):""; // if($is_custom===""){ // return error_show(1004,"参数is_custom不能为空"); // } // $unit = isset($this->post['unit'])&&$this->post['unit']!==""?trim($this->post['unit']):""; // if($unit===""){ // return error_show(1004,"参数unit不能为空"); // } // $brand_id = isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):""; // if($brand_id===""){ // return error_show(1004,"参数brand_id不能为空"); // } // $material = isset($this->post['material'])&&$this->post['material']!==""?trim($this->post['material']):""; // if($material===""){ // return error_show(1004,"参数material不能为空"); // } // $color = isset($this->post['color'])&&$this->post['color']!==""?trim($this->post['color']):""; // if($color===""){ // return error_show(1004,"参数color不能为空"); // } // $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!==""?trim($this->post['cost_desc']):""; // if($cost_desc===""){ // return error_show(1004,"参数cost_desc不能为空"); // } // $model = isset($this->post['model'])&&$this->post['model']!==""?trim($this->post['model']):""; // if($model===""){ // return error_show(1004,"参数model不能为空"); // } // // $is_addrs = isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):""; // if($is_addrs===""){ // return error_show(1004,"参数is_addrs不能为空"); // } // // $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!==""?trim($this->post['metal_id']):""; // if($metal_id===""){ // return error_show(1004,"参数metal_id不能为空"); // } // if($metal_id==0){ // $config = isset($this->post['config'])&&!empty($this->post['config'])?$this->post['config']:""; // if($config===""){ // return error_show(1004,"参数config不能为空"); // } // $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""?trim($this->post['other_config']) // :""; // if($other_config===""){ // return error_show(1004,"参数other_config不能为空"); // } // $specs_weight = isset($this->post['specs_weight'])&&$this->post['specs_weight']!==""?floatval($this->post['specs_weight']):""; // if($specs_weight===""){ // return error_show(1004,"参数specs_weight不能为空"); // } // $gold_price = isset($this->post['gold_price'])&&$this->post['gold_price']!==""?floatval($this->post['gold_price']):""; // if($gold_price===""){ // return error_show(1004,"参数gold_price不能为空"); // } // // } // $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):""; // if($budget_price===""){ // return error_show(1004,"参数budget_price不能为空"); // } // $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):""; // if($num===""){ // return error_show(1004,"参数num不能为空"); // } // $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!==""?trim($this->post['use_desc']):""; // if($use_desc===""){ // return error_show(1004,"参数use_desc不能为空"); // } // $remark = isset($this->post['remark'])&&$this->post['remark']!==""?trim($this->post['remark']):""; // if($remark===""){ // return error_show(1004,"参数remark不能为空"); // } // // Db::startTrans(); // try{ // $infoNo=makeNo("INF"); // $info=[ // "infoNo"=>$infoNo, // "zxNo"=>$zxNo, // "spuCode"=>"", // "good_name"=>$good_name, // "good_img"=>$good_img, // "cat_id"=>$cat_id, // "unit"=>$unit, // "brand_id"=>$brand_id, // "arrival_time"=>$arrival_time, // "model"=>$model, // "color"=>$color, // "material"=>$material, // "cost_desc"=>$cost_desc, // "is_addrs"=>$is_addrs, // "is_custom"=>$is_custom, // "metal_id"=>$metal_id, // "config"=>isset($config)?$config:"", // "other_config"=>isset($other_config)?$other_config:"", // "specs_weight"=>isset($specs_weight)?$specs_weight:0, // "gold_price"=>isset($gold_price)?$gold_price:0, // "budget_price"=>$budget_price, // "num"=>$num, // "use_desc"=>$use_desc, // "remark"=>$remark, // "status"=>0, // "is_del"=>0, // "addtime"=>date("Y-m-d H:i:s"), // "updatetime"=>date("Y-m-d H:i:s") // ]; // $up = Db::name("consult_info")->insert($info); // if($up){ // Db::commit(); // return app_show(0,"添加成功",["infoNo"=>$infoNo]); // }else{ // Db::rollback(); // return error_show(1004,'添加失败'); // } // }catch (\Exception $e){ // Db::rollback(); // return error_show(1004,$e->getMessage()); // } // } public function zxinfo(){ $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):""; if($infoNo==""){ return error_show(1004,"参数infoNo不能为空"); } $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find(); if($zxinfo==false){ return error_show(1004,"未找到信息数据"); } $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find(); if($zxorder==false){ return error_show(1004,"未找到咨询信息数据"); } $cat =Db::name("cat")->where(["id"=>$zxinfo['cat_id']])->find(); $budget = isset($cat['order_rate']) ? $cat['order_rate']:100; $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[]; $zxinfo['khname']=""; $zxinfo['original_price']=sprintf("%.2f",$zxinfo['budget_price']* (1 -$budget/100)); $zxinfo['khNo']=""; $zxinfo['brand_id']=$zxinfo['brand_id']==0 ?"":$zxinfo['brand_id']; $zxinfo['companyNo']=isset($zxorder['companyNo'])?$zxorder['companyNo']:""; $zxinfo['projectNo']=isset($zxorder['projectNo'])?$zxorder['projectNo']:""; $zxinfo['is_project']=isset($zxorder['is_project'])?$zxorder['is_project']:""; $zxinfo['company']=""; $zxinfo['endtime']=isset($zxorder['endtime'])?$zxorder['endtime']:""; $zxinfo['platform_code'] =isset($zxorder['platform_code'])?$zxorder['platform_code']:""; $zxinfo['salesman'] =isset($zxorder['salesman'])?$zxorder['salesman']:""; $zxinfo['saleid'] =isset($zxorder['saleid'])?$zxorder['saleid']:""; $zxinfo['depart'] =isset($zxorder['depart'])?$zxorder['depart']:""; $zxinfo['project_name']=""; $zxinfo['budget_total']=""; $zxinfo['departinfo']=[]; $zxinfo['unit_name']=""; if($zxorder['khNo']!==""){ $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find(); $zxinfo['khname']= isset($kh['companyName'])?$kh['companyName']:""; $zxinfo['khNo']= $zxorder['khNo']; } if($zxinfo['unit']!==""){ $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find(); $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:""; } if($zxorder['companyNo']!==""){ $kh=Db::name("business")->where(['companyNo'=>$zxorder['companyNo']])->find(); $zxinfo['company']= isset($kh['company'])?$kh['company']:""; } if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){ $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find(); $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:""; $zxinfo['budget_total']=isset($project['budget_total'])?$project['budget_total']:""; $zxinfo['project_use_desc']=isset($project['use_desc'])?$project['use_desc']:""; $projectinfo = Db::name("project_info")->where(["pgNo"=>$zxinfo['infoNo']])->find(); $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo']:""; } if($zxorder['depart']>0){ $zxinfo['departinfo']=GetPart($zxorder['depart']); } if($zxorder['platform_code']>0){ $palt=Db::name("platform")->where(["id"=>$zxorder['platform_code']])->find(); $zxinfo['platform_name']=isset($palt['platform_name'])?$palt['platform_name']:""; } return app_show(0,"获取成功",$zxinfo); } //** 发布竞标任务 */ public function bargain(){ $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):""; if($infoNo==""){ return error_show(1004,"参数infoNo不能为空"); } $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find(); if($zxinfo==false){ return error_show(1004,"未找到信息数据"); } $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):""; if($status===""){ return error_show(1004,"参数status不能为空"); } if($status==1&&$zxinfo['status']>1){ $zxinfo['bargain_num']=+1; } $zxinfo['status']=$status; $zxinfo['updatetime']=date("Y-m-d H:i:s"); $up = Db::name("consult_info")->save($zxinfo); if($up){ return app_show(0,"状态更新成功"); }else{ return error_show(1003,"状态更新失败"); } } public function feadback(){ $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):""; if($infoNo==""){ return error_show(1004,"参数infoNo不能为空"); } $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find(); if($zxinfo==false){ return error_show(1004,"未找到信息数据"); } if($zxinfo['status']!==1){ return error_show(1004,"任务未进行"); } $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):""; if($pname==""){ return error_show(1004,"参数pname不能为空"); } $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):""; if($brandid==""){ return error_show(1004,"参数brandid不能为空"); } $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):""; if($cat_id==""){ return error_show(1004,"参数cat_id不能为空"); } $model = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):""; //$unit = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):""; $material = isset($this->post['material'])&&$this->post['material']!=""? trim($this->post['material']):""; $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):""; $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):""; $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):""; $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):""; $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):""; $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day']) :""; $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):""; $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):""; $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):""; $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):""; $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):""; $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):""; $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):""; $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:""; $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):""; $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):""; $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):""; $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):""; $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):""; $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""? floatval($this->post['nake_fee']):""; $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):""; $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):""; $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):""; $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):""; $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):""; $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):""; $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):""; $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):""; if($token==''){ return error_show(1005,"参数token不能为空"); } $user =GetUserInfo($token); if(empty($user)||$user['code']!=0){ return error_show(1002,"用户数据不存在"); } $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : ""; $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : ""; $bidNo=makeNo("BD"); $spucode=makeNo("SPU"); $data=[ "bidNo"=>$bidNo, "infoNo"=>$infoNo, "zxNo"=>$zxinfo['zxNo'], "spuCode"=>$spucode, "good_name"=>$pname, "brand_id"=>$brandid, "cat_id"=>$cat_id, "model"=>$model, "material"=>$material, "unit_id"=>$unit_id, "cost_desc"=>$cost_desc, "work_day"=>$work_day, "delivery_day"=>$delivery_day, "good_img"=>$good_img, "expire_day"=>$expire_day, "origin_place"=>$origin_place, "supplierNo"=>$supplierNo, "pay_way"=>$pay_way, "tax"=>$tax, "send_way"=>$send_way, "metal_id"=>$metal_id, "is_gold_price"=>$is_gold_price, "config"=>$config, "weight"=>$weight, "is_diff"=>$is_diff, "demo_fee"=>$demo_fee, "delivery_fee"=>$delivery_fee, "open_fee"=>$open_fee, "pakge_fee"=>$pakge_fee, "nake_fee"=>$nake_fee, "mark_fee"=>$mark_fee, "cert_fee"=>$cert_fee, "cost_fee"=>$cost_fee, "total_fee"=>$total_fee, "supply_area"=>$supply_area, "remark"=>$remark, "sale_price"=>0, "createrid"=>$createrid, "creater"=>$creater, "status"=>$zxinfo['status']==1 ?1 :2, "is_del"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; Db::startTrans(); try{ $insert= Db::name("consult_bids")->insert($data); if($insert){ $data=[ "spuCode"=>$spucode, "good_name"=>$pname, "brand_id"=>$brandid, "good_unit"=>$unit_id, "good_type"=>0, "moq"=>1, "customized"=>$work_day, "tax"=>$tax, "supplierNo"=>$supplierNo, "is_auth"=>0, "craft_desc"=>$cost_desc, "good_remark"=>$remark, "good_img"=>$good_img, "good_thumb_img"=>"", "good_info_img"=>"", "status"=>1, "is_del"=>0, "createrid"=>$createrid, "creater"=>$creater, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $good = Db::name("good_zixun")->insert($data); if($good){ Db::commit(); return app_show(0,"反馈成功",["bidNo"=>$bidNo]); }else{ Db::rollback(); return error_show(1004,"反馈失败"); } }else{ Db::rollback(); return error_show(1004,"反馈失败"); } }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function feadinfo(){ $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):""; if($bidNo==""){ return error_show(1004,"参数bidNo不能为空"); } $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到商品数据"); } $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find(); $info['unit'] = isset($unit['unit'])?$unit['unit']:''; $info['cat_info'] = made($info['cat_id'],[]); $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find(); $info['supplierName'] = isset($supplier['name'])?$supplier['name']:""; if($info['brand_id']!=0){ $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find(); $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:""; }else{ $info["brand_name"]=""; $info["brand_id"]=""; } $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find(); $info['bargain'] =$bargain; return app_show(0,"获取成功",$info); } public function bargain_add(){ $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):""; if($bidNo===""){ return error_show(1004,"参数bidNo不能为空"); } $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到商品数据"); } $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find(); if($infos==false){ return error_show(1004,"未找到商品数据"); } $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):""; if($token==''){ return error_show(1005,"参数token不能为空"); } $user =GetUserInfo($token); if(empty($user)||$user['code']!=0){ return error_show(1002,"用户数据不存在"); } $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : ""; $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : ""; $bargainNo =makeNo("BAR"); Db::startTrans(); try{ $data=[ "bidsNo"=>$bidNo, "bargainNo"=>$bargainNo, "bargain_type"=>1, "sale_price"=>$info['sale_price'], "cost_before_price"=>$info['cost_fee'], "cost_after_price"=>$info['cost_fee'], "before_rate"=>$info['cost_fee'], "after_rate"=>$info['cost_fee'], "after_price"=>$infos['budget_price'], "status"=>1, "is_del"=>0, "creater"=>$creater, "createrid"=>$createrid, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $int = Db::name("bargain_order")->insert($data); if($int){ $info['status']=3; $info['updatetime']=date("Y-m-d H:i:s"); $up =Db::name("consult_bids")->save($info); if($up){ Db::commit(); return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]); } } }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function bargain_status(){ $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):""; if($bargainNo===""){ return error_show(1004,"参数bargainNo不能为空"); } $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到议价数据"); } $bids=Db::name("consult_bids")->where(["bidNo"=>$info["bidsNo"],"is_del"=>0])->find(); if($bids==false){ return error_show(1004,"未找到商品数据"); } $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):""; if($status==''){ return error_show(1005,"参数status不能为空"); } Db::startTrans(); try{ $info['status'] =$status; $info['updatetime'] =date("Y-m-d H:i:s"); $up =Db::name("bargain_order")->save($info); if($up){ if($status==4){ $bids['status']=4; $bids['sale_price']=$info['after_price']; $bids['updatetime']=date("Y-m-d H:i:s"); $up =Db::name("consult_bids")->save($bids); if($up==false){ Db::rollback(); return error_show(1004,"数据更新失败"); } } if($status==5||$status==6||$status==7){ $bids['status']=4; $bids['updatetime']=date("Y-m-d H:i:s"); $up =Db::name("consult_bids")->save($bids); if($up==false){ Db::rollback(); return error_show(1004,"数据更新失败"); } } Db::commit(); return app_show(0,"更新成功"); } }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function bargain_info(){ $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):""; if($bargainNo===""){ return error_show(1004,"参数bargainNo不能为空"); } $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到议价数据"); } return app_show(0,"获取成功",$info); } public function bidlist(){ $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1"; $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10"; $where=[['is_del',"=",0]]; $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : ""; if ($zxNo !== "") { $where[] = ['zxNo','=',$zxNo]; } $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : ""; if ($infoNo !== "") { $where[] = ['infoNo','=',$infoNo]; } $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : ""; if ($bidNo !== "") { $where[] = ['bidNo','=',$bidNo]; } $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : ""; if ($projectNo !== "") { $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column ("zxNo"); $where[] = ['zxNo','in',$zxlist]; } $count = Db::name('consult_bids')->where($where)->count(); $total = ceil($count / $size); $page = $page >= $total ? $total : $page; $list =Db::name('consult_bids')->where($where)->page($page,$size)->select(); $data=[]; foreach ($list as $value){ $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[]; $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find(); $value['unit'] = isset($unit['unit'])?$unit['unit']:''; $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find(); $value['supplierName'] = isset($supplier['name'])?$supplier['name']:""; if($value['brand_id']!=0){ $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find(); $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:""; }else{ $value["brand_name"]=""; $value["brand_id"]=""; } $data[]=$value; } return app_show(0,"获取成功",['count'=>$count,'list'=>$data]); } }