Suppler.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\Ocr;
  4. use app\BaseController;
  5. use think\App;
  6. use think\facade\Db;
  7. class Suppler extends BaseController
  8. {
  9. public $post = "";
  10. public function __construct(App $app)
  11. {
  12. parent::__construct($app);
  13. $this->post=$this->request->post();
  14. }
  15. public function create(){
  16. $name = isset($this->post['name']) && $this->post['name'] !=="" ? trim($this->post['name']) :"";
  17. if($name==""){
  18. return error_show(1002,"参数name不能为空");
  19. }
  20. $rename = Db::name('supplier')->where(['is_del' => 0, 'name' => $name])->find();
  21. if (!empty($rename)) {
  22. return error_show(1002, "公司名称已存在");
  23. }
  24. $code = rand(0000,9999);
  25. $str = sprintf("%04d",$code);
  26. $tr="GYS-".date("Ymd")."-".$str;
  27. $source= isset($this->post['source']) && $this->post['source']!==""? intval($this->post['source']) :"";
  28. if($source===""){
  29. return error_show(1002,"供应商来源不能为空");
  30. }
  31. $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
  32. if($token==''){
  33. return error_show(1005,"参数token不能为空");
  34. }
  35. $user =GetUserInfo($token);
  36. if(empty($user)||$user['code']!=0){
  37. return error_show(1002,"创建人数据不存在");
  38. }
  39. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  40. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  41. $type = isset($this->post['type']) && $this->post['type']!==""? intval($this->post['type']) :"";
  42. if($type===""){
  43. return error_show(1002,"申请类型不能为空");
  44. }
  45. $coop_state = isset($this->post['coop_state']) && $this->post['coop_state'] !==""? intval($this->post['coop_state']):"";
  46. if($coop_state===""){
  47. return error_show(1002,"参数coop_state不能为空");
  48. }
  49. $category = isset($this->post['category']) && $this->post['category'] !==""? intval($this->post['category']):"";
  50. if($category===""){
  51. return error_show(1002,"参数category不能为空");
  52. }
  53. $delivery_way = isset($this->post['delivery_way']) && $this->post['delivery_way'] !==""? intval($this->post['delivery_way']):"";
  54. if($delivery_way===""){
  55. return error_show(1002,"参数delivery_way不能为空");
  56. }
  57. $level = isset($this->post['level']) && $this->post['level'] !==""? intval($this->post['level']):"";
  58. if($level===""){
  59. return error_show(1002,"参数level不能为空");
  60. }
  61. $supplier_type = isset($this->post['supplier_type']) && $this->post['supplier_type'] !==""? intval($this->post['supplier_type']):"";
  62. if($supplier_type===""){
  63. return error_show(1002,"参数supplier_type不能为空");
  64. }
  65. $pay_type = isset($this->post['pay_type']) && $this->post['pay_type'] !==""? intval($this->post['pay_type']):"";
  66. if($pay_type===""){
  67. return error_show(1002,"参数pay_type不能为空");
  68. }
  69. $prove_img = isset($this->post['prove_img']) && $this->post['prove_img'] !==""? trim($this->post['prove_img']):"";
  70. if($prove_img==""){
  71. return error_show(1002,"参数prove_img不能为空");
  72. }
  73. // $area = isset($this->post['area']) && $this->post['area']!==""? trim($this->post['area']) :"";
  74. // $city = isset($this->post['city']) && $this->post['city']!==""? trim($this->post['city']) :"";
  75. $nature = isset($this->post['nature']) && $this->post['nature']!==""? intval($this->post['nature']) :"";
  76. $is_platform = isset($this->post['is_platform']) && $this->post['is_platform']!==""? intval($this->post['is_platform']) :"0";
  77. $ticket_type = isset($this->post['ticket_type']) && $this->post['ticket_type']!==""? intval($this->post['ticket_type']) :"";
  78. $legaler = isset($this->post['legaler']) && $this->post['legaler']!==""? trim($this->post['legaler']) :"";
  79. $addr = isset($this->post['addr']) && $this->post['addr']!==""? trim($this->post['addr']) :"";
  80. $registercode= isset($this->post['registercode']) && $this->post['registercode']!==""? trim($this->post['registercode']) :"";
  81. $capital= isset($this->post['capital']) && $this->post['capital']!==""? intval($this->post['capital']) :"";
  82. $product_category= isset($this->post['product_category']) && $this->post['product_category']!==""? trim($this->post['product_category']) :"";
  83. $is_payment= isset($this->post['is_payment']) && $this->post['is_payment']!==""?trim($this->post['is_payment']) :"";
  84. $notice_mark= isset($this->post['notice_mark']) && $this->post['notice_mark']!==""?trim($this->post['notice_mark']) :"";
  85. $agreement= isset($this->post['agreement']) && $this->post['agreement']!==""?trim($this->post['agreement']) :"";
  86. $warehouse= isset($this->post['warehouse']) && $this->post['warehouse']!==""?trim($this->post['warehouse']) :"";
  87. $pay_day= isset($this->post['pay_day']) && $this->post['pay_day']!==""?trim($this->post['pay_day']) :"";
  88. $scope= isset($this->post['scope']) && $this->post['scope']!==""?trim($this->post['scope']) :"";
  89. $status= isset($this->post['status']) && $this->post['status']!==""?intval($this->post['status']) :"1";
  90. //$registertime= isset($this->post['registertime']) && $this->post['registertime']!==""?
  91. // $this->post['registertime'] :"";
  92. $supplier_img = isset($this->post['supplier_img']) && $this->post['supplier_img'] !=="" ? trim($this->post['supplier_img']):"";
  93. $contactor = isset($this->post['contactor']) && $this->post['contactor'] !=="" ? trim($this->post['contactor']):"";
  94. if($contactor==""){
  95. return error_show(1002,"参数contactor不能为空");
  96. }
  97. $mobile = isset($this->post['mobile']) && $this->post['mobile'] !=="" ? trim($this->post['mobile']):"";
  98. if($mobile==""){
  99. return error_show(1002,"参数mobile不能为空");
  100. }
  101. $position = isset($this->post['position']) && $this->post['position'] !=="" ? trim($this->post['position']):"";
  102. if($position==""){
  103. return error_show(1002,"参数position不能为空");
  104. }
  105. if($registercode==""){
  106. return error_show(1002,"参数registercode不能为空");
  107. }
  108. Db::startTrans();
  109. try{
  110. $data=[
  111. "name"=>$name,
  112. "source"=>$source,
  113. "coop_state"=>$coop_state,
  114. "category"=>$category,
  115. "delivery_way"=>$delivery_way,
  116. "level"=>$level,
  117. "supplier_type"=>$supplier_type,
  118. "pay_type"=>$pay_type,
  119. "registercode"=>$registercode,
  120. "capital"=>$capital,
  121. "product_category"=>$product_category,
  122. "is_payment"=>$is_payment,
  123. "notice_mark"=>$notice_mark,
  124. "agreement"=>$agreement,
  125. "warehouse"=>$warehouse,
  126. "pay_day"=>$pay_day,
  127. "scope"=>$scope,
  128. "status"=>$status,
  129. "code"=>$tr,
  130. "type"=>$type,
  131. "nature"=>$nature,
  132. "legaler"=>$legaler,
  133. "addr"=>$addr,
  134. "is_del"=>0,
  135. "ticket_type"=>$ticket_type,
  136. "addtime"=>date('Y-m-d H:i:s'),
  137. "updatetime"=>date("Y-m-d H:i:s"),
  138. "is_platform"=>$is_platform,
  139. "prove_img"=>$prove_img,
  140. "license_img"=>$supplier_img,
  141. "creater"=>$creater,
  142. "createrid"=>$createrid,
  143. "registertime"=>date('Y-m-d H:i:s')
  144. ];
  145. if($supplier_img!==""){
  146. $ocr=new Ocr();
  147. $datwa = $ocr->query("",$supplier_img);
  148. // var_dump($data);
  149. if($datwa['code']==0 && isset($datwa['data']['result'])){
  150. $license = $datwa['data']['result'];
  151. $data['legaler']= isset($license['legal_representative'])?$license['legal_representative']:"";
  152. $data['addr']= isset($license['address'])?$license['address']:"";
  153. $data['registertime']= isset($license['found_date'])? date("Y-m-d",strtotime(str_replace(["年","月","日"],[""],$license['found_date']))):"";
  154. $data['scope']= isset($license['business_scope'])?$license['business_scope']:"";
  155. $data['capital']= isset($license['registered_capital'])?str_replace("万元","",$license['registered_capital'])*10000:"";
  156. $data['nature']= isset($license['type'])?$license['type']:"";
  157. $data['status']=1;
  158. if($data['name']!=$license['name']){
  159. $data['remark']="企业名称与营业执照不匹配";
  160. $data['status']=0;
  161. }
  162. if($data['code']!=$license['registration_number']){
  163. $data['remark'].="企业名称与营业执照不匹配";
  164. $data['status']=0;
  165. }
  166. }else{
  167. $data['remark']="营业执照识别失败";
  168. $data['status']=0;
  169. }
  170. }
  171. $join = Db::name('supplier')->insert($data,true);
  172. if($join>0){
  173. $temp = [];
  174. $temp['code']=$tr;
  175. $temp['contactor'] =$contactor;
  176. $temp['mobile'] = $mobile;
  177. $temp['position'] = $position;
  178. $temp['email'] ="";
  179. $temp['is_del'] = 0;
  180. $temp['addtime'] = date("Y-m-d H:i:s");
  181. $temp['updatetime'] = date("Y-m-d H:i:s");
  182. $vp = Db::name('supplier_contact')->insert($temp);
  183. if ($vp == "") {
  184. Db::rollback();
  185. return error_show(1002, "添加失败");
  186. }
  187. Db::commit();
  188. return error_show(0,"添加成功") ;
  189. }else{
  190. Db::rollback();
  191. return error_show(1002,"添加失败");
  192. }
  193. }catch (\Exception $e) {
  194. Db::rollback();
  195. return error_show(1003, $e->getMessage());
  196. }
  197. }
  198. public function list(){
  199. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  200. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  201. $where =[['a.is_del',"=",0]];
  202. $name = isset($this->post['name']) && $this->post['name'] !=="" ? trim($this->post['name']):"";
  203. if($name !==""){
  204. $where[]=["a.name","like","%$name%"];
  205. }
  206. $creater = isset($this->post['creater']) && $this->post['creater'] !=="" ? trim($this->post['creater']):"";
  207. if($creater !==""){
  208. $where[] = ["a.creater","like","%$creater%"];
  209. }
  210. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']):"";
  211. if($status!==""){
  212. $where[]= ["a.status","=",$status];
  213. }
  214. $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  215. if($start!==""){
  216. $where[]=['a.addtime',">=",$start];
  217. }
  218. // $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  219. // if($end !=""){
  220. // $where[]=['a.addtime',"<=",$end];
  221. // }
  222. $contactor = isset($this->post['contactor']) && $this->post['contactor'] !==""? trim($this->post['contactor']):"";
  223. if($contactor !=""){
  224. $where[]=["b.contactor","like","%$contactor%"];
  225. }
  226. $mobile = isset($this->post['mobile']) && $this->post['mobile'] !=="" ? intval($this->post['mobile']):"";
  227. if($mobile !=""){
  228. $where[] = ['b.mobile',"like","%$mobile%"];
  229. }
  230. $count = Db::name('supplier')->alias("a")
  231. ->join("supplier_contact b","b.code=a.code","left")
  232. ->where($where)->count();
  233. $total = ceil($count / $size);
  234. $page = $page >= $total ? $total : $page;
  235. $list = Db::name('supplier')->alias('a')
  236. ->join("supplier_contact b","b.code=a.code","left")
  237. ->where($where)->page($page,$size)->order("a.addtime desc")
  238. ->field("a.*,b.contactor,b.mobile")->select();
  239. return app_show("0","获取成功",['list'=>$list,'count'=>$count]);
  240. }
  241. public function edit(){
  242. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
  243. if($id==""){
  244. return error_show(1002,"参数id不能为空");
  245. }
  246. $info = Db::name("supplier")->where(['id'=>$id,'is_del'=>0])->find();
  247. if($info==""){
  248. return error_show(1002,"未找到数据");
  249. }
  250. $source= isset($this->post['source']) && $this->post['source']!==""? trim($this->post['source']) :"";
  251. if($source==""){
  252. return error_show(1002,"供应商来源不能为空");
  253. }
  254. $type = isset($this->post['type']) && $this->post['type']!==""? trim($this->post['type']) :"";
  255. if($type==""){
  256. return error_show(1002,"申请类型不能为空");
  257. }
  258. $coop_state = isset($this->post['coop_state']) && $this->post['coop_state'] !==""? trim($this->post['coop_state']):"";
  259. if($coop_state==""){
  260. return error_show(1002,"参数coop_state不能为空");
  261. }
  262. $category = isset($this->post['category']) && $this->post['category'] !==""? trim($this->post['category']):"";
  263. if($category==""){
  264. return error_show(1002,"参数category不能为空");
  265. }
  266. $delivery_way = isset($this->post['delivery_way']) && $this->post['delivery_way'] !==""? trim($this->post['delivery_way']):"";
  267. if($delivery_way==""){
  268. return error_show(1002,"参数delivery_way不能为空");
  269. }
  270. $level = isset($this->post['level']) && $this->post['level'] !==""? trim($this->post['level']):"";
  271. if($level==""){
  272. return error_show(1002,"参数level不能为空");
  273. }
  274. $supplier_type = isset($this->post['supplier_type']) && $this->post['supplier_type'] !==""? trim($this->post['supplier_type']):"";
  275. if($supplier_type==""){
  276. return error_show(1002,"参数supplier_type不能为空");
  277. }
  278. $pay_type = isset($this->post['pay_type']) && $this->post['pay_type'] !==""? trim($this->post['pay_type']):"";
  279. if($pay_type==""){
  280. return error_show(1002,"参数pay_type不能为空");
  281. }
  282. $prove_img = isset($this->post['prove_img']) && $this->post['prove_img'] !==""? trim($this->post['prove_img']):"";
  283. if($prove_img==""){
  284. return error_show(1002,"参数prove_img不能为空");
  285. }
  286. $name = isset($this->post['name']) && $this->post['name'] !=="" ? trim($this->post['name']) :"";
  287. if($name==""){
  288. return error_show(1002,"数据标题不能为空");
  289. }
  290. $rename = Db::name('supplier')->where(['is_del' => 0, 'name' => $name])->find();
  291. if (!empty($rename)&&$rename['id']!=$id) {
  292. return error_show(1002, "公司名称已存在");
  293. }
  294. // $nature = isset($this->post['nature']) && $this->post['nature']!==""? trim($this->post['nature']) :"";
  295. $is_platform = isset($this->post['is_platform']) && $this->post['is_platform']!==""? intval($this->post['is_platform']) :"0";
  296. $ticket_type = isset($this->post['ticket_type']) && $this->post['ticket_type']!==""? trim($this->post['ticket_type']) :"";
  297. // $legaler = isset($this->post['legaler']) && $this->post['legaler']!==""? trim($this->post['legaler']) :"";
  298. // $addr = isset($this->post['addr']) && $this->post['addr']!==""? trim($this->post['addr']) :"";
  299. $registercode= isset($this->post['registercode']) && $this->post['registercode']!==""? trim($this->post['registercode']) :"";
  300. // $capital= isset($this->post['capital']) && $this->post['capital']!==""? intval($this->post['capital']) :"";
  301. $product_category= isset($this->post['product_category']) && $this->post['product_category']!==""? trim($this->post['product_category']) :"";
  302. $is_payment= isset($this->post['is_payment']) && $this->post['is_payment']!==""?trim($this->post['is_payment']) :"";
  303. $notice_mark= isset($this->post['notice_mark']) && $this->post['notice_mark']!==""?trim($this->post['notice_mark']) :"";
  304. $agreement= isset($this->post['agreement']) && $this->post['agreement']!==""?trim($this->post['agreement']) :"";
  305. $warehouse= isset($this->post['warehouse']) && $this->post['warehouse']!==""?trim($this->post['warehouse']) :"";
  306. $pay_day= isset($this->post['pay_day']) && $this->post['pay_day']!==""?trim($this->post['pay_day']) :"";
  307. // $scope= isset($this->post['scope']) && $this->post['scope']!==""?trim($this->post['scope']) :"";
  308. //// $status= isset($this->post['status']) && $this->post['status']!==""?trim($this->post['status']) :"";
  309. // $registertime= isset($this->post['registertime']) && $this->post['registertime']!==""? $this->post['registertime'] :"";
  310. $supplier_img = isset($this->post['supplier_img']) && $this->post['supplier_img'] !=="" ? trim($this->post['supplier_img']):"";
  311. $contactor = isset($this->post['contactor']) && $this->post['contactor'] !=="" ? trim($this->post['contactor']):"";
  312. if($contactor==""){
  313. return error_show(1002,"参数contactor不能为空");
  314. }
  315. $mobile = isset($this->post['mobile']) && $this->post['mobile'] !=="" ? trim($this->post['mobile']):"";
  316. if($mobile==""){
  317. return error_show(1002,"参数mobile不能为空");
  318. }
  319. $position = isset($this->post['position']) && $this->post['position'] !=="" ? trim($this->post['position']):"";
  320. if($position==""){
  321. return error_show(1002,"参数position不能为空");
  322. }
  323. if($registercode==""){
  324. return error_show(1002,"参数registercode不能为空");
  325. }
  326. Db::startTrans();
  327. try{
  328. $data=[
  329. "id"=>$id,
  330. "source"=>$source,
  331. "coop_state"=>$coop_state,
  332. "category"=>$category,
  333. "delivery_way"=>$delivery_way,
  334. "level"=>$level,
  335. "supplier_type"=>$supplier_type,
  336. "pay_type"=>$pay_type,
  337. "registercode"=>$registercode,
  338. "product_category"=>$product_category,
  339. "is_payment"=>$is_payment,
  340. "notice_mark"=>$notice_mark,
  341. "agreement"=>$agreement,
  342. "warehouse"=>$warehouse,
  343. "pay_day"=>$pay_day,
  344. "type"=>$type,
  345. "license_img"=>$supplier_img,
  346. "is_del"=>0,
  347. "status"=>$info['license_img']==$supplier_img ? $info['status']:0,
  348. "ticket_type"=>$ticket_type,
  349. "updatetime"=>date("Y-m-d H:i:s"),
  350. "is_platform"=>$is_platform,
  351. "prove_img"=>$prove_img
  352. ];
  353. if($supplier_img!=="" &&$info['license_img']!=$supplier_img){
  354. $ocr=new Ocr();
  355. $dataw = $ocr->query("",$supplier_img);
  356. // var_dump($data);
  357. if($dataw['code']==0 && isset($dataw['data']['result'])){
  358. $license = $dataw['data']['result'];
  359. $data['legaler']= isset($license['legal_representative'])?$license['legal_representative']:"";
  360. $data['addr']= isset($license['address'])?$license['address']:"";
  361. $data['registertime']= isset($license['found_date'])? date("Y-m-d",strtotime(str_replace(["年","月","日"],[""],$license['found_date']))):"";
  362. $data['scope']= isset($license['business_scope'])?$license['business_scope']:"";
  363. $data['capital']= isset($license['registered_capital'])?str_replace("万元","",$license['registered_capital'])*10000:"";
  364. $data['nature']= isset($license['type'])?$license['type']:"";
  365. $data['status']=1;
  366. if($data['name']!=$license['name']){
  367. $data['remark']="企业名称与营业执照不匹配";
  368. $data['status']=0;
  369. }
  370. if($data['code']!=$license['registration_number']){
  371. $data['remark'].="企业名称与营业执照不匹配";
  372. $data['status']=0;
  373. }
  374. }else{
  375. $data['remark']="营业执照识别失败";
  376. $data['status']=0;
  377. }
  378. }
  379. $join = Db::name('supplier')->where(['id'=>$id,'is_del'=>0])->save($data);
  380. if($join){
  381. $item = Db::name('supplier_contact')->where(['code'=>$join['code']])->find();
  382. $temp = [];
  383. isset($item['id']) && $item['id'] !== "" ? $temp['id'] = $item['id'] : '';
  384. $temp['code'] = $info['code'];
  385. $temp['contactor'] = $contactor;
  386. $temp['mobile'] = $mobile;
  387. $temp['position'] = $position;
  388. $temp['email'] ="";
  389. $temp['is_del'] = 0;
  390. isset($item['id']) && $item['id'] !== "" ? '' : $temp['addtime'] = date("Y-m-d H:i:s");
  391. $temp['updatetime'] = date("Y-m-d H:i:s");
  392. $vp = Db::name('supplier_contact')->save($temp);
  393. if ($vp == "") {
  394. Db::rollback();
  395. return error_show(1002, "更新失败");
  396. }
  397. Db::commit();
  398. return error_show(0,"编辑成功") ;
  399. }else{
  400. Db::rollback();
  401. return error_show(1002,"编辑失败");
  402. }
  403. }catch (\Exception $e) {
  404. Db::rollback();
  405. return error_show(1003, $e->getMessage());
  406. }
  407. }
  408. public function info(){
  409. $id = isset($this->post['id'])&& $this->post['id'] !=="" ? intval($this->post['id']) :"";
  410. if($id ==""){
  411. return error_show(1002,"参数id不能为空");
  412. }
  413. $info = Db::name('supplier')->where(['id'=>$id,'is_del'=>0])->find();
  414. if($info==""){
  415. return error_show(1002,"未找到数据");
  416. }
  417. $contact = Db::name("supplier_contact")->where(["code"=>$info['code'],"is_del"=>0])->find();
  418. $info['contactor']=isset($contact['contactor'])? $contact['contactor']:"";
  419. $info['mobile']=isset($contact['mobile'])? $contact['mobile']:"";
  420. $info['position']=isset($contact['position'])? $contact['position']:"";
  421. $info['email']=isset($contact['email'])? $contact['email']:"";
  422. $info['supplier_img']=isset($info['license_img'])? $info['license_img']:"";
  423. return app_show(0,"获取成功",$info);
  424. }
  425. public function del(){
  426. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
  427. $sup = Db::name('supplier')->where(["is_del"=>0,'id'=>$id])->find();
  428. if($sup==false){
  429. return error_show(1002,"供应商信息不存在");
  430. }
  431. $supp= Db::name('supplier')->update(['id'=>$id,'is_del'=>1,"updatetime"=>date("Y-m-d H:i:s")]);
  432. if($supp){
  433. return error_show(0,"删除成功");
  434. }else{
  435. return error_show(1002,"删除失败");
  436. }
  437. }
  438. public function status(){
  439. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
  440. if($id==""){
  441. return error_show(1002,"参数id不能为空");
  442. }
  443. $info = Db::name("supplier")->where([["id","=",$id],["is_del","=",0]])->find();
  444. if(!$info){
  445. return error_show(1002,"未找到对应数据");
  446. }
  447. $status = isset($this->post['status']) && $this->post['status']!==""? intval($this->post['status']):"";
  448. if($status===""){
  449. return error_show(1002,"参数status不能为空");
  450. }
  451. if(!in_array($status,[0,1,2])){
  452. return error_show(1002,"参数status无效");
  453. }
  454. $info['status']=$status;
  455. $info['updatetime']=date("Y-m-d H:i:s");
  456. $msg = $status==1?"启用":"禁用";
  457. $update = Db::name("supplier")->save($info);
  458. return $update? error_show(0,"{$msg}成功"):error_show(1004,"{$msg}失败");
  459. }
  460. }