feat: 添加更新门店商品功能

This commit is contained in:
mkm 2024-06-12 10:29:29 +08:00
parent 2ecb52ca97
commit e46aa8d36e
4 changed files with 41 additions and 20 deletions

View File

@ -5,6 +5,7 @@ namespace app\admin\controller\store_branch_product;
use app\admin\controller\BaseAdminController; use app\admin\controller\BaseAdminController;
use app\admin\lists\store_branch_product\StoreBranchProductLists; use app\admin\lists\store_branch_product\StoreBranchProductLists;
use app\admin\logic\store_branch_product\StoreBranchProductLogic;
use app\admin\logic\store_product\StoreProductLogic; use app\admin\logic\store_product\StoreProductLogic;
use app\admin\validate\store_product\StoreProductValidate; use app\admin\validate\store_product\StoreProductValidate;
use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product\StoreBranchProduct;
@ -45,7 +46,15 @@ class StoreBranchProductController extends BaseAdminController
} }
return $this->fail(StoreProductLogic::getError()); return $this->fail(StoreProductLogic::getError());
} }
public function update()
{
$params = $this->request->post();
StoreBranchProductLogic::edit($params);
if (StoreBranchProductLogic::hasError()) {
return $this->fail(StoreBranchProductLogic::getError());
}
return $this->success('更新成功', [], 1, 1);
}
/** /**
* @notes 编辑门店商品辅助列表 * @notes 编辑门店商品辅助列表
@ -55,10 +64,10 @@ class StoreBranchProductController extends BaseAdminController
*/ */
public function edit() public function edit()
{ {
$params =$this->request->post(); $params = $this->request->post();
foreach($params['data'] as $k=>$v){ foreach ($params['data'] as $k => $v) {
StoreProductLogic::stock($v); StoreProductLogic::stock($v);
if(StoreProductLogic::hasError()){ if (StoreProductLogic::hasError()) {
return $this->fail(StoreProductLogic::getError()); return $this->fail(StoreProductLogic::getError());
} }
} }
@ -73,13 +82,13 @@ class StoreBranchProductController extends BaseAdminController
*/ */
public function edit_price() public function edit_price()
{ {
$params =$this->request->post(); $params = $this->request->post();
$res= StoreBranchProduct::where('id',$params['id'])->update(['price'=>$params['price']]); $res = StoreBranchProduct::where('id', $params['id'])->update(['price' => $params['price']]);
if($res){ if ($res) {
return $this->success('编辑成功', [], 1, 1); return $this->success('编辑成功', [], 1, 1);
}else{ } else {
return $this->fail('编辑失败', [], 1, 1); return $this->fail('编辑失败', [], 1, 1);
} }
} }
/** /**
* @notes 编辑门店商品辅助库存 * @notes 编辑门店商品辅助库存
@ -117,6 +126,4 @@ class StoreBranchProductController extends BaseAdminController
$result = StoreProductLogic::detail($params); $result = StoreProductLogic::detail($params);
return $this->data($result); return $this->data($result);
} }
}
}

View File

@ -101,12 +101,7 @@ class StoreProductLogic extends BaseLogic
public static function edit(array $params): bool public static function edit(array $params): bool
{ {
Db::startTrans(); Db::startTrans();
$StoreProduct = StoreProduct::where('id', $params['id'])->find();
try { try {
if ($StoreProduct['cate_id'] != $params['cate_id']) {
StoreCategory::where('id', $params['cate_id'])->inc('three')->update();
StoreCategory::where('id', $StoreProduct['cate_id'])->dec('three')->update();
}
$data = [ $data = [
'store_name' => $params['store_name'], 'store_name' => $params['store_name'],
'image' => $params['image'], 'image' => $params['image'],

View File

@ -64,6 +64,7 @@ class StoreStorageSend implements Consumer
if ($product_arr['stock'] > 0) { if ($product_arr['stock'] > 0) {
$this->storage($find, $store_id, $admin_id, $product_arr); $this->storage($find, $store_id, $admin_id, $product_arr);
} }
StoreProductLogic::updateGoodsclass($find['cate_id']);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -17,6 +17,8 @@ namespace app\store\controller;
use app\admin\logic\ConfigLogic; use app\admin\logic\ConfigLogic;
use app\admin\logic\system_store\SystemStoreLogic; use app\admin\logic\system_store\SystemStoreLogic;
use app\common\controller\Definitions; use app\common\controller\Definitions;
use app\common\service\ConfigService;
use app\common\service\FileService;
use hg\apidoc\annotation as ApiDoc; use hg\apidoc\annotation as ApiDoc;
use think\facade\Db; use think\facade\Db;
@ -48,7 +50,23 @@ class ConfigController extends BaseAdminController
] ]
public function getConfig() public function getConfig()
{ {
$data = ConfigLogic::getConfig(); // $data = ConfigLogic::getConfig();
$data = [
// 文件域名
'oss_domain' => FileService::getFileUrl(),
// 网站名称
'web_name' => '泸优采门店后台',
// 网站图标
'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
// 网站logo
'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
// 登录页
'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
// 版权信息
'copyright_config' => ConfigService::get('copyright', 'config', []),
];
return $this->data($data); return $this->data($data);
} }