Business.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. use think\facade\Validate;
  7. //业务企业
  8. class Business extends Base
  9. {
  10. //业务企业只能从供应商升级而来
  11. public function create()
  12. {
  13. $companyNo = makeNo("GS");
  14. $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
  15. if ($company == "") {
  16. return error_show(1002, "参数company不能为空");
  17. }
  18. $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
  19. if ($type == "") {
  20. return error_show(1002, "参数type不能为空");
  21. }
  22. $inv_code = isset($this->post['inv_code']) && $this->post['inv_code'] !== "" ? trim($this->post['inv_code']) : "";
  23. if ($inv_code == "") {
  24. return error_show(1002, "参数inv_code不能为空");
  25. }
  26. $inv_legaler = isset($this->post['inv_legaler']) && $this->post['inv_legaler'] !== "" ? trim($this->post['inv_legaler']) : "";
  27. if ($inv_legaler == "") {
  28. return error_show(1002, "参数inv_legaler不能为空");
  29. }
  30. $inv_time = isset($this->post['inv_time']) && $this->post['inv_time'] !== "" ? $this->post['inv_time'] : "";
  31. if ($inv_time == "") {
  32. return error_show(1005, '参数inv_time不能为空');
  33. }
  34. $inv_addr = isset($this->post['inv_addr']) && $this->post['inv_addr'] !== "" ? trim($this->post['inv_addr']) : "";
  35. if ($inv_addr == "") {
  36. return error_show(1002, "参数inv_addr不能为空");
  37. }
  38. $inv_bank = isset($this->post['inv_bank']) && $this->post['inv_bank'] !== "" ? trim($this->post['inv_bank']) : "";
  39. if ($inv_bank == "") {
  40. return error_show(1002, "参数inv_bank不能为空");
  41. }
  42. $inv_bankNo = isset($this->post['inv_bankNo']) && $this->post['inv_bankNo'] !== "" ? trim($this->post['inv_bankNo']) : "";
  43. if ($inv_bankNo == "") {
  44. return error_show(1002, "参数inv_bankNo不能为空");
  45. }
  46. $contactor = isset($this->post['contactor']) && $this->post['contactor'] !== "" ? trim($this->post['contactor']) : "";
  47. if ($contactor == "") {
  48. return error_show(1002, "参数contactor不能为空");
  49. }
  50. $mobile = isset($this->post['mobile']) && $this->post['mobile'] !== "" ? trim($this->post['mobile']) : "";
  51. if ($mobile == "") {
  52. return error_show(1002, "参数mobile不能为空");
  53. }
  54. $addr = isset($this->post['addr']) && $this->post['addr'] !== "" ? trim($this->post['addr']) : "";
  55. if ($addr == "") {
  56. return error_show(1002, "参数addr不能为空");
  57. }
  58. $inv_scope = isset($this->post['inv_scope']) && $this->post['inv_scope'] !== "" ? trim($this->post['inv_scope']) : "";
  59. if ($inv_scope == "") {
  60. return error_show(1002, "参数inv_scope不能为空");
  61. }
  62. $license_img = isset($this->post['license_img']) && $this->post['license_img'] !== "" ? trim($this->post['license_img']) : "";
  63. $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
  64. if ($token == '') {
  65. return error_show(105, "参数token不能为空");
  66. }
  67. $createrid = $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
  68. $creater = $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  69. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "1";
  70. $data = [
  71. "company" => $company,
  72. "companyNo" => $companyNo,
  73. "inv_code" => $inv_code,
  74. "type" => $type,
  75. "inv_legaler" => $inv_legaler,
  76. "inv_time" => $inv_time,
  77. "inv_addr" => $inv_addr,
  78. "inv_bank" => $inv_bank,
  79. "inv_bankNo" => $inv_bankNo,
  80. "contactor" => $contactor,
  81. "mobile" => $mobile,
  82. "addr" => $addr,
  83. "creater" => $creater,
  84. "createrid" => $createrid,
  85. "inv_scope" => $inv_scope,
  86. "license_img" => $license_img,
  87. "status" => $status,
  88. "is_del" => 0,
  89. "addtime" => date("Y-m-d H:i:s"),
  90. "updatetime" => date("Y-m-d H:i:s")
  91. ];
  92. $userCommon = \app\admin\common\User::getIns();
  93. $rs = $userCommon->handle('bCreate', $data);
  94. return json_show($rs['code'], $rs['message'], $rs['data']);
  95. }
  96. public function list()
  97. {
  98. $param = $this->request->only([
  99. 'page' => 1,
  100. 'size' => 10,
  101. 'company' => '',
  102. 'status' => '',
  103. 'creater' => '',
  104. 'start' => '',
  105. 'end' => '',
  106. 'company_name' => '',
  107. ], 'post', 'trim');
  108. $userCommon =\app\admin\common\User::getIns();
  109. $rs = $userCommon->handle('bGetList', $param);
  110. return json_show($rs['code'], $rs['message'], $rs['data']);
  111. }
  112. public function edit()
  113. {
  114. $param = $this->request->only(['id', 'inv_addr', 'inv_bank', 'inv_bankNo', 'invoice_mobile','invoice_title'], 'post', 'trim');
  115. $val = Validate::rule([
  116. 'id' => 'require|number|gt:0',
  117. 'inv_addr' => 'require|max:255',
  118. 'inv_bank' => 'require|max:255',
  119. 'inv_bankNo' => 'require|max:255',
  120. 'invoice_mobile' => 'require|max:255',
  121. 'invoice_title' => 'require|max:255',
  122. ]);
  123. if ($val->check($param) == false) return json_show(1005, $val->getError());
  124. $param['updatetime'] = date("Y-m-d H:i:s");
  125. $userCommon = \app\admin\common\User::getIns();
  126. $rs = $userCommon->handle('bEdit', $param);
  127. return json_show($rs['code'], $rs['message'], $rs['data']);
  128. }
  129. public function del()
  130. {
  131. $param = $this->request->only(['id' => 0], 'post', 'trim');
  132. $userCommon = \app\admin\common\User::getIns();
  133. $rs = $userCommon->handle('delete', [
  134. 'ids' => [$param['id']],
  135. 'type' => 1,
  136. 'updater' => $this->uname,
  137. 'updaterid' => $this->uid,
  138. ]);
  139. return json_show($rs['code'], $rs['message'], $rs['data']);
  140. }
  141. public function status()
  142. {
  143. $param = $this->request->only(['id', 'status'], 'post', 'trim');
  144. $val = Validate::rule([
  145. 'id' => 'require|number|gt:0',
  146. 'status|状态' => 'require|number|in:0,1'
  147. ]);
  148. if (!$val->check($param)) return json_show(1005, $val->getError());
  149. $userCommon = \app\admin\common\User::getIns();
  150. $rs = $userCommon->handle('status', [
  151. 'id' => $param['id'],
  152. 'status' => $param['status'],
  153. 'type' => 1,
  154. 'updater' => $this->uname,
  155. 'updaterid' => $this->uid,
  156. ]);
  157. return json_show($rs['code'], $rs['message'], $rs['data']);
  158. }
  159. public function info()
  160. {
  161. $param = $this->request->only(['companyNo'], 'post', 'trim');
  162. $userCommon = \app\admin\common\User::getIns();
  163. $rs = $userCommon->handle('bInfo', $param);
  164. return json_show($rs['code'], $rs['message'], $rs['data']);
  165. }
  166. public function title()
  167. {
  168. $param = $this->request->only(['company_type' => '', 'status' => ''], 'post', 'trim');
  169. $userCommon = \app\admin\common\User::getIns();
  170. $rs = $userCommon->handle('bTitle', $param);
  171. return json_show($rs['code'], $rs['message'], $rs['data']);
  172. }
  173. }