feat: 添加根据商品源获取门店列表的API
This commit is contained in:
parent
cde1d98426
commit
13395e424c
@ -6,6 +6,7 @@ namespace app\admin\controller\system_store;
|
|||||||
use app\admin\controller\BaseAdminController;
|
use app\admin\controller\BaseAdminController;
|
||||||
use app\admin\lists\system_store\SystemStoreLists;
|
use app\admin\lists\system_store\SystemStoreLists;
|
||||||
use app\admin\lists\system_store\SystemStoreSourceLists;
|
use app\admin\lists\system_store\SystemStoreSourceLists;
|
||||||
|
use app\admin\logic\store_product\StoreProductLogic;
|
||||||
use app\admin\logic\system_store\SystemStoreLogic;
|
use app\admin\logic\system_store\SystemStoreLogic;
|
||||||
use app\admin\validate\system_store\SystemStoreValidate;
|
use app\admin\validate\system_store\SystemStoreValidate;
|
||||||
|
|
||||||
@ -39,7 +40,29 @@ class SystemStoreController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
return $this->dataLists(new SystemStoreSourceLists());
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$removeList=$this->request->post('removeList');
|
||||||
|
if($removeList){
|
||||||
|
foreach ($removeList as $key=>$value){
|
||||||
|
StoreProductLogic::store_del($product_id,$value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->dataLists(new SystemStoreSourceLists());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 添加门店列表
|
* @notes 添加门店列表
|
||||||
|
@ -114,7 +114,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'rose' => $params['rose'],
|
'rose' => $params['rose'],
|
||||||
];
|
];
|
||||||
if ($params['rose'] > 0) {
|
if ($params['rose'] > 0) {
|
||||||
$rose_price = bcmul($params['cost'],bcdiv($params['rose'], 100, 2), 2);
|
$rose_price = bcmul($params['cost'], bcdiv($params['rose'], 100, 2), 2);
|
||||||
$data['price'] = bcadd($params['cost'], $rose_price, 2);
|
$data['price'] = bcadd($params['cost'], $rose_price, 2);
|
||||||
} else {
|
} else {
|
||||||
$data['price'] = 0;
|
$data['price'] = 0;
|
||||||
@ -195,7 +195,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
/**
|
/**
|
||||||
* 复制商品到门店
|
* 复制商品到门店
|
||||||
*/
|
*/
|
||||||
public static function copy($id, $store_id,$stock=0)
|
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();
|
||||||
@ -236,4 +236,24 @@ class StoreProductLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除门店商品
|
||||||
|
*/
|
||||||
|
public static function store_del($id, $store_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]);
|
||||||
|
StoreProductAttrValue::where(['product_id' => $id, 'store_id' => $store_id])->update(['delete_time' => time()]);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user