Consult.php 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  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. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  70. if ($zxNo !== "") {
  71. $where[] = ['a.zxNo','=',$zxNo];
  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. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  93. if ($start !="") {
  94. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  95. $where[]= ["a.addtime",'>=',$start];
  96. }
  97. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  98. if($end !=""){
  99. $where[]= ["a.addtime",'<=',$end];
  100. }
  101. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  102. if ($status !== "") {
  103. $where[]= ["a.status",'=',$status];
  104. }
  105. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  106. ->count();
  107. $total = ceil($count / $size);
  108. $page = $page >= $total ? $total : $page;
  109. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  110. ->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();
  111. $data=[];
  112. foreach ($list as $value){
  113. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  114. $value['khname']="";
  115. if($value['khNo']!==""){
  116. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  117. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  118. }
  119. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  120. $data[]=$value;
  121. }
  122. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  123. }
  124. public function info(){
  125. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  126. if($id==""){
  127. return error_show(1002,"咨询单编号不能为空");
  128. }
  129. $fo = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  130. $in= isset($fo['cat_id']) && $fo['cat_id'] !=0 ? made($fo['cat_id']):[];
  131. $fo['can']=$in;
  132. if(empty($fo)){
  133. return error_show(1002,"未找到咨询单编号");
  134. }else{
  135. return app_show(0,"获取成功",$fo);
  136. }
  137. }
  138. public function del(){
  139. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  140. $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  141. if($de==false){
  142. return error_show(1002,'咨询单信息未找到');
  143. }
  144. $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
  145. if($dell){
  146. return error_show(0,"删除成功");
  147. }else
  148. return error_show(1002,"删除失败");
  149. }
  150. public function create(){
  151. $is_project= isset($this->post['is_project']) && $this->post['is_project'] !=="" ? intval($this->post['is_project']) : "";
  152. if($is_project===""){
  153. return error_show(1002,"参数is_project不能为空");
  154. }
  155. if($is_project==1){
  156. $projectNo= isset($this->post['projectNo']) && $this->post['projectNo'] !=="" ? trim($this->post['projectNo']) : "";
  157. if($projectNo===""){
  158. return error_show(1002,"参数projectNo不能为空");
  159. }
  160. }
  161. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !=="" ? trim($this->post['khNo']) : "";
  162. if($khNo===""){
  163. return error_show(1002,"参数khNo不能为空");
  164. }
  165. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) : "";
  166. if($companyNo===""){
  167. return error_show(1002,"参数companyNo不能为空");
  168. }
  169. $endtime = isset($this->post['endtime']) && $this->post['endtime'] !=="" ? $this->post['endtime'] : "";
  170. if($endtime===""){
  171. return error_show(1002,"参数endtime不能为空");
  172. }
  173. // $saleid = isset($this->post['saleid']) && $this->post['saleid'] !=="" ? intval($this->post['saleid']) : "";
  174. // if($saleid===""){
  175. // return error_show(1002,"参数saleid不能为空");
  176. // }
  177. // $depart = isset($this->post['depart']) && $this->post['depart'] !=="" ? intval($this->post['depart']) : "";
  178. // if($depart===""){
  179. // return error_show(1002,"参数depart不能为空");
  180. // }
  181. $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) :
  182. "";
  183. if($platform_code===""){
  184. return error_show(1002,"参数platform_code不能为空");
  185. }
  186. $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder']) ? $this->post['ladder']:"";
  187. if($ladder==""){
  188. return error_show(1005,"参数ladder不能为空");
  189. }
  190. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  191. if($token==''){
  192. return error_show(1005,"参数token不能为空");
  193. }
  194. $user =GetUserInfo($token);
  195. if(empty($user)||$user['code']!=0){
  196. return error_show(1002,"用户数据不存在");
  197. }
  198. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  199. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  200. $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find();
  201. $zxNo=makeNo("ZX");
  202. $data=[
  203. "zxNo"=>$zxNo,
  204. "createrid"=>$createrid,
  205. "creater"=>$creater,
  206. "is_project"=>$is_project,
  207. "projectNo"=>isset($projectNo) ? $projectNo:"",
  208. "khNo"=>$khNo,
  209. "companyNo"=>$companyNo,
  210. "endtime"=>$endtime,
  211. "salesman"=>$creater,
  212. "platform_code"=>$platform_code,
  213. "saleid"=>$createrid,
  214. "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
  215. "status"=>0,
  216. "is_del"=>0,
  217. "addtime"=>date("Y-m-d H:i:s"),
  218. "updatetime"=>date("Y-m-d H:i:s"),
  219. ];
  220. $zx = Db::name("consult_order")->insert($data);
  221. if($zx){
  222. foreach ($ladder as $value){
  223. $infoNo=makeNo("INF");
  224. $specinfo=[];
  225. if(isset($value['specinfo']) &&!empty($value['specinfo'])){
  226. foreach ($value["specinfo"] as $v){
  227. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  228. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  229. $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
  230. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
  231. $specinfo[]=$v;
  232. }
  233. }
  234. $info=[
  235. "infoNo"=>$infoNo,
  236. "zxNo"=>$zxNo,
  237. "spuCode"=>"",
  238. "good_name"=>$value['good_name'],
  239. "good_img"=>$value['good_img'],
  240. "cat_id"=>$value['cat_id'],
  241. "unit"=>$value['unit'],
  242. "brand_id"=>$value['brand_id'],
  243. "arrival_time"=>$value['arrival_time'],
  244. "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
  245. "cost_desc"=>$value['cost_desc'],
  246. "is_addrs"=>$value['is_addrs'],
  247. "is_custom"=>$value['is_custom'],
  248. "metal_id"=>$value['metal_id'],
  249. "config"=>isset($value['config'])?$value['config']:"",
  250. "other_config"=>isset($value['other_config'])?$value['other_config']:"",
  251. "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
  252. "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
  253. "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
  254. "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
  255. "budget_price"=>$value['budget_price'],
  256. "num"=>$value['num'],
  257. "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
  258. "use_desc"=>$value['use_desc'],
  259. "remark"=>$value['remark'],
  260. "status"=>1,
  261. "is_del"=>0,
  262. "addtime"=>date("Y-m-d H:i:s"),
  263. "updatetime"=>date("Y-m-d H:i:s")
  264. ];
  265. $up = Db::name("consult_info")->insert($info);
  266. if(!$up){
  267. Db::rollback();
  268. return error_show(1004,'添加失败');
  269. }
  270. }
  271. return app_show(0,"新建成功",["zxNo"=>$zxNo]);
  272. }else{
  273. return error_show(1004,"新建失败");
  274. }
  275. }
  276. // public function zxadd(){
  277. // $good_name = isset($this->post['good_name'])&&$this->post['good_name']!==""?trim($this->post['good_name']):"";
  278. // if($good_name===""){
  279. // return error_show(1004,"参数good_name不能为空");
  280. // }
  281. // $zxNo = isset($this->post['zxNo'])&&$this->post['zxNo']!==""?trim($this->post['zxNo']):"";
  282. // if($zxNo===""){
  283. // return error_show(1004,"参数zxNo不能为空");
  284. // }
  285. //
  286. // $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):"";
  287. // if($cat_id===""){
  288. // return error_show(1004,"参数cat_id不能为空");
  289. // }
  290. // $arrival_time = isset($this->post['arrival_time'])&&$this->post['arrival_time']!==""?$this->post['arrival_time']
  291. // :"";
  292. // if($arrival_time===""){
  293. // return error_show(1004,"参数arrival_time不能为空");
  294. // }
  295. // $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""?trim($this->post['good_img']):"";
  296. // if($good_img===""){
  297. // return error_show(1004,"参数good_img不能为空");
  298. // }
  299. // $is_custom = isset($this->post['is_custom'])&&$this->post['is_custom']!==""?intval($this->post['is_custom']):"";
  300. // if($is_custom===""){
  301. // return error_show(1004,"参数is_custom不能为空");
  302. // }
  303. // $unit = isset($this->post['unit'])&&$this->post['unit']!==""?trim($this->post['unit']):"";
  304. // if($unit===""){
  305. // return error_show(1004,"参数unit不能为空");
  306. // }
  307. // $brand_id = isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"";
  308. // if($brand_id===""){
  309. // return error_show(1004,"参数brand_id不能为空");
  310. // }
  311. // $material = isset($this->post['material'])&&$this->post['material']!==""?trim($this->post['material']):"";
  312. // if($material===""){
  313. // return error_show(1004,"参数material不能为空");
  314. // }
  315. // $color = isset($this->post['color'])&&$this->post['color']!==""?trim($this->post['color']):"";
  316. // if($color===""){
  317. // return error_show(1004,"参数color不能为空");
  318. // }
  319. // $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!==""?trim($this->post['cost_desc']):"";
  320. // if($cost_desc===""){
  321. // return error_show(1004,"参数cost_desc不能为空");
  322. // }
  323. // $model = isset($this->post['model'])&&$this->post['model']!==""?trim($this->post['model']):"";
  324. // if($model===""){
  325. // return error_show(1004,"参数model不能为空");
  326. // }
  327. //
  328. // $is_addrs = isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  329. // if($is_addrs===""){
  330. // return error_show(1004,"参数is_addrs不能为空");
  331. // }
  332. //
  333. // $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!==""?trim($this->post['metal_id']):"";
  334. // if($metal_id===""){
  335. // return error_show(1004,"参数metal_id不能为空");
  336. // }
  337. // if($metal_id==0){
  338. // $config = isset($this->post['config'])&&!empty($this->post['config'])?$this->post['config']:"";
  339. // if($config===""){
  340. // return error_show(1004,"参数config不能为空");
  341. // }
  342. // $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""?trim($this->post['other_config'])
  343. // :"";
  344. // if($other_config===""){
  345. // return error_show(1004,"参数other_config不能为空");
  346. // }
  347. // $specs_weight = isset($this->post['specs_weight'])&&$this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  348. // if($specs_weight===""){
  349. // return error_show(1004,"参数specs_weight不能为空");
  350. // }
  351. // $gold_price = isset($this->post['gold_price'])&&$this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  352. // if($gold_price===""){
  353. // return error_show(1004,"参数gold_price不能为空");
  354. // }
  355. //
  356. // }
  357. // $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  358. // if($budget_price===""){
  359. // return error_show(1004,"参数budget_price不能为空");
  360. // }
  361. // $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
  362. // if($num===""){
  363. // return error_show(1004,"参数num不能为空");
  364. // }
  365. // $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!==""?trim($this->post['use_desc']):"";
  366. // if($use_desc===""){
  367. // return error_show(1004,"参数use_desc不能为空");
  368. // }
  369. // $remark = isset($this->post['remark'])&&$this->post['remark']!==""?trim($this->post['remark']):"";
  370. // if($remark===""){
  371. // return error_show(1004,"参数remark不能为空");
  372. // }
  373. //
  374. // Db::startTrans();
  375. // try{
  376. // $infoNo=makeNo("INF");
  377. // $info=[
  378. // "infoNo"=>$infoNo,
  379. // "zxNo"=>$zxNo,
  380. // "spuCode"=>"",
  381. // "good_name"=>$good_name,
  382. // "good_img"=>$good_img,
  383. // "cat_id"=>$cat_id,
  384. // "unit"=>$unit,
  385. // "brand_id"=>$brand_id,
  386. // "arrival_time"=>$arrival_time,
  387. // "model"=>$model,
  388. // "color"=>$color,
  389. // "material"=>$material,
  390. // "cost_desc"=>$cost_desc,
  391. // "is_addrs"=>$is_addrs,
  392. // "is_custom"=>$is_custom,
  393. // "metal_id"=>$metal_id,
  394. // "config"=>isset($config)?$config:"",
  395. // "other_config"=>isset($other_config)?$other_config:"",
  396. // "specs_weight"=>isset($specs_weight)?$specs_weight:0,
  397. // "gold_price"=>isset($gold_price)?$gold_price:0,
  398. // "budget_price"=>$budget_price,
  399. // "num"=>$num,
  400. // "use_desc"=>$use_desc,
  401. // "remark"=>$remark,
  402. // "status"=>0,
  403. // "is_del"=>0,
  404. // "addtime"=>date("Y-m-d H:i:s"),
  405. // "updatetime"=>date("Y-m-d H:i:s")
  406. // ];
  407. // $up = Db::name("consult_info")->insert($info);
  408. // if($up){
  409. // Db::commit();
  410. // return app_show(0,"添加成功",["infoNo"=>$infoNo]);
  411. // }else{
  412. // Db::rollback();
  413. // return error_show(1004,'添加失败');
  414. // }
  415. // }catch (\Exception $e){
  416. // Db::rollback();
  417. // return error_show(1004,$e->getMessage());
  418. // }
  419. // }
  420. public function zxinfo(){
  421. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  422. if($infoNo==""){
  423. return error_show(1004,"参数infoNo不能为空");
  424. }
  425. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  426. if($zxinfo==false){
  427. return error_show(1004,"未找到信息数据");
  428. }
  429. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  430. if($zxorder==false){
  431. return error_show(1004,"未找到咨询信息数据");
  432. }
  433. $cat =Db::name("cat")->where(["id"=>$zxinfo['cat_id']])->find();
  434. $budget = isset($cat['order_rate']) ? $cat['order_rate']:100;
  435. $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
  436. $zxinfo['khname']="";
  437. $zxinfo['original_price']=sprintf("%.2f",$zxinfo['budget_price']* (1 -$budget/100));
  438. $zxinfo['khNo']="";
  439. $zxinfo['brand_id']=$zxinfo['brand_id']==0 ?"":$zxinfo['brand_id'];
  440. $zxinfo['brand']="";
  441. $zxinfo['companyNo']=isset($zxorder['companyNo'])?$zxorder['companyNo']:"";
  442. $zxinfo['projectNo']=isset($zxorder['projectNo'])?$zxorder['projectNo']:"";
  443. $zxinfo['is_project']=isset($zxorder['is_project'])?$zxorder['is_project']:"";
  444. $zxinfo['company']="";
  445. $zxinfo['endtime']=isset($zxorder['endtime'])?$zxorder['endtime']:"";
  446. $zxinfo['platform_code'] =isset($zxorder['platform_code'])?$zxorder['platform_code']:"";
  447. $zxinfo['salesman'] =isset($zxorder['salesman'])?$zxorder['salesman']:"";
  448. $zxinfo['saleid'] =isset($zxorder['saleid'])?$zxorder['saleid']:"";
  449. $zxinfo['depart'] =isset($zxorder['depart'])?$zxorder['depart']:"";
  450. $zxinfo['project_name']="";
  451. $zxinfo['budget_total']="";
  452. $zxinfo['departinfo']=[];
  453. $zxinfo['unit_name']="";
  454. $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
  455. $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
  456. if($zxorder['khNo']!==""){
  457. $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
  458. $zxinfo['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  459. $zxinfo['khNo']= $zxorder['khNo'];
  460. }
  461. if($zxinfo['unit']!==""){
  462. $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find();
  463. $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:"";
  464. }
  465. if($zxinfo['brand_id']!==""){
  466. $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
  467. $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
  468. }
  469. if($zxorder['companyNo']!==""){
  470. $kh=Db::name("business")->where(['companyNo'=>$zxorder['companyNo']])->find();
  471. $zxinfo['company']= isset($kh['company'])?$kh['company']:"";
  472. }
  473. if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){
  474. $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find();
  475. $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:"";
  476. $zxinfo['budget_total']=isset($project['budget_total'])?$project['budget_total']:"";
  477. $zxinfo['project_use_desc']=isset($project['use_desc'])?$project['use_desc']:"";
  478. $projectinfo = Db::name("project_info")->where(["pgNo"=>$zxinfo['pgNo']])->find();
  479. $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo']:"";
  480. }
  481. if($zxorder['depart']>0){
  482. $zxinfo['departinfo']=GetPart($zxorder['depart']);
  483. }
  484. if($zxorder['platform_code']>0){
  485. $palt=Db::name("platform")->where(["id"=>$zxorder['platform_code']])->find();
  486. $zxinfo['platform_name']=isset($palt['platform_name'])?$palt['platform_name']:"";
  487. }
  488. return app_show(0,"获取成功",$zxinfo);
  489. }
  490. public function zxedit(){
  491. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  492. if($infoNo==""){
  493. return error_show(1004,"参数infoNo不能为空");
  494. }
  495. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  496. if($zxinfo==false){
  497. return error_show(1004,"未找到信息数据");
  498. }
  499. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
  500. if($good_name==""){
  501. return error_show(1003,"参数good_name不能为空");
  502. }
  503. $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
  504. if($good_img==""){
  505. return error_show(1003,"参数good_img不能为空");
  506. }
  507. $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
  508. if($cat_id==""){
  509. return error_show(1003,"参数cat_id不能为空");
  510. }
  511. $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
  512. if($unit==""){
  513. return error_show(1003,"参数unit不能为空");
  514. }
  515. $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
  516. $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
  517. if($arrival_time==""){
  518. return error_show(1003,"参数arrival_time不能为空");
  519. }
  520. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  521. if($specin==""){
  522. return error_show(1003,"参数specinfo不能为空");
  523. }
  524. // $color= isset($this->post['color'])&&$this->post['color']!=""?trim($this->post['color']):"";
  525. // if($color==""){
  526. // return error_show(1003,"参数color不能为空");
  527. // }
  528. // $material= isset($this->post['material'])&&$this->post['material']!=""?trim($this->post['material']):"";
  529. // if($material==""){
  530. // return error_show(1003,"参数material不能为空");
  531. // }
  532. $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
  533. if($cost_desc==""){
  534. return error_show(1003,"参数cost_desc不能为空");
  535. }
  536. $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  537. if($is_addrs===""){
  538. return error_show(1003,"参数is_addrs不能为空");
  539. }
  540. $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
  541. if($is_custom===""){
  542. return error_show(1003,"参数is_custom不能为空");
  543. }
  544. $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
  545. if($metal_id===""){
  546. return error_show(1003,"参数metal_id不能为空");
  547. }
  548. $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
  549. $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
  550. $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  551. $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  552. $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
  553. $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  554. $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
  555. $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
  556. if($num===""){
  557. return error_show(1003,"参数num不能为空");
  558. }
  559. if($budget_price===""){
  560. return error_show(1003,"参数budget_price不能为空");
  561. }
  562. $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
  563. $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
  564. if($use_desc==""){
  565. return error_show(1003,"参数use_desc不能为空");
  566. }
  567. $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
  568. if($remark==""){
  569. return error_show(1003,"参数remark不能为空");
  570. }
  571. if($metal_id!=0){
  572. if($config==""){
  573. return error_show(1003,"参数config不能为空");
  574. }
  575. if($other_config==""){
  576. return error_show(1003,"参数other_config不能为空");
  577. }
  578. if($specs_weight===""){
  579. return error_show(1003,"参数specs_weight不能为空");
  580. }
  581. if($gold_price===""){
  582. return error_show(1003,"参数gold_price不能为空");
  583. }
  584. }
  585. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  586. if($token==''){
  587. return error_show(102,"参数token不能为空");
  588. }
  589. $user =GetUserInfo($token);
  590. if(empty($user)||$user['code']!=0){
  591. return error_show(105,"用户数据不存在");
  592. }
  593. $specinfo=[];
  594. foreach ($specin as $v){
  595. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  596. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  597. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  598. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  599. $specinfo[]=$v;
  600. }
  601. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  602. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  603. $bidlist = Db::name("consult_bids")->where(["infoNo"=>$zxinfo['infoNo'],"is_del"=>0])->select();
  604. try{
  605. $innew =makeNo("INF");
  606. $info=[
  607. "infoNo"=>$innew,
  608. "zxNo"=>$zxinfo['zxNo'],
  609. "spuCode"=>"",
  610. "good_name"=>$good_name,
  611. "good_img"=>$good_img,
  612. "cat_id"=>$cat_id,
  613. "unit"=>$unit,
  614. "brand_id"=>$brand_id,
  615. "arrival_time"=>$arrival_time,
  616. "specinfo"=>json_encode($specinfo),
  617. // "color"=>$color,
  618. // "material"=>$material,
  619. "cost_desc"=>$cost_desc,
  620. "is_addrs"=>$is_addrs,
  621. "is_custom"=>$is_custom,
  622. "metal_id"=>$metal_id,
  623. "config"=>$config,
  624. "other_config"=>$other_config,
  625. "specs_weight"=>$specs_weight===""?0:$specs_weight,
  626. "gold_price"=>$gold_price===""? 0 : $gold_price,
  627. "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
  628. "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
  629. "budget_price"=>$budget_price,
  630. "num"=>$num,
  631. "pgNo"=>$pgNo,
  632. "use_desc"=>$use_desc,
  633. "remark"=>$remark,
  634. "status"=>1,
  635. "is_del"=>0,
  636. "addtime"=>date("Y-m-d H:i:s"),
  637. "updatetime"=>date("Y-m-d H:i:s")
  638. ];
  639. $up = Db::name("consult_info")->insert($info);
  640. if($up){
  641. if (!empty($bidlist)){
  642. foreach ($bidlist as $value){
  643. unset($value['id']);
  644. $value['infoNo']=$innew;
  645. $value['sale_price'] =$value['total_price'];
  646. $value['status'] =0;
  647. $value['updatetime'] =date("Y-m-d H:i:s");
  648. $in = Db::name("consult_bids")->insert($value);
  649. if($in==false){
  650. Db::rollback();
  651. return error_show(1004,"反馈商品新建失败");
  652. }
  653. }
  654. }
  655. $zxinfo["bargain_status"] =1;
  656. $zxinfo["bargain_code"] =$innew;
  657. $zxinfo["updatetime"] =date("Y-m-d H:i:s");
  658. $bar=Db::name("consult_info")->save($zxinfo);
  659. if($bar==false){
  660. Db::rollback();
  661. return error_show(1004,"反馈商品更新失败");
  662. }
  663. Db::commit();
  664. return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
  665. }
  666. }catch (\Exception $e){
  667. Db::rollback();
  668. return error_show(1004,$e->getMessage());
  669. }
  670. }
  671. //** 发布竞标任务 */
  672. public function bargain(){
  673. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  674. if($infoNo==""){
  675. return error_show(1004,"参数infoNo不能为空");
  676. }
  677. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  678. if($zxinfo==false){
  679. return error_show(1004,"未找到信息数据");
  680. }
  681. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  682. if($status===""){
  683. return error_show(1004,"参数status不能为空");
  684. }
  685. if($status==1&&$zxinfo['status']>1){
  686. $zxinfo['bargain_num']=+1;
  687. }
  688. $zxinfo['status']=$status;
  689. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  690. $up = Db::name("consult_info")->save($zxinfo);
  691. if($up){
  692. return app_show(0,"状态更新成功");
  693. }else{
  694. return error_show(1003,"状态更新失败");
  695. }
  696. }
  697. public function feadback(){
  698. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  699. if($infoNo==""){
  700. return error_show(1002,"参数infoNo不能为空");
  701. }
  702. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  703. if($zxinfo==false){
  704. return error_show(1003,"未找到信息数据");
  705. }
  706. if($zxinfo['status']!=1){
  707. return error_show(1004,"任务未进行");
  708. }
  709. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  710. if($pname==""){
  711. return error_show(1002,"参数pname不能为空");
  712. }
  713. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  714. // if($brandid==""){
  715. // return error_show(1002,"参数brandid不能为空");
  716. // }
  717. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  718. if($cat_id==""){
  719. return error_show(1002,"参数cat_id不能为空");
  720. }
  721. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  722. if($specin==""){
  723. return error_show(1003,"参数specinfo不能为空");
  724. }
  725. $specinfo=[];
  726. foreach ($specin as $v){
  727. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  728. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  729. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  730. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  731. $specinfo[]=$v;
  732. }
  733. // $model = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
  734. // //$unit = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
  735. // $material = isset($this->post['material'])&&$this->post['material']!=""? trim($this->post['material']):"";
  736. // $color = isset($this->post['color'])&&$this->post['color']!=""? trim($this->post['color']):"";
  737. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  738. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  739. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  740. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  741. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  742. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  743. :"";
  744. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  745. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  746. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  747. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  748. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  749. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  750. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  751. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  752. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  753. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  754. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  755. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  756. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  757. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  758. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""? floatval($this->post['nake_fee']):"";
  759. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  760. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  761. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  762. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  763. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  764. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  765. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  766. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  767. if($token==''){
  768. return error_show(1002,"参数token不能为空");
  769. }
  770. $user =GetUserInfo($token);
  771. if(empty($user)||$user['code']!=0){
  772. return error_show(1005,"用户数据不存在");
  773. }
  774. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  775. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  776. $bidNo=makeNo("BD");
  777. $spucode=makeNo("SPU");
  778. $data=[
  779. "bidNo"=>$bidNo,
  780. "infoNo"=>$infoNo,
  781. "zxNo"=>$zxinfo['zxNo'],
  782. "spuCode"=>$spucode,
  783. "good_name"=>$pname,
  784. "brand_id"=>$brandid,
  785. "cat_id"=>$cat_id,
  786. "specinfo"=>json_encode($specinfo),
  787. // "color"=>$color,
  788. // "material"=>$material,
  789. "unit_id"=>$unit_id,
  790. "cost_desc"=>$cost_desc,
  791. "work_day"=>$work_day,
  792. "delivery_day"=>$delivery_day,
  793. "good_img"=>$good_img,
  794. "expire_day"=>$expire_day,
  795. "origin_place"=>$origin_place,
  796. "supplierNo"=>$supplierNo,
  797. "pay_way"=>$pay_way,
  798. "tax"=>$tax,
  799. "send_way"=>$send_way,
  800. "metal_id"=>$metal_id,
  801. "is_gold_price"=>$is_gold_price,
  802. "config"=>$config,
  803. "other_config"=>$other_config,
  804. "weight"=>$weight,
  805. "is_diff"=>$is_diff,
  806. "demo_fee"=>$demo_fee,
  807. "delivery_fee"=>$delivery_fee,
  808. "open_fee"=>$open_fee,
  809. "pakge_fee"=>$pakge_fee,
  810. "nake_fee"=>$nake_fee,
  811. "mark_fee"=>$mark_fee,
  812. "cert_fee"=>$cert_fee,
  813. "cost_fee"=>$cost_fee,
  814. "total_fee"=>$total_fee,
  815. "supply_area"=>$supply_area,
  816. "remark"=>$remark,
  817. "sale_price"=>0,
  818. "createrid"=>$createrid,
  819. "creater"=>$creater,
  820. "status"=>$zxinfo['status']==1 ?1 :2,
  821. "is_del"=>0,
  822. "addtime"=>date("Y-m-d H:i:s"),
  823. "updatetime"=>date("Y-m-d H:i:s")
  824. ];
  825. Db::startTrans();
  826. try{
  827. $insert= Db::name("consult_bids")->insert($data);
  828. if($insert){
  829. $data=[
  830. "spuCode"=>$spucode,
  831. "good_name"=>$pname,
  832. "brand_id"=>$brandid,
  833. "good_unit"=>$unit_id,
  834. "good_type"=>0,
  835. "moq"=>1,
  836. "customized"=>$work_day,
  837. "tax"=>$tax,
  838. "supplierNo"=>$supplierNo,
  839. "is_auth"=>0,
  840. "craft_desc"=>$cost_desc,
  841. "good_remark"=>$remark,
  842. "good_img"=>$good_img,
  843. "good_thumb_img"=>"",
  844. "good_info_img"=>"",
  845. "status"=>1,
  846. "is_del"=>0,
  847. "createrid"=>$createrid,
  848. "creater"=>$creater,
  849. "addtime"=>date("Y-m-d H:i:s"),
  850. "updatetime"=>date("Y-m-d H:i:s")
  851. ];
  852. $good = Db::name("good_zixun")->insert($data);
  853. if($good){
  854. Db::commit();
  855. return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
  856. }else{
  857. Db::rollback();
  858. return error_show(1006,"反馈失败");
  859. }
  860. }else{
  861. Db::rollback();
  862. return error_show(1006,"反馈失败");
  863. }
  864. }catch (\Exception $e){
  865. Db::rollback();
  866. return error_show(1006,$e->getMessage());
  867. }
  868. }
  869. public function feadinfo(){
  870. $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  871. if($bidNo==""){
  872. return error_show(1004,"参数bidNo不能为空");
  873. }
  874. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  875. if($info==false){
  876. return error_show(1004,"未找到商品数据");
  877. }
  878. $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
  879. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  880. $info['cat_info'] = made($info['cat_id'],[]);
  881. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  882. $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  883. if($info['brand_id']!=0){
  884. $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
  885. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  886. }else{
  887. $info["brand_name"]="";
  888. $info["brand_id"]="";
  889. }
  890. $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
  891. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  892. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  893. $god=[
  894. "metal_id"=>$info['metal_id'],
  895. "weight"=>$info["weight"],
  896. "demo_fee"=>$info["demo_fee"],
  897. "delivery_fee"=>$info["delivery_fee"],
  898. "open_fee"=>$info["open_fee"],
  899. "packing_fee"=>$info["pakge_fee"],
  900. "mark_fee"=>$info["mark_fee"],
  901. "nake_fee"=>$info["nake_fee"],
  902. "cert_fee"=>$info["cert_fee"],
  903. "cost_fee"=>$info["cost_fee"],
  904. "num"=>$bidinfo["num"],
  905. ];
  906. if($info['is_gold_price']==1){
  907. $price = GoldPrice($god, $budget/100);
  908. }else{
  909. $price = GoodPrice($god, $budget/100);
  910. }
  911. $info['specinfo'] = json_decode($info['specinfo'],true);
  912. $info['sale_price'] =round($price,2);
  913. $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
  914. $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
  915. $info['bargain'] =$bargain;
  916. return app_show(0,"获取成功",$info);
  917. }
  918. public function feededit(){
  919. $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  920. if($bidNo==""){
  921. return error_show(1002,"参数bidNo不能为空");
  922. }
  923. $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
  924. if($bidinfo==false){
  925. return error_show(1003,"未找到信息数据");
  926. }
  927. if($bidinfo['status']>=5){
  928. return error_show(1004,"咨询单已确认无法修改");
  929. }
  930. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
  931. if($zxinfo==false){
  932. return error_show(1003,"未找到信息数据");
  933. }
  934. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  935. if($pname==""){
  936. return error_show(1002,"参数pname不能为空");
  937. }
  938. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  939. // if($brandid==""){
  940. // return error_show(1002,"参数brandid不能为空");
  941. // }
  942. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  943. if($cat_id==""){
  944. return error_show(1002,"参数cat_id不能为空");
  945. }
  946. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  947. if($specin==""){
  948. return error_show(1003,"参数specinfo不能为空");
  949. }
  950. $specinfo=[];
  951. foreach ($specin as $v){
  952. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  953. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  954. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  955. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  956. $specinfo[]=$v;
  957. }
  958. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  959. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  960. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  961. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  962. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  963. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  964. :"";
  965. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  966. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  967. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  968. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  969. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  970. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  971. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  972. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  973. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  974. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  975. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  976. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  977. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  978. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  979. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""? floatval($this->post['nake_fee']):"";
  980. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  981. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  982. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  983. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  984. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  985. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  986. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  987. $data=[
  988. "good_name"=>$pname,
  989. "brand_id"=>$brandid,
  990. "cat_id"=>$cat_id,
  991. "specinfo"=>json_encode($specinfo),
  992. // "material"=>$material,
  993. "unit_id"=>$unit_id,
  994. "cost_desc"=>$cost_desc,
  995. "work_day"=>$work_day,
  996. "delivery_day"=>$delivery_day,
  997. "good_img"=>$good_img,
  998. "expire_day"=>$expire_day,
  999. "origin_place"=>$origin_place,
  1000. "supplierNo"=>$supplierNo,
  1001. "pay_way"=>$pay_way,
  1002. "tax"=>$tax,
  1003. "send_way"=>$send_way,
  1004. "metal_id"=>$metal_id,
  1005. "is_gold_price"=>$is_gold_price,
  1006. "config"=>$config,
  1007. "other_config"=>$other_config,
  1008. "weight"=>$weight,
  1009. "is_diff"=>$is_diff,
  1010. "demo_fee"=>$demo_fee,
  1011. "delivery_fee"=>$delivery_fee,
  1012. "open_fee"=>$open_fee,
  1013. "pakge_fee"=>$pakge_fee,
  1014. "nake_fee"=>$nake_fee,
  1015. "mark_fee"=>$mark_fee,
  1016. "cert_fee"=>$cert_fee,
  1017. "cost_fee"=>$cost_fee,
  1018. "total_fee"=>$total_fee,
  1019. "supply_area"=>$supply_area,
  1020. "remark"=>$remark,
  1021. "updatetime"=>date("Y-m-d H:i:s")
  1022. ];
  1023. $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
  1024. if($insert){
  1025. return app_show(0,"编辑成功");
  1026. }else{
  1027. return error_show(1004,"编辑失败");
  1028. }
  1029. }
  1030. public function bargain_add(){
  1031. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1032. if($bidNo===""){
  1033. return error_show(1004,"参数bidNo不能为空");
  1034. }
  1035. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1036. if($info==false){
  1037. return error_show(1004,"未找到商品数据");
  1038. }
  1039. $bargain_price = isset($this->post['bargain_price'])&& $this->post['bargain_price']!=""?floatval($this->post['bargain_price']):"";
  1040. if($bargain_price===""){
  1041. return error_show(1004,"参数bargain_price不能为空");
  1042. }
  1043. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1044. if($infos==false){
  1045. return error_show(1004,"未找到商品数据");
  1046. }
  1047. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1048. if($token==''){
  1049. return error_show(1005,"参数token不能为空");
  1050. }
  1051. $user =GetUserInfo($token);
  1052. if(empty($user)||$user['code']!=0){
  1053. return error_show(1002,"用户数据不存在");
  1054. }
  1055. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1056. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1057. $bargainNo =makeNo("BA");
  1058. Db::startTrans();//::todo 金价 毛利计算
  1059. try{
  1060. $data=[
  1061. "bidsNo"=>$bidNo,
  1062. "bargainNo"=>$bargainNo,
  1063. "bargain_type"=>1,
  1064. "sale_price"=>$info['sale_price'],
  1065. "cost_before_price"=>$info['cost_fee'],
  1066. "cost_after_price"=>$info['cost_fee'],
  1067. "before_rate"=>$info['cost_fee'],
  1068. "after_rate"=>$info['cost_fee'],
  1069. "after_price"=>$bargain_price,
  1070. "status"=>1,
  1071. "is_del"=>0,
  1072. "creater"=>$creater,
  1073. "createrid"=>$createrid,
  1074. "addtime"=>date("Y-m-d H:i:s"),
  1075. "updatetime"=>date("Y-m-d H:i:s")
  1076. ];
  1077. $int = Db::name("bargain_order")->insert($data);
  1078. if($int){
  1079. $info['status']=3;
  1080. $info['updatetime']=date("Y-m-d H:i:s");
  1081. $up =Db::name("consult_bids")->save($info);
  1082. if($up){
  1083. Db::commit();
  1084. return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]);
  1085. }
  1086. }
  1087. }catch (\Exception $e){
  1088. Db::rollback();
  1089. return error_show(1004,$e->getMessage());
  1090. }
  1091. }
  1092. public function bargain_status(){
  1093. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1094. if($bargainNo===""){
  1095. return error_show(1004,"参数bargainNo不能为空");
  1096. }
  1097. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1098. if($info==false){
  1099. return error_show(1004,"未找到议价数据");
  1100. }
  1101. $bids=Db::name("consult_bids")->where(["bidNo"=>$info["bidsNo"],"is_del"=>0])->find();
  1102. if($bids==false){
  1103. return error_show(1004,"未找到商品数据");
  1104. }
  1105. $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):"";
  1106. if($status==''){
  1107. return error_show(1005,"参数status不能为空");
  1108. }
  1109. Db::startTrans();
  1110. try{
  1111. $info['status'] =$status;
  1112. $info['updatetime'] =date("Y-m-d H:i:s");
  1113. $up =Db::name("bargain_order")->save($info);
  1114. if($up){
  1115. if($status==4){
  1116. $bids['status']=4;
  1117. $bids['sale_price']=$info['after_price'];
  1118. $bids['updatetime']=date("Y-m-d H:i:s");
  1119. $up =Db::name("consult_bids")->save($bids);
  1120. if($up==false){
  1121. Db::rollback();
  1122. return error_show(1004,"数据更新失败");
  1123. }
  1124. }
  1125. if($status==5||$status==6||$status==7){
  1126. $bids['status']=4;
  1127. $bids['updatetime']=date("Y-m-d H:i:s");
  1128. $up =Db::name("consult_bids")->save($bids);
  1129. if($up==false){
  1130. Db::rollback();
  1131. return error_show(1004,"数据更新失败");
  1132. }
  1133. }
  1134. Db::commit();
  1135. return app_show(0,"更新成功");
  1136. }
  1137. }catch (\Exception $e){
  1138. Db::rollback();
  1139. return error_show(1004,$e->getMessage());
  1140. }
  1141. }
  1142. public function bargain_info(){
  1143. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1144. if($bargainNo===""){
  1145. return error_show(1004,"参数bargainNo不能为空");
  1146. }
  1147. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1148. if($info==false){
  1149. return error_show(1004,"未找到议价数据");
  1150. }
  1151. return app_show(0,"获取成功",$info);
  1152. }
  1153. public function bidlist(){
  1154. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1155. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1156. $where=[['is_del',"=",0]];
  1157. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1158. if ($zxNo !== "") {
  1159. $where[] = ['zxNo','=',$zxNo];
  1160. }
  1161. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1162. if ($infoNo !== "") {
  1163. $where[] = ['infoNo','=',$infoNo];
  1164. }
  1165. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1166. if ($bidNo !== "") {
  1167. $where[] = ['bidNo','=',$bidNo];
  1168. }
  1169. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1170. if ($pgNo !== "") {
  1171. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1172. $where[] = ['infoNo','in',$bidinfo];
  1173. }
  1174. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  1175. if ($bargain_status !== "") {
  1176. $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
  1177. $where[] = ['infoNo','in',$bidinfo];
  1178. }
  1179. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1180. if ($projectNo !== "") {
  1181. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1182. ("zxNo");
  1183. $where[] = ['zxNo','in',$zxlist];
  1184. }
  1185. $count = Db::name('consult_bids')->where($where)->count();
  1186. $total = ceil($count / $size);
  1187. $page = $page >= $total ? $total : $page;
  1188. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select();
  1189. $data=[];
  1190. foreach ($list as $value){
  1191. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1192. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1193. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1194. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1195. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1196. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1197. if($value['brand_id']!=0){
  1198. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1199. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1200. }else{
  1201. $value["brand_name"]="";
  1202. $value["brand_id"]="";
  1203. }
  1204. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1205. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  1206. $god=[
  1207. "metal_id"=>$value['metal_id'],
  1208. "weight"=>$value["weight"],
  1209. "demo_fee"=>$value["demo_fee"],
  1210. "delivery_fee"=>$value["delivery_fee"],
  1211. "open_fee"=>$value["open_fee"],
  1212. "packing_fee"=>$value["pakge_fee"],
  1213. "mark_fee"=>$value["mark_fee"],
  1214. "nake_fee"=>$value["nake_fee"],
  1215. "cert_fee"=>$value["cert_fee"],
  1216. "cost_fee"=>$value["cost_fee"],
  1217. "num"=>$bidinfo["num"],
  1218. ];
  1219. if($value['is_gold_price']==1){
  1220. $price = GoldPrice($god, $budget/100);
  1221. }else{
  1222. $price = GoodPrice($god, $budget/100);
  1223. }
  1224. $value['specinfo'] = json_decode($value['specinfo'],true);
  1225. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1226. $value['sale_price'] =round($price,2);
  1227. $value['bargain_status']=$bidinfo['bargain_status'];
  1228. $data[]=$value;
  1229. }
  1230. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1231. }
  1232. public function feedlist(){
  1233. $where=[['is_del',"=",0]];
  1234. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1235. if ($zxNo !== "") {
  1236. $where[] = ['zxNo','=',$zxNo];
  1237. }
  1238. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1239. if ($infoNo !== "") {
  1240. $where[] = ['infoNo','=',$infoNo];
  1241. }
  1242. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1243. if ($bidNo !== "") {
  1244. $where[] = ['bidNo','=',$bidNo];
  1245. }
  1246. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1247. if ($projectNo !== "") {
  1248. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1249. ("zxNo");
  1250. $where[] = ['zxNo','in',$zxlist];
  1251. }
  1252. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1253. if($token==''){
  1254. return error_show(102,"参数token不能为空");
  1255. }
  1256. $user =GetUserInfo($token);
  1257. if(empty($user)||$user['code']!=0){
  1258. return error_show(105,"用户数据不存在");
  1259. }
  1260. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1261. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1262. $where[] = ["createrid","=",$createrid];
  1263. $list =Db::name('consult_bids')->where($where)->select();
  1264. $data=[];
  1265. foreach ($list as $value){
  1266. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1267. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1268. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1269. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1270. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1271. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1272. if($value['brand_id']!=0){
  1273. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1274. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1275. }else{
  1276. $value["brand_name"]="";
  1277. $value["brand_id"]="";
  1278. }
  1279. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1280. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  1281. $god=[
  1282. "metal_id"=>$value['metal_id'],
  1283. "weight"=>$value["weight"],
  1284. "demo_fee"=>$value["demo_fee"],
  1285. "delivery_fee"=>$value["delivery_fee"],
  1286. "open_fee"=>$value["open_fee"],
  1287. "packing_fee"=>$value["pakge_fee"],
  1288. "mark_fee"=>$value["mark_fee"],
  1289. "nake_fee"=>$value["nake_fee"],
  1290. "cert_fee"=>$value["cert_fee"],
  1291. "cost_fee"=>$value["cost_fee"],
  1292. "num"=>$bidinfo["num"],
  1293. ];
  1294. if($value['is_gold_price']==1){
  1295. $price = GoldPrice($god, $budget/100);
  1296. }else{
  1297. $price = GoodPrice($god, $budget/100);
  1298. }
  1299. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1300. $value['sale_price'] =round($price,2);
  1301. $value['specinfo'] = json_decode($value['specinfo'],true);
  1302. $value['bargain_status']=$bidinfo['bargain_status'];
  1303. $data[]=$value;
  1304. }
  1305. return app_show(0,"获取成功",$data);
  1306. }
  1307. }