post['name'])&&$this->post['name']!=""? trim($this->post['name']):""; if($name==""){ return error_show(1004,"参数name不能为空"); } $platform = isset($this->post['platform'])&&$this->post['platform']!=""? trim($this->post['platform']):""; if($platform==""){ return error_show(1004,"参数platform不能为空"); } $khNo = isset($this->post['khNo'])&&$this->post['khNo']!=""?trim($this->post['khNo']):""; $companyNo = isset($this->post['companyNo'])&&$this->post['companyNo']!=""?trim($this->post['companyNo']):""; if($khNo==""){ return error_show(1004,"参数khNo不能为空"); } if($companyNo==""){ return error_show(1004,"参数companyNo不能为空"); } $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!=""?trim($this->post['use_desc']):""; $budget_total = isset($this->post['budget_total'])&&$this->post['budget_total']!=""?floatval($this->post['budget_total']):""; $arrtime = isset($this->post['arrtime'])&&$this->post['arrtime']!=""?$this->post['arrtime']:""; $endtime = isset($this->post['endtime'])&&$this->post['endtime']!=""?$this->post['endtime']:""; if($use_desc==""){ return error_show(1004,"参数use_desc不能为空"); } if($budget_total==""){ return error_show(1004,"参数budget_total不能为空"); } if($arrtime==""){ return error_show(1004,"参数arrtime不能为空"); } if($endtime==""){ return error_show(1004,"参数endtime不能为空"); } $low_rate = isset($this->post['low_rate'])&&$this->post['low_rate']!=""?floatval($this->post['low_rate']):"0"; // if($low_rate==""){ // return error_show(1004,"参数low_rate不能为空"); // } $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder'])? $this->post['ladder']:""; if($ladder==""){ return error_show(1004,"参数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'] : ""; Db::startTrans(); try { $projectNo = makeNo("PRO"); $data=[ "projectNo"=>$projectNo, "platform_id"=>$platform, "khNo"=>$khNo, "companyNo"=>$companyNo, "project_name"=>$name, "budget_total"=>$budget_total, "use_desc"=>$use_desc, "low_rate"=>$low_rate, "creater"=>$creater, "createrid"=>$createrid, "arrtime"=>$arrtime, "endtime"=>$endtime, "status"=>1, "is_del"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $pro=Db::name("project")->insert($data); if($pro){ if(!empty($ladder)){ $la=[]; foreach ($ladder as $value){ $pgNo = makeNo("PRI"); $temp=[]; $temp['pgNo']=$pgNo; $temp['projectNo']=$projectNo; $temp['good_type']=$value['good_type']; $temp['good_name']=$value['good_name']; $temp['good_img']=$value['good_img']; $temp['cat_id']=$value['cat_id']; $temp['budget_price']=$value['budget_price']; $temp['num']=$value['num']; $temp['creater']=$creater; $temp['createrid']=$createrid; $temp['status']=1; $temp['is_del']=0; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $la[]=$temp; } $in = Db::name("project_info")->insertAll($la); if($in>0){ Db::commit(); return app_show(0,"项目新建成功",['projectNo'=>$projectNo]); } } } Db::rollback(); return error_show(1004,"项目新建失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function addfeed(){ $pgNo =isset($this->post['pgNo']) && $this->post['pgNo']!=""? trim($this->post['pgNo']):""; if($pgNo==""){ return error_show(1004,"参数pgNo不能为空"); } $projectinfo = Db::name("project_info")->where(["pgNo"=>$pgNo,"is_del"=>0])->find(); if($projectinfo==false){ return error_show(1004,"未找到项目阶梯信息"); } $spuCode =isset($this->post['spuCode'])&&!empty($this->post['spuCode']) ?$this->post['spuCode']:""; if($spuCode==""){ return error_show(1004,"参数spuCode不能为空"); } $source =isset($this->post['source'])&&$this->post['source']!=="" ?intval($this->post['source']):"1"; if($source==""){ return error_show(1004,"参数source不能为空"); } $good=[]; if($source==1){ $good=Db::name("good_platform")->alias("a")->leftJoin("good b","a.spuCode=b.spuCode")->where (["a.skuCode"=>$spuCode,"a.is_del"=>0])->select()->toArray(); if(empty($good)){ return error_show(1004,"未找到商品信息"); } }else{ $good=Db::name("consult_bids")->where(["spuCode"=>$spuCode,"is_del"=>0])->select()->toArray(); if(empty($good)){ 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($user['code'],"用户数据不存在"); } $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : ""; $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : ""; Db::startTrans(); try{ $data=[]; foreach ($good as $value){ $temp=[]; $temp['spuCode']=$value['spuCode']; $temp['skuCode']=isset($value['skuCode'])?$value['skuCode']:""; $temp['pgNo']=$projectinfo['pgNo']; $temp['projectNo']=$projectinfo['projectNo']; $temp['good_name']=$value['good_name']; $temp['good_type']=$projectinfo['good_type']; $temp['data_source']=$source; $temp['cat_id']=$value['cat_id']; $temp['budget_price']=$projectinfo['budget_price']; if($source==1){ $ladd = Db::name("good_ladder")->where([["skuCode","=",$value['skuCode']],["min_num","<=", $projectinfo["num"]],["status","=",1],["is_del","=",0]])->order("min_num desc")->find(); $sale_price = $ladd['sale_price']; }else{ $sale_price =$value['sale_price']; } $temp['sale_price']=$sale_price; $temp['num']=$projectinfo['num']; $temp['status']=0; $temp['is_del']=0; $temp['creater']=$creater; $temp['createrid']=$createrid; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $data[]=$temp; } $nu = Db::name("project_feedback")->insertAll($data); if($nu>0){ $projectinfo['status']=2; $projectinfo['updatetime']=date("Y-m-d H:i:s"); $up = Db::name("project_info")->save($projectinfo); if($up){ $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1]) ->count(); if($count==0){ $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]); if($proc){ Db::commit(); return app_show(0,"添加成功"); } } } Db::commit(); return app_show(0,"添加成功"); }else{ Db::rollback(); return error_show(1004,"添加失败"); } }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } 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]]; $khNo = isset($this->post['khNo']) &&$this->post['khNo']!==""? trim($this->post['khNo']):""; if($khNo!==""){ $where[]=["khNo","=",$khNo]; } $project_name = isset($this->post['project_name']) &&$this->post['project_name']!==""? trim($this->post['project_name']):""; if($project_name!==""){ $where[]=["project_name","like","%$project_name%"]; } $status = isset($this->post['status']) &&$this->post['status']!==""? intval($this->post['status']):""; if($status!==""){ $where[]=["status","=",$status]; } $start = isset($this->post['start'])&&$this->post['start']!=="" ? $this->post['start']:""; if($start!==''){ $where[]=["addtime",">=",$start]; } $end = isset($this->post['end'])&&$this->post['end']!=="" ? $this->post['end']:""; if($end!==''){ $where[]=["addtime","<=",$end]; } $low = isset($this->post['low'])&&$this->post['low']!=="" ? floatval($this->post['low']):""; if($low!==''){ $where[]=["budget_total",">=",$low]; } $up = isset($this->post['up'])&&$this->post['up']!=="" ? floatval($this->post['up']):""; if($up!==''){ $where[]=["budget_total","<=",$up]; } $companyNo = isset($this->post['companyNo'])&&$this->post['companyNo']!=="" ? trim($this->post['companyNo']):""; if($companyNo!==''){ $where[]=["companyNo","like","%$companyNo%"]; } $platform_id = isset($this->post['platform_id'])&&$this->post['platform_id']!=="" ? intval($this->post['platform_id']):""; if($platform_id!==''){ $where[]=["platform_id","=",$platform_id]; } $count = Db::name('project')->where($where)->count(); $total = ceil($count / $size); $page = $page >= $total ? $total : $page; $list = Db::name('project')->where($where)->page($page,$size)->order("addtime desc")->select(); $data=[]; foreach ($list as $value){ $info = Db::name("platform")->where(['id'=>$value['platform_id']])->find(); $value['platform_name']=isset($info['platform_name'])?$info['platform_name']:""; $value['platform_code']=isset($info['platform_code'])?$info['platform_code']:""; $khinfo = Db::name("customer_info")->where(["companyNo"=>$value['khNo']])->find(); $value['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:""; $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find(); $value['company'] = isset($company['company'])?$company['company']:""; $data[]=$value; } return app_show(0,"获取成功",['list'=>$data,'count'=>$count]); } public function feedlist(){ $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]]; $pgNo =isset($this->post['pgNo'])&&$this->post['pgNo']!==""?trim($this->post['pgNo']):""; if($pgNo!==""){ $where[]=["pgNo","=",$pgNo]; } $source =isset($this->post['source'])&&$this->post['source']!==""?intval($this->post['source']):""; if($source!==""){ $where[]=["data_source","=",$source]; } $cat_id =isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):""; if($cat_id!==""){ $where[]=["cat_id","=",$cat_id]; } $status =isset($this->post['status'])&&$this->post['status']!==""?intval($this->post['status']):""; if($status!==""){ $where[]=["status","=",$status]; } $count = Db::name('project_feedback')->where($where)->count(); $total = ceil($count / $size); $page = $page >= $total ? $total : $page; $list = Db::name('project_feedback')->where($where)->page($page,$size)->order("addtime desc")->select(); $data=[]; foreach ($list as $value){ $value['can']=isset($value['cat_id'])&&$value['cat_id']!=""?made($value['cat_id']):""; if($value['data_source']==1){ $good=Db::name("good_platform")->alias("a")->leftJoin("good b","a.spuCode=b.spuCode")->where (["a.skuCode"=>$value['skuCode'],"a.is_del"=>0])->find(); $good['unit_id'] = isset($good['good_unit'])?$good['good_unit']:""; $good['cost_desc'] = isset($good['craft_desc'])?$good['craft_desc']:""; $good['pakge_fee'] = isset($good['packing_fee'])?$good['packing_fee']:"0"; $good['nake_fee'] = isset($good['nake_price'])?$good['nake_price']:"0"; $good['metal_id'] = isset($good['noble_metal'])?$good['noble_metal']:"0"; }else{ $good=Db::name("consult_bids")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find(); } $value['good_name'] = isset($good['good_name'])?$good['good_name']:""; $value['brand_id'] = isset($good['brand_id'])?$good['brand_id']:""; $brand = Db::name("brand")->where(['id'=>$value["brand_id"]])->find(); $value['brand_name'] =isset($brand['brand_name']) ? $brand['brand_name']:""; $value['specinfo'] = isset($good['specinfo'])?json_decode($good['specinfo'],true):""; $value['unit_id'] = isset($good['unit_id'])?$good['unit_id']:""; $unit = Db::name("unit")->where(['id'=>$value["unit_id"]])->find(); $value["unit_name"]=isset($unit['unit'])?$unit['unit']:""; $value['cost_desc'] = isset($good['cost_desc'])?$good['cost_desc']:""; $value['work_day'] = isset($good['work_day'])?$good['work_day']:""; $value['good_img'] = isset($good['good_img'])?$good['good_img']:""; $value['expire_day'] = isset($good['expire_day'])?$good['expire_day']:""; $value['origin_place'] = isset($good['origin_place'])?$good['origin_place']:""; $value['supplierNo'] = isset($good['supplierNo'])?$good['supplierNo']:""; $value['pay_way'] = isset($good['pay_way'])?$good['pay_way']:""; $value['tax'] = isset($good['tax'])?$good['tax']:""; $value['send_way'] = isset($good['send_way'])?$good['send_way']:""; $value['metal_id'] = isset($good['metal_id'])?$good['metal_id']:""; $value['is_gold_price'] = isset($good['is_gold_price'])?$good['is_gold_price']:""; $value['config'] = isset($good['config'])?$good['config']:""; $value['weight'] = isset($good['weight'])?$good['weight']:""; $value['is_diff'] = isset($good['is_diff'])?$good['is_diff']:"0"; $value['demo_fee'] = isset($good['demo_fee'])?$good['demo_fee']:"0"; $value['deivery_fee'] = isset($good['deivery_fee'])?$good['deivery_fee']:"0"; $value['open_fee'] = isset($good['open_fee'])?$good['open_fee']:"0"; $value['pakge_fee'] = isset($good['pakge_fee'])?$good['pakge_fee']:"0"; $value['nake_fee'] = isset($good['nake_fee'])?$good['nake_fee']:"0"; $value['mark_fee'] = isset($good['mark_fee'])?$good['mark_fee']:"0"; $value['cert_fee'] = isset($good['cert_fee'])?$good['cert_fee']:"0"; $value['cost_fee'] = isset($good['cost_fee'])?$good['cost_fee']:"0"; //$value['total_fee'] = isset($good['total_fee'])?$good['total_fee']:"0"; $value['supply_area'] = isset($good['supply_area'])?$good['supply_area']:""; $data[]=$value; } return app_show(0,"获取成功",['list'=>$data,'count'=>$count]); } public function info(){ $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):""; if($projectNo==""){ return error_show(1004,"参数projectNo不能为空"); } $type = isset($this->post['type'])&&$this->post['type']!=="" ? intval($this->post['type']) :0; $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到项目信息"); } $plat = Db::name("platform")->where(['id'=>$info['platform_id']])->find(); $info['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:""; $info['platform_code']=isset($plat['platform_code'])?$plat['platform_code']:""; $khinfo = Db::name("customer_info")->where(["companyNo"=>$info['khNo']])->find(); $info['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:""; $company = Db::name("business")->where(["companyNo"=>$info['companyNo']])->find(); $info['company'] = isset($company['company'])?$company['company']:""; $ladder = Db::name("project_info")->where(['projectNo'=>$projectNo,"is_del"=>0])->select()->toArray(); $info['ladder']=[]; if(!empty($ladder)){ foreach ($ladder as $value){ $value["cat_info"]=isset($value['cat_id']) &&$value['cat_id']!=""? made($value['cat_id'],[]):[]; $condition = $type==0?['pgNo'=>$value['pgNo'],"is_del"=>0] : ['pgNo'=>$value['pgNo'],"is_del"=>0,"status"=>1]; $feedback = Db::name("project_feedback")->where($condition)->select()->toArray(); array_walk($feedback,function (&$v){ $v["cat_info"]=isset($v['cat_id'])&&$v['cat_id']!=""? made($v['cat_id'],[]):[]; }); // $zx = Db::name("consult_info")->where(["pgNo"=>$value["pgNo"],"is_del"=>0,"bargain_status"=>0]) // ->column("infoNo"); // if(!empty($zx)){ // $zxback = Db::name("consult_bids")->where(["infoNo"=>$zx,"is_del"=>0])->select()->toArray(); // array_walk($zxback,function (&$v){ // $v["cat_info"]=isset($v['cat_id'])? made($v['cat_id'],[]):[]; // }); // }else{ // $zxback=[]; // } $value['feedback']=$feedback; // $value['zxback']=$zxback; $info['ladder'][]=$value; } } return app_show(0,"获取成功",$info); } public function plan_create(){ $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):""; if($projectNo==""){ return error_show(1004,"参数projectNo不能为空"); } $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到项目信息"); } if($info['status']!=3 || $info['status']!=4){ return error_show(1004,"项目状态有误"); } $feedback =isset($this->post['feedback'])&&!empty($this->post['feedback'])?$this->post['feedback']:""; if($feedback==""){ return error_show(1004,"参数feedback不能为空"); } $feedinfo = Db::name("project_feedback")->where(['id'=>$feedback,"projectNo"=>$projectNo,"is_del"=>0]) ->select()->toArray(); if(empty($feedinfo)){ 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'] : ""; Db::startTrans(); try { $planNo=makeNo("PLA"); $total=0; $dl=[]; foreach ($feedinfo as $value){ $temp=[]; $temp['planNo']=$planNo; $temp['feedback_id']=$value['id']; $temp['status']=1; $temp['is_del']=0; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $total+=$value['num']*$value['sale_price']; $dl[]=$temp; } $inn=Db::name("project_plan_rela")->insertAll($dl); if($inn>0){ $data=[ "planNo"=>$planNo, "projectNo"=>$projectNo, "createrid"=>$createrid, "creater"=>$creater, "sale_total"=>round($total,2), "status"=>0, "is_del"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $up =Db::name("project_plan")->insert($data); if($up){ $info['status']=4; $info['updatetime']=date("Y-m-d H:i:s"); $cr =Db::name("project")->save($info); if($cr){ Db::commit(); return app_show(0,"方案制作成功",["planNo"=>$planNo]); } } } Db::rollback(); return error_show(1004,"方案制作失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function planinfo(){ $planNo = isset($this->post['planNo'])&& $this->post['planNo']!==""?trim($this->post["planNo"]):""; if($planNo==""){ return error_show(1004,"参数planNo不能为空"); } $plan = Db::name("project_plan")->where(["planNo"=>$planNo,"is_del"=>0])->find(); if($plan==false){ return error_show(1004,"未找到项目方案信息"); } $plan['feedback']=[]; $feedback =Db::name("project_plan_rela")->where(["planNo"=>$planNo,"is_del"=>0])->column("feedback_id"); if(!empty($feedback)){ $feedlist = Db::name("project_feedback")->where(["id"=>$feedback,"is_del"=>0])->select(); if(!empty($feedlist)){ foreach ($feedlist as $value){ $value["cat_info"]=isset($value['cat_id'])&&$value['cat_id']!=""? made($value['cat_id'],[]):[]; $plan['feedback'][]=$value; } } } return app_show(0,"获取成功",$plan); } public function project_plan(){ $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):""; if($projectNo==""){ return error_show(1004,"参数projectNo不能为空"); } $type = isset($this->post['type'])&&$this->post['type']!=="" ? intval($this->post['type']) :0; $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到项目信息"); } $plat = Db::name("platform")->where(['id'=>$info['platform_id']])->find(); $info['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:""; $info['platform_code']=isset($plat['platform_code'])?$plat['platform_code']:""; $khinfo = Db::name("customer_info")->where(["companyNo"=>$plat['khNo']])->find(); $info['khName'] = isset($khinfo['CompanyName'])?$khinfo['CompanyName']:""; $ladder = Db::name("project_plan")->where(['projectNo'=>$projectNo,"is_del"=>0])->select()->toArray(); $info['plan']=[]; if(!empty($ladder)){ foreach ($ladder as $value){ $value['feedback']=[]; $feedback =Db::name("project_plan_rela")->where(["planNo"=>$value['planNo'],"is_del"=>0])->column("feedback_id"); if(!empty($feedback)){ $feedlist = Db::name("project_feedback")->where(["id"=>$feedback,"is_del"=>0])->select(); if(!empty($feedlist)){ foreach ($feedlist as $value){ $value["cat_info"]=isset($value['cat_id'])&&$value['cat_id']!=""? made($value['cat_id'],[]):[]; $plan['feedback'][]=$value; } } } $info['plan'][]=$value; } } return app_show(0,"获取成功",$info); } public function feedCheck(){ $feedid = isset($this->post['feedid'])&&!empty($this->post['feedid']) ? $this->post['feedid'] :[]; if(empty($feedid)){ return error_show(1004,"参数feedid不能为空"); } $feedid=array_unique($feedid); $selec = Db::name("project_feedback")->where(["id"=>$feedid,'is_del'=>0,"status"=>0])->select()->toArray(); if(empty($selec)){ return error_show(1004,"反馈数据信息未找到"); } $pgnos =array_column($selec,"pgNo"); $infolist = Db::name("project_info")->where(['pgNo'=>$pgnos])->select()->toArray(); if(empty($infolist)){ return error_show(1004,"项目商品数据未找到"); } Db::startTrans(); try{ $up = Db::name("project_feedback")->where(["id"=>$feedid,'is_del'=>0,"status"=>0])->save(["status"=>1,"updatetime"=>date("Y-m-d H:i:s")]); if($up){ foreach ($infolist as $value){ $value['status']=3; $value['updatetime']=date("Y-m-d H:i:s"); $up = Db::name("project_info")->save($value); if($up){ $count = Db::name("project_info")->where(["projectNo"=>$value['projectNo'],"status"=>2]) ->count(); if($count==0){ $proc =Db::name("project")->where(["projectNo"=>$value['projectNo']])->save (["status"=>3,"updatetime"=>date("Y-m-d H:i:s")]); if(!$proc){ Db::rollback(); return error_show(1004,"反馈数据选择失败"); } } }else{ Db::rollback(); return error_show(1004,"反馈数据选择失败"); } } Db::commit(); return app_show(0,"反馈数据选择成功"); }else{ Db::rollback(); return error_show(1004,"反馈数据选择失败"); } }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function planCheck(){ $planNos = isset($this->post['planNos'])&&!empty($this->post['planNos'])? $this->post['planNos'] :""; if($planNos==""){ return error_show(1004,"参数planNos不能为空"); } $status=isset($this->post['status'])&&$this->post['status']!=="" ? intval($this->post['status']):""; if($status==""){ return error_show(1004,"参数status不能为空"); } $selec = Db::name("project_plan")->where(["planNo"=>$planNos,'is_del'=>0,"status"=>0])->select(); if(empty($selec)){ return error_show(1004,"项目方案数据信息未找到"); } Db::startTrans(); try{ $up = Db::name("project_plan")->where(["planNo"=>$planNos,'is_del'=>0,"status"=>0])->save(["status"=>1,"updatetime"=>date("Y-m-d H:i:s")]); if($up) { $project = array_column($selec, "projectNo"); if (empty($project)) { Db::rollback(); return error_show(1004, "方案选择失败"); } $pro = Db::name("project")->where(["projectNo" => $project, "status" => 4])->save(["status" => 5, "updatetime" => date("Y-m-d H:i:s")]); if ($pro) { Db::commit(); return app_show(0, "方案数据修改成功"); } } Db::rollback(); return error_show(1004,"方案选择失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } public function changeRate(){ $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):""; if($projectNo==""){ return error_show(1004,"参数projectNo不能为空"); } $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find(); if($info==false){ return error_show(1004,"未找到项目信息"); } $rate = isset($this->post['rate'])&&$this->post['rate']!=="" ?floatval($this->post['rate']):""; if($rate===""){ return error_show(1004,"参数rate不能为空"); } $info['low_rate']=$rate; $info['updatetime']=date("Y-m-d H:i:s"); $up =Db::name("project")->save($info); if($up){ return app_show(0,"利润率修改成功"); }else{ return error_show(1004,"利润率修改失败"); } } public function order(){ $id = isset($this->post['id'])&& $this->post['id']!=="" ? intval($this->post['id']):""; if($id==""){ return error_show(1004,"参数id不能为空"); } $backinfo = Db::name("project_feedback")->where(["id"=>$id,"is_del"=>0])->find(); if($backinfo==false){ return error_show(1004,"未找到数据"); } $prject = Db::name("project")->where(["projectNo"=>$backinfo['projectNo'],"is_del"=>0])->find(); if($prject==false) { return error_show(1004, "未找到项目数据"); } $send_type =isset($this->post['send_type'])&&$this->post['send_type']!=""? intval($this->post['send_type']):""; if($send_type==""){ return error_show(1004,"参数send_type不能为空"); } if($send_type==1){ $va = isset($this->post['order_addr']) && $this->post['order_addr'] !== "" ? $this->post['order_addr'] : ""; if ($va == "") { return error_show(1002, "参数order_addr不能为空"); } } $plat = Db::name("platform")->where(["id"=>$prject['platform_id']])->find(); $token = isset($this->post['token'])&& $this->post['token']!=="" ? trim($this->post['token']):""; if($token==""){ return error_show(1004,"参数token不能为空"); } $apply_id = GetUserInfo($token); if (empty($apply_id) || $apply_id['code'] != 0) { return error_show(1002, "申请人数据不存在"); } $rm = isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : ""; $ri = isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : ""; $orderCode = makeNo("CX"); Db::startTrans(); try{ $data = [ "orderCode" => $orderCode, "good_code" => $backinfo['spuCode'], "customer_code" => $prject['khNo'], "good_name" => $backinfo['good_name'], "good_num" => $backinfo['num'], "order_type" =>3, "item_code"=>isset($plat['platform_code'])? $plat['platform_code']:"", "good_type"=>1, "apply_id" => $rm, "apply_name" => $ri, "origin_price" =>$backinfo['nake_price'], "sale_price" => $backinfo['sale_price'], "post_fee" => 0, "status" => 0, "supplierNo" =>$prject['companyNo'], "send_num" => 0, "zxNo"=>$backinfo['pgNo'], "wsend_num" => $backinfo['num'], "send_type" => $send_type, "send_status" => 1, "is_del" => 0, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s"), 'total_price' => $backinfo['sale_price'] * $backinfo['num'], ]; $datainfo = Db::name('sale')->insert($data, true); if($datainfo>0){ if($send_type==1){ foreach ($va as $value) { $temp = []; $addrs = []; if ($value['addr_code'] !== '' && is_array($value['addr_code'])) { $addrs['provice_code'] = $value['addr_code'][0]; $addrs['city_code'] = $value['addr_code'][1]; $addrs['area_code'] = $value['addr_code'][2]; $addr = json_encode($addrs); } else { $addr = isset($value['addr_code']) ? $value['addr_code'] : ''; } $temp['orderCode'] = $orderCode; $temp['contactor'] = $value['contactor']; $temp['mobile'] = $value['mobile']; $temp['addr'] = $value['addr']; $temp['addr_code'] = $addr; $temp['customer_code'] = $prject['khNo']; $temp['receipt_quantity'] = $value['receipt_quantity']; $temp['post_fee'] = 0; $temp['is_del'] = 0; $temp['addtime'] = date("Y-m-d H:i:s"); $temp['updatetime'] = date("Y-m-d H:i:s"); $temp['arrive_time'] = date("Y-m-d H:i:s"); $vat[] = $temp; } $vmp = Db::name('order_addr')->insertAll($vat); if ($vmp==false) { Db::rollback(); return error_show(1004, "销售订单创建失败"); } } Db::commit(); return error_show(0, "销售订单创建成功"); } Db::rollback(); return error_show(1004, "销售订单创建失败"); }catch (\Exception $w){ Db::rollback(); return error_show(1004, $w->getMessage()); } } public function feeddel(){ $feedid = isset($this->post['id'])&&!empty($this->post['id']) ? $this->post['id'] :[]; if(empty($feedid)){ return error_show(1004,"参数feedid不能为空"); } $selec = Db::name("project_feedback")->where(["id"=>$feedid,'is_del'=>0])->select(); if(empty($selec)){ return error_show(1004,"反馈数据信息未找到"); } $up = Db::name("project_feedback")->where(["id"=>$feedid,'is_del'=>0])->save(["is_del"=>1,"updatetime"=>date("Y-m-d H:i:s")]); if($up){ return app_show(0,"反馈数据删除成功"); }else{ return error_show(1004,"反馈数据删除失败"); } } }