Consult.php 78 KB

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