new-admin-api/app/controller/api/store/merchant/Merchant.php

147 lines
4.5 KiB
PHP

<?php
namespace app\controller\api\store\merchant;
use app\common\repositories\store\service\StoreServiceRepository;
use app\common\repositories\user\UserMerchantRepository;
use crmeb\services\QrcodeService;
use think\App;
use crmeb\basic\BaseController;
use app\common\repositories\system\merchant\MerchantRepository as repository;
class Merchant extends BaseController
{
protected $repository;
protected $userInfo;
/**
* ProductCategory constructor.
* @param App $app
* @param repository $repository
*/
public function __construct(App $app, repository $repository)
{
parent::__construct($app);
$this->repository = $repository;
$this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null;
}
/**
* @Author:Qinii
* @Date: 2020/5/27
* @return mixed
*/
public function lst()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id','is_trader']);
return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
}
/**
* @Author:Qinii
* @Date: 2020/5/29
* @param $id
* @return mixed
*/
public function detail($id)
{
if (!$this->repository->apiGetOne($id))
return app('json')->fail('店铺已打烊');
if ($this->request->isLogin()) {
app()->make(UserMerchantRepository::class)->updateLastTime($this->request->uid(), intval($id));
}
return app('json')->success($this->repository->detail($id, $this->userInfo));
}
public function systemDetail()
{
$config = systemConfig(['site_logo', 'site_name','login_logo']);
return app('json')->success([
'mer_avatar' => $config['site_logo'],
'mer_name' => $config['site_name'],
'mer_id' => 0,
'postage_score' => '5.0',
'product_score' => '5.0',
'service_score' => '5.0',
]);
}
/**
* @Author:Qinii
* @Date: 2020/5/29
* @param $id
* @return mixed
*/
public function productList($id)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['keyword','order','mer_cate_id','cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid']);
if(!$this->repository->apiGetOne($id)) return app('json')->fail(' 店铺已打烊');
return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo));
}
/**
* @Author:Qinii
* @Date: 2020/5/29
* @param int $id
* @return mixed
*/
public function categoryList($id)
{
if(!$this->repository->merExists((int)$id))
return app('json')->fail('店铺已打烊');
return app('json')->success($this->repository->categoryList($id));
}
public function qrcode($id)
{
if(!$this->repository->merExists($id))
return app('json')->fail('店铺已打烊');
$url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id));
return app('json')->success(compact('url'));
}
public function localLst()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id']);
$where['delivery_way'] = 1;
return app('json')->success($this->repository->getList($where, $page, $limit, $this->userInfo));
}
/**
* Common: 员工推广二维码
* Author: wu-hui
* Time: 2024/01/23 11:54
* @return mixed
*/
public function promoteQrCode(){
// 参数获取
$merId = $this->request->param('mer_id');
if((int)$merId > 0){
$qrcode = $this->repository->createQrCode(['mer_id'=>$merId]);
return app('json')->success(['qr_code' => $qrcode]);
}
return app('json')->fail('小程序码生成失败!');
}
/**
* Common: 员工买单二维码
* Author: wu-hui
* Time: 2024/01/23 13:56
* @return mixed
*/
public function onlinePaymentQrCode(){
// 参数获取
$merId = $this->request->param('mer_id');
if((int)$merId > 0){
$qrcode = $this->repository->createQrCode(['mer_id'=>$merId],'online_payment');
return app('json')->success(['qr_code' => $qrcode]);
}
return app('json')->fail('小程序码生成失败!');
}
}