123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <?php
- namespace app\abutment\controller;
- use app\abutment\logic\Index as IndexLogic;
- use think\exception\ValidateException;
- use think\facade\Config;
- use think\facade\Db;
- use think\facade\Validate;
- class Index extends HomeBaseController
- {
- //获取上线平台列表
- public function getPlatformList()
- {
- $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
- $val = Validate::rule(Config::get('validate_rules.common'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getPlatformList($param['keyword'], $param['page'], $param['size']);
- }
- //获取分类列表
- public function getCatList()
- {
- $param = $this->request->filter('trim')->only(['keyword' => '', 'pid' => 0], 'post');
- $val = Validate::rule(Config::get('validate_rules.getCatList'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getCatList($param['keyword'], $param['pid']);
- }
- //获取品牌列表-api
- public function getBrandList()
- {
- $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
- $val = Validate::rule(Config::get('validate_rules.common'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getBrandList($param['keyword'], $param['page'], $param['size']);
- }
- //获取品牌列表-前端
- public function brandList()
- {
- $this->post = $this->request->filter('trim')->post();
- $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
- $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
- $where = [["b.is_del", "=", 0]];
- $brand_name = isset($this->post['brand_name']) && $this->post['brand_name'] !== "" ? trim($this->post['brand_name']) : "";
- if ($brand_name !== "") {
- $where[] = ['b.brand_name', "like", "%$brand_name%"];
- }
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- if ($status !== "") {
- $where[] = ['b.status', "=", $status];
- }
- $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
- if ($creater !== "") {
- $where[] = ['b.creater', "like", "%$creater%"];
- }
- $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
- if ($start !== "") {
- $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
- }
- $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
- if ($end !== "") {
- $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
- }
- $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
- if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
- $count = Db::name('brand')
- ->alias('b')
- ->where($where)
- ->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('brand')
- ->alias('b')
- ->where($where)
- ->page($page, $size)
- ->order("addtime desc,id desc")
- ->select()
- ->toArray();
- $all_createrid = array_column($list,'createrid');
- $item = get_company_name_by_uid($all_createrid);
- foreach ($list as &$value){
- $value['company_name']=$item[$value['createrid']]??'';
- }
- return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
- }
- //获取单位列表
- public function getUnitList()
- {
- $param = $this->request->filter('trim')->only(['keyword' => '', 'page' => 1, 'size' => 15], 'post');
- $val = Validate::rule(Config::get('validate_rules.common'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getUnitList($param['keyword'], $param['page'], $param['size']);
- }
- //获取规格标题列表
- public function getSpecsTitleList()
- {
- $param = $this->request->filter('trim')->only(['keyword' => ''], 'post');
- $val = Validate::rule(Config::get('validate_rules.keyword'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getSpecsTitleList($param['keyword']);
- }
- //获取规格值列表
- public function getSpecsValueByTitleList()
- {
- $param = $this->request->filter('trim')->only(['spec_id'], 'post');
- $val = Validate::rule(Config::get('validate_rules.getSpecsValueByTitleList'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getSpecsValueByTitleList($param['spec_id']);
- }
- //获取省市区列表
- public function getAreaList()
- {
- $param = $this->request->filter('trim')->only(['level' => 1, 'pid_code' => ''], 'post');
- $val = Validate::rule(Config::get('validate_rules.getAreaList'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getAreaList($param['level'], $param['pid_code']);
- }
- //获取业务公司编码-api
- public function getCompanyNoList()
- {
- $param = $this->request->filter('trim')->only(['keyword' => ''], 'post');
- $val = Validate::rule(Config::get('validate_rules.keyword'));
- if (!$val->check($param)) throw new ValidateException($val->getError());
- return IndexLogic::getCompanyNoList($param['keyword']);
- }
- //获取业务公司编码-前端
- public function businessList()
- {
- $this->post = $this->request->filter('trim')->post();
- $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
- $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
- $where = [["b.is_del", "=", 0]];
- $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
- if ($company !== "") {
- $where[] = ['b.company', "like", "%$company%"];
- }
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- if ($status !== "") {
- $where[] = ['b.status', "=", $status];
- }
- $creater = isset($this->post['creater']) && $this->post['creater'] !== "" ? trim($this->post['creater']) : "";
- if ($creater !== "") {
- $where[] = ['b.creater', "like", "%$creater%"];
- }
- $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
- if ($start !== "") {
- $where[] = ['b.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
- }
- $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
- if ($end !== "") {
- $where[] = ['b.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
- }
- $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
- if ($company_name !== "") $where[] = ["b.createrid", 'in', get_company_item_user_by_name($company_name)];
- $count = Db::name('business')
- ->alias('b')
- ->where($where)
- ->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('business')
- ->alias('b')
- ->where($where)
- ->page($page, $size)
- ->field("b.id,b.company,b.companyNo,b.status,b.creater,b.addtime,b.type")
- ->order("addtime desc")
- ->select()
- ->toArray();
- $all_createrid = array_column($list, 'createrid');
- $item = get_company_name_by_uid($all_createrid);
- foreach ($list as &$value) {
- $value['company_name'] = $item[$value['createrid']] ?? '';
- }
- return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
- }
- //专属类型列表
- public function getExclusiveList()
- {
- $pid = $this->request->filter('trim')->post('pid/d', 0);
- $where = [["is_del", "=", 0], ["pid", "=", $pid]];
- $cat_name = $this->request->filter('trim')->post('cat_name', '');
- if ($cat_name !== "") $where[] = ['cat_name', "like", "%$cat_name%"];
- $data = Db::name("exclusive")
- ->where($where)
- ->select()
- ->toArray();
- $vmp = [];
- foreach ($data as $sts) {
- $vmp[] = coco($sts);
- }
- return json_show(0, "获取成功", $vmp);
- }
- //上传图片
- public function uploadImg()
- {
- $files = $this->request->file('image');
- $list = "";
- if ($files != "") $list = UploadImg($files);
- if (is_array($list) && !empty($list)) return json_show(0, "上传成功!", $list);
- else return json_show(1005, "上传失败!" . $list);
- }
- }
|