Consult.php 87 KB

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