Suppler.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\Ocr;
  4. use app\admin\model\ChangeLog;
  5. use think\App;
  6. use think\Exception;
  7. use think\facade\Config;
  8. use think\facade\Db;
  9. use think\facade\Validate;
  10. //供应商
  11. class Suppler extends Base
  12. {
  13. public function create()
  14. {
  15. $name = isset($this->post['name']) && $this->post['name'] !== "" ? trim($this->post['name']) : "";
  16. if ($name == "") {
  17. return error_show(1002, "参数name不能为空");
  18. }
  19. $tr = makeNo("QS");
  20. $source = isset($this->post['source']) && $this->post['source'] !== "" ? intval($this->post['source']) : "";
  21. if ($source === "") {
  22. return error_show(1002, "供应商来源不能为空");
  23. }
  24. $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
  25. // if ($token == '') {
  26. // return error_show(105, "参数token不能为空");
  27. // }
  28. // $user = GetUserInfo($token);
  29. // if (empty($user) || $user['code'] != 0) {
  30. // return error_show(1002, "创建人数据不存在");
  31. // }
  32. $createrid = $this->uid;
  33. $creater = $this->uname;
  34. $personid = isset($this->post['personid']) && $this->post['personid'] !== "" ? intval($this->post['personid']) : "";
  35. if ($personid == "") {
  36. return error_show(1002, "参数personid不能为空");
  37. }
  38. $to = GetInfoById($token, ['id' => $personid]);
  39. if (empty($to) || $to['code'] != 0) {
  40. return app_show(1002, "负责人信息不存在");
  41. }
  42. $person = isset($to['data']['nickname']) && $to['data']['nickname'] != "" ? $to['data']['nickname'] : "";
  43. $type = isset($this->post['type']) && $this->post['type'] !== "" ? intval($this->post['type']) : "";
  44. if ($type === "") {
  45. return error_show(1002, "申请类型不能为空");
  46. }
  47. $coop_state = isset($this->post['coop_state']) && $this->post['coop_state'] !== "" ? intval($this->post['coop_state']) : "";
  48. if ($coop_state === "") {
  49. return error_show(1002, "参数coop_state不能为空");
  50. }
  51. $category = isset($this->post['category']) && $this->post['category'] !== "" ? intval($this->post['category']) : "";
  52. if ($category === "") {
  53. return error_show(1002, "参数category不能为空");
  54. }
  55. $delivery_way = isset($this->post['delivery_way']) && $this->post['delivery_way'] !== "" ? intval($this->post['delivery_way']) : "";
  56. if ($delivery_way === "") {
  57. return error_show(1002, "参数delivery_way不能为空");
  58. }
  59. $level = isset($this->post['level']) && $this->post['level'] !== "" ? trim($this->post['level']) : "";
  60. if ($level === "") {
  61. return error_show(1002, "参数level不能为空");
  62. }
  63. $supplier_type = isset($this->post['supplier_type']) && $this->post['supplier_type'] !== "" ? intval($this->post['supplier_type']) : "";
  64. if ($supplier_type === "") {
  65. return error_show(1002, "参数supplier_type不能为空");
  66. }
  67. $pay_type = isset($this->post['pay_type']) && $this->post['pay_type'] !== "" ? intval($this->post['pay_type']) : "";
  68. if ($pay_type === "") {
  69. return error_show(1002, "参数pay_type不能为空");
  70. }
  71. $prove_img = isset($this->post['prove_img']) && $this->post['prove_img'] !== "" ? trim($this->post['prove_img']) : "";
  72. // $area = isset($this->post['area']) && $this->post['area']!==""? trim($this->post['area']) :"";
  73. // $city = isset($this->post['city']) && $this->post['city']!==""? trim($this->post['city']) :"";
  74. $nature = isset($this->post['nature']) && $this->post['nature'] !== "" ? intval($this->post['nature']) : "";
  75. $is_platform = isset($this->post['is_platform']) && $this->post['is_platform'] !== "" ? intval($this->post['is_platform']) : "0";
  76. $ticket_type = isset($this->post['ticket_type']) && $this->post['ticket_type'] !== "" ? intval($this->post['ticket_type']) : "";
  77. $legaler = isset($this->post['legaler']) && $this->post['legaler'] !== "" ? trim($this->post['legaler']) : "";
  78. $addr = isset($this->post['addr']) && $this->post['addr'] !== "" ? trim($this->post['addr']) : "";
  79. $registercode = isset($this->post['registercode']) && $this->post['registercode'] !== "" ? trim($this->post['registercode']) : "";
  80. $capital = isset($this->post['capital']) && $this->post['capital'] !== "" ? intval($this->post['capital']) : "";
  81. $product_category = isset($this->post['product_category']) && $this->post['product_category'] !== "" ? trim($this->post['product_category']) : "";
  82. $is_payment = isset($this->post['is_payment']) && $this->post['is_payment'] !== "" ? trim($this->post['is_payment']) : "";
  83. $notice_mark = isset($this->post['notice_mark']) && $this->post['notice_mark'] !== "" ? trim($this->post['notice_mark']) : "";
  84. $agreement = isset($this->post['agreement']) && $this->post['agreement'] !== "" ? trim($this->post['agreement']) : "";
  85. $warehouse = isset($this->post['warehouse']) && $this->post['warehouse'] !== "" ? trim($this->post['warehouse']) : "";
  86. $pay_day = isset($this->post['pay_day']) && $this->post['pay_day'] !== "" ? trim($this->post['pay_day']) : "";
  87. $scope = isset($this->post['scope']) && $this->post['scope'] !== "" ? trim($this->post['scope']) : "";
  88. // $status= isset($this->post['status']) && $this->post['status']!==""?intval($this->post['status']) :"1";
  89. //$registertime= isset($this->post['registertime']) && $this->post['registertime']!==""?
  90. // $this->post['registertime'] :"";
  91. $supplier_img = isset($this->post['supplier_img']) && $this->post['supplier_img'] !== "" ? trim($this->post['supplier_img']) : "";
  92. $contactor = isset($this->post['contactor']) && $this->post['contactor'] !== "" ? trim($this->post['contactor']) : "";
  93. if ($contactor == "") {
  94. return error_show(1002, "参数contactor不能为空");
  95. }
  96. $mobile = isset($this->post['mobile']) && $this->post['mobile'] !== "" ? trim($this->post['mobile']) : "";
  97. if ($mobile == "") {
  98. return error_show(1002, "参数mobile不能为空");
  99. }
  100. $telephone = isset($this->post['telephone']) && $this->post['telephone'] !== "" ? trim($this->post['telephone']) : "";
  101. $position = isset($this->post['position']) && $this->post['position'] !== "" ? trim($this->post['position']) : "";
  102. if ($position == "") {
  103. return error_show(1002, "参数position不能为空");
  104. }
  105. $email = isset($this->post['email']) && $this->post['email'] !== "" ? trim($this->post['email']) : "";
  106. // Db::startTrans();
  107. // try {
  108. $date = date('Y-m-d H:i:s');
  109. $data = [
  110. "name" => $name,
  111. "source" => $source,
  112. "coop_state" => $coop_state,
  113. "category" => $category,
  114. "delivery_way" => $delivery_way,
  115. "level" => $level,
  116. "supplier_type" => $supplier_type,
  117. "pay_type" => $pay_type,
  118. "registercode" => $registercode,
  119. "capital" => $capital,
  120. "product_category" => $product_category,
  121. "is_payment" => $is_payment,
  122. "notice_mark" => $notice_mark,
  123. "agreement" => $agreement,
  124. "warehouse" => $warehouse,
  125. "pay_day" => $pay_day,
  126. "scope" => $scope,
  127. "code" => $tr,
  128. "type" => $type,
  129. "nature" => $nature,
  130. "legaler" => $legaler,
  131. "addr" => $addr,
  132. "status" => 0,
  133. "is_del" => 0,
  134. "remark" => '',
  135. "ticket_type" => $ticket_type,
  136. "addtime" => $date,
  137. "updatetime" => $date,
  138. "is_platform" => $is_platform,
  139. "prove_img" => $prove_img,
  140. "license_img" => $supplier_img,
  141. "creater" => $creater,
  142. "createrid" => $createrid,
  143. "registertime" => $date,
  144. "person" => $person,
  145. "personid" => $personid,
  146. ];
  147. if ($supplier_img !== "") {
  148. $ocr = new Ocr();
  149. $datwa = $ocr->query("", $supplier_img);
  150. if ($datwa['code'] == 0 && isset($datwa['data']['result'])) {
  151. $license = $datwa['data']['result'];
  152. $data['legaler'] = isset($license['legal_representative']) ? $license['legal_representative'] : "";
  153. $data['addr'] = isset($license['address']) ? $license['address'] : "";
  154. $data['registertime'] = isset($license['found_date']) ? $license['found_date'] : "";
  155. $data['scope'] = isset($license['business_scope']) ? $license['business_scope'] : "";
  156. $data['capital'] = isset($license['registered_capital']) ? $license['registered_capital'] : "";
  157. $data['nature'] = isset($license['type']) ? $license['type'] : "";
  158. $data['registercode'] = isset($license['registration_number']) ? $license['registration_number'] : "";
  159. $data['ocr_status'] = 1;
  160. if ($name != $license['name']) {
  161. $data['remark'] = "企业名称与营业执照不匹配";
  162. $data['status'] = 0;
  163. $data['ocr_status'] = 1;
  164. }
  165. if ($registercode != $license['registration_number'] && $registercode != "") {
  166. $data['remark'] .= "企业名称与营业执照不匹配";
  167. $data['status'] = 0;
  168. $data['ocr_status'] = 1;
  169. }
  170. } else {
  171. $data['remark'] = "营业执照识别失败";
  172. $data['status'] = 0;
  173. $data['ocr_status'] = 2;
  174. }
  175. }
  176. // $join = Db::name('supplier')->insert($data, true);
  177. // if ($join > 0) {
  178. $temp = [];
  179. $temp['code'] = $tr;
  180. $temp['contactor'] = $contactor;
  181. $temp['mobile'] = $mobile;
  182. $temp['position'] = $position;
  183. $temp['telephone'] = $telephone;
  184. $temp['email'] = $email;
  185. $temp['is_del'] = 0;
  186. $temp['addtime'] = $date;
  187. $temp['updatetime'] = $date;
  188. // $vp = Db::name('supplier_contact')->insert($temp);
  189. $userCommon = \app\admin\common\User::getIns();
  190. $rs = $userCommon->handle('sCreate', ['data' => $data, 'contact' => $temp]);
  191. return json_show($rs['code'], $rs['message'], $rs['data']);
  192. }
  193. public function list()
  194. {
  195. $param = $this->request->only(['page' => 1, 'size' => 10, 'name' => '', 'creater' => '', 'person' => '', 'status' => '', 'ocr_status' => '', 'start' => '', 'end' => '', 'company_name' => ''], 'post', 'trim');
  196. $userCommon = \app\admin\common\User::getIns();
  197. $rs = $userCommon->handle('sGetList', $param);
  198. return json_show($rs['code'], $rs['message'], $rs['data']);
  199. /*
  200. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  201. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  202. $where = [['s.is_del', "=", 0]];
  203. $name = isset($this->post['name']) && $this->post['name'] !== "" ? trim($this->post['name']) : "";
  204. if ($name !== "") {
  205. $where[] = ["s.name", "like", "%$name%"];
  206. }
  207. $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
  208. if ($creater !== "") {
  209. $where[] = ["s.creater", "like", "%$creater%"];
  210. }
  211. $person = isset($this->post['person']) && $this->post['person'] !== "" ? trim($this->post['person']) : "";
  212. if ($person !== "") {
  213. $where[] = ["s.person", "like", "%$person%"];
  214. }
  215. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  216. if ($status !== "") {
  217. $where[] = ["s.status", "=", $status];
  218. }
  219. $ocr_status = isset($this->post['ocr_status']) && $this->post['ocr_status'] !== "" ? intval($this->post['ocr_status']) : "";
  220. if ($ocr_status !== "") {
  221. $where[] = ["s.ocr_status", "=", $ocr_status];
  222. }
  223. $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
  224. if ($start !== "") {
  225. $where[] = ['s.addtime', ">=", $start];
  226. }
  227. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  228. if ($company_name !== "") $where[] = ["s.createrid", 'in', get_company_item_user_by_name($company_name)];
  229. // $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  230. // if($end !=""){
  231. // $where[]=['s.addtime',"<=",$end];
  232. // }
  233. // $contactor = isset($this->post['contactor']) && $this->post['contactor'] !==""? trim($this->post['contactor']):"";
  234. // if($contactor !=""){
  235. // $where[]=["s.contactor","like","%$contactor%"];
  236. // }
  237. // $mobile = isset($this->post['mobile']) && $this->post['mobile'] !=="" ? intval($this->post['mobile']):"";
  238. // if($mobile !=""){
  239. // $where[] = ['s.mobile',"like","%$mobile%"];
  240. // }
  241. $count = Db::name('supplier')
  242. ->alias('s')
  243. ->where($where)
  244. ->count();
  245. $total = ceil($count / $size);
  246. $page = $page >= $total ? $total : $page;
  247. // $list = Db::name('supplier')->alias('a')
  248. // ->join("supplier_contact b","b.code=a.code","left")
  249. // ->where($where)->page($page,$size)->order("a.addtime desc")
  250. // ->field("a.*,b.contactor,b.mobile")->select();
  251. $list = Db::name('supplier')
  252. ->alias('s')
  253. ->field('s.*,u.itemid')
  254. ->leftJoin("depart_user u", "u.uid=s.createrid AND u.is_del=0")
  255. ->where($where)
  256. ->page($page, $size)
  257. ->order("addtime desc")
  258. ->select()
  259. ->toArray();
  260. $all_codes = Db::name('supplier_contact')
  261. ->whereIn('code', array_column($list, 'code'))
  262. ->column("id,contactor,mobile", 'code');
  263. //获取开通账号的供应商
  264. $account = checkHasAccountBySupplierNos(array_column($list,'code'));
  265. foreach ($list as &$value) {
  266. $value['contactor'] = isset($all_codes[$value['code']]['contactor']) ? $all_codes[$value['code']]['contactor'] : '';
  267. $value['mobile'] = isset($all_codes[$value['code']]['mobile']) ? $all_codes[$value['code']]['mobile'] : '';
  268. $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
  269. $value['has_account'] = (int)isset($account[$value['code']]);
  270. }
  271. return app_show("0", "获取成功", ['list' => $list, 'count' => $count]);
  272. */
  273. }
  274. public function edit()
  275. {
  276. $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
  277. if ($token == '') {
  278. return error_show(105, "参数token不能为空");
  279. }
  280. $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
  281. if ($id == "") {
  282. return error_show(1002, "参数id不能为空");
  283. }
  284. $code = $this->request->only(['code' => ''], 'post', 'trim');
  285. $userCommon = \app\admin\common\User::getIns();
  286. $info = $userCommon->handle('sInfo', $code);
  287. if (!isset($info['code']) || $info['code'] != 0) return json_show($info['code'], $info['message']);
  288. //
  289. if ($info['data']['status'] == 1) return json_show(1002, "状态是启用状态,无法编辑");
  290. $source = isset($this->post['source']) && $this->post['source'] !== "" ? trim($this->post['source']) : "";
  291. if ($source == "") {
  292. return error_show(1002, "供应商来源不能为空");
  293. }
  294. $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
  295. if ($type == "") {
  296. return error_show(1002, "申请类型不能为空");
  297. }
  298. $coop_state = isset($this->post['coop_state']) && $this->post['coop_state'] !== "" ? trim($this->post['coop_state']) : "";
  299. if ($coop_state == "") {
  300. return error_show(1002, "参数coop_state不能为空");
  301. }
  302. $category = isset($this->post['category']) && $this->post['category'] !== "" ? trim($this->post['category']) : "";
  303. if ($category == "") {
  304. return error_show(1002, "参数category不能为空");
  305. }
  306. $delivery_way = isset($this->post['delivery_way']) && $this->post['delivery_way'] !== "" ? trim($this->post['delivery_way']) : "";
  307. if ($delivery_way == "") {
  308. return error_show(1002, "参数delivery_way不能为空");
  309. }
  310. $level = isset($this->post['level']) && $this->post['level'] !== "" ? trim($this->post['level']) : "";
  311. if ($level == "") {
  312. return error_show(1002, "参数level不能为空");
  313. }
  314. $supplier_type = isset($this->post['supplier_type']) && $this->post['supplier_type'] !== "" ? trim($this->post['supplier_type']) : "";
  315. if ($supplier_type == "") {
  316. return error_show(1002, "参数supplier_type不能为空");
  317. }
  318. $pay_type = isset($this->post['pay_type']) && $this->post['pay_type'] !== "" ? trim($this->post['pay_type']) : "";
  319. if ($pay_type == "") {
  320. return error_show(1002, "参数pay_type不能为空");
  321. }
  322. $prove_img = isset($this->post['prove_img']) && $this->post['prove_img'] !== "" ? trim($this->post['prove_img']) : "";
  323. $personid = isset($this->post['personid']) && $this->post['personid'] !== "" ? intval($this->post['personid']) : "";
  324. if ($personid == "") {
  325. return error_show(1002, "参数personid不能为空");
  326. }
  327. $to = GetInfoById($token, ['id' => $personid]);
  328. if (empty($to) || $to['code'] != 0) {
  329. return app_show(1002, "负责人信息不存在");
  330. }
  331. $telephone = isset($this->post['telephone']) && $this->post['telephone'] !== "" ? trim($this->post['telephone']) : "";
  332. $person = isset($to['data']['nickname']) && $to['data']['nickname'] != "" ? $to['data']['nickname'] : "";
  333. $name = isset($this->post['name']) && $this->post['name'] !== "" ? trim($this->post['name']) : "";
  334. if ($name == "") {
  335. return error_show(1002, "数据标题不能为空");
  336. }
  337. $is_platform = isset($this->post['is_platform']) && $this->post['is_platform'] !== "" ? intval($this->post['is_platform']) : "0";
  338. $ticket_type = isset($this->post['ticket_type']) && $this->post['ticket_type'] !== "" ? trim($this->post['ticket_type']) : "";
  339. $registercode = isset($this->post['registercode']) && $this->post['registercode'] !== "" ? trim($this->post['registercode']) : "";
  340. // $capital= isset($this->post['capital']) && $this->post['capital']!==""? intval($this->post['capital']) :"";
  341. $product_category = isset($this->post['product_category']) && $this->post['product_category'] !== "" ? trim($this->post['product_category']) : "";
  342. $is_payment = isset($this->post['is_payment']) && $this->post['is_payment'] !== "" ? trim($this->post['is_payment']) : "";
  343. $notice_mark = isset($this->post['notice_mark']) && $this->post['notice_mark'] !== "" ? trim($this->post['notice_mark']) : "";
  344. $agreement = isset($this->post['agreement']) && $this->post['agreement'] !== "" ? trim($this->post['agreement']) : "";
  345. $warehouse = isset($this->post['warehouse']) && $this->post['warehouse'] !== "" ? trim($this->post['warehouse']) : "";
  346. $pay_day = isset($this->post['pay_day']) && $this->post['pay_day'] !== "" ? trim($this->post['pay_day']) : "";
  347. $scope= isset($this->post['scope']) && $this->post['scope']!==""?trim($this->post['scope']) :"";
  348. //// $status= isset($this->post['status']) && $this->post['status']!==""?trim($this->post['status']) :"";
  349. // $registertime= isset($this->post['registertime']) && $this->post['registertime']!==""? $this->post['registertime'] :"";
  350. $supplier_img = isset($this->post['supplier_img']) && $this->post['supplier_img'] !== "" ? trim($this->post['supplier_img']) : "";
  351. $contactor = isset($this->post['contactor']) && $this->post['contactor'] !== "" ? trim($this->post['contactor']) : "";
  352. if ($contactor == "") {
  353. return error_show(1002, "参数contactor不能为空");
  354. }
  355. $mobile = isset($this->post['mobile']) && $this->post['mobile'] !== "" ? trim($this->post['mobile']) : "";
  356. if ($mobile == "") {
  357. return error_show(1002, "参数mobile不能为空");
  358. }
  359. $position = isset($this->post['position']) && $this->post['position'] !== "" ? trim($this->post['position']) : "";
  360. if ($position == "") {
  361. return error_show(1002, "参数position不能为空");
  362. }
  363. $email = isset($this->post['email']) && $this->post['email'] !== "" ? trim($this->post['email']) : "";
  364. // if($registercode==""){
  365. // return error_show(1002,"参数registercode不能为空");
  366. // }
  367. // Db::startTrans();
  368. // try {
  369. $data = [
  370. "id" => $id,
  371. "source" => $source,
  372. "name" => $name,
  373. "code" => $code['code'],
  374. "coop_state" => $coop_state,
  375. "category" => $category,
  376. "delivery_way" => $delivery_way,
  377. "level" => $level,
  378. "supplier_type" => $supplier_type,
  379. "pay_type" => $pay_type,
  380. "registercode" => $registercode,
  381. "product_category" => $product_category,
  382. "is_payment" => $is_payment,
  383. "notice_mark" => $notice_mark,
  384. "agreement" => $agreement,
  385. "warehouse" => $warehouse,
  386. "pay_day" => $pay_day,
  387. "type" => $type,
  388. "license_img" => $supplier_img ?:$info['data']['license_img'],
  389. "is_del" => 0,
  390. "scope"=>$scope,
  391. "ticket_type" => $ticket_type,
  392. "updatetime" => date("Y-m-d H:i:s"),
  393. "is_platform" => $is_platform,
  394. "prove_img" => $prove_img,
  395. "person" => $person,
  396. "personid" => $personid,
  397. "remark" => "",
  398. 'updaterid' => $this->uid,
  399. 'updater' => $this->uname,
  400. ];
  401. if ($supplier_img !== "" && $info['data']['license_img'] != $supplier_img) {
  402. $ocr = new Ocr();
  403. $dataw = $ocr->query("", $supplier_img);
  404. if ($dataw['code'] == 0 && isset($dataw['data']['result'])) {
  405. $license = $dataw['data']['result'];
  406. $data['legaler'] = isset($license['legal_representative']) ? $license['legal_representative'] : "";
  407. $data['addr'] = isset($license['address']) ? $license['address'] : "";
  408. $data['registertime'] = isset($license['found_date']) ? $license['found_date'] : "";
  409. $data['scope'] = isset($license['business_scope']) ? $license['business_scope'] : "";
  410. $data['capital'] = isset($license['registered_capital']) ? $license['registered_capital'] : "";
  411. $data['nature'] = isset($license['type']) ? $license['type'] : "";
  412. $data['registercode'] = isset($license['registration_number']) ? $license['registration_number'] : "";//12356
  413. $data['ocr_status'] = 1;
  414. if ($name != $license['name']) {
  415. $data['remark'] = "企业名称与营业执照不匹配";
  416. $data['ocr_status'] = 1;
  417. }
  418. if ($registercode != $license['registration_number'] && $registercode != '') {
  419. $data['remark'] .= "企业名称与营业执照不匹配";
  420. $data['ocr_status'] = 1;
  421. }
  422. } else {
  423. $data['remark'] = "营业执照识别失败";
  424. $data['ocr_status'] = 2;
  425. }
  426. }
  427. $temp = [];
  428. $temp['code'] = $info['data']['code'];
  429. $temp['contactor'] = $contactor;
  430. $temp['mobile'] = $mobile;
  431. $temp['position'] = $position;
  432. $temp['telephone'] = $telephone;
  433. $temp['email'] = $email;
  434. $temp['is_del'] = 0;
  435. $temp['updatetime'] = date("Y-m-d H:i:s");
  436. $res = $userCommon->handle('sEdit', ['data' => $data, 'contact' => $temp]);
  437. Db::startTrans();
  438. try {
  439. if ($info['data']['personid'] != $personid) {
  440. $good = Db::name("good_basic")->where(["supplierNo" => $info['data']['code'], "is_del" => 0])->column('id');
  441. if (!empty($good)) {
  442. $up = Db::name("good_basic")->where(["id" => $good])->update(["chargerid" => $personid, "charger" => $person, "updatetime" => date("Y-m-d H:i:s")]);
  443. if ($up == false) throw new Exception("商品负责人更新失败");
  444. }
  445. }
  446. //更新同一个供应商下虚拟仓的负责人
  447. Db::name('warehouse_info')
  448. ->where(['is_del' => 0, 'supplierNo' => $code['code'], 'wsm_type' => 2])
  449. ->update(['contactor' => $data['personid'], 'contactor_name' => $data['person']]);
  450. Db::commit();
  451. return json_show($res['code'], $res['message'], $res['data']);
  452. } catch (Exception $exception) {
  453. Db::rollback();
  454. return json_show(1004, $exception->getMessage());
  455. }
  456. }
  457. public function info()
  458. {
  459. $code = $this->request->only(['code' => ''], 'post', 'trim');
  460. $userCommon = \app\admin\common\User::getIns();
  461. $rs = $userCommon->handle('sInfo', $code);
  462. return json_show($rs['code'], $rs['message'], $rs['data']);
  463. }
  464. //删除 供应商
  465. public function del()
  466. {
  467. $param = $this->request->only(['id' => 0], 'post', 'trim');
  468. $userCommon = \app\admin\common\User::getIns();
  469. $rs = $userCommon->handle('delete', [
  470. 'ids' => [$param['id']],
  471. 'type' => 3,
  472. 'updater' => $this->uname,
  473. 'updaterid' => $this->uid,
  474. ]);
  475. return json_show($rs['code'], $rs['message'], $rs['data']);
  476. }
  477. //启/禁用 供应商
  478. public function status()
  479. {
  480. $param = $this->request->only(['id', 'status'], 'post', 'trim');
  481. $val = Validate::rule([
  482. 'id' => 'require|number|gt:0',
  483. 'status|状态' => 'require|number|in:0,1'
  484. ]);
  485. if (!$val->check($param)) return json_show(1005, $val->getError());
  486. $userCommon = \app\admin\common\User::getIns();
  487. $rs = $userCommon->handle('status', [
  488. 'id' => $param['id'],
  489. 'status' => $param['status'],
  490. 'type' => 3,
  491. 'updater' => $this->uname,
  492. 'updaterid' => $this->uid,
  493. ]);
  494. return json_show($rs['code'], $rs['message'], $rs['data']);
  495. }
  496. //供应商升级成业务公司IIV2407051106408353
  497. public function upgrade(){
  498. $param = $this->request->filter('trim')->post();
  499. $userCommon = \app\admin\common\User::getIns();
  500. $param['uid']=$this->uid;
  501. $param['uname']=$this->uname;
  502. $rs = $userCommon->handle('upgrade', $param);
  503. if (isset($rs['code']) && $rs['code'] == 0) {
  504. //更新用户和角色关联表的数据
  505. Db::name('user_role')
  506. ->where(['companyNo' => $param['code'], 'company_type' => 1])
  507. ->update(['company_type' => 2]);
  508. }
  509. return json_show($rs['code'], $rs['message'], $rs['data']);
  510. }
  511. }