Consult.php 90 KB

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