shop-php/app/controller/middle/Merchant.php
2023-12-05 13:37:46 +08:00

69 lines
2.1 KiB
PHP

<?php
namespace app\controller\middle;
use crmeb\basic\BaseController;
use think\App;
use think\facade\Db;
use app\common\repositories\system\merchant\MerchantRepository;
use Overtrue\Pinyin\Pinyin;
/**
* Class Auth
* @package app\controller\api
* @author xaboy
* @day 2020-05-06
*/
class Merchant extends BaseController
{
protected $repository;
public function __construct(App $app, MerchantRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
}
public function get_area(){
$city_code = $this->request->param('city_code', '');
$select = Db::name('geo_area')->where('city_code',$city_code)->field('area_id id,area_code code,area_name name')->select();
return app('json')->success($select);
}
public function get_street(){
$area_code = $this->request->param('area_code', '');
$select=Db::name('geo_street')->where('area_code',$area_code)->field('street_id id,street_code code,street_name name')->select();
$arr=$select?$select->toArray():[];
foreach ($arr as $k=>$item){
$first_char = mb_str_split($item['name']);
if($first_char[0]){
$pinyin=new Pinyin();
$string=$first_char[0];
$pinyin = $pinyin->abbr($string);
$arr[$k]['pinyin']=$pinyin;
}else{
$arr[$k]['pinyin']='';
}
}
return app('json')->success($arr);
}
public function count()
{
$where = $this->request->params(['keyword', 'date', 'status', 'statusTag', 'is_trader', 'category_id', 'type_id']);
return app('json')->success($this->repository->count($where));
}
public function lst()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['keyword', 'date', 'status', 'statusTag', 'is_trader', 'category_id', 'type_id', 'area_id', 'street_id']);
$data = $this->repository->lst($where, $page, $limit);
$data['lists'] = $data['list'];
unset($data['list']);
return app('json')->success($data);
}
}