Consult.php 62 KB

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