修改预订单商品分组价格查询

This commit is contained in:
DESKTOP-GMUNQ1B\Administrator 2024-12-09 17:37:48 +08:00
parent e3cff35799
commit 942a04f514
2 changed files with 19 additions and 3 deletions

View File

@ -64,10 +64,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
}
}
$is_warehouse=$this->request->get('is_warehouse',0);
$userShip = 0;
if (!empty($this->params['user_id'])) {
$userShip = User::where('id', $this->params['user_id'])->value('user_ship');
}
$list = StoreProduct::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) use($is_warehouse) {
->select()->each(function ($item) use($is_warehouse, $userShip) {
$item['product_id'] = $item['id'];
$item['bar_code_two'] = '';
if (in_array($item['unit'], [2, 21])) {
@ -111,10 +115,12 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
$nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
$item['stock'] = bcadd($nums, $stock);
}
if ($userShip == 4) {
$item['price'] = $item['cost'];
}
return $item;
})?->toArray();
if (!empty($this->params['user_id'])) {
$userShip = User::where('id', $this->params['user_id'])->value('user_ship');
if ($userShip > 0 && $userShip != 4) {
$list = StoreProductGroupPrice::resetProductsPrice($list, $userShip);
}
return $list;

View File

@ -11,9 +11,11 @@ use app\common\model\store_branch_product_exchange\StoreBranchProductExchange;
use app\common\model\store_category\StoreCategory;
use app\common\model\store_product_attr_value\StoreProductAttrValue;
use app\common\model\store_product_cate\StoreProductCate;
use app\common\model\store_product_group_price\StoreProductGroupPrice;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore;
use app\common\model\system_store_storage\SystemStoreStorage;
use app\common\model\user\User;
use Illuminate\Support\Facades\Log;
use support\exception\BusinessException;
use think\facade\Db;
@ -304,6 +306,14 @@ class StoreProductLogic extends BaseLogic
$data['cate_arr'][]=$data['cate_id'];
}
$data['unit_name']=StoreProductUnit::where('id', $data['unit'])->value('name');
if (!empty($params['user_id'])) {
$userShip = User::where('id', $params['user_id'])->value('user_ship');
if ($userShip == 4) {
$data['price'] = $data['cost'];
} else {
$data = StoreProductGroupPrice::resetProductPrice($data, $userShip);
}
}
return $data;
}