修改商品分组价格同步
This commit is contained in:
parent
d51d56a314
commit
0b025edcda
@ -53,7 +53,13 @@ class StoreProductGroupPriceLists extends BaseAdminDataLists implements ListsSea
|
|||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item['lists'] =StoreProductGroupPrice::where('product_id',$item['id'])->field('id,group_id,price')
|
$item['lists'] =StoreProductGroupPrice::where('product_id',$item['id'])->field('id,group_id,price')
|
||||||
->select()->each(function ($item_two){
|
->select()->each(function ($item_two){
|
||||||
$item_two['group_name']=UserShip::where('id',$item_two['group_id'])->value('title');
|
if ($item_two['group_id'] == 100001) {
|
||||||
|
$item_two['group_name'] = '供货价';
|
||||||
|
} else if ($item_two['group_id'] == 100002) {
|
||||||
|
$item_two['group_name'] = '零售价';
|
||||||
|
} else {
|
||||||
|
$item_two['group_name'] = UserShip::where('id', $item_two['group_id'])->value('title');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
@ -48,7 +48,7 @@ class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
$this->searchWhere[]=['product_id','in',$store_id];
|
$this->searchWhere[]=['product_id','in',$store_id];
|
||||||
}
|
}
|
||||||
return StoreProductPrice::where($this->searchWhere)
|
return StoreProductPrice::where($this->searchWhere)
|
||||||
->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'status'])
|
->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'price_config', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item){
|
||||||
|
@ -106,6 +106,8 @@ class StoreProductGroupPriceLogic extends BaseLogic
|
|||||||
$arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray();
|
$arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray();
|
||||||
$purchase=StoreProduct::where('id',$params['product_id'])->value('purchase');
|
$purchase=StoreProduct::where('id',$params['product_id'])->value('purchase');
|
||||||
$arr_two=UserShip::where('id','>',4)->select()->toArray();
|
$arr_two=UserShip::where('id','>',4)->select()->toArray();
|
||||||
|
$arr_two[] = ['id' => 100001, 'title' => '供货价'];
|
||||||
|
$arr_two[] = ['id' => 100002, 'title' => '零售价'];
|
||||||
foreach ($arr_two as $k=>$v){
|
foreach ($arr_two as $k=>$v){
|
||||||
$arr_two[$k]['purchase']=$purchase;
|
$arr_two[$k]['purchase']=$purchase;
|
||||||
$arr_two[$k]['product_id']=$params['product_id'];
|
$arr_two[$k]['product_id']=$params['product_id'];
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace app\admin\logic\store_product_price;
|
namespace app\admin\logic\store_product_price;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||||
use app\common\model\store_product_price\StoreProductPrice;
|
use app\common\model\store_product_price\StoreProductPrice;
|
||||||
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\StoreBranchProduct;
|
||||||
@ -59,7 +60,8 @@ class StoreProductPriceLogic extends BaseLogic
|
|||||||
'status' => 1,
|
'status' => 1,
|
||||||
'purchase' => $params['purchase'],
|
'purchase' => $params['purchase'],
|
||||||
'cost' => $params['cost'],
|
'cost' => $params['cost'],
|
||||||
'price' => $params['price']
|
'price' => $params['price'],
|
||||||
|
'price_config' => $params['price_config'],
|
||||||
]);
|
]);
|
||||||
StoreProduct::where('id', $find['product_id'])->update([
|
StoreProduct::where('id', $find['product_id'])->update([
|
||||||
'purchase' => $find['purchase'],
|
'purchase' => $find['purchase'],
|
||||||
@ -73,6 +75,7 @@ class StoreProductPriceLogic extends BaseLogic
|
|||||||
'vip_price' => $find['cost'],
|
'vip_price' => $find['cost'],
|
||||||
'price' => $find['price']
|
'price' => $find['price']
|
||||||
]);
|
]);
|
||||||
|
self::setProductGroupPrice($find);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -109,6 +112,7 @@ class StoreProductPriceLogic extends BaseLogic
|
|||||||
'vip_price' => $find['cost'],
|
'vip_price' => $find['cost'],
|
||||||
'price' => $find['price']
|
'price' => $find['price']
|
||||||
]);
|
]);
|
||||||
|
self::setProductGroupPrice($find);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -143,4 +147,28 @@ class StoreProductPriceLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
return StoreProductPrice::findOrEmpty($params['id'])->toArray();
|
return StoreProductPrice::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setProductGroupPrice($storeProductPrice)
|
||||||
|
{
|
||||||
|
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $storeProductPrice['product_id'])->select()->toArray();
|
||||||
|
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
|
||||||
|
$insertData = [];
|
||||||
|
foreach ($storeProductPrice['price_config'] as $k => $v) {
|
||||||
|
$current = $storeProductGroupPrice[$v['group_id']] ?? [];
|
||||||
|
$item = [
|
||||||
|
'product_id' => $storeProductPrice['product_id'],
|
||||||
|
'group_id' => $v['group_id'],
|
||||||
|
'price' => $v['price'],
|
||||||
|
'price_type' => 3,
|
||||||
|
'base_rate' => $v['base_rate'],
|
||||||
|
];
|
||||||
|
if (!empty($current)) {
|
||||||
|
$item['base_rate'] = $current['base_rate'];
|
||||||
|
$item['id'] = $current['id'];
|
||||||
|
}
|
||||||
|
$insertData[] = $item;
|
||||||
|
}
|
||||||
|
(new StoreProductGroupPrice())->saveAll($insertData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user