商户权限限制新增批发价
This commit is contained in:
parent
db6ef815aa
commit
4849540761
@ -14,6 +14,7 @@ namespace app\common\repositories\store\product;
|
||||
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\product\ProductLabel;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\community\CommunityRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
@ -518,10 +519,18 @@ class ProductRepository extends BaseRepository
|
||||
if ($data['integral_rate'] > 100) $integral_rate = 100;
|
||||
|
||||
}
|
||||
//判断商户的权限
|
||||
$check = Merchant::getDB()->where('mer_id',$data['mer_id'])->value('wholesale');
|
||||
|
||||
$wholesalePrices = array_column($data['attrValue'], 'wholesale_price');
|
||||
$minPriceOtPrice = min($wholesalePrices);
|
||||
|
||||
if($check){ //权限为1或者2
|
||||
$wholesalePrices = array_column($data['attrValue'], 'wholesale_price');
|
||||
if(empty($wholesalePrices)){
|
||||
return app('json')->fail('商户为批发或者零售+批发缺失批发价');
|
||||
}
|
||||
$minPriceOtPrice = min($wholesalePrices);
|
||||
}else{
|
||||
$minPriceOtPrice = 0;
|
||||
}
|
||||
$result = [
|
||||
'store_name' => $data['store_name'],
|
||||
'image' => $data['image'],
|
||||
@ -680,10 +689,18 @@ class ProductRepository extends BaseRepository
|
||||
}
|
||||
$new_price = $value['price'] ? (($value['price'] < 0) ? 0 : $value['price']) : 0;
|
||||
$otPrice = $value['ot_price'] ? (($value['ot_price'] < 0) ? 0 : $value['ot_price']) : 0;
|
||||
|
||||
if(isset($value['wholesale_price'])){
|
||||
$wholesale_price = $value['wholesale_price'] ? (($value['wholesale_price'] < 0) ? 0 : $value['wholesale_price']) : 0;
|
||||
}else{
|
||||
$wholesale_price = min($new_price,$otPrice);
|
||||
$check = Merchant::getDB()->where('mer_id',$data['mer_id'])->value('wholesale');
|
||||
|
||||
if($check){
|
||||
$wholesale_price = min($new_price,$otPrice);
|
||||
}else{
|
||||
$wholesale_price = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$new_stock = $value['stock'] ? (($value['stock'] < 0) ? 0 : $value['stock']) : 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user