123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770 |
- <?php
- namespace app\admin\controller;
- use think\App;
- use think\facade\Db;
- class Consult extends Base
- {
- public $noble=[];
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->noble =\think\facade\Config::get("noble");
- }
- // 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]];
- $infoNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
- if ($infoNo !== "") {
- $where[] = ['a.infoNo','=',$infoNo];
- }
- // $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['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
- true):[];
- $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
- $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
- $value['khname']="";
- if($value['khNo']!==""){
- $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
- $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
- }
- $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
- $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(105,"参数token不能为空");
- }
- $user =GetUserInfo($token);
- if(empty($user)||$user['code']!=0){
- return error_show(102,"用户数据不存在");
- }
- $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=makeNo("INF");
- $specinfo=[];
- if(isset($value['specinfo']) &&!empty($value['specinfo'])){
- foreach ($value["specinfo"] as $v){
- $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
- $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
- $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
- $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
- $specinfo[]=$v;
- }
- }
- $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'],
- "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
- "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'],
- "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
- "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']:0;
- $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['brand']="";
- $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']="";
- $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
- $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
- 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($zxinfo['brand_id']!==""){
- $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
- $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
- }
- 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['pgNo']])->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 zxedit(){
- $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,"未找到信息数据");
- }
- $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
- if($good_name==""){
- return error_show(1003,"参数good_name不能为空");
- }
- $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
- if($good_img==""){
- return error_show(1003,"参数good_img不能为空");
- }
- $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
- if($cat_id==""){
- return error_show(1003,"参数cat_id不能为空");
- }
- $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
- if($unit==""){
- return error_show(1003,"参数unit不能为空");
- }
- $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
- $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
- if($arrival_time==""){
- return error_show(1003,"参数arrival_time不能为空");
- }
- $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
- if($specin==""){
- return error_show(1003,"参数specinfo不能为空");
- }
- // $color= isset($this->post['color'])&&$this->post['color']!=""?trim($this->post['color']):"";
- // if($color==""){
- // return error_show(1003,"参数color不能为空");
- // }
- // $material= isset($this->post['material'])&&$this->post['material']!=""?trim($this->post['material']):"";
- // if($material==""){
- // return error_show(1003,"参数material不能为空");
- // }
- $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
- if($cost_desc==""){
- return error_show(1003,"参数cost_desc不能为空");
- }
- $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
- if($is_addrs===""){
- return error_show(1003,"参数is_addrs不能为空");
- }
- $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
- if($is_custom===""){
- return error_show(1003,"参数is_custom不能为空");
- }
- $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
- if($metal_id===""){
- return error_show(1003,"参数metal_id不能为空");
- }
- $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
- $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
- $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
- $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
- $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
- $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
- $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
- $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
- if($num===""){
- return error_show(1003,"参数num不能为空");
- }
- if($budget_price===""){
- return error_show(1003,"参数budget_price不能为空");
- }
- $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
- $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
- if($use_desc==""){
- return error_show(1003,"参数use_desc不能为空");
- }
- $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
- if($remark==""){
- return error_show(1003,"参数remark不能为空");
- }
- if($metal_id!=0){
- if($config==""){
- return error_show(1003,"参数config不能为空");
- }
- if($other_config==""){
- return error_show(1003,"参数other_config不能为空");
- }
- if($specs_weight===""){
- return error_show(1003,"参数specs_weight不能为空");
- }
- if($gold_price===""){
- return error_show(1003,"参数gold_price不能为空");
- }
- }
- $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
- if($token==''){
- return error_show(102,"参数token不能为空");
- }
- $user =GetUserInfo($token);
- if(empty($user)||$user['code']!=0){
- return error_show(105,"用户数据不存在");
- }
- $specinfo=[];
- foreach ($specin as $v){
- $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
- $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
- $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
- $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
- $specinfo[]=$v;
- }
- $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
- $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
- $bidlist = Db::name("consult_bids")->where(["infoNo"=>$zxinfo['infoNo'],"is_del"=>0])->select();
- try{
- $innew =makeNo("INF");
- $info=[
- "infoNo"=>$innew,
- "zxNo"=>$zxinfo['zxNo'],
- "spuCode"=>"",
- "good_name"=>$good_name,
- "good_img"=>$good_img,
- "cat_id"=>$cat_id,
- "unit"=>$unit,
- "brand_id"=>$brand_id,
- "arrival_time"=>$arrival_time,
- "specinfo"=>json_encode($specinfo),
- // "color"=>$color,
- // "material"=>$material,
- "cost_desc"=>$cost_desc,
- "is_addrs"=>$is_addrs,
- "is_custom"=>$is_custom,
- "metal_id"=>$metal_id,
- "config"=>$config,
- "other_config"=>$other_config,
- "specs_weight"=>$specs_weight===""?0:$specs_weight,
- "gold_price"=>$gold_price===""? 0 : $gold_price,
- "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
- "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
- "budget_price"=>$budget_price,
- "num"=>$num,
- "pgNo"=>$pgNo,
- "use_desc"=>$use_desc,
- "remark"=>$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){
- if (!empty($bidlist)){
- foreach ($bidlist as $value){
- unset($value['id']);
- $value['infoNo']=$innew;
- $value['bidNo']=makeNo("BD");
- $value['spuCode']=makeNo("SPU");
- $value['status'] =0;
- $value['updatetime'] =date("Y-m-d H:i:s");
- $in = Db::name("consult_bids")->insert($value);
- if($in==false){
- Db::rollback();
- return error_show(1004,"反馈商品新建失败");
- }
- }
- }
- $zxinfo["bargain_status"] =1;
- $zxinfo["bargain_code"] =$innew;
- $zxinfo["updatetime"] =date("Y-m-d H:i:s");
- $bar=Db::name("consult_info")->save($zxinfo);
- if($bar==false){
- Db::rollback();
- return error_show(1004,"反馈商品更新失败");
- }
- Db::commit();
- return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
- }
- }catch (\Exception $e){
- Db::rollback();
- return error_show(1004,$e->getMessage());
- }
- }
- //** 发布竞标任务 */
- 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(1002,"参数infoNo不能为空");
- }
- $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
- if($zxinfo==false){
- return error_show(1003,"未找到信息数据");
- }
- if($zxinfo['status']!=1){
- return error_show(1004,"任务未进行");
- }
- $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
- if($zx==false){
- return error_show(1003,"未找咨询信息数据");
- }
- $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
- if($pname==""){
- return error_show(1002,"参数pname不能为空");
- }
- $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
- $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
- if($cat_id==""){
- return error_show(1002,"参数cat_id不能为空");
- }
- $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
- if($specin==""){
- return error_show(1003,"参数specinfo不能为空");
- }
- $specinfo=[];
- foreach ($specin as $v){
- $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
- $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
- $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
- $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
- $specinfo[]=$v;
- }
- $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']:"";
- $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
- $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
- $good_weight = isset($this->post['good_weight'])&&$this->post['good_weight']!==""? floatval($this->post['good_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']):"";
- if($nake_fee==="" ||$nake_fee==0 ){
- return error_show(1004,"参数nake_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(1002,"参数token不能为空");
- }
- $user =GetUserInfo($token);
- if(empty($user)||$user['code']!=0){
- return error_show(1005,"用户数据不存在");
- }
- $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
- $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
- $bidNo=makeNo("BD");
- $spucode=makeNo("SPU");
- $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
- if($is_gold_price==1){
- $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
- ->find();
- $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
- $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
- $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- }else{
- $saleprice = $open_fee/$zxinfo['num'] +
- $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
- $total_fee = $open_fee/$zxinfo['num'] +
- $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- }
- $data=[
- "bidNo"=>$bidNo,
- "infoNo"=>$infoNo,
- "zxNo"=>$zxinfo['zxNo'],
- "spuCode"=>$spucode,
- "good_name"=>$pname,
- "brand_id"=>$brandid,
- "cat_id"=>$cat_id,
- "specinfo"=>json_encode($specinfo),
- "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,
- "other_config"=>$other_config,
- "weight"=>$weight,
- "good_weight"=>$good_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"=>$saleprice,
- "origin_price"=>$saleprice,
- "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($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
- $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
- if($projectinfo==false){
- Db::rollback();
- return error_show(1006,"未找到项目信息");
- }
- $temp=[];
- $temp['spuCode']=$spucode;
- $temp['skuCode']="";
- $temp['pgNo']=$zxinfo['pgNo'];
- $temp['projectNo']=$zx['projectNo'];
- $temp['good_name']=$pname;
- $temp['good_type']=$projectinfo['good_type'];
- $temp['data_source']=2;
- $temp['cat_id']=$cat_id;
- $temp['budget_price']=$projectinfo['budget_price'];
- $temp['sale_price']=$saleprice;
- $temp['origin_price']=$total_fee;
- $temp['num']=$zxinfo['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");
- $nu = Db::name("project_feedback")->insert($temp);
- if($nu==false){
- Db::rollback();
- return error_show(1006,"项目反馈失败");
- }else{
- $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==false){
- Db::rollback();
- return error_show(1006,"项目反馈失败");
- }
- }
- }
- }
- }
- Db::commit();
- return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
- }else{
- Db::rollback();
- return error_show(1006,"反馈失败");
- }
- }catch (\Exception $e){
- Db::rollback();
- return error_show(1006,$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"]="";
- }
- $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
- $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
- $god=[
- "metal_id"=>$info['metal_id'],
- "weight"=>$info["weight"],
- "demo_fee"=>$info["demo_fee"],
- "delivery_fee"=>$info["delivery_fee"],
- "open_fee"=>$info["open_fee"],
- "packing_fee"=>$info["pakge_fee"],
- "mark_fee"=>$info["mark_fee"],
- "nake_fee"=>$info["nake_fee"],
- "cert_fee"=>$info["cert_fee"],
- "cost_fee"=>$info["cost_fee"],
- "num"=>$bidinfo["num"],
- ];
- if($info['is_gold_price']==1){
- $price = GoldPrice($god, $budget/100);
- $info['sale_price'] =round($price,2);
- }
- $info['specinfo'] = json_decode($info['specinfo'],true);
- $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
- $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
- $info['bargain'] =$bargain;
- return app_show(0,"获取成功",$info);
- }
- public function feededit(){
- $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
- if($bidNo==""){
- return error_show(1002,"参数bidNo不能为空");
- }
- $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
- if($bidinfo==false){
- return error_show(1003,"未找到信息数据");
- }
- if($bidinfo['status']>=5){
- return error_show(1004,"咨询单已确认无法修改");
- }
- $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
- if($zxinfo==false){
- return error_show(1003,"未找到信息数据");
- }
- $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
- if($zx==false){
- return error_show(1003,"未找咨询信息数据");
- }
- $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
- if($pname==""){
- return error_show(1002,"参数pname不能为空");
- }
- $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
- // if($brandid==""){
- // return error_show(1002,"参数brandid不能为空");
- // }
- $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
- if($cat_id==""){
- return error_show(1002,"参数cat_id不能为空");
- }
- $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
- if($specin==""){
- return error_show(1003,"参数specinfo不能为空");
- }
- $specinfo=[];
- foreach ($specin as $v){
- $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
- $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
- $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
- $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
- $specinfo[]=$v;
- }
- $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']:"";
- $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_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']):"";
- if($nake_fee==="" ||$nake_fee==0 ){
- return error_show(1004,"参数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']):"";
- $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
- if($is_gold_price==1){
- $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
- ->find();
- $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
- $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
- $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- }else{
- $saleprice = $open_fee/$zxinfo['num'] +
- $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
- $total_fee = $open_fee/$zxinfo['num'] +
- $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- }
- Db::startTrans();
- try{
- $data=[
- "good_name"=>$pname,
- "brand_id"=>$brandid,
- "cat_id"=>$cat_id,
- "specinfo"=>json_encode($specinfo),
- // "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,
- "other_config"=>$other_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,
- "sale_price"=>$saleprice,
- "supply_area"=>$supply_area,
- "remark"=>$remark,
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
- if($insert){
- if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
- $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
- if($projectinfo==false){
- Db::rollback();
- return error_show(1006,"未找到项目信息");
- }
- $feed = Db::name("project_feedback")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"spuCode"=>$bidinfo['spuCode'],"is_del"=>0])->find();
- if($feed==false){
- Db::rollback();
- return error_show(1006,"未找到项目反馈信息");
- }
- $feed['good_name']=$pname;
- $feed['good_type']=$projectinfo['good_type'];
- $feed['cat_id']=$cat_id;
- $feed['sale_price']=$saleprice;
- $feed['origin_price']=$total_fee;
- $temp['updatetime']=date("Y-m-d H:i:s");
- $nu = Db::name("project_feedback")->save($feed);
- if($nu==false){
- Db::rollback();
- return error_show(1006,"项目反馈失败");
- }else{
- $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==false){
- Db::rollback();
- return error_show(1006,"项目反馈失败");
- }
- }
- }
- }
- }
- 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 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,"未找到商品数据");
- }
- $bargain_price = isset($this->post['bargain_price'])&& $this->post['bargain_price']!=""?floatval($this->post['bargain_price']):"";
- if($bargain_price===""){
- return error_show(1004,"参数bargain_price不能为空");
- }
- $bargain_reason = isset($this->post['bargain_reason'])&& $this->post['bargain_reason']!=""?trim($this->post['bargain_reason']):"";
- // if($bargain_reason===""){
- // return error_show(1004,"参数bargain_reason不能为空");
- // }
- $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
- if($infos==false){
- return error_show(1004,"未找到商品数据");
- }
- if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
- return error_show(1004,"咨询单招标未结束或已确认商品");
- }
- $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
- if($token==''){
- return error_show(105,"参数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("BA");
- Db::startTrans();//::todo 金价 毛利计算
- try{
- $data=[
- "bidsNo"=>$bidNo,
- "infoNo"=>$info['infoNo'],
- "zxNo"=>$info['zxNo'],
- "bargainNo"=>$bargainNo,
- "bargain_type"=>1,
- "bargain_reason"=>$bargain_reason,
- "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"=>$bargain_price,
- "exam_info"=>"",
- "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){
- $infos['status']=3;
- $infos['updatetime']=date("Y-m-d H:i:s");
- $ups =Db::name("consult_info")->save($infos);
- if($ups){
- Db::commit();
- return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]);
- }
- }
- }
- Db::rollback();
- return error_show(1004,"议价单新建失败");
- }catch (\Exception $e){
- Db::rollback();
- return error_show(1004,$e->getMessage());
- }
- }
- public function bids_check(){
- $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,"未找到商品数据");
- }
- if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
- return error_show(1004,"咨询单招标未结束或已确认商品");
- }
- Db::startTrans();
- try {
- $info['status']=6;
- $info['updatetime']=date("Y-m-d H:i:s");
- $bids = Db::name("consult_bids")->save($info);
- if($bids){
- $infos['status']=4;
- $infos['updatetime']=date("Y-m-d H:i:s");
- $se = Db::name("consult_info")->save($infos);
- if($se){
- 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 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,"未找到商品数据");
- }
- $coninfo=Db::name("consult_info")->where(["infoNo"=>$bids["infoNo"],"is_del"=>0])->find();
- if($coninfo==false){
- return error_show(1004,"未找到咨询单数据");
- }
- $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):"";
- if($status==''){
- return error_show(1005,"参数status不能为空");
- }
- $remark = isset($this->post['remark'])&& $this->post['remark']!=""?trim($this->post['remark']):"";
- // if($remark==""){
- // return error_show(1004,"参数remark不能为空");
- // }
- $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
- if($token==''){
- return error_show(105,"参数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{
- $examinfo = isset($info['exam_info'])&&$info['exam_info']!="" ? json_decode($info['exam_info'],true):[];
- $examinfo[]=["status"=>$status,"remark"=>$remark,"createrid"=>$createrid,"creater"=>$creater];
- $info['status'] =$status;
- $info['remark'] =$remark;
- $info['exam_info']=json_encode($examinfo) ;
- $info['updatetime'] =date("Y-m-d H:i:s");
- $up =Db::name("bargain_order")->save($info);
- if($up){
- if($status==4||$status==5||$status==6||$status==7){
- $bids['status']=5;
- if($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,"数据更新失败");
- }
- }
- 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,"未找到议价数据");
- }
- $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$info['bidsNo']],["is_del","=",0]])->find();
- if($bidinfos==false){
- return error_show(1004,"未找到商品数据");
- }
- $consultinfos = Db::name("consult_info")->where([["infoNo","=",$bidinfos['infoNo']],["is_del","=",0]])
- ->find();
- if($consultinfos==false){
- return error_show(1004,"未找到咨询商品数据");
- }
- $info['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
- $info['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
- $info['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
- $info['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
- $info['good_num'] = isset($consultinfos['num'])?$consultinfos['num']:"";
- $info['exam_info'] = isset($info['exam_info'])&&$info['exam_info']!=""?json_encode($info['exam_info']):"";
- if($bidinfos['brand_id']!=0){
- $info['brand_id'] = $bidinfos['brand_id'];
- $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
- $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
- }else{
- $info["brand_name"]="";
- $info["brand_id"]="";
- }
- $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
- $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
- $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
- $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
- $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
- $info['budget'] =$budget;
- $god=[
- "metal_id"=>$bidinfos['metal_id'],
- "weight"=>$bidinfos["weight"],
- "demo_fee"=>$bidinfos["demo_fee"],
- "delivery_fee"=>$bidinfos["delivery_fee"],
- "open_fee"=>$bidinfos["open_fee"],
- "packing_fee"=>$bidinfos["pakge_fee"],
- "mark_fee"=>$bidinfos["mark_fee"],
- "nake_fee"=>$bidinfos["nake_fee"],
- "cert_fee"=>$bidinfos["cert_fee"],
- "cost_fee"=>$bidinfos["cost_fee"],
- "num"=>$bidinfoe["num"],
- ];
- $info['gold_price']=0;
- if($bidinfos['is_gold_price']==1 &&$bidinfos['metal_id']>0){
- $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
- ->find();
- $info['gold_price'] =$gold['price'];
- }
- $info['cost_desc'] =$bidinfos['cost_desc'];
- $info['work_day'] =$bidinfos['work_day'];
- $info['delivery_day'] =$bidinfos['delivery_day'];
- $info['expire_day'] =$bidinfos['expire_day'];
- $info['origin_place'] =$bidinfos['origin_place'];
- $info['origin_addr'] ="";
- if($bidinfos['origin_place']!=''){
- $code = explode(",",$bidinfos['origin_place']);
- $temp=[];
- $temp['provice_code']=isset($code[0])?$code[0]:"";
- $temp['city_code']=isset($code[1])?$code[1]:"";
- $temp['area_code']=isset($code[2])?$code[2]:"";
- $addr= GetAddr(json_encode($temp));
- $info['origin_addr'] = $addr;
- }
- $info['supplierNo'] =$bidinfos['supplierNo'];
- $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
- $info['supplier_name'] = isset($supplier['name'])?$supplier['name']:"";
- $info['pay_way'] =$bidinfos['pay_way'];
- $info['tax'] =$bidinfos['tax'];
- $info['send_way'] =$bidinfos['send_way'];
- $info['metal_id'] =$bidinfos['metal_id'];
- $info['is_gold_price'] =$bidinfos['is_gold_price'];
- $info['config'] =$bidinfos['config'];
- $info['other_config'] =$bidinfos['other_config'];
- $info['weight'] =$bidinfos['weight'];
- $info['is_diff'] =$bidinfos['is_diff'];
- $info['demo_fee'] =$bidinfos['demo_fee'];
- $info['delivery_fee'] =$bidinfos['delivery_fee'];
- $info['open_fee'] =$bidinfos['open_fee'];
- $info['pakge_fee'] =$bidinfos['pakge_fee'];
- $info['nake_fee'] =$bidinfos['nake_fee'];
- $info['mark_fee'] =$bidinfos['mark_fee'];
- $info['cert_fee'] =$bidinfos['cert_fee'];
- $info['cost_fee'] =$bidinfos['cost_fee'];
- $info['total_fee'] =$bidinfos['total_fee'];
- $info['supply_area'] =$bidinfos['supply_area'];
- $info['remark'] =$bidinfos['remark'];
- $info['is_addrs'] =$consultinfos['is_addrs'];
- $info['is_custom'] =$consultinfos['is_custom'];
- $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
- $info['sale_price'] =round($bidinfos['sale_price'],2);
- $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
- 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];
- }
- $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
- if ($pgNo !== "") {
- $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
- $where[] = ['infoNo','in',$bidinfo];
- }
- $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
- if ($bargain_status !== "") {
- $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
- $where[] = ['infoNo','in',$bidinfo];
- }
- $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){
- $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
- $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"]="";
- }
- $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
- $god=[
- "metal_id"=>$value['metal_id'],
- "weight"=>$value["weight"],
- "demo_fee"=>$value["demo_fee"],
- "delivery_fee"=>$value["delivery_fee"],
- "open_fee"=>$value["open_fee"],
- "packing_fee"=>$value["pakge_fee"],
- "mark_fee"=>$value["mark_fee"],
- "nake_fee"=>$value["nake_fee"],
- "cert_fee"=>$value["cert_fee"],
- "cost_fee"=>$value["cost_fee"],
- "num"=>$bidinfo["num"],
- ];
- if($value['is_gold_price']==1){
- $price = GoldPrice($god, $budget/100);
- $value['sale_price'] = round($price,2);
- }
- $value['specinfo'] = json_decode($value['specinfo'],true);
- $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
- $value['bargain_status']=$bidinfo['bargain_status'];
- $data[]=$value;
- }
- return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
- }
- public function feedlist(){
- $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];
- }
- $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
- if($token==''){
- return error_show(102,"参数token不能为空");
- }
- $user =GetUserInfo($token);
- if(empty($user)||$user['code']!=0){
- return error_show(105,"用户数据不存在");
- }
- $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
- $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
- $where[] = ["createrid","=",$createrid];
- $list =Db::name('consult_bids')->where($where)->select();
- $data=[];
- foreach ($list as $value){
- $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
- $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"]="";
- }
- $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
- $god=[
- "metal_id"=>$value['metal_id'],
- "weight"=>$value["weight"],
- "demo_fee"=>$value["demo_fee"],
- "delivery_fee"=>$value["delivery_fee"],
- "open_fee"=>$value["open_fee"],
- "packing_fee"=>$value["pakge_fee"],
- "mark_fee"=>$value["mark_fee"],
- "nake_fee"=>$value["nake_fee"],
- "cert_fee"=>$value["cert_fee"],
- "cost_fee"=>$value["cost_fee"],
- "num"=>$bidinfo["num"],
- ];
- if($value['is_gold_price']==1){
- $price = GoldPrice($god, $budget/100);
- $value['sale_price'] =round($price,2);
- }
- $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
- $value['specinfo'] = json_decode($value['specinfo'],true);
- $value['bargain_status']=$bidinfo['bargain_status'];
- $data[]=$value;
- }
- return app_show(0,"获取成功",$data);
- }
- public function bragain_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]];
- $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
- if($bidsNo!=""){
- $where[]=["bidsNo","=",$bidsNo];
- }
- $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];
- }
- $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];
- }
- $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
- if ($pgNo !== "") {
- $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
- $where[] = ['infoNo','in',$bidinfo];
- }
- $count=Db::name("bargain_order")->where($where)->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list =Db::name('bargain_order')->where($where)->page($page,$size)->select();
- $data=[];
- foreach ($list as $value){
- $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
- $value['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
- $value['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
- $value['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
- $value['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
- if($bidinfos['brand_id']!=0){
- $value['brand_id'] = $bidinfos['brand_id'];
- $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
- $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
- }else{
- $value["brand_name"]="";
- $value["brand_id"]="";
- }
- $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
- $value['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
- $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
- $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
- $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
- $value['budget'] =$budget;
- $god=[
- "metal_id"=>$bidinfos['metal_id'],
- "weight"=>$bidinfos["weight"],
- "demo_fee"=>$bidinfos["demo_fee"],
- "delivery_fee"=>$bidinfos["delivery_fee"],
- "open_fee"=>$bidinfos["open_fee"],
- "packing_fee"=>$bidinfos["pakge_fee"],
- "mark_fee"=>$bidinfos["mark_fee"],
- "nake_fee"=>$bidinfos["nake_fee"],
- "cert_fee"=>$bidinfos["cert_fee"],
- "cost_fee"=>$bidinfos["cost_fee"],
- "num"=>$bidinfoe["num"],
- ];
- // if($bidinfos['is_gold_price']==1){
- // $price = GoldPrice($god, $budget/100);
- // }else{
- // $price = GoodPrice($god, $budget/100);
- // }
- $value['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
- $value['sale_price'] =round($bidinfos['sale_price'],2);
- $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
- $data[]=$value;
- }
- return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
- }
- public function crontablist(){
- $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];
- }
- $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']):[];
- $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
- $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
- $value['khname']="";
- $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
- true):[];
- if($value['khNo']!==""){
- $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
- $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
- }
- $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
- $data[]=$value;
- }
- return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
- }
- }
|