12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823 |
- <?php
- namespace app\admin\controller;
- use app\admin\model\ActionLog;
- use app\admin\model\ProcessOrder;
- use think\App;
- use think\facade\Db;
- use think\facade\Validate;
- //咨询单
- class Consult extends Base
- {
- public $noble=[];
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->noble =\think\facade\Config::get("noble");
- }
- 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];
- }
- $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%"];
- }
- $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
- if ($companyNo !== "") {
- // $where['khNo'] = $khNo;
- $where[]= ["b.companyNo",'like',"%$companyNo%"];
- }
- $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")->order("a.id desc")->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不能为空");
- }
- $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");
- Db::startTrans();
- try{
- $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("IF");
- $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" => isset($value['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"),
- 'enclosure_file'=>isset($value['enclosure_file'])?$value['enclosure_file']:'',
- ];
- $up = Db::name("consult_info")->insert($info);
- if(!$up){
- Db::rollback();
- return error_show(1004,'添加失败');
- }else{
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $infoNo,//咨询单详情编号
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "create"//新建create,编辑edit,更改状态status
- ], "ZXD", 1, $info);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'ZXD',
- "order_code" => $infoNo,//咨询单详情编号
- "order_id" => 0,
- "order_status" => 1
- ]);
- }
- }
- $stn = ["order_code"=>$zxNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
- ActionLog::logAdd($this->post['token'],$stn,"ZXD",2,$info);
- $process=["order_code"=>$zxNo,"order_id"=>Db::name("consult_order")->getLastInsID(),"order_status"=>1,"order_type"=>'ZXD'];
- ProcessOrder::AddProcess($this->post['token'],$process);
- Db::commit();
- return app_show(0,"新建成功",["zxNo"=>$zxNo]);
- }else{
- Db::rollback();
- return error_show(1004,"新建失败");
- }
- }catch (\Exception $e){
- Db::rollback();
- return error_show(1003,$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,"未找到信息数据");
- }
- $enclosure_file =isset($this->post['enclosure_file'])&&$this->post['enclosure_file']!=""?trim($this->post['enclosure_file']):$zxinfo['enclosure_file'];
- $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不能为空");
- }
- $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不能为空");
- }
- $endtime = isset($this->post['endtime'])&& $this->post['endtime']!="" ? trim($this->post['endtime']):"";
- if($endtime==""){
- return error_show(1003,"参数endtime不能为空");
- }
- 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();
- Db::startTrans();
- try{
- $innew =makeNo("IF");
- $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"),
- 'bargain_status'=>1,
- 'enclosure_file'=>$enclosure_file
- ];
- $up = Db::name("consult_info")->insert($info);
- if($up){
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $innew,//咨询单详情编号
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "create"//新建create,编辑edit,更改状态status
- ], "ZXD", 1, $info);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'ZXD',
- "order_code" => $innew,//咨询单详情编号
- "order_id" => 0,
- "order_status" => 1
- ]);
- if (!empty($bidlist)){
- foreach ($bidlist as $value){
- unset($value['id']);
- $value['infoNo']=$innew;
- $value['bidNo']=makeNo("BD");
- $value['spuCode']=makeNo("SKU");
- $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,"反馈商品更新失败");
- }else{
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $zxinfo['infoNo'],//咨询单详情编号
- "status" => $zxinfo['status'],//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "edit"//新建create,编辑edit,更改状态status
- ], "ZXD", $zxinfo['status'], $zxinfo);
- // 并没有修改状态
- // ProcessOrder::AddProcess($this->post['token'], [
- // "order_type" => 'ZXD',
- // "order_code" => $zxinfo['infoNo'],//咨询单详情编号
- // "order_id" => $zxinfo['id'],
- // "order_status" => $zxinfo['status']
- // ]);
- }
- //更新consule_order记录
- Db::name('consult_order')->where('zxNo',$zxinfo['zxNo'])->update(['endtime'=>$endtime,'updatetime'=>date('Y-m-d H:i:s')]);
- 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;
- }
- $old_zxinfo_status = $zxinfo['status'];
- $zxinfo['status']=$status;
- $zxinfo['updatetime']=date("Y-m-d H:i:s");
- $up = Db::name("consult_info")->save($zxinfo);
- if($up){
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $zxinfo['infoNo'],//咨询单详情编号
- "status" => $old_zxinfo_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "ZXD", $zxinfo['status'], $zxinfo);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'ZXD',
- "order_code" => $zxinfo['infoNo'],//咨询单详情编号
- "order_id" => $zxinfo['id'],
- "order_status" => $zxinfo['status']
- ]);
- 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==="" ){
- 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("SKU");
- $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
- //部分参数的大小校验
- $vali = Validate::rule([
- 'expire_day|有效时长'=>'require|elt:214748364',
- 'delivery_day|物流时长'=>'require|elt:214748364',
- 'work_day|生产工期'=>'require|elt:214748364',
- 'weight|总重量'=>'require|max:10',
- ]);
- $temp = [
- 'expire_day'=>$expire_day,
- 'delivery_day'=>$delivery_day,
- 'work_day'=>$work_day,
- 'weight'=>$weight,
- ];
- if(!$vali->check($temp)) return error_show(0,$vali->getError());
- 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{
- $old_projectinfo_status = $projectinfo['status'];
- $projectinfo['status']=2;
- $projectinfo['updatetime']=date("Y-m-d H:i:s");
- $up = Db::name("project_info")->save($projectinfo);
- if($up){
- //修改状态,添加待办,只记录动作
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $projectinfo['pgNo'],//编码
- "status" => $old_projectinfo_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRO", 2, $projectinfo);
- $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
- ->count();
- if($count==0){
- $projetc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->find();
- if($projetc!=false){
- $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,"项目反馈失败");
- }else{
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $projetc['projectNo'],//项目编码
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRO", 2, $projetc);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'PRO',
- "order_code" => $projetc['projectNo'],
- "order_id" => $projetc['id'],
- "order_status" => 2
- ]);
- }
- }
- }
- }
- }
- }
- 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;
- $feed['updatetime']=date("Y-m-d H:i:s");
- $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{
- $old_projectinfo_status = $projectinfo['status'];
- $projectinfo['status']=2;
- $projectinfo['updatetime']=date("Y-m-d H:i:s");
- $up = Db::name("project_info")->save($projectinfo);
- if($up){
- //修改状态,添加待办,只记录动作
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $projectinfo['pgNo'],//编码
- "status" => $old_projectinfo_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRO", 2, $projectinfo);
- $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->count();
- if ($count == 0) {
- //先查询是否存在status==1的项目,有的话再更新,否则跳过
- $project_id = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->value('id', 0);
- if ($project_id) {
- $proc = Db::name("project")->where(["id" => $project_id])->update(["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
- if ($proc == false) {
- Db::rollback();
- return error_show(1006, "项目反馈失败");
- }else{
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $projectinfo['projectNo'],//项目编码
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRO", 2, $this->post);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'PRO',
- "order_code" => $projectinfo['projectNo'],
- "order_id" => $project_id,
- "order_status" => 2
- ]);
- }
- }
- }
- }
- }
- }
- 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,"用户数据不存在");
- }
- //新增两个字段
- //议价备注
- $bargain_remark = isset($this->post['bargain_remark']) && $this->post['bargain_remark'] != "" ? trim($this->post['bargain_remark']) : "";
- //议价原因id
- $result_info_id = isset($this->post['result_info_id']) && $this->post['result_info_id'] != "" ? $this->post['result_info_id'] : "";
- if ($result_info_id != '') {
- $temp = Db::name('result_info')->field('id')->where(['result_code' => $result_info_id, 'type' => 7, 'status' => 1, 'is_del' => 0])->find();//type 7议价原因
- if (empty($temp)) return error_show(1004, "议价原因选择不正确");
- }
- $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"),
- 'bargain_remark'=>$bargain_remark,
- 'result_info_id'=>$result_info_id,
- ];
- $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){
- $old_infos_status = $infos['status'];
- $infos['status']=3;
- $infos['updatetime']=date("Y-m-d H:i:s");
- $ups =Db::name("consult_info")->save($infos);
- if($ups){
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $infos['infoNo'],//咨询单详情编号
- "status" => $old_infos_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "ZXD", $infos['status'], $infos);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'ZXD',
- "order_code" => $infos['infoNo'],//咨询单详情编号
- "order_id" => $infos['id'],
- "order_status" => $infos['status']
- ]);
- 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){
- $old_infos_status = $infos['status'];
- $infos['status']=4;
- $infos['updatetime']=date("Y-m-d H:i:s");
- $se = Db::name("consult_info")->save($infos);
- if($se){
- //修改状态,添加待办
- ActionLog::logAdd($this->post['token'], [
- "order_code" => $infos['infoNo'],//咨询单详情编号
- "status" => $old_infos_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "ZXD", $infos['status'], $infos);
- ProcessOrder::AddProcess($this->post['token'], [
- "order_type" => 'ZXD',
- "order_code" => $infos['infoNo'],//咨询单详情编号
- "order_id" => $infos['id'],
- "order_status" => $infos['status']
- ]);
- 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):[];
- //获取议价原因
- if ($info['result_info_id'] != 0) {
- $info['result_info'] = Db::name('result_info')->where(['result_code' => $info['result_info_id'], 'type' => 7, 'status' => 1, 'is_del' => 0])->value('result');
- } else {
- $info['result_info'] = '';
- }
- 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];
- }
- $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
- if($is_own==1){
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
- if($token==""){
- return error_show(101,'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'] : "";
- $where[]=['createrid',"=",$rm];
- }
- $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()->toArray();
- $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'];
- //reject驳回原因,status==5表示驳回
- $value['reject']=[];
- if ($value['status'] == 5) {
- $value['reject'] = Db::name('bargain_order')
- ->field('id,remark,status')
- ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
- ->whereIn('status', [5, 6])
- ->find();
- }
- $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不能为空");
- }
- $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
- if($is_own==1){
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
- if($token==""){
- return error_show(101,'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'] : "";
- $where[]=['createrid',"=",$rm];
- }
- $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)->order('addtime','desc')->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]);
- }
- }
|