(创建门店商品逻辑类方法)
This commit is contained in:
parent
f0537ea234
commit
c66598010c
@ -26,7 +26,8 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['name','pid'],
|
'=' => ['pid'],
|
||||||
|
'%like%' => ['name'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ namespace app\admin\logic\store_product;
|
|||||||
|
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
|
use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue;
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -85,7 +87,15 @@ class StoreProductLogic extends BaseLogic
|
|||||||
StoreCategory::where('id', $StoreProduct['cate_id'])->dec('three')->update();
|
StoreCategory::where('id', $StoreProduct['cate_id'])->dec('three')->update();
|
||||||
}
|
}
|
||||||
StoreProduct::where('id', $params['id'])->update([
|
StoreProduct::where('id', $params['id'])->update([
|
||||||
'store_name' => $params['store_name']
|
'store_name' => $params['store_name'],
|
||||||
|
'image' => $params['image'],
|
||||||
|
'bar_code' => $params['bar_code'] ?? '',
|
||||||
|
'cate_id' => $params['cate_id'],
|
||||||
|
'unit' => $params['unit'],
|
||||||
|
'stock' => $params['stock'],
|
||||||
|
'cost' => $params['cost'],
|
||||||
|
'purchase' => $params['purchase'],
|
||||||
|
'rose' => $params['rose'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -120,7 +130,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return StoreProduct::findOrEmpty($params['id'])->toArray();
|
return StoreProduct::where('id',$params['id'])->findOrEmpty()->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,10 +156,38 @@ class StoreProductLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function copy($id){
|
/**
|
||||||
$find= StoreProduct::findOrEmpty($id);
|
* 复制商品到门店
|
||||||
if($find){
|
*/
|
||||||
|
public static function copy($id,$store_id){
|
||||||
|
$find= StoreProduct::where('id',$id)->findOrEmpty();
|
||||||
|
$store_find= StoreProduct::where(['source_id',$id,'store_id'=>$store_id])->findOrEmpty();
|
||||||
|
if($find && !$store_find){
|
||||||
|
$attr_value=StoreProductAttrValue::where('product_id',$id)->findOrEmpty();
|
||||||
|
$res=StoreProduct::create($find);
|
||||||
|
$product=[
|
||||||
|
'product_id'=>$res['id'],
|
||||||
|
'image'=>$res['image'],
|
||||||
|
'store_name'=>$res['store_name'],
|
||||||
|
'store_info'=>$res['store_info'],
|
||||||
|
'keyword'=>$res['keyword'],
|
||||||
|
'bar_code'=>$res['bar_code'],
|
||||||
|
'cate_id'=>$res['cate_id'],
|
||||||
|
'store_id'=>$store_id,
|
||||||
|
'sales'=>$res['sales'],
|
||||||
|
'stock'=>$res['stock'],
|
||||||
|
];
|
||||||
|
StoreBranchProduct::create($product);
|
||||||
|
$arr=[
|
||||||
|
'product_id'=>$id,
|
||||||
|
'store_id'=>$store_id,
|
||||||
|
'unique'=>$attr_value['unique'],
|
||||||
|
'sales'=>0,
|
||||||
|
'stock'=>0,
|
||||||
|
'type'=>0,
|
||||||
|
'bar_code'=>$attr_value['bar_code']
|
||||||
|
];
|
||||||
|
StoreBranchProductAttrValue::create($arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ class IndexController extends BaseApiController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
d(uniqid(1 . '_', true));
|
||||||
return json(['msg' =>create_password(123456, '11d3')]);
|
return json(['msg' =>create_password(123456, '11d3')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,10 +57,4 @@ class IndexController extends BaseApiController
|
|||||||
return $this->success('ok',$find);
|
return $this->success('ok',$find);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取快递列表
|
|
||||||
*/
|
|
||||||
public function express_list(){
|
|
||||||
return $this->dataLists(new ExpressLists());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use think\model\concern\SoftDelete;
|
|||||||
* Class StoreBranchProduct
|
* Class StoreBranchProduct
|
||||||
* @package app\common\model\store_branch_product
|
* @package app\common\model\store_branch_product
|
||||||
*/
|
*/
|
||||||
class StoreProduct extends BaseModel
|
class StoreBranchProduct extends BaseModel
|
||||||
{
|
{
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
protected $name = 'store_branch_product';
|
protected $name = 'store_branch_product';
|
||||||
|
@ -12,7 +12,7 @@ use think\model\concern\SoftDelete;
|
|||||||
* Class StoreBranchProduct
|
* Class StoreBranchProduct
|
||||||
* @package app\common\model\store_branch_product_attr_value
|
* @package app\common\model\store_branch_product_attr_value
|
||||||
*/
|
*/
|
||||||
class StoreProduct extends BaseModel
|
class StoreBranchProductAttrValue extends BaseModel
|
||||||
{
|
{
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
protected $name = 'store_branch_product_attr_value';
|
protected $name = 'store_branch_product_attr_value';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user