EnterpriseVerifyMgrApi.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\common\api;
  3. use app\common\model\EnterpriseVerifyMgr;
  4. class EnterpriseVerifyMgrApi {
  5. public static function getOne($id) {
  6. return EnterpriseVerifyMgr::findOrEmpty($id);
  7. }
  8. public static function getList($params) {
  9. $order = $params["order"] ?: "desc";
  10. $offset = $params["offset"] ?: 0;
  11. $limit = $params["limit"] ?: 10;
  12. $where[] = ["m.delete", "=", 0];
  13. $count = EnterpriseVerifyMgr::alias("m")->leftJoin("sys_company c", "c.id=m.companyId")->where($where)->count();
  14. $list = EnterpriseVerifyMgr::alias("m")->leftJoin("sys_company c", "c.id=m.companyId")->where($where)->limit($offset, $limit)->order("m.updateTime desc,m.createTime desc")->field("m.*,c.name as companyName")->select()->toArray();
  15. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  16. foreach ($list as $key => $item) {
  17. $list[$key]["enterpriseTagName"] = $enterpriseTags[$item["enterpriseTag"]];
  18. }
  19. return ["total" => $count, "rows" => $list];
  20. }
  21. public static function getAll() {
  22. $where[] = ["delete", "=", 0];
  23. $list = EnterpriseVerifyMgr::where($where)->order("sn asc")->select()->toArray();
  24. return $list;
  25. }
  26. public static function edit($params) {
  27. $data["enterpriseTag"] = $params["enterpriseTag"];
  28. $data["companyId"] = $params["companyId"];
  29. $data["description"] = $params["description"];
  30. $data["uniCode"] = implode(",", array_unique(array_filter(explode(",", $params["uniCode"]))));
  31. if ($params["id"]) {
  32. $data["id"] = $params["id"];
  33. $data["updateTime"] = date("Y-m-d H:i:s");
  34. $data["updateUser"] = session("user")["uid"];
  35. return EnterpriseVerifyMgr::update($data);
  36. } else {
  37. $data["id"] = getStringId();
  38. $data["createTime"] = date("Y-m-d H:i:s");
  39. $data["createUser"] = session("user")["uid"];
  40. return EnterpriseVerifyMgr::insert($data);
  41. }
  42. }
  43. public static function delete($id) {
  44. $data["id"] = $id;
  45. $data["delete"] = 1;
  46. $data["updateUser"] = session("user")["uid"];
  47. $data["updateTime"] = date("Y-m-d H:i:s");
  48. return EnterpriseVerifyMgr::update($data);
  49. }
  50. public static function chkExist($tag, $id = 0) {
  51. $where = [];
  52. if ($id) {
  53. $where[] = ["id", "<>", $id];
  54. }
  55. $where[] = ["delete", "=", 0];
  56. $where[] = ["enterpriseTag", "=", $tag];
  57. return EnterpriseVerifyMgr::where($where)->find();
  58. }
  59. public static function chkUnicodeExist($codes, $id = 0) {
  60. $where = [];
  61. if ($id) {
  62. $where[] = ["id", "<>", $id];
  63. }
  64. $codes = array_unique(array_filter(explode(",", $codes)));
  65. $where[] = ["delete", "=", 0];
  66. $whereRaw = sprintf("concat(',',uniCode,',') regexp(',%s,')", implode(",|,", $codes));
  67. return EnterpriseVerifyMgr::where($where)->whereRaw($whereRaw)->find();
  68. }
  69. }