multi-store/app/admin/controller/system_store/SystemStoreController.php

135 lines
3.6 KiB
PHP

<?php
namespace app\admin\controller\system_store;
use app\admin\controller\BaseAdminController;
use app\admin\lists\system_store\SystemStoreLists;
use app\admin\lists\system_store\SystemStoreSourceLists;
use app\admin\logic\store_product\StoreProductLogic;
use app\admin\logic\system_store\SystemStoreLogic;
use app\admin\validate\system_store\SystemStoreValidate;
/**
* 门店列表控制器
* Class SystemStoreController
* @package app\admin\controller\system_store
*/
class SystemStoreController extends BaseAdminController
{
/**
* @notes 获取门店列表列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function lists()
{
return $this->dataLists(new SystemStoreLists());
}
/**
* @notes 根据商品源获取门店列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function source_product_store_lists()
{
return $this->dataLists(new SystemStoreSourceLists());
}
/**
* @notes 根据商品源获取门店列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function source_product_update_store()
{
$addList=$this->request->post('addList');
$product_id=$this->request->post('product_id');
if($addList){
foreach ($addList as $key=>$value){
StoreProductLogic::copy($product_id,$value);
if(StoreProductLogic::hasError()){
return $this->fail(StoreProductLogic::getError());
}
}
}
$removeList=$this->request->post('removeList');
if($removeList){
foreach ($removeList as $key=>$value){
StoreProductLogic::store_del($product_id,$value);
if(StoreProductLogic::hasError()){
return $this->fail(StoreProductLogic::getError());
}
}
}
return $this->success('设置成功', [], 1, 1);
}
/**
* @notes 添加门店列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function add()
{
$params = (new SystemStoreValidate())->post()->goCheck('add');
$result = SystemStoreLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SystemStoreLogic::getError());
}
/**
* @notes 编辑门店列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function edit()
{
$params = (new SystemStoreValidate())->post()->goCheck('edit');
$result = SystemStoreLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SystemStoreLogic::getError());
}
/**
* @notes 删除门店列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function delete()
{
$params = (new SystemStoreValidate())->post()->goCheck('delete');
SystemStoreLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取门店列表详情
* @return \think\response\Json
* @author admin
* @date 2024/05/31 17:45
*/
public function detail()
{
$params = (new SystemStoreValidate())->goCheck('detail');
$result = SystemStoreLogic::detail($params);
return $this->data($result);
}
}