diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index e8f58ed18..a32f501f4 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) + ->field(['id', 'image', 'store_name', 'cate_id', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 5f0f40ae7..7629e7066 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -116,16 +116,16 @@ class StoreProductLogic extends BaseLogic 'purchase' => $params['purchase'], 'rose' => $params['rose'], 'is_return' => $params['is_return'], + 'price' => $params['price'], + 'vip_price' => $params['vip_price'], + 'cost' => $params['cost'], ]; - if ($params['rose'] > 0) { - $rose_price = bcmul($params['cost'], bcdiv($params['rose'], 100, 2), 2); - $data['price'] = bcadd($params['cost'], $rose_price, 2); - } else { - $data['price'] = 0; - } StoreProduct::where('id', $params['id'])->update($data); - + StoreBranchProduct::where('product_id', $params['id'])->update([ + 'price' => $params['price'], 'vip_price' => $params['vip_price'], + 'cost' => $params['cost'] + ]); Db::commit(); return true; } catch (\Exception $e) { @@ -185,21 +185,21 @@ class StoreProductLogic extends BaseLogic $two = StoreCategory::where('id', $one['pid'])->find(); if ($two) { if ($two['pid'] != 0) { - self::cate_update($cate_id,$two['id'],0,3); - self::cate_update($two['id'],$two['pid'],0,2); - self::cate_update($two['pid'],0,0,1); + self::cate_update($cate_id, $two['id'], 0, 3); + self::cate_update($two['id'], $two['pid'], 0, 2); + self::cate_update($two['pid'], 0, 0, 1); } } } } - public static function cate_update($cate_id = 0,$pid=0, $product_id = 0, $level = 1) + public static function cate_update($cate_id = 0, $pid = 0, $product_id = 0, $level = 1) { $find = Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id, 'level' => $level])->find(); if ($find) { Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update(); } else { - Db::name('store_product_cate')->insert(['pid'=>$pid,'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); + Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); } } /**