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