128 lines
3.6 KiB
PHP
128 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\merchat;
|
|
|
|
|
|
use app\admin\controller\BaseAdminController;
|
|
use app\admin\lists\merchant\MerchantLists;
|
|
use app\admin\logic\merchant\MerchantLogic;
|
|
use app\admin\validate\merchant\MerchantValidate;
|
|
use app\common\model\goods\Goods;
|
|
use app\common\model\goods\GoodsLabel;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* 商户列表控制器
|
|
* Class MerchantController
|
|
* @package app\admin\controller\merchant
|
|
*/
|
|
class MerchantController extends BaseAdminController
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 获取商户列表列表
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/23 16:35
|
|
*/
|
|
public function lists()
|
|
{
|
|
return $this->dataLists(new MerchantLists());
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 添加商户列表
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/23 16:35
|
|
*/
|
|
public function add()
|
|
{
|
|
$params = (new MerchantValidate())->post()->goCheck('add');
|
|
$result = MerchantLogic::add($params);
|
|
if (true === $result) {
|
|
return $this->success('添加成功', [], 1, 1);
|
|
}
|
|
return $this->fail(MerchantLogic::getError());
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 编辑商户列表
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/23 16:35
|
|
*/
|
|
public function edit()
|
|
{
|
|
$params = (new MerchantValidate())->post()->goCheck('edit');
|
|
$result = MerchantLogic::edit($params);
|
|
if (true === $result) {
|
|
return $this->success('编辑成功', [], 1, 1);
|
|
}
|
|
return $this->fail(MerchantLogic::getError());
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 删除商户列表
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/23 16:35
|
|
*/
|
|
public function delete()
|
|
{
|
|
$params = (new MerchantValidate())->post()->goCheck('delete');
|
|
MerchantLogic::delete($params);
|
|
return $this->success('删除成功', [], 1, 1);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取商户列表详情
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/23 16:35
|
|
*/
|
|
public function detail()
|
|
{
|
|
$params = (new MerchantValidate())->goCheck('detail');
|
|
$result = MerchantLogic::detail($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
public function bind_goods(){
|
|
$params = (new MerchantValidate())->post()->goCheck('detail');
|
|
$result = MerchantLogic::bindGoods($params);
|
|
if (true === $result) {
|
|
return $this->success('绑定成功', [], 1, 1);
|
|
}
|
|
return $this->fail(MerchantLogic::getError());
|
|
}
|
|
|
|
public function bind_goods_lists(){
|
|
$mer_id = $this->request->get('mer_id');
|
|
$page_no = $this->request->get('page_no',1);
|
|
$page_size = $this->request->get('page_size',15);
|
|
if(empty($mer_id)){
|
|
return $this->fail('参数错误');
|
|
}
|
|
$data = Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->page($page_no,$page_size)->select()->each(function($item){
|
|
$item['goods_info'] = Goods::where('id',$item['goods_id'])->with(['className','brandName','unitName','warehouseName'])->findOrEmpty();
|
|
if(!empty($item['goods_info']['sys_labels'])){
|
|
$goodslabel = GoodsLabel::where('id','in',trim($item['goods_info']['sys_labels'],','))->column('name');
|
|
$item['goods_info']['sys_labels_text'] = implode(',',$goodslabel);
|
|
}else{
|
|
$item['goods_info']['sys_labels_text'] = '';
|
|
}
|
|
return $item;
|
|
})->toArray();
|
|
$count = Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->count();
|
|
return $this->success('请求成功',['lists'=>$data,'count'=>$count,'page_no'=>$page_no,'page_size'=>$page_size]);
|
|
}
|
|
|
|
|
|
} |