feat: 修改了商品管理的逻辑和查询方法
This commit is contained in:
parent
6a7b3d9701
commit
c28a719e82
@ -51,11 +51,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||||
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
|
||||||
if($item['store_id'] == 0){
|
|
||||||
$item['system_store_name'] = '平台';
|
|
||||||
}else{
|
|
||||||
$item['system_store_name'] = '门店:'.SystemStore::where('id', $item['store_id'])->value('name');
|
|
||||||
}
|
|
||||||
return $item;
|
return $item;
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
@ -174,23 +174,19 @@ class StoreProductLogic extends BaseLogic
|
|||||||
public static function copy($id, $store_id)
|
public static function copy($id, $store_id)
|
||||||
{
|
{
|
||||||
$find = StoreProduct::where('id', $id)->findOrEmpty()->toArray();
|
$find = StoreProduct::where('id', $id)->findOrEmpty()->toArray();
|
||||||
$store_find = StoreProduct::where(['source_id' => $id, 'store_id' => $store_id])->findOrEmpty()->toArray();
|
$store_find = StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->findOrEmpty()->toArray();
|
||||||
if ($find && !$store_find) {
|
if ($find && !$store_find) {
|
||||||
$attr_value = StoreProductAttrValue::where('product_id', $id)->findOrEmpty();
|
$attr_value = StoreProductAttrValue::where('product_id', $id)->findOrEmpty();
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
unset($find['create_time'], $find['update_time'], $find['id'],$find['stock']);
|
|
||||||
$find['store_id'] = $store_id;
|
|
||||||
$find['source_id'] = $id;
|
|
||||||
$res = StoreProduct::create($find);
|
|
||||||
$product = [
|
$product = [
|
||||||
'product_id' => $res['id'],
|
'product_id' => $find['id'],
|
||||||
'image' => $res['image'],
|
'image' => $find['image'],
|
||||||
'store_name' => $res['store_name'],
|
'store_name' => $find['store_name'],
|
||||||
'store_info' => $res['store_info'],
|
'store_info' => $find['store_info'],
|
||||||
'keyword' => $res['keyword'],
|
'keyword' => $find['keyword'],
|
||||||
'bar_code' => $res['bar_code'],
|
'bar_code' => $find['bar_code'],
|
||||||
'cate_id' => $res['cate_id'],
|
'cate_id' => $find['cate_id'],
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'sales' => 0,
|
'sales' => 0,
|
||||||
'stock' =>0,
|
'stock' =>0,
|
||||||
@ -199,7 +195,6 @@ class StoreProductLogic extends BaseLogic
|
|||||||
$arr = [
|
$arr = [
|
||||||
'product_id' => $id,
|
'product_id' => $id,
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'unique' => setUnique($res['id'], '', 0),
|
|
||||||
'sales' => 0,
|
'sales' => 0,
|
||||||
'stock' => 0,
|
'stock' => 0,
|
||||||
'type' => 0,
|
'type' => 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user