Consult.php 53 KB

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