Consult.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  195. if($token==''){
  196. return error_show(1005,"参数token不能为空");
  197. }
  198. $user =GetUserInfo($token);
  199. if(empty($user)||$user['code']!=0){
  200. return error_show(1002,"用户数据不存在");
  201. }
  202. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  203. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  204. $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find();
  205. $zxNo=makeNo("ZX");
  206. $data=[
  207. "zxNo"=>$zxNo,
  208. "createrid"=>$createrid,
  209. "creater"=>$creater,
  210. "is_project"=>$is_project,
  211. "projectNo"=>isset($projectNo) ? $projectNo:"",
  212. "khNo"=>$khNo,
  213. "companyNo"=>$companyNo,
  214. "endtime"=>$endtime,
  215. "salesman"=>$creater,
  216. "platform_code"=>$platform_code,
  217. "saleid"=>$createrid,
  218. "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
  219. "status"=>0,
  220. "is_del"=>0,
  221. "addtime"=>date("Y-m-d H:i:s"),
  222. "updatetime"=>date("Y-m-d H:i:s"),
  223. ];
  224. $zx = Db::name("consult_order")->insert($data);
  225. if($zx){
  226. return app_show(0,"新建成功",["zxNo"=>$zxNo]);
  227. }else{
  228. return error_show(1004,"新建失败");
  229. }
  230. }
  231. public function zxadd(){
  232. $good_name = isset($this->post['good_name'])&&$this->post['good_name']!==""?trim($this->post['good_name']):"";
  233. if($good_name===""){
  234. return error_show(1004,"参数good_name不能为空");
  235. }
  236. $zxNo = isset($this->post['zxNo'])&&$this->post['zxNo']!==""?trim($this->post['zxNo']):"";
  237. if($zxNo===""){
  238. return error_show(1004,"参数zxNo不能为空");
  239. }
  240. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):"";
  241. if($cat_id===""){
  242. return error_show(1004,"参数cat_id不能为空");
  243. }
  244. $arrival_time = isset($this->post['arrival_time'])&&$this->post['arrival_time']!==""?$this->post['arrival_time']
  245. :"";
  246. if($arrival_time===""){
  247. return error_show(1004,"参数arrival_time不能为空");
  248. }
  249. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""?trim($this->post['good_img']):"";
  250. if($good_img===""){
  251. return error_show(1004,"参数good_img不能为空");
  252. }
  253. $is_custom = isset($this->post['is_custom'])&&$this->post['is_custom']!==""?intval($this->post['is_custom']):"";
  254. if($is_custom===""){
  255. return error_show(1004,"参数is_custom不能为空");
  256. }
  257. $unit = isset($this->post['unit'])&&$this->post['unit']!==""?trim($this->post['unit']):"";
  258. if($unit===""){
  259. return error_show(1004,"参数unit不能为空");
  260. }
  261. $brand_id = isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"";
  262. if($brand_id===""){
  263. return error_show(1004,"参数brand_id不能为空");
  264. }
  265. $material = isset($this->post['material'])&&$this->post['material']!==""?trim($this->post['material']):"";
  266. if($material===""){
  267. return error_show(1004,"参数material不能为空");
  268. }
  269. $color = isset($this->post['color'])&&$this->post['color']!==""?trim($this->post['color']):"";
  270. if($color===""){
  271. return error_show(1004,"参数color不能为空");
  272. }
  273. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!==""?trim($this->post['cost_desc']):"";
  274. if($cost_desc===""){
  275. return error_show(1004,"参数cost_desc不能为空");
  276. }
  277. $model = isset($this->post['model'])&&$this->post['model']!==""?trim($this->post['model']):"";
  278. if($model===""){
  279. return error_show(1004,"参数model不能为空");
  280. }
  281. $is_addrs = isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  282. if($is_addrs===""){
  283. return error_show(1004,"参数is_addrs不能为空");
  284. }
  285. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!==""?trim($this->post['metal_id']):"";
  286. if($metal_id===""){
  287. return error_show(1004,"参数metal_id不能为空");
  288. }
  289. if($metal_id==0){
  290. $config = isset($this->post['config'])&&!empty($this->post['config'])?$this->post['config']:"";
  291. if($config===""){
  292. return error_show(1004,"参数config不能为空");
  293. }
  294. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""?trim($this->post['other_config'])
  295. :"";
  296. if($other_config===""){
  297. return error_show(1004,"参数other_config不能为空");
  298. }
  299. $specs_weight = isset($this->post['specs_weight'])&&$this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  300. if($specs_weight===""){
  301. return error_show(1004,"参数specs_weight不能为空");
  302. }
  303. $gold_price = isset($this->post['gold_price'])&&$this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  304. if($gold_price===""){
  305. return error_show(1004,"参数gold_price不能为空");
  306. }
  307. }
  308. $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  309. if($budget_price===""){
  310. return error_show(1004,"参数budget_price不能为空");
  311. }
  312. $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
  313. if($num===""){
  314. return error_show(1004,"参数num不能为空");
  315. }
  316. $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!==""?trim($this->post['use_desc']):"";
  317. if($use_desc===""){
  318. return error_show(1004,"参数use_desc不能为空");
  319. }
  320. $remark = isset($this->post['remark'])&&$this->post['remark']!==""?trim($this->post['remark']):"";
  321. if($remark===""){
  322. return error_show(1004,"参数remark不能为空");
  323. }
  324. Db::startTrans();
  325. try{
  326. $infoNo=makeNo("INF");
  327. $info=[
  328. "infoNo"=>$infoNo,
  329. "zxNo"=>$zxNo,
  330. "spuCode"=>"",
  331. "good_name"=>$good_name,
  332. "good_img"=>$good_img,
  333. "cat_id"=>$cat_id,
  334. "unit"=>$unit,
  335. "brand_id"=>$brand_id,
  336. "arrival_time"=>$arrival_time,
  337. "model"=>$model,
  338. "color"=>$color,
  339. "material"=>$material,
  340. "cost_desc"=>$cost_desc,
  341. "is_addrs"=>$is_addrs,
  342. "is_custom"=>$is_custom,
  343. "metal_id"=>$metal_id,
  344. "config"=>isset($config)?$config:"",
  345. "other_config"=>isset($other_config)?$other_config:"",
  346. "specs_weight"=>isset($specs_weight)?$specs_weight:0,
  347. "gold_price"=>isset($gold_price)?$gold_price:0,
  348. "budget_price"=>$budget_price,
  349. "num"=>$num,
  350. "use_desc"=>$use_desc,
  351. "remark"=>$remark,
  352. "status"=>0,
  353. "is_del"=>0,
  354. "addtime"=>date("Y-m-d H:i:s"),
  355. "updatetime"=>date("Y-m-d H:i:s")
  356. ];
  357. $up = Db::name("consult_info")->insert($info);
  358. if($up){
  359. Db::commit();
  360. return app_show(0,"添加成功",["infoNo"=>$infoNo]);
  361. }else{
  362. Db::rollback();
  363. return error_show(1004,'添加失败');
  364. }
  365. }catch (\Exception $e){
  366. Db::rollback();
  367. return error_show(1004,$e->getMessage());
  368. }
  369. }
  370. public function zxinfo(){
  371. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  372. if($infoNo==""){
  373. return error_show(1004,"参数infoNo不能为空");
  374. }
  375. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  376. if($zxinfo==false){
  377. return error_show(1004,"未找到信息数据");
  378. }
  379. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  380. if($zxorder==false){
  381. return error_show(1004,"未找到咨询信息数据");
  382. }
  383. $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
  384. $zxorder['khname']="";
  385. if($zxorder['khNo']!==""){
  386. $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
  387. $zxorder['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  388. }
  389. return app_show(0,"获取成功",$zxinfo);
  390. }
  391. //** 发布竞标任务 */
  392. public function bargain(){
  393. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  394. if($infoNo==""){
  395. return error_show(1004,"参数infoNo不能为空");
  396. }
  397. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  398. if($zxinfo==false){
  399. return error_show(1004,"未找到信息数据");
  400. }
  401. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  402. if($status===""){
  403. return error_show(1004,"参数status不能为空");
  404. }
  405. if($status==1&&$zxinfo['status']>1){
  406. $zxinfo['bargain_num']=+1;
  407. }
  408. $zxinfo['status']=$status;
  409. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  410. $up = Db::name("consult_info")->save($zxinfo);
  411. if($up){
  412. return app_show(0,"状态更新成功");
  413. }else{
  414. return error_show(1003,"状态更新失败");
  415. }
  416. }
  417. public function feadback(){
  418. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  419. if($infoNo==""){
  420. return error_show(1004,"参数infoNo不能为空");
  421. }
  422. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  423. if($zxinfo==false){
  424. return error_show(1004,"未找到信息数据");
  425. }
  426. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  427. if($pname==""){
  428. return error_show(1004,"参数pname不能为空");
  429. }
  430. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  431. if($brandid==""){
  432. return error_show(1004,"参数brandid不能为空");
  433. }
  434. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  435. if($cat_id==""){
  436. return error_show(1004,"参数cat_id不能为空");
  437. }
  438. $model = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
  439. //$unit = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
  440. $material = isset($this->post['material'])&&$this->post['material']!=""? trim($this->post['material']):"";
  441. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  442. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  443. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  444. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  445. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  446. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  447. :"";
  448. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  449. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  450. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  451. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  452. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  453. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  454. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  455. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  456. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  457. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  458. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  459. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  460. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  461. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""? floatval($this->post['nake_fee']):"";
  462. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  463. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  464. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  465. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  466. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  467. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  468. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  469. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  470. if($token==''){
  471. return error_show(1005,"参数token不能为空");
  472. }
  473. $user =GetUserInfo($token);
  474. if(empty($user)||$user['code']!=0){
  475. return error_show(1002,"用户数据不存在");
  476. }
  477. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  478. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  479. $bidNo=makeNo("BD");
  480. $spucode=makeNo("SPU");
  481. $data=[
  482. "bidNo"=>$bidNo,
  483. "infoNo"=>$infoNo,
  484. "zxNo"=>$zxinfo['zxNo'],
  485. "spuCode"=>$spucode,
  486. "good_name"=>$pname,
  487. "brand_id"=>$brandid,
  488. "cat_id"=>$cat_id,
  489. "model"=>$model,
  490. "material"=>$material,
  491. "unit_id"=>$unit_id,
  492. "cost_desc"=>$cost_desc,
  493. "work_day"=>$work_day,
  494. "delivery_day"=>$delivery_day,
  495. "good_img"=>$good_img,
  496. "expire_day"=>$expire_day,
  497. "origin_place"=>$origin_place,
  498. "supplierNo"=>$supplierNo,
  499. "pay_way"=>$pay_way,
  500. "tax"=>$tax,
  501. "send_way"=>$send_way,
  502. "metal_id"=>$metal_id,
  503. "is_gold_price"=>$is_gold_price,
  504. "config"=>$config,
  505. "weight"=>$weight,
  506. "is_diff"=>$is_diff,
  507. "demo_fee"=>$demo_fee,
  508. "delivery_fee"=>$delivery_fee,
  509. "open_fee"=>$open_fee,
  510. "pakge_fee"=>$pakge_fee,
  511. "nake_fee"=>$nake_fee,
  512. "mark_fee"=>$mark_fee,
  513. "cert_fee"=>$cert_fee,
  514. "cost_fee"=>$cost_fee,
  515. "total_fee"=>$total_fee,
  516. "supply_area"=>$supply_area,
  517. "remark"=>$remark,
  518. "sale_price"=>0,
  519. "createrid"=>$createrid,
  520. "creater"=>$creater,
  521. "status"=>0,
  522. "is_del"=>0,
  523. "addtime"=>date("Y-m-d H:i:s"),
  524. "updatetime"=>date("Y-m-d H:i:s")
  525. ];
  526. Db::startTrans();
  527. try{
  528. $insert= Db::name("consult_bids")->insert($data);
  529. if($insert){
  530. $data=[
  531. "spuCode"=>$spucode,
  532. "good_name"=>$pname,
  533. "brand_id"=>$brandid,
  534. "good_unit"=>$unit_id,
  535. "good_type"=>0,
  536. "moq"=>1,
  537. "customized"=>$work_day,
  538. "tax"=>$tax,
  539. "supplierNo"=>$supplierNo,
  540. "is_auth"=>0,
  541. "craft_desc"=>$cost_desc,
  542. "good_remark"=>$remark,
  543. "good_img"=>$good_img,
  544. "good_thumb_img"=>"",
  545. "good_info_img"=>"",
  546. "status"=>0,
  547. "is_del"=>0,
  548. "createrid"=>$createrid,
  549. "creater"=>$creater,
  550. "addtime"=>date("Y-m-d H:i:s"),
  551. "updatetime"=>date("Y-m-d H:i:s")
  552. ];
  553. $good = Db::name("good_zixun")->insert($data);
  554. if($good){
  555. Db::commit();
  556. return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
  557. }else{
  558. Db::rollback();
  559. return error_show(1004,"反馈失败");
  560. }
  561. }else{
  562. Db::rollback();
  563. return error_show(1004,"反馈失败");
  564. }
  565. }catch (\Exception $e){
  566. Db::rollback();
  567. return error_show(1004,$e->getMessage());
  568. }
  569. }
  570. public function feadinfo(){
  571. $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  572. if($bidNo==""){
  573. return error_show(1004,"参数bidNo不能为空");
  574. }
  575. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  576. if($info==false){
  577. return error_show(1004,"未找到商品数据");
  578. }
  579. $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
  580. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  581. $info['cat_info'] = made($info['cat_id'],[]);
  582. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  583. $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  584. if($info['brand_id']!=0){
  585. $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
  586. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  587. }else{
  588. $info["brand_name"]="";
  589. $info["brand_id"]="";
  590. }
  591. return app_show(0,"获取成功",$info);
  592. }
  593. public function bargain_add(){
  594. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  595. if($bidNo===""){
  596. return error_show(1004,"参数bidNo不能为空");
  597. }
  598. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  599. if($info==false){
  600. return error_show(1004,"未找到商品数据");
  601. }
  602. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  603. if($token==''){
  604. return error_show(1005,"参数token不能为空");
  605. }
  606. $user =GetUserInfo($token);
  607. if(empty($user)||$user['code']!=0){
  608. return error_show(1002,"用户数据不存在");
  609. }
  610. $type = isset($this->post['type'])&& $this->post['type']!=""?intval($this->post['type']):"";
  611. if($type===""){
  612. return error_show(1004,"参数type不能为空");
  613. }
  614. $status = isset($this->post['status'])&& $this->post['status']!==""?intval($this->post['status']):"";
  615. if($status===""){
  616. return error_show(1004,"参数status不能为空");
  617. }
  618. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  619. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  620. $bargainNo =makeNo("BAR");
  621. Db::startTrans();
  622. try{
  623. $data=[
  624. "bidsNo"=>$bidNo,
  625. "bargainNo"=>$bargainNo,
  626. "bargain_type"=>$type,
  627. "sale_price"=>$info['sale_price'],
  628. "cost_before_price"=>$info['cost_fee'],
  629. "cost_after_price"=>$info['cost_fee'],
  630. "before_rate"=>$info['cost_fee'],
  631. "after_rate"=>$info['cost_fee'],
  632. "after_price"=>$info['cost_fee'],
  633. "status"=>$status,
  634. "is_del"=>0,
  635. "creater"=>$creater,
  636. "createrid"=>$createrid,
  637. "addtime"=>date("Y-m-d H:i:s"),
  638. "updatetime"=>date("Y-m-d H:i:s")
  639. ];
  640. $int = Db::name("bargain_order")->insert($data);
  641. if($int){
  642. if($type===1){
  643. $info['status']=3;
  644. $info['updatetime']=date("Y-m-d H:i:s");
  645. }
  646. if($type===2){
  647. $info['status']=4;
  648. $status==1?$info['sale_price']=$data['after_price']:"";
  649. $info['updatetime']=date("Y-m-d H:i:s");
  650. }
  651. $up =Db::name("consult_bids")->save($info);
  652. if($up){
  653. Db::commit();
  654. return app_show(0,"审核成功");
  655. }else{
  656. Db::rollback();
  657. return error_show(1004,"审核失败");
  658. }
  659. }
  660. }catch (\Exception $e){
  661. Db::rollback();
  662. return error_show(1004,$e->getMessage());
  663. }
  664. }
  665. public function bidlist(){
  666. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  667. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  668. $where=[['is_del',"=",0]];
  669. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  670. if ($zxNo !== "") {
  671. $where[] = ['zxNo','=',$zxNo];
  672. }
  673. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  674. if ($infoNo !== "") {
  675. $where[] = ['infoNo','=',$infoNo];
  676. }
  677. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  678. if ($bidNo !== "") {
  679. $where[] = ['bidNo','=',$bidNo];
  680. }
  681. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  682. if ($projectNo !== "") {
  683. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  684. ("zxNo");
  685. $where[] = ['zxNo','in',$zxlist];
  686. }
  687. $count = Db::name('consult_bids')->where($where)->count();
  688. $total = ceil($count / $size);
  689. $page = $page >= $total ? $total : $page;
  690. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select();
  691. $data=[];
  692. foreach ($list as $value){
  693. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  694. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  695. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  696. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  697. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  698. if($value['brand_id']!=0){
  699. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  700. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  701. }else{
  702. $value["brand_name"]="";
  703. $value["brand_id"]="";
  704. }
  705. $data[]=$value;
  706. }
  707. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  708. }
  709. }