feat: 修改了商品列表和商品逻辑,增加了VIP价格字段,并更新了分类统计功能。
This commit is contained in:
parent
37f7d9ef4e
commit
69236a50d2
@ -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) {
|
||||
|
@ -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()]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user