feat: 添加门店商品辅助控制器及逻辑
This commit is contained in:
parent
f0976184b3
commit
9760d34129
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\store_branch_product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\store_product\StoreProductLists;
|
||||||
|
use app\admin\logic\store_product\StoreProductLogic;
|
||||||
|
use app\admin\validate\store_product\StoreProductValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店商品辅助控制器
|
||||||
|
* Class StoreBranchProductController
|
||||||
|
* @package app\admin\controller\store_product
|
||||||
|
*/
|
||||||
|
class StoreBranchProductController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取门店商品辅助列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/05/31 10:53
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new StoreProductLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加门店商品辅助列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/05/31 10:53
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new StoreProductValidate())->post()->goCheck('add');
|
||||||
|
$result = StoreProductLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(StoreProductLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑门店商品辅助列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/05/31 10:53
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new StoreProductValidate())->post()->goCheck('edit');
|
||||||
|
$result = StoreProductLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(StoreProductLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除门店商品辅助列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/05/31 10:53
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new StoreProductValidate())->post()->goCheck('delete');
|
||||||
|
StoreProductLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取门店商品辅助列表详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/05/31 10:53
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new StoreProductValidate())->goCheck('detail');
|
||||||
|
$result = StoreProductLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -195,7 +195,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
/**
|
/**
|
||||||
* 复制商品到门店
|
* 复制商品到门店
|
||||||
*/
|
*/
|
||||||
public static function copy($id, $store_id)
|
public static function copy($id, $store_id,$stock=0)
|
||||||
{
|
{
|
||||||
$find = StoreProduct::where('id', $id)->findOrEmpty()->toArray();
|
$find = StoreProduct::where('id', $id)->findOrEmpty()->toArray();
|
||||||
$store_find = StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->findOrEmpty()->toArray();
|
$store_find = StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->findOrEmpty()->toArray();
|
||||||
@ -214,14 +214,13 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'price' => $find['price'],
|
'price' => $find['price'],
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'sales' => 0,
|
'sales' => 0,
|
||||||
'stock' => 0,
|
'stock' => $stock,
|
||||||
];
|
];
|
||||||
StoreBranchProduct::create($product);
|
StoreBranchProduct::create($product);
|
||||||
$arr = [
|
$arr = [
|
||||||
'product_id' => $id,
|
'product_id' => $id,
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'sales' => 0,
|
'sales' => 0,
|
||||||
'stock' => 0,
|
|
||||||
'type' => 0,
|
'type' => 0,
|
||||||
'bar_code' => $attr_value['bar_code']
|
'bar_code' => $attr_value['bar_code']
|
||||||
];
|
];
|
||||||
|
@ -21,8 +21,9 @@ class CopyProductSend implements Consumer
|
|||||||
public function consume($data)
|
public function consume($data)
|
||||||
{
|
{
|
||||||
$store_arr=$data['store_arr'];
|
$store_arr=$data['store_arr'];
|
||||||
|
$stock=$data['stock']??0;
|
||||||
foreach ($store_arr as $key => $id) {
|
foreach ($store_arr as $key => $id) {
|
||||||
StoreProductLogic::copy($data['product_id'],$id);
|
StoreProductLogic::copy($data['product_id'],$id,$stock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onConsumeFailure(\Throwable $e, $package)
|
public function onConsumeFailure(\Throwable $e, $package)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user