Index.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. namespace app\abutment\controller;
  3. use app\abutment\logic\Index as IndexLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Db;
  8. use think\facade\Validate;
  9. class Index extends BaseController
  10. {
  11. //获取上线平台列表
  12. public function getPlatformList()
  13. {
  14. $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
  15. $val = Validate::rule(Config::get('validate_rules.common'));
  16. if (!$val->check($param)) throw new ValidateException($val->getError());
  17. return IndexLogic::getPlatformList($param['keyword'], $param['page'], $param['size']);
  18. }
  19. //获取分类列表
  20. public function getCatList()
  21. {
  22. $param = $this->request->filter('trim')->only(['keyword' => '', 'pid' => 0], 'post');
  23. $val = Validate::rule(Config::get('validate_rules.getCatList'));
  24. if (!$val->check($param)) throw new ValidateException($val->getError());
  25. return IndexLogic::getCatList($param['keyword'], $param['pid']);
  26. }
  27. //获取品牌列表-api
  28. public function getBrandList()
  29. {
  30. $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
  31. $val = Validate::rule(Config::get('validate_rules.common'));
  32. if (!$val->check($param)) throw new ValidateException($val->getError());
  33. return IndexLogic::getBrandList($param['keyword'], $param['page'], $param['size']);
  34. }
  35. //获取品牌列表-前端
  36. public function brandList()
  37. {
  38. $this->post = $this->request->filter('trim')->post();
  39. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  40. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  41. $where = [["b.is_del", "=", 0]];
  42. $brand_name = isset($this->post['brand_name']) && $this->post['brand_name'] !== "" ? trim($this->post['brand_name']) : "";
  43. if ($brand_name !== "") {
  44. $where[] = ['b.brand_name', "like", "%$brand_name%"];
  45. }
  46. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  47. if ($status !== "") {
  48. $where[] = ['b.status', "=", $status];
  49. }
  50. $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
  51. if ($creater !== "") {
  52. $where[] = ['b.creater', "like", "%$creater%"];
  53. }
  54. $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
  55. if ($start !== "") {
  56. $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
  57. }
  58. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
  59. if ($end !== "") {
  60. $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
  61. }
  62. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  63. if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
  64. $count = Db::name('brand')
  65. ->alias('b')
  66. ->where($where)
  67. ->count();
  68. $total = ceil($count / $size);
  69. $page = $page >= $total ? $total : $page;
  70. $list = Db::name('brand')
  71. ->alias('b')
  72. ->field('b.*,u.itemid')
  73. ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
  74. ->where($where)
  75. ->append(['company_name'])
  76. ->withAttr('company_name', function ($val, $data) {
  77. return implode('/', array_column(GetPart($data['itemid']), 'name'));
  78. })
  79. ->page($page, $size)
  80. ->order("addtime desc,id desc")
  81. ->select();
  82. return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  83. }
  84. //获取单位列表
  85. public function getUnitList()
  86. {
  87. $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
  88. $val = Validate::rule(Config::get('validate_rules.common'));
  89. if (!$val->check($param)) throw new ValidateException($val->getError());
  90. return IndexLogic::getUnitList($param['keyword'], $param['page'], $param['size']);
  91. }
  92. //获取规格标题列表
  93. public function getSpecsTitleList()
  94. {
  95. $param = $this->request->filter('trim')->only(['keyword' => ''], 'post');
  96. $val = Validate::rule(Config::get('validate_rules.keyword'));
  97. if (!$val->check($param)) throw new ValidateException($val->getError());
  98. return IndexLogic::getSpecsTitleList($param['keyword']);
  99. }
  100. //获取规格值列表
  101. public function getSpecsValueByTitleList()
  102. {
  103. $param = $this->request->filter('trim')->only(['spec_id'], 'post');
  104. $val = Validate::rule(Config::get('validate_rules.getSpecsValueByTitleList'));
  105. if (!$val->check($param)) throw new ValidateException($val->getError());
  106. return IndexLogic::getSpecsValueByTitleList($param['spec_id']);
  107. }
  108. //获取省市区列表
  109. public function getAreaList()
  110. {
  111. $param = $this->request->filter('trim')->only(['level' => 1, 'pid_code' => ''], 'post');
  112. $val = Validate::rule(Config::get('validate_rules.getAreaList'));
  113. if (!$val->check($param)) throw new ValidateException($val->getError());
  114. return IndexLogic::getAreaList($param['level'], $param['pid_code']);
  115. }
  116. //获取业务公司编码-api
  117. public function getCompanyNoList()
  118. {
  119. $param = $this->request->filter('trim')->only(['keyword' => ''], 'post');
  120. $val = Validate::rule(Config::get('validate_rules.keyword'));
  121. if (!$val->check($param)) throw new ValidateException($val->getError());
  122. return IndexLogic::getCompanyNoList($param['keyword']);
  123. }
  124. //获取业务公司编码-前端
  125. public function businessList()
  126. {
  127. $this->post = $this->request->filter('trim')->post();
  128. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  129. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  130. $where = [["b.is_del", "=", 0]];
  131. $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
  132. if ($company !== "") {
  133. $where[] = ['b.company', "like", "%$company%"];
  134. }
  135. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  136. if ($status !== "") {
  137. $where[] = ['b.status', "=", $status];
  138. }
  139. $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
  140. if ($creater !== "") {
  141. $where[] = ['b.creater', "like", "%$creater%"];
  142. }
  143. $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
  144. if ($start !== "") {
  145. $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
  146. }
  147. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
  148. if ($end !== "") {
  149. $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
  150. }
  151. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  152. if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
  153. $count = Db::name('business')
  154. ->alias('b')
  155. ->where($where)
  156. ->count();
  157. $total = ceil($count / $size);
  158. $page = $page >= $total ? $total : $page;
  159. $list = Db::name('business')
  160. ->alias('b')
  161. ->where($where)
  162. ->page($page, $size)
  163. ->field("b.id,b.company,b.companyNo,b.status,b.creater,b.addtime,b.type,u.itemid")
  164. ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
  165. ->order("addtime desc")
  166. ->append(['company_name'])
  167. ->withAttr('company_name', function ($val, $data) {
  168. return implode('/', array_column(GetPart($data['itemid']), 'name'));
  169. })
  170. ->select()
  171. ->toArray();
  172. return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  173. }
  174. //专属类型列表
  175. public function getExclusiveList()
  176. {
  177. $pid = $this->request->filter('trim')->post('pid/d', 0);
  178. $where = [["is_del", "=", 0], ["pid", "=", $pid]];
  179. $cat_name = $this->request->filter('trim')->post('cat_name', '');
  180. if ($cat_name !== "") $where[] = ['cat_name', "like", "%$cat_name%"];
  181. $data = Db::name("exclusive")
  182. ->where($where)
  183. ->select()
  184. ->toArray();
  185. $vmp = [];
  186. foreach ($data as $sts) {
  187. $vmp[] = coco($sts);
  188. }
  189. return json_show(0, "获取成功", $vmp);
  190. }
  191. }