WareHouse.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. class WareHouse extends BaseController
  7. {
  8. public function __construct(App $app)
  9. {
  10. parent::__construct($app);
  11. $post =$this->request->post();
  12. $token = isset($post['token']) ? trim($post['token']) : "";
  13. // if($token==""){
  14. // return error_show(101,'token不能为空');
  15. //
  16. // }
  17. // $effetc = VerifyTokens($token);
  18. // if(!empty($effetc) && $effetc['code']!=0){
  19. // return error_show($effetc['code'],$effetc['message']);
  20. //
  21. // }
  22. }
  23. public function add(){
  24. $post =$this->request->post();
  25. $name = isset($post['name'])&& $post['name']!='' ?trim($post['name']) :'';
  26. if($name==''){
  27. return error_show(1004,'参数name 不能为空');
  28. }
  29. $supplier = isset($post['supplierid'])&& $post['supplierid']!='' ?intval($post['supplierid']) :'';
  30. if($supplier==''){
  31. return error_show(1004,'参数supplierid 不能为空');
  32. }
  33. $wsmtype = isset($post['wsmtype'])&& $post['wsmtype']!='' ?intval($post['wsmtype']) :'';
  34. if($wsmtype==''){
  35. return error_show(1004,'参数wsmtype 不能为空');
  36. }
  37. $isT = Db::name('warehouse_info')->where([['name',"=",$name]])->find();
  38. if(!empty($isT)){
  39. return error_show(1004,'仓库名称已存在');
  40. }
  41. $addr = isset($post['addr'])&& $post['addr']!='' ?trim($post['addr']) :'';
  42. if($addr==''){
  43. return error_show(1004,'参数addr 不能为空');
  44. }
  45. $contactor = isset($post['contactor'])&& $post['contactor']!='' ?trim($post['contactor']) :'';
  46. if($contactor==''){
  47. return error_show(1004,'参数contactor 不能为空');
  48. }
  49. $mobile = isset($post['mobile'])&& $post['mobile']!='' ?trim($post['mobile']) :'';
  50. if($mobile==''){
  51. return error_show(1004,'参数mobile 不能为空');
  52. }
  53. $position = isset($post['position'])&& $post['position']!='' ?trim($post['position']) :'';
  54. $data =[
  55. 'wsm_code'=>makeNo("WSM"),
  56. 'name'=>$name,
  57. 'wsm_type'=>$wsmtype,
  58. 'supplierid'=>$supplier,
  59. 'addr'=>$addr,
  60. 'contactor'=>$contactor,
  61. 'mobile'=>$mobile,
  62. 'position'=>$position,
  63. 'status'=>1,
  64. 'addtime'=>date("Y-m-d H:i:s"),
  65. 'updatetime'=>date("Y-m-d H:i:s")
  66. ];
  67. $add = Db::name('warehouse_info')->insert($data);
  68. return $add ? app_show(0,'仓库创建成功'): error_show(1005,'仓库创建失败');
  69. }
  70. public function list(){
  71. $post =$this->request->post();
  72. $supplier = isset($post['supplierid'])&& $post['supplierid']!='' ?intval($post['supplierid']) :'';
  73. if($supplier==''){
  74. return error_show(1004,'参数supplierid 不能为空');
  75. }
  76. }
  77. }