Consult.php 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\facade\Db;
  5. class Consult extends Base
  6. {
  7. public $noble=[];
  8. public function __construct(App $app)
  9. {
  10. parent::__construct($app);
  11. $this->noble =\think\facade\Config::get("noble");
  12. }
  13. // public function list(){
  14. // $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  15. // $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  16. // $where=[['is_del',"=",0],["cat_id","<>",0]];
  17. // $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  18. // if ($zxNo !== "") {
  19. // $where[] = ['zxNo','=',$zxNo];
  20. // }
  21. // $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
  22. // if ($sequenceNo !== "") {
  23. // $where[] = ['sequenceNo','like',"%$sequenceNo%"];
  24. // }
  25. // $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  26. // if ($salesman !== "") {
  27. // //$where["salesman"] =Db::Raw("like '%$salesman%'");
  28. // $where[]= ["salesman",'like',"%$salesman%"];
  29. // }
  30. // $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  31. // if ($cpName !== "") {
  32. // //$where["cpName"]= Db::Raw("like '%$cpName%'");
  33. // $where[]= ["cpName",'like',"%$cpName%"];
  34. // }
  35. // $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  36. // if ($khNo !== "") {
  37. // // $where['khNo'] = $khNo;
  38. // $where[]= ["khNo",'like',"%$khNo%"];
  39. // }
  40. // $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  41. // if ($start !="") {
  42. // //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  43. // $where[]= ["zxtime",'>=',$start];
  44. // }
  45. // $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  46. // if($end !=""){
  47. // $where[]= ["zxtime",'<=',$end];
  48. // }
  49. // $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  50. // if ($status !== "") {
  51. // $where[]= ["status",'=',$status];
  52. // }
  53. // $count = Db::name('consult')->where($where)->count();
  54. // $total = ceil($count / $size);
  55. // $page = $page >= $total ? $total : $page;
  56. // $list = Db::name('consult')->where($where)->page($page,$size)
  57. // ->select();
  58. // $data=[];
  59. // foreach ($list as $value){
  60. // $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  61. // $data[]=$value;
  62. // }
  63. // return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  64. // }
  65. public function conlist(){
  66. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  67. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  68. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  69. $infoNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  70. if ($infoNo !== "") {
  71. $where[] = ['a.infoNo','=',$infoNo];
  72. }
  73. // $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
  74. // if ($sequenceNo !== "") {
  75. // $where[] = ['sequenceNo','like',"%$sequenceNo%"];
  76. // }
  77. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  78. if ($salesman !== "") {
  79. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  80. $where[]= ["b.salesman",'like',"%$salesman%"];
  81. }
  82. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  83. if ($cpName !== "") {
  84. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  85. $where[]= ["a.good_Name",'like',"%$cpName%"];
  86. }
  87. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  88. if ($khNo !== "") {
  89. // $where['khNo'] = $khNo;
  90. $where[]= ["b.khNo",'like',"%$khNo%"];
  91. }
  92. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
  93. if ($companyNo !== "") {
  94. // $where['khNo'] = $khNo;
  95. $where[]= ["b.companyNo",'like',"%$companyNo%"];
  96. }
  97. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  98. if ($start !="") {
  99. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  100. $where[]= ["a.addtime",'>=',$start];
  101. }
  102. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  103. if($end !=""){
  104. $where[]= ["a.addtime",'<=',$end];
  105. }
  106. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  107. if ($status !== "") {
  108. $where[]= ["a.status",'=',$status];
  109. }
  110. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  111. ->count();
  112. $total = ceil($count / $size);
  113. $page = $page >= $total ? $total : $page;
  114. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  115. ->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();
  116. $data=[];
  117. foreach ($list as $value){
  118. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  119. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  120. true):[];
  121. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  122. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  123. $value['khname']="";
  124. if($value['khNo']!==""){
  125. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  126. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  127. }
  128. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  129. $data[]=$value;
  130. }
  131. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  132. }
  133. public function info(){
  134. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  135. if($id==""){
  136. return error_show(1002,"咨询单编号不能为空");
  137. }
  138. $fo = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  139. $in= isset($fo['cat_id']) && $fo['cat_id'] !=0 ? made($fo['cat_id']):[];
  140. $fo['can']=$in;
  141. if(empty($fo)){
  142. return error_show(1002,"未找到咨询单编号");
  143. }else{
  144. return app_show(0,"获取成功",$fo);
  145. }
  146. }
  147. public function del(){
  148. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  149. $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  150. if($de==false){
  151. return error_show(1002,'咨询单信息未找到');
  152. }
  153. $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
  154. if($dell){
  155. return error_show(0,"删除成功");
  156. }else
  157. return error_show(1002,"删除失败");
  158. }
  159. public function create(){
  160. $is_project= isset($this->post['is_project']) && $this->post['is_project'] !=="" ? intval($this->post['is_project']) : "";
  161. if($is_project===""){
  162. return error_show(1002,"参数is_project不能为空");
  163. }
  164. if($is_project==1){
  165. $projectNo= isset($this->post['projectNo']) && $this->post['projectNo'] !=="" ? trim($this->post['projectNo']) : "";
  166. if($projectNo===""){
  167. return error_show(1002,"参数projectNo不能为空");
  168. }
  169. }
  170. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !=="" ? trim($this->post['khNo']) : "";
  171. if($khNo===""){
  172. return error_show(1002,"参数khNo不能为空");
  173. }
  174. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) : "";
  175. if($companyNo===""){
  176. return error_show(1002,"参数companyNo不能为空");
  177. }
  178. $endtime = isset($this->post['endtime']) && $this->post['endtime'] !=="" ? $this->post['endtime'] : "";
  179. if($endtime===""){
  180. return error_show(1002,"参数endtime不能为空");
  181. }
  182. // $saleid = isset($this->post['saleid']) && $this->post['saleid'] !=="" ? intval($this->post['saleid']) : "";
  183. // if($saleid===""){
  184. // return error_show(1002,"参数saleid不能为空");
  185. // }
  186. // $depart = isset($this->post['depart']) && $this->post['depart'] !=="" ? intval($this->post['depart']) : "";
  187. // if($depart===""){
  188. // return error_show(1002,"参数depart不能为空");
  189. // }
  190. $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) :
  191. "";
  192. if($platform_code===""){
  193. return error_show(1002,"参数platform_code不能为空");
  194. }
  195. $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder']) ? $this->post['ladder']:"";
  196. if($ladder==""){
  197. return error_show(1005,"参数ladder不能为空");
  198. }
  199. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  200. if($token==''){
  201. return error_show(105,"参数token不能为空");
  202. }
  203. $user =GetUserInfo($token);
  204. if(empty($user)||$user['code']!=0){
  205. return error_show(102,"用户数据不存在");
  206. }
  207. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  208. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  209. $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find();
  210. $zxNo=makeNo("ZX");
  211. $data=[
  212. "zxNo"=>$zxNo,
  213. "createrid"=>$createrid,
  214. "creater"=>$creater,
  215. "is_project"=>$is_project,
  216. "projectNo"=>isset($projectNo) ? $projectNo:"",
  217. "khNo"=>$khNo,
  218. "companyNo"=>$companyNo,
  219. "endtime"=>$endtime,
  220. "salesman"=>$creater,
  221. "platform_code"=>$platform_code,
  222. "saleid"=>$createrid,
  223. "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
  224. "status"=>0,
  225. "is_del"=>0,
  226. "addtime"=>date("Y-m-d H:i:s"),
  227. "updatetime"=>date("Y-m-d H:i:s"),
  228. ];
  229. $zx = Db::name("consult_order")->insert($data);
  230. if($zx){
  231. foreach ($ladder as $value){
  232. $infoNo=makeNo("INF");
  233. $specinfo=[];
  234. if(isset($value['specinfo']) &&!empty($value['specinfo'])){
  235. foreach ($value["specinfo"] as $v){
  236. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  237. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  238. $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
  239. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
  240. $specinfo[]=$v;
  241. }
  242. }
  243. $info=[
  244. "infoNo"=>$infoNo,
  245. "zxNo"=>$zxNo,
  246. "spuCode"=>"",
  247. "good_name"=>$value['good_name'],
  248. "good_img"=>$value['good_img'],
  249. "cat_id"=>$value['cat_id'],
  250. "unit"=>$value['unit'],
  251. "brand_id"=>$value['brand_id'],
  252. "arrival_time"=>$value['arrival_time'],
  253. "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
  254. "cost_desc"=>$value['cost_desc'],
  255. "is_addrs"=>$value['is_addrs'],
  256. "is_custom"=>$value['is_custom'],
  257. "metal_id"=>$value['metal_id'],
  258. "config"=>isset($value['config'])?$value['config']:"",
  259. "other_config"=>isset($value['other_config'])?$value['other_config']:"",
  260. "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
  261. "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
  262. "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
  263. "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
  264. "budget_price"=>$value['budget_price'],
  265. "num"=>$value['num'],
  266. "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
  267. "use_desc"=>$value['use_desc'],
  268. "remark"=>$value['remark'],
  269. "status"=>1,
  270. "is_del"=>0,
  271. "addtime"=>date("Y-m-d H:i:s"),
  272. "updatetime"=>date("Y-m-d H:i:s")
  273. ];
  274. $up = Db::name("consult_info")->insert($info);
  275. if(!$up){
  276. Db::rollback();
  277. return error_show(1004,'添加失败');
  278. }
  279. }
  280. return app_show(0,"新建成功",["zxNo"=>$zxNo]);
  281. }else{
  282. return error_show(1004,"新建失败");
  283. }
  284. }
  285. // public function zxadd(){
  286. // $good_name = isset($this->post['good_name'])&&$this->post['good_name']!==""?trim($this->post['good_name']):"";
  287. // if($good_name===""){
  288. // return error_show(1004,"参数good_name不能为空");
  289. // }
  290. // $zxNo = isset($this->post['zxNo'])&&$this->post['zxNo']!==""?trim($this->post['zxNo']):"";
  291. // if($zxNo===""){
  292. // return error_show(1004,"参数zxNo不能为空");
  293. // }
  294. //
  295. // $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):"";
  296. // if($cat_id===""){
  297. // return error_show(1004,"参数cat_id不能为空");
  298. // }
  299. // $arrival_time = isset($this->post['arrival_time'])&&$this->post['arrival_time']!==""?$this->post['arrival_time']
  300. // :"";
  301. // if($arrival_time===""){
  302. // return error_show(1004,"参数arrival_time不能为空");
  303. // }
  304. // $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""?trim($this->post['good_img']):"";
  305. // if($good_img===""){
  306. // return error_show(1004,"参数good_img不能为空");
  307. // }
  308. // $is_custom = isset($this->post['is_custom'])&&$this->post['is_custom']!==""?intval($this->post['is_custom']):"";
  309. // if($is_custom===""){
  310. // return error_show(1004,"参数is_custom不能为空");
  311. // }
  312. // $unit = isset($this->post['unit'])&&$this->post['unit']!==""?trim($this->post['unit']):"";
  313. // if($unit===""){
  314. // return error_show(1004,"参数unit不能为空");
  315. // }
  316. // $brand_id = isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"";
  317. // if($brand_id===""){
  318. // return error_show(1004,"参数brand_id不能为空");
  319. // }
  320. // $material = isset($this->post['material'])&&$this->post['material']!==""?trim($this->post['material']):"";
  321. // if($material===""){
  322. // return error_show(1004,"参数material不能为空");
  323. // }
  324. // $color = isset($this->post['color'])&&$this->post['color']!==""?trim($this->post['color']):"";
  325. // if($color===""){
  326. // return error_show(1004,"参数color不能为空");
  327. // }
  328. // $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!==""?trim($this->post['cost_desc']):"";
  329. // if($cost_desc===""){
  330. // return error_show(1004,"参数cost_desc不能为空");
  331. // }
  332. // $model = isset($this->post['model'])&&$this->post['model']!==""?trim($this->post['model']):"";
  333. // if($model===""){
  334. // return error_show(1004,"参数model不能为空");
  335. // }
  336. //
  337. // $is_addrs = isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  338. // if($is_addrs===""){
  339. // return error_show(1004,"参数is_addrs不能为空");
  340. // }
  341. //
  342. // $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!==""?trim($this->post['metal_id']):"";
  343. // if($metal_id===""){
  344. // return error_show(1004,"参数metal_id不能为空");
  345. // }
  346. // if($metal_id==0){
  347. // $config = isset($this->post['config'])&&!empty($this->post['config'])?$this->post['config']:"";
  348. // if($config===""){
  349. // return error_show(1004,"参数config不能为空");
  350. // }
  351. // $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""?trim($this->post['other_config'])
  352. // :"";
  353. // if($other_config===""){
  354. // return error_show(1004,"参数other_config不能为空");
  355. // }
  356. // $specs_weight = isset($this->post['specs_weight'])&&$this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  357. // if($specs_weight===""){
  358. // return error_show(1004,"参数specs_weight不能为空");
  359. // }
  360. // $gold_price = isset($this->post['gold_price'])&&$this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  361. // if($gold_price===""){
  362. // return error_show(1004,"参数gold_price不能为空");
  363. // }
  364. //
  365. // }
  366. // $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  367. // if($budget_price===""){
  368. // return error_show(1004,"参数budget_price不能为空");
  369. // }
  370. // $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
  371. // if($num===""){
  372. // return error_show(1004,"参数num不能为空");
  373. // }
  374. // $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!==""?trim($this->post['use_desc']):"";
  375. // if($use_desc===""){
  376. // return error_show(1004,"参数use_desc不能为空");
  377. // }
  378. // $remark = isset($this->post['remark'])&&$this->post['remark']!==""?trim($this->post['remark']):"";
  379. // if($remark===""){
  380. // return error_show(1004,"参数remark不能为空");
  381. // }
  382. //
  383. // Db::startTrans();
  384. // try{
  385. // $infoNo=makeNo("INF");
  386. // $info=[
  387. // "infoNo"=>$infoNo,
  388. // "zxNo"=>$zxNo,
  389. // "spuCode"=>"",
  390. // "good_name"=>$good_name,
  391. // "good_img"=>$good_img,
  392. // "cat_id"=>$cat_id,
  393. // "unit"=>$unit,
  394. // "brand_id"=>$brand_id,
  395. // "arrival_time"=>$arrival_time,
  396. // "model"=>$model,
  397. // "color"=>$color,
  398. // "material"=>$material,
  399. // "cost_desc"=>$cost_desc,
  400. // "is_addrs"=>$is_addrs,
  401. // "is_custom"=>$is_custom,
  402. // "metal_id"=>$metal_id,
  403. // "config"=>isset($config)?$config:"",
  404. // "other_config"=>isset($other_config)?$other_config:"",
  405. // "specs_weight"=>isset($specs_weight)?$specs_weight:0,
  406. // "gold_price"=>isset($gold_price)?$gold_price:0,
  407. // "budget_price"=>$budget_price,
  408. // "num"=>$num,
  409. // "use_desc"=>$use_desc,
  410. // "remark"=>$remark,
  411. // "status"=>0,
  412. // "is_del"=>0,
  413. // "addtime"=>date("Y-m-d H:i:s"),
  414. // "updatetime"=>date("Y-m-d H:i:s")
  415. // ];
  416. // $up = Db::name("consult_info")->insert($info);
  417. // if($up){
  418. // Db::commit();
  419. // return app_show(0,"添加成功",["infoNo"=>$infoNo]);
  420. // }else{
  421. // Db::rollback();
  422. // return error_show(1004,'添加失败');
  423. // }
  424. // }catch (\Exception $e){
  425. // Db::rollback();
  426. // return error_show(1004,$e->getMessage());
  427. // }
  428. // }
  429. public function zxinfo(){
  430. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  431. if($infoNo==""){
  432. return error_show(1004,"参数infoNo不能为空");
  433. }
  434. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  435. if($zxinfo==false){
  436. return error_show(1004,"未找到信息数据");
  437. }
  438. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  439. if($zxorder==false){
  440. return error_show(1004,"未找到咨询信息数据");
  441. }
  442. $cat =Db::name("cat")->where(["id"=>$zxinfo['cat_id']])->find();
  443. $budget = isset($cat['order_rate']) ? $cat['order_rate']:0;
  444. $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
  445. $zxinfo['khname']="";
  446. $zxinfo['original_price']=sprintf("%.2f",$zxinfo['budget_price']* (1 -$budget/100));
  447. $zxinfo['khNo']="";
  448. $zxinfo['brand_id']=$zxinfo['brand_id']==0 ?"":$zxinfo['brand_id'];
  449. $zxinfo['brand']="";
  450. $zxinfo['companyNo']=isset($zxorder['companyNo'])?$zxorder['companyNo']:"";
  451. $zxinfo['projectNo']=isset($zxorder['projectNo'])?$zxorder['projectNo']:"";
  452. $zxinfo['is_project']=isset($zxorder['is_project'])?$zxorder['is_project']:"";
  453. $zxinfo['company']="";
  454. $zxinfo['endtime']=isset($zxorder['endtime'])?$zxorder['endtime']:"";
  455. $zxinfo['platform_code'] =isset($zxorder['platform_code'])?$zxorder['platform_code']:"";
  456. $zxinfo['salesman'] =isset($zxorder['salesman'])?$zxorder['salesman']:"";
  457. $zxinfo['saleid'] =isset($zxorder['saleid'])?$zxorder['saleid']:"";
  458. $zxinfo['depart'] =isset($zxorder['depart'])?$zxorder['depart']:"";
  459. $zxinfo['project_name']="";
  460. $zxinfo['budget_total']="";
  461. $zxinfo['departinfo']=[];
  462. $zxinfo['unit_name']="";
  463. $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
  464. $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
  465. if($zxorder['khNo']!==""){
  466. $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
  467. $zxinfo['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  468. $zxinfo['khNo']= $zxorder['khNo'];
  469. }
  470. if($zxinfo['unit']!==""){
  471. $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find();
  472. $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:"";
  473. }
  474. if($zxinfo['brand_id']!==""){
  475. $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
  476. $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
  477. }
  478. if($zxorder['companyNo']!==""){
  479. $kh=Db::name("business")->where(['companyNo'=>$zxorder['companyNo']])->find();
  480. $zxinfo['company']= isset($kh['company'])?$kh['company']:"";
  481. }
  482. if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){
  483. $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find();
  484. $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:"";
  485. $zxinfo['budget_total']=isset($project['budget_total'])?$project['budget_total']:"";
  486. $zxinfo['project_use_desc']=isset($project['use_desc'])?$project['use_desc']:"";
  487. $projectinfo = Db::name("project_info")->where(["pgNo"=>$zxinfo['pgNo']])->find();
  488. $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo']:"";
  489. }
  490. if($zxorder['depart']>0){
  491. $zxinfo['departinfo']=GetPart($zxorder['depart']);
  492. }
  493. if($zxorder['platform_code']>0){
  494. $palt=Db::name("platform")->where(["id"=>$zxorder['platform_code']])->find();
  495. $zxinfo['platform_name']=isset($palt['platform_name'])?$palt['platform_name']:"";
  496. }
  497. return app_show(0,"获取成功",$zxinfo);
  498. }
  499. public function zxedit(){
  500. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  501. if($infoNo==""){
  502. return error_show(1004,"参数infoNo不能为空");
  503. }
  504. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  505. if($zxinfo==false){
  506. return error_show(1004,"未找到信息数据");
  507. }
  508. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
  509. if($good_name==""){
  510. return error_show(1003,"参数good_name不能为空");
  511. }
  512. $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
  513. if($good_img==""){
  514. return error_show(1003,"参数good_img不能为空");
  515. }
  516. $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
  517. if($cat_id==""){
  518. return error_show(1003,"参数cat_id不能为空");
  519. }
  520. $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
  521. if($unit==""){
  522. return error_show(1003,"参数unit不能为空");
  523. }
  524. $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
  525. $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
  526. if($arrival_time==""){
  527. return error_show(1003,"参数arrival_time不能为空");
  528. }
  529. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  530. if($specin==""){
  531. return error_show(1003,"参数specinfo不能为空");
  532. }
  533. // $color= isset($this->post['color'])&&$this->post['color']!=""?trim($this->post['color']):"";
  534. // if($color==""){
  535. // return error_show(1003,"参数color不能为空");
  536. // }
  537. // $material= isset($this->post['material'])&&$this->post['material']!=""?trim($this->post['material']):"";
  538. // if($material==""){
  539. // return error_show(1003,"参数material不能为空");
  540. // }
  541. $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
  542. if($cost_desc==""){
  543. return error_show(1003,"参数cost_desc不能为空");
  544. }
  545. $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  546. if($is_addrs===""){
  547. return error_show(1003,"参数is_addrs不能为空");
  548. }
  549. $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
  550. if($is_custom===""){
  551. return error_show(1003,"参数is_custom不能为空");
  552. }
  553. $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
  554. if($metal_id===""){
  555. return error_show(1003,"参数metal_id不能为空");
  556. }
  557. $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
  558. $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
  559. $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  560. $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  561. $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
  562. $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  563. $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
  564. $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
  565. if($num===""){
  566. return error_show(1003,"参数num不能为空");
  567. }
  568. if($budget_price===""){
  569. return error_show(1003,"参数budget_price不能为空");
  570. }
  571. $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
  572. $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
  573. if($use_desc==""){
  574. return error_show(1003,"参数use_desc不能为空");
  575. }
  576. $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
  577. if($remark==""){
  578. return error_show(1003,"参数remark不能为空");
  579. }
  580. if($metal_id!=0){
  581. if($config==""){
  582. return error_show(1003,"参数config不能为空");
  583. }
  584. if($other_config==""){
  585. return error_show(1003,"参数other_config不能为空");
  586. }
  587. if($specs_weight===""){
  588. return error_show(1003,"参数specs_weight不能为空");
  589. }
  590. if($gold_price===""){
  591. return error_show(1003,"参数gold_price不能为空");
  592. }
  593. }
  594. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  595. if($token==''){
  596. return error_show(102,"参数token不能为空");
  597. }
  598. $user =GetUserInfo($token);
  599. if(empty($user)||$user['code']!=0){
  600. return error_show(105,"用户数据不存在");
  601. }
  602. $specinfo=[];
  603. foreach ($specin as $v){
  604. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  605. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  606. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  607. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  608. $specinfo[]=$v;
  609. }
  610. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  611. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  612. $bidlist = Db::name("consult_bids")->where(["infoNo"=>$zxinfo['infoNo'],"is_del"=>0])->select();
  613. try{
  614. $innew =makeNo("INF");
  615. $info=[
  616. "infoNo"=>$innew,
  617. "zxNo"=>$zxinfo['zxNo'],
  618. "spuCode"=>"",
  619. "good_name"=>$good_name,
  620. "good_img"=>$good_img,
  621. "cat_id"=>$cat_id,
  622. "unit"=>$unit,
  623. "brand_id"=>$brand_id,
  624. "arrival_time"=>$arrival_time,
  625. "specinfo"=>json_encode($specinfo),
  626. // "color"=>$color,
  627. // "material"=>$material,
  628. "cost_desc"=>$cost_desc,
  629. "is_addrs"=>$is_addrs,
  630. "is_custom"=>$is_custom,
  631. "metal_id"=>$metal_id,
  632. "config"=>$config,
  633. "other_config"=>$other_config,
  634. "specs_weight"=>$specs_weight===""?0:$specs_weight,
  635. "gold_price"=>$gold_price===""? 0 : $gold_price,
  636. "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
  637. "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
  638. "budget_price"=>$budget_price,
  639. "num"=>$num,
  640. "pgNo"=>$pgNo,
  641. "use_desc"=>$use_desc,
  642. "remark"=>$remark,
  643. "status"=>1,
  644. "is_del"=>0,
  645. "addtime"=>date("Y-m-d H:i:s"),
  646. "updatetime"=>date("Y-m-d H:i:s")
  647. ];
  648. $up = Db::name("consult_info")->insert($info);
  649. if($up){
  650. if (!empty($bidlist)){
  651. foreach ($bidlist as $value){
  652. unset($value['id']);
  653. $value['infoNo']=$innew;
  654. $value['bidNo']=makeNo("BD");
  655. $value['spuCode']=makeNo("SPU");
  656. $value['status'] =0;
  657. $value['updatetime'] =date("Y-m-d H:i:s");
  658. $in = Db::name("consult_bids")->insert($value);
  659. if($in==false){
  660. Db::rollback();
  661. return error_show(1004,"反馈商品新建失败");
  662. }
  663. }
  664. }
  665. $zxinfo["bargain_status"] =1;
  666. $zxinfo["bargain_code"] =$innew;
  667. $zxinfo["updatetime"] =date("Y-m-d H:i:s");
  668. $bar=Db::name("consult_info")->save($zxinfo);
  669. if($bar==false){
  670. Db::rollback();
  671. return error_show(1004,"反馈商品更新失败");
  672. }
  673. Db::commit();
  674. return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
  675. }
  676. }catch (\Exception $e){
  677. Db::rollback();
  678. return error_show(1004,$e->getMessage());
  679. }
  680. }
  681. //** 发布竞标任务 */
  682. public function bargain(){
  683. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  684. if($infoNo==""){
  685. return error_show(1004,"参数infoNo不能为空");
  686. }
  687. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  688. if($zxinfo==false){
  689. return error_show(1004,"未找到信息数据");
  690. }
  691. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  692. if($status===""){
  693. return error_show(1004,"参数status不能为空");
  694. }
  695. if($status==1&&$zxinfo['status']>1){
  696. $zxinfo['bargain_num']=+1;
  697. }
  698. $zxinfo['status']=$status;
  699. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  700. $up = Db::name("consult_info")->save($zxinfo);
  701. if($up){
  702. return app_show(0,"状态更新成功");
  703. }else{
  704. return error_show(1003,"状态更新失败");
  705. }
  706. }
  707. public function feadback(){
  708. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  709. if($infoNo==""){
  710. return error_show(1002,"参数infoNo不能为空");
  711. }
  712. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  713. if($zxinfo==false){
  714. return error_show(1003,"未找到信息数据");
  715. }
  716. if($zxinfo['status']!=1){
  717. return error_show(1004,"任务未进行");
  718. }
  719. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  720. if($zx==false){
  721. return error_show(1003,"未找咨询信息数据");
  722. }
  723. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  724. if($pname==""){
  725. return error_show(1002,"参数pname不能为空");
  726. }
  727. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  728. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  729. if($cat_id==""){
  730. return error_show(1002,"参数cat_id不能为空");
  731. }
  732. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  733. if($specin==""){
  734. return error_show(1003,"参数specinfo不能为空");
  735. }
  736. $specinfo=[];
  737. foreach ($specin as $v){
  738. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  739. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  740. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  741. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  742. $specinfo[]=$v;
  743. }
  744. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  745. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  746. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  747. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  748. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  749. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  750. :"";
  751. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  752. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  753. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  754. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  755. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  756. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  757. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  758. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  759. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  760. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  761. $good_weight = isset($this->post['good_weight'])&&$this->post['good_weight']!==""? floatval($this->post['good_weight']):"";
  762. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"";
  763. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!==""? floatval($this->post['delivery_fee']):"";
  764. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"";
  765. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!==""? floatval
  766. ($this->post['pakge_fee']):"";
  767. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"";
  768. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"";
  769. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"";
  770. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"";
  771. if($nake_fee==="" ||$nake_fee==0 ){
  772. return error_show(1004,"参数nake_fee不能为空或零");
  773. }
  774. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  775. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  776. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  777. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  778. if($token==''){
  779. return error_show(1002,"参数token不能为空");
  780. }
  781. $user =GetUserInfo($token);
  782. if(empty($user)||$user['code']!=0){
  783. return error_show(1005,"用户数据不存在");
  784. }
  785. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  786. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  787. $bidNo=makeNo("BD");
  788. $spucode=makeNo("SPU");
  789. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  790. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  791. if($is_gold_price==1){
  792. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  793. ->find();
  794. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  795. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  796. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  797. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  798. }else{
  799. $saleprice = $open_fee/$zxinfo['num'] +
  800. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  801. $total_fee = $open_fee/$zxinfo['num'] +
  802. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  803. }
  804. $data=[
  805. "bidNo"=>$bidNo,
  806. "infoNo"=>$infoNo,
  807. "zxNo"=>$zxinfo['zxNo'],
  808. "spuCode"=>$spucode,
  809. "good_name"=>$pname,
  810. "brand_id"=>$brandid,
  811. "cat_id"=>$cat_id,
  812. "specinfo"=>json_encode($specinfo),
  813. "unit_id"=>$unit_id,
  814. "cost_desc"=>$cost_desc,
  815. "work_day"=>$work_day,
  816. "delivery_day"=>$delivery_day,
  817. "good_img"=>$good_img,
  818. "expire_day"=>$expire_day,
  819. "origin_place"=>$origin_place,
  820. "supplierNo"=>$supplierNo,
  821. "pay_way"=>$pay_way,
  822. "tax"=>$tax,
  823. "send_way"=>$send_way,
  824. "metal_id"=>$metal_id,
  825. "is_gold_price"=>$is_gold_price,
  826. "config"=>$config,
  827. "other_config"=>$other_config,
  828. "weight"=>$weight,
  829. "good_weight"=>$good_weight,
  830. "is_diff"=>$is_diff,
  831. "demo_fee"=>$demo_fee,
  832. "delivery_fee"=>$delivery_fee,
  833. "open_fee"=>$open_fee,
  834. "pakge_fee"=>$pakge_fee,
  835. "nake_fee"=>$nake_fee,
  836. "mark_fee"=>$mark_fee,
  837. "cert_fee"=>$cert_fee,
  838. "cost_fee"=>$cost_fee,
  839. "total_fee"=>$total_fee,
  840. "supply_area"=>$supply_area,
  841. "remark"=>$remark,
  842. "sale_price"=>$saleprice,
  843. "origin_price"=>$saleprice,
  844. "createrid"=>$createrid,
  845. "creater"=>$creater,
  846. "status"=>$zxinfo['status']==1 ?1 :2,
  847. "is_del"=>0,
  848. "addtime"=>date("Y-m-d H:i:s"),
  849. "updatetime"=>date("Y-m-d H:i:s")
  850. ];
  851. Db::startTrans();
  852. try{
  853. $insert= Db::name("consult_bids")->insert($data);
  854. if($insert){
  855. // $data=[
  856. // "spuCode"=>$spucode,
  857. // "good_name"=>$pname,
  858. // "brand_id"=>$brandid,
  859. // "good_unit"=>$unit_id,
  860. // "good_type"=>0,
  861. // "moq"=>1,
  862. // "customized"=>$work_day,
  863. // "tax"=>$tax,
  864. // "supplierNo"=>$supplierNo,
  865. // "is_auth"=>0,
  866. // "craft_desc"=>$cost_desc,
  867. // "good_remark"=>$remark,
  868. // "good_img"=>$good_img,
  869. // "good_thumb_img"=>"",
  870. // "good_info_img"=>"",
  871. // "status"=>1,
  872. // "is_del"=>0,
  873. // "createrid"=>$createrid,
  874. // "creater"=>$creater,
  875. // "addtime"=>date("Y-m-d H:i:s"),
  876. // "updatetime"=>date("Y-m-d H:i:s")
  877. // ];
  878. // $good = Db::name("good_zixun")->insert($data);
  879. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  880. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  881. if($projectinfo==false){
  882. Db::rollback();
  883. return error_show(1006,"未找到项目信息");
  884. }
  885. $temp=[];
  886. $temp['spuCode']=$spucode;
  887. $temp['skuCode']="";
  888. $temp['pgNo']=$zxinfo['pgNo'];
  889. $temp['projectNo']=$zx['projectNo'];
  890. $temp['good_name']=$pname;
  891. $temp['good_type']=$projectinfo['good_type'];
  892. $temp['data_source']=2;
  893. $temp['cat_id']=$cat_id;
  894. $temp['budget_price']=$projectinfo['budget_price'];
  895. $temp['sale_price']=$saleprice;
  896. $temp['origin_price']=$total_fee;
  897. $temp['num']=$zxinfo['num'];
  898. $temp['status']=0;
  899. $temp['is_del']=0;
  900. $temp['creater']=$creater;
  901. $temp['createrid']=$createrid;
  902. $temp['addtime']=date("Y-m-d H:i:s");
  903. $temp['updatetime']=date("Y-m-d H:i:s");
  904. $nu = Db::name("project_feedback")->insert($temp);
  905. if($nu==false){
  906. Db::rollback();
  907. return error_show(1006,"项目反馈失败");
  908. }else{
  909. $projectinfo['status']=2;
  910. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  911. $up = Db::name("project_info")->save($projectinfo);
  912. if($up){
  913. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  914. ->count();
  915. if($count==0){
  916. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  917. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  918. if($proc==false){
  919. Db::rollback();
  920. return error_show(1006,"项目反馈失败");
  921. }
  922. }
  923. }
  924. }
  925. }
  926. Db::commit();
  927. return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
  928. }else{
  929. Db::rollback();
  930. return error_show(1006,"反馈失败");
  931. }
  932. }catch (\Exception $e){
  933. Db::rollback();
  934. return error_show(1006,$e->getMessage());
  935. }
  936. }
  937. public function feadinfo(){
  938. $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  939. if($bidNo==""){
  940. return error_show(1004,"参数bidNo不能为空");
  941. }
  942. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  943. if($info==false){
  944. return error_show(1004,"未找到商品数据");
  945. }
  946. $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
  947. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  948. $info['cat_info'] = made($info['cat_id'],[]);
  949. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  950. $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  951. if($info['brand_id']!=0){
  952. $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
  953. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  954. }else{
  955. $info["brand_name"]="";
  956. $info["brand_id"]="";
  957. }
  958. $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
  959. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  960. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  961. $god=[
  962. "metal_id"=>$info['metal_id'],
  963. "weight"=>$info["weight"],
  964. "demo_fee"=>$info["demo_fee"],
  965. "delivery_fee"=>$info["delivery_fee"],
  966. "open_fee"=>$info["open_fee"],
  967. "packing_fee"=>$info["pakge_fee"],
  968. "mark_fee"=>$info["mark_fee"],
  969. "nake_fee"=>$info["nake_fee"],
  970. "cert_fee"=>$info["cert_fee"],
  971. "cost_fee"=>$info["cost_fee"],
  972. "num"=>$bidinfo["num"],
  973. ];
  974. if($info['is_gold_price']==1){
  975. $price = GoldPrice($god, $budget/100);
  976. $info['sale_price'] =round($price,2);
  977. }
  978. $info['specinfo'] = json_decode($info['specinfo'],true);
  979. $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
  980. $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
  981. $info['bargain'] =$bargain;
  982. return app_show(0,"获取成功",$info);
  983. }
  984. public function feededit(){
  985. $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  986. if($bidNo==""){
  987. return error_show(1002,"参数bidNo不能为空");
  988. }
  989. $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
  990. if($bidinfo==false){
  991. return error_show(1003,"未找到信息数据");
  992. }
  993. if($bidinfo['status']>=5){
  994. return error_show(1004,"咨询单已确认无法修改");
  995. }
  996. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
  997. if($zxinfo==false){
  998. return error_show(1003,"未找到信息数据");
  999. }
  1000. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  1001. if($zx==false){
  1002. return error_show(1003,"未找咨询信息数据");
  1003. }
  1004. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  1005. if($pname==""){
  1006. return error_show(1002,"参数pname不能为空");
  1007. }
  1008. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  1009. // if($brandid==""){
  1010. // return error_show(1002,"参数brandid不能为空");
  1011. // }
  1012. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  1013. if($cat_id==""){
  1014. return error_show(1002,"参数cat_id不能为空");
  1015. }
  1016. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  1017. if($specin==""){
  1018. return error_show(1003,"参数specinfo不能为空");
  1019. }
  1020. $specinfo=[];
  1021. foreach ($specin as $v){
  1022. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  1023. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  1024. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  1025. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  1026. $specinfo[]=$v;
  1027. }
  1028. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  1029. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  1030. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  1031. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  1032. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  1033. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  1034. :"";
  1035. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  1036. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  1037. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  1038. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  1039. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  1040. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  1041. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  1042. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  1043. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  1044. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  1045. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  1046. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  1047. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  1048. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  1049. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"";
  1050. if($nake_fee==="" ||$nake_fee==0 ){
  1051. return error_show(1004,"参数nake_fee不能为空或零");
  1052. }
  1053. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  1054. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  1055. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  1056. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  1057. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  1058. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  1059. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  1060. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  1061. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  1062. if($is_gold_price==1){
  1063. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  1064. ->find();
  1065. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  1066. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1067. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  1068. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1069. }else{
  1070. $saleprice = $open_fee/$zxinfo['num'] +
  1071. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  1072. $total_fee = $open_fee/$zxinfo['num'] +
  1073. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1074. }
  1075. Db::startTrans();
  1076. try{
  1077. $data=[
  1078. "good_name"=>$pname,
  1079. "brand_id"=>$brandid,
  1080. "cat_id"=>$cat_id,
  1081. "specinfo"=>json_encode($specinfo),
  1082. // "material"=>$material,
  1083. "unit_id"=>$unit_id,
  1084. "cost_desc"=>$cost_desc,
  1085. "work_day"=>$work_day,
  1086. "delivery_day"=>$delivery_day,
  1087. "good_img"=>$good_img,
  1088. "expire_day"=>$expire_day,
  1089. "origin_place"=>$origin_place,
  1090. "supplierNo"=>$supplierNo,
  1091. "pay_way"=>$pay_way,
  1092. "tax"=>$tax,
  1093. "send_way"=>$send_way,
  1094. "metal_id"=>$metal_id,
  1095. "is_gold_price"=>$is_gold_price,
  1096. "config"=>$config,
  1097. "other_config"=>$other_config,
  1098. "weight"=>$weight,
  1099. "is_diff"=>$is_diff,
  1100. "demo_fee"=>$demo_fee,
  1101. "delivery_fee"=>$delivery_fee,
  1102. "open_fee"=>$open_fee,
  1103. "pakge_fee"=>$pakge_fee,
  1104. "nake_fee"=>$nake_fee,
  1105. "mark_fee"=>$mark_fee,
  1106. "cert_fee"=>$cert_fee,
  1107. "cost_fee"=>$cost_fee,
  1108. "total_fee"=>$total_fee,
  1109. "sale_price"=>$saleprice,
  1110. "supply_area"=>$supply_area,
  1111. "remark"=>$remark,
  1112. "updatetime"=>date("Y-m-d H:i:s")
  1113. ];
  1114. $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
  1115. if($insert){
  1116. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  1117. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  1118. if($projectinfo==false){
  1119. Db::rollback();
  1120. return error_show(1006,"未找到项目信息");
  1121. }
  1122. $feed = Db::name("project_feedback")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"spuCode"=>$bidinfo['spuCode'],"is_del"=>0])->find();
  1123. if($feed==false){
  1124. Db::rollback();
  1125. return error_show(1006,"未找到项目反馈信息");
  1126. }
  1127. $feed['good_name']=$pname;
  1128. $feed['good_type']=$projectinfo['good_type'];
  1129. $feed['cat_id']=$cat_id;
  1130. $feed['sale_price']=$saleprice;
  1131. $feed['origin_price']=$total_fee;
  1132. $temp['updatetime']=date("Y-m-d H:i:s");
  1133. $nu = Db::name("project_feedback")->save($feed);
  1134. if($nu==false){
  1135. Db::rollback();
  1136. return error_show(1006,"项目反馈失败");
  1137. }else{
  1138. $projectinfo['status']=2;
  1139. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  1140. $up = Db::name("project_info")->save($projectinfo);
  1141. if($up){
  1142. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  1143. ->count();
  1144. if($count==0){
  1145. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  1146. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  1147. if($proc==false){
  1148. Db::rollback();
  1149. return error_show(1006,"项目反馈失败");
  1150. }
  1151. }
  1152. }
  1153. }
  1154. }
  1155. Db::commit();
  1156. return app_show(0,"编辑成功");
  1157. }else{
  1158. Db::rollback();
  1159. return error_show(1004,"编辑失败");
  1160. }
  1161. }catch (\Exception $e){
  1162. Db::rollback();
  1163. return error_show(1004,$e->getMessage());
  1164. }
  1165. }
  1166. public function bargain_add(){
  1167. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1168. if($bidNo===""){
  1169. return error_show(1004,"参数bidNo不能为空");
  1170. }
  1171. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1172. if($info==false){
  1173. return error_show(1004,"未找到商品数据");
  1174. }
  1175. $bargain_price = isset($this->post['bargain_price'])&& $this->post['bargain_price']!=""?floatval($this->post['bargain_price']):"";
  1176. if($bargain_price===""){
  1177. return error_show(1004,"参数bargain_price不能为空");
  1178. }
  1179. $bargain_reason = isset($this->post['bargain_reason'])&& $this->post['bargain_reason']!=""?trim($this->post['bargain_reason']):"";
  1180. // if($bargain_reason===""){
  1181. // return error_show(1004,"参数bargain_reason不能为空");
  1182. // }
  1183. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1184. if($infos==false){
  1185. return error_show(1004,"未找到商品数据");
  1186. }
  1187. if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
  1188. return error_show(1004,"咨询单招标未结束或已确认商品");
  1189. }
  1190. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1191. if($token==''){
  1192. return error_show(105,"参数token不能为空");
  1193. }
  1194. $user =GetUserInfo($token);
  1195. if(empty($user)||$user['code']!=0){
  1196. return error_show(1002,"用户数据不存在");
  1197. }
  1198. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1199. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1200. $bargainNo =makeNo("BA");
  1201. Db::startTrans();//::todo 金价 毛利计算
  1202. try{
  1203. $data=[
  1204. "bidsNo"=>$bidNo,
  1205. "infoNo"=>$info['infoNo'],
  1206. "zxNo"=>$info['zxNo'],
  1207. "bargainNo"=>$bargainNo,
  1208. "bargain_type"=>1,
  1209. "bargain_reason"=>$bargain_reason,
  1210. "sale_price"=>$info['sale_price'],
  1211. "cost_before_price"=>$info['cost_fee'],
  1212. "cost_after_price"=>$info['cost_fee'],
  1213. "before_rate"=>$info['cost_fee'],
  1214. "after_rate"=>$info['cost_fee'],
  1215. "after_price"=>$bargain_price,
  1216. "exam_info"=>"",
  1217. "status"=>1,
  1218. "is_del"=>0,
  1219. "creater"=>$creater,
  1220. "createrid"=>$createrid,
  1221. "addtime"=>date("Y-m-d H:i:s"),
  1222. "updatetime"=>date("Y-m-d H:i:s")
  1223. ];
  1224. $int = Db::name("bargain_order")->insert($data);
  1225. if($int){
  1226. $info['status']=3;
  1227. $info['updatetime']=date("Y-m-d H:i:s");
  1228. $up =Db::name("consult_bids")->save($info);
  1229. if($up){
  1230. $infos['status']=3;
  1231. $infos['updatetime']=date("Y-m-d H:i:s");
  1232. $ups =Db::name("consult_info")->save($infos);
  1233. if($ups){
  1234. Db::commit();
  1235. return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]);
  1236. }
  1237. }
  1238. }
  1239. Db::rollback();
  1240. return error_show(1004,"议价单新建失败");
  1241. }catch (\Exception $e){
  1242. Db::rollback();
  1243. return error_show(1004,$e->getMessage());
  1244. }
  1245. }
  1246. public function bids_check(){
  1247. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1248. if($bidNo===""){
  1249. return error_show(1004,"参数bidNo不能为空");
  1250. }
  1251. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1252. if($info==false){
  1253. return error_show(1004,"未找到商品数据");
  1254. }
  1255. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1256. if($infos==false){
  1257. return error_show(1004,"未找到商品数据");
  1258. }
  1259. if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
  1260. return error_show(1004,"咨询单招标未结束或已确认商品");
  1261. }
  1262. Db::startTrans();
  1263. try {
  1264. $info['status']=6;
  1265. $info['updatetime']=date("Y-m-d H:i:s");
  1266. $bids = Db::name("consult_bids")->save($info);
  1267. if($bids){
  1268. $infos['status']=4;
  1269. $infos['updatetime']=date("Y-m-d H:i:s");
  1270. $se = Db::name("consult_info")->save($infos);
  1271. if($se){
  1272. Db::commit();
  1273. return app_show(0,"商品确定成功");
  1274. }
  1275. }
  1276. Db::rollback();
  1277. return error_show(1004,"商品确认失败");
  1278. }catch (\Exception $e){
  1279. Db::rollback();
  1280. return error_show(1004,$e->getMessage());
  1281. }
  1282. }
  1283. public function bargain_status(){
  1284. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1285. if($bargainNo===""){
  1286. return error_show(1004,"参数bargainNo不能为空");
  1287. }
  1288. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1289. if($info==false){
  1290. return error_show(1004,"未找到议价数据");
  1291. }
  1292. $bids=Db::name("consult_bids")->where(["bidNo"=>$info["bidsNo"],"is_del"=>0])->find();
  1293. if($bids==false){
  1294. return error_show(1004,"未找到商品数据");
  1295. }
  1296. $coninfo=Db::name("consult_info")->where(["infoNo"=>$bids["infoNo"],"is_del"=>0])->find();
  1297. if($coninfo==false){
  1298. return error_show(1004,"未找到咨询单数据");
  1299. }
  1300. $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):"";
  1301. if($status==''){
  1302. return error_show(1005,"参数status不能为空");
  1303. }
  1304. $remark = isset($this->post['remark'])&& $this->post['remark']!=""?trim($this->post['remark']):"";
  1305. // if($remark==""){
  1306. // return error_show(1004,"参数remark不能为空");
  1307. // }
  1308. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1309. if($token==''){
  1310. return error_show(105,"参数token不能为空");
  1311. }
  1312. $user =GetUserInfo($token);
  1313. if(empty($user)||$user['code']!=0){
  1314. return error_show(1002,"用户数据不存在");
  1315. }
  1316. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1317. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1318. Db::startTrans();
  1319. try{
  1320. $examinfo = isset($info['exam_info'])&&$info['exam_info']!="" ? json_decode($info['exam_info'],true):[];
  1321. $examinfo[]=["status"=>$status,"remark"=>$remark,"createrid"=>$createrid,"creater"=>$creater];
  1322. $info['status'] =$status;
  1323. $info['remark'] =$remark;
  1324. $info['exam_info']=json_encode($examinfo) ;
  1325. $info['updatetime'] =date("Y-m-d H:i:s");
  1326. $up =Db::name("bargain_order")->save($info);
  1327. if($up){
  1328. if($status==4||$status==5||$status==6||$status==7){
  1329. $bids['status']=5;
  1330. if($status==4){
  1331. $bids['sale_price']=$info['after_price'];
  1332. }
  1333. $bids['updatetime']=date("Y-m-d H:i:s");
  1334. $up =Db::name("consult_bids")->save($bids);
  1335. if($up==false){
  1336. Db::rollback();
  1337. return error_show(1004,"数据更新失败");
  1338. }
  1339. }
  1340. Db::commit();
  1341. return app_show(0,"更新成功");
  1342. }
  1343. }catch (\Exception $e){
  1344. Db::rollback();
  1345. return error_show(1004,$e->getMessage());
  1346. }
  1347. }
  1348. public function bargain_info(){
  1349. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1350. if($bargainNo===""){
  1351. return error_show(1004,"参数bargainNo不能为空");
  1352. }
  1353. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1354. if($info==false){
  1355. return error_show(1004,"未找到议价数据");
  1356. }
  1357. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$info['bidsNo']],["is_del","=",0]])->find();
  1358. if($bidinfos==false){
  1359. return error_show(1004,"未找到商品数据");
  1360. }
  1361. $consultinfos = Db::name("consult_info")->where([["infoNo","=",$bidinfos['infoNo']],["is_del","=",0]])
  1362. ->find();
  1363. if($consultinfos==false){
  1364. return error_show(1004,"未找到咨询商品数据");
  1365. }
  1366. $info['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1367. $info['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1368. $info['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1369. $info['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1370. $info['good_num'] = isset($consultinfos['num'])?$consultinfos['num']:"";
  1371. $info['exam_info'] = isset($info['exam_info'])&&$info['exam_info']!=""?json_encode($info['exam_info']):"";
  1372. if($bidinfos['brand_id']!=0){
  1373. $info['brand_id'] = $bidinfos['brand_id'];
  1374. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1375. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1376. }else{
  1377. $info["brand_name"]="";
  1378. $info["brand_id"]="";
  1379. }
  1380. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1381. $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1382. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1383. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1384. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  1385. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1386. $info['budget'] =$budget;
  1387. $god=[
  1388. "metal_id"=>$bidinfos['metal_id'],
  1389. "weight"=>$bidinfos["weight"],
  1390. "demo_fee"=>$bidinfos["demo_fee"],
  1391. "delivery_fee"=>$bidinfos["delivery_fee"],
  1392. "open_fee"=>$bidinfos["open_fee"],
  1393. "packing_fee"=>$bidinfos["pakge_fee"],
  1394. "mark_fee"=>$bidinfos["mark_fee"],
  1395. "nake_fee"=>$bidinfos["nake_fee"],
  1396. "cert_fee"=>$bidinfos["cert_fee"],
  1397. "cost_fee"=>$bidinfos["cost_fee"],
  1398. "num"=>$bidinfoe["num"],
  1399. ];
  1400. $info['gold_price']=0;
  1401. if($bidinfos['is_gold_price']==1 &&$bidinfos['metal_id']>0){
  1402. $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
  1403. ->find();
  1404. $info['gold_price'] =$gold['price'];
  1405. }
  1406. $info['cost_desc'] =$bidinfos['cost_desc'];
  1407. $info['work_day'] =$bidinfos['work_day'];
  1408. $info['delivery_day'] =$bidinfos['delivery_day'];
  1409. $info['expire_day'] =$bidinfos['expire_day'];
  1410. $info['origin_place'] =$bidinfos['origin_place'];
  1411. $info['origin_addr'] ="";
  1412. if($bidinfos['origin_place']!=''){
  1413. $code = explode(",",$bidinfos['origin_place']);
  1414. $temp=[];
  1415. $temp['provice_code']=isset($code[0])?$code[0]:"";
  1416. $temp['city_code']=isset($code[1])?$code[1]:"";
  1417. $temp['area_code']=isset($code[2])?$code[2]:"";
  1418. $addr= GetAddr(json_encode($temp));
  1419. $info['origin_addr'] = $addr;
  1420. }
  1421. $info['supplierNo'] =$bidinfos['supplierNo'];
  1422. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  1423. $info['supplier_name'] = isset($supplier['name'])?$supplier['name']:"";
  1424. $info['pay_way'] =$bidinfos['pay_way'];
  1425. $info['tax'] =$bidinfos['tax'];
  1426. $info['send_way'] =$bidinfos['send_way'];
  1427. $info['metal_id'] =$bidinfos['metal_id'];
  1428. $info['is_gold_price'] =$bidinfos['is_gold_price'];
  1429. $info['config'] =$bidinfos['config'];
  1430. $info['other_config'] =$bidinfos['other_config'];
  1431. $info['weight'] =$bidinfos['weight'];
  1432. $info['is_diff'] =$bidinfos['is_diff'];
  1433. $info['demo_fee'] =$bidinfos['demo_fee'];
  1434. $info['delivery_fee'] =$bidinfos['delivery_fee'];
  1435. $info['open_fee'] =$bidinfos['open_fee'];
  1436. $info['pakge_fee'] =$bidinfos['pakge_fee'];
  1437. $info['nake_fee'] =$bidinfos['nake_fee'];
  1438. $info['mark_fee'] =$bidinfos['mark_fee'];
  1439. $info['cert_fee'] =$bidinfos['cert_fee'];
  1440. $info['cost_fee'] =$bidinfos['cost_fee'];
  1441. $info['total_fee'] =$bidinfos['total_fee'];
  1442. $info['supply_area'] =$bidinfos['supply_area'];
  1443. $info['remark'] =$bidinfos['remark'];
  1444. $info['is_addrs'] =$consultinfos['is_addrs'];
  1445. $info['is_custom'] =$consultinfos['is_custom'];
  1446. $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1447. $info['sale_price'] =round($bidinfos['sale_price'],2);
  1448. $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1449. return app_show(0,"获取成功",$info);
  1450. }
  1451. public function bidlist(){
  1452. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1453. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1454. $where=[['is_del',"=",0]];
  1455. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1456. if ($zxNo !== "") {
  1457. $where[] = ['zxNo','=',$zxNo];
  1458. }
  1459. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1460. if ($infoNo !== "") {
  1461. $where[] = ['infoNo','=',$infoNo];
  1462. }
  1463. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1464. if ($bidNo !== "") {
  1465. $where[] = ['bidNo','=',$bidNo];
  1466. }
  1467. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1468. if ($pgNo !== "") {
  1469. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1470. $where[] = ['infoNo','in',$bidinfo];
  1471. }
  1472. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  1473. if ($bargain_status !== "") {
  1474. $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
  1475. $where[] = ['infoNo','in',$bidinfo];
  1476. }
  1477. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1478. if ($projectNo !== "") {
  1479. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1480. ("zxNo");
  1481. $where[] = ['zxNo','in',$zxlist];
  1482. }
  1483. $count = Db::name('consult_bids')->where($where)->count();
  1484. $total = ceil($count / $size);
  1485. $page = $page >= $total ? $total : $page;
  1486. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select();
  1487. $data=[];
  1488. foreach ($list as $value){
  1489. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1490. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1491. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1492. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1493. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1494. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1495. if($value['brand_id']!=0){
  1496. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1497. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1498. }else{
  1499. $value["brand_name"]="";
  1500. $value["brand_id"]="";
  1501. }
  1502. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1503. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1504. $god=[
  1505. "metal_id"=>$value['metal_id'],
  1506. "weight"=>$value["weight"],
  1507. "demo_fee"=>$value["demo_fee"],
  1508. "delivery_fee"=>$value["delivery_fee"],
  1509. "open_fee"=>$value["open_fee"],
  1510. "packing_fee"=>$value["pakge_fee"],
  1511. "mark_fee"=>$value["mark_fee"],
  1512. "nake_fee"=>$value["nake_fee"],
  1513. "cert_fee"=>$value["cert_fee"],
  1514. "cost_fee"=>$value["cost_fee"],
  1515. "num"=>$bidinfo["num"],
  1516. ];
  1517. if($value['is_gold_price']==1){
  1518. $price = GoldPrice($god, $budget/100);
  1519. $value['sale_price'] = round($price,2);
  1520. }
  1521. $value['specinfo'] = json_decode($value['specinfo'],true);
  1522. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1523. $value['bargain_status']=$bidinfo['bargain_status'];
  1524. $data[]=$value;
  1525. }
  1526. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1527. }
  1528. public function feedlist(){
  1529. $where=[['is_del',"=",0]];
  1530. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1531. if ($zxNo !== "") {
  1532. $where[] = ['zxNo','=',$zxNo];
  1533. }
  1534. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1535. if ($infoNo !== "") {
  1536. $where[] = ['infoNo','=',$infoNo];
  1537. }
  1538. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1539. if ($bidNo !== "") {
  1540. $where[] = ['bidNo','=',$bidNo];
  1541. }
  1542. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1543. if ($projectNo !== "") {
  1544. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1545. ("zxNo");
  1546. $where[] = ['zxNo','in',$zxlist];
  1547. }
  1548. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1549. if($token==''){
  1550. return error_show(102,"参数token不能为空");
  1551. }
  1552. $user =GetUserInfo($token);
  1553. if(empty($user)||$user['code']!=0){
  1554. return error_show(105,"用户数据不存在");
  1555. }
  1556. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1557. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1558. $where[] = ["createrid","=",$createrid];
  1559. $list =Db::name('consult_bids')->where($where)->select();
  1560. $data=[];
  1561. foreach ($list as $value){
  1562. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1563. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1564. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1565. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1566. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1567. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1568. if($value['brand_id']!=0){
  1569. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1570. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1571. }else{
  1572. $value["brand_name"]="";
  1573. $value["brand_id"]="";
  1574. }
  1575. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1576. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1577. $god=[
  1578. "metal_id"=>$value['metal_id'],
  1579. "weight"=>$value["weight"],
  1580. "demo_fee"=>$value["demo_fee"],
  1581. "delivery_fee"=>$value["delivery_fee"],
  1582. "open_fee"=>$value["open_fee"],
  1583. "packing_fee"=>$value["pakge_fee"],
  1584. "mark_fee"=>$value["mark_fee"],
  1585. "nake_fee"=>$value["nake_fee"],
  1586. "cert_fee"=>$value["cert_fee"],
  1587. "cost_fee"=>$value["cost_fee"],
  1588. "num"=>$bidinfo["num"],
  1589. ];
  1590. if($value['is_gold_price']==1){
  1591. $price = GoldPrice($god, $budget/100);
  1592. $value['sale_price'] =round($price,2);
  1593. }
  1594. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1595. $value['specinfo'] = json_decode($value['specinfo'],true);
  1596. $value['bargain_status']=$bidinfo['bargain_status'];
  1597. $data[]=$value;
  1598. }
  1599. return app_show(0,"获取成功",$data);
  1600. }
  1601. public function bragain_list(){
  1602. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1603. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1604. $where=[['is_del',"=",0]];
  1605. $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
  1606. if($bidsNo!=""){
  1607. $where[]=["bidsNo","=",$bidsNo];
  1608. }
  1609. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1610. if ($zxNo !== "") {
  1611. $where[] = ['zxNo','=',$zxNo];
  1612. }
  1613. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1614. if ($infoNo !== "") {
  1615. $where[] = ['infoNo','=',$infoNo];
  1616. }
  1617. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1618. if ($projectNo !== "") {
  1619. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1620. ("zxNo");
  1621. $where[] = ['zxNo','in',$zxlist];
  1622. }
  1623. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1624. if ($pgNo !== "") {
  1625. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1626. $where[] = ['infoNo','in',$bidinfo];
  1627. }
  1628. $count=Db::name("bargain_order")->where($where)->count();
  1629. $total = ceil($count / $size);
  1630. $page = $page >= $total ? $total : $page;
  1631. $list =Db::name('bargain_order')->where($where)->page($page,$size)->select();
  1632. $data=[];
  1633. foreach ($list as $value){
  1634. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
  1635. $value['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1636. $value['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1637. $value['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1638. $value['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1639. if($bidinfos['brand_id']!=0){
  1640. $value['brand_id'] = $bidinfos['brand_id'];
  1641. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1642. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1643. }else{
  1644. $value["brand_name"]="";
  1645. $value["brand_id"]="";
  1646. }
  1647. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1648. $value['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1649. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1650. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1651. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1652. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1653. $value['budget'] =$budget;
  1654. $god=[
  1655. "metal_id"=>$bidinfos['metal_id'],
  1656. "weight"=>$bidinfos["weight"],
  1657. "demo_fee"=>$bidinfos["demo_fee"],
  1658. "delivery_fee"=>$bidinfos["delivery_fee"],
  1659. "open_fee"=>$bidinfos["open_fee"],
  1660. "packing_fee"=>$bidinfos["pakge_fee"],
  1661. "mark_fee"=>$bidinfos["mark_fee"],
  1662. "nake_fee"=>$bidinfos["nake_fee"],
  1663. "cert_fee"=>$bidinfos["cert_fee"],
  1664. "cost_fee"=>$bidinfos["cost_fee"],
  1665. "num"=>$bidinfoe["num"],
  1666. ];
  1667. // if($bidinfos['is_gold_price']==1){
  1668. // $price = GoldPrice($god, $budget/100);
  1669. // }else{
  1670. // $price = GoodPrice($god, $budget/100);
  1671. // }
  1672. $value['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1673. $value['sale_price'] =round($bidinfos['sale_price'],2);
  1674. $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1675. $data[]=$value;
  1676. }
  1677. return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
  1678. }
  1679. public function crontablist(){
  1680. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1681. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1682. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  1683. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1684. if ($zxNo !== "") {
  1685. $where[] = ['a.zxNo','=',$zxNo];
  1686. }
  1687. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  1688. if ($salesman !== "") {
  1689. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  1690. $where[]= ["b.salesman",'like',"%$salesman%"];
  1691. }
  1692. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  1693. if ($cpName !== "") {
  1694. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  1695. $where[]= ["a.good_Name",'like',"%$cpName%"];
  1696. }
  1697. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  1698. if ($khNo !== "") {
  1699. // $where['khNo'] = $khNo;
  1700. $where[]= ["b.khNo",'like',"%$khNo%"];
  1701. }
  1702. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  1703. if ($start !="") {
  1704. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  1705. $where[]= ["a.addtime",'>=',$start];
  1706. }
  1707. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  1708. if($end !=""){
  1709. $where[]= ["a.addtime",'<=',$end];
  1710. }
  1711. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  1712. if ($status !== "") {
  1713. $where[]= ["a.status",'=',$status];
  1714. }
  1715. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  1716. ->count();
  1717. $total = ceil($count / $size);
  1718. $page = $page >= $total ? $total : $page;
  1719. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  1720. ->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();
  1721. $data=[];
  1722. foreach ($list as $value){
  1723. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1724. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  1725. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  1726. $value['khname']="";
  1727. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  1728. true):[];
  1729. if($value['khNo']!==""){
  1730. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  1731. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  1732. }
  1733. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1734. $data[]=$value;
  1735. }
  1736. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1737. }
  1738. }