commit
87bdbea515
@ -225,6 +225,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -358,18 +359,26 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
if (!empty($productCatePriceRate)) {
|
||||
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray();
|
||||
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
|
||||
$purchase=0;
|
||||
foreach ($productCatePriceRate as $k => $v) {
|
||||
if ($v['id'] == 4) {
|
||||
$data['cost_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['cost'] = bcmul($params['purchase'], bcadd($data['cost_lv'], 1, 2), 2);
|
||||
continue;
|
||||
} elseif ($v['id'] == 100001) {
|
||||
if ($v['id'] == 100001) {
|
||||
//供货
|
||||
$data['purchase_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['purchase'] = bcmul($params['purchase'], bcadd($data['purchase_lv'], 1, 2), 2);
|
||||
$purchase=$data['purchase'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ($productCatePriceRate as $k => $v) {
|
||||
if ($v['id'] == 4 &&$purchase>0) {
|
||||
//商户
|
||||
$data['cost_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2);
|
||||
continue;
|
||||
} elseif ($v['id'] == 100002) {
|
||||
}elseif ($v['id'] == 100002 &&$purchase>0) {
|
||||
//零售
|
||||
$data['price_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['price'] = bcmul($params['purchase'], bcadd($data['price_lv'], 1, 2), 1);
|
||||
$data['price'] = bcmul($purchase, bcadd($data['price_lv'], 1, 2), 1);
|
||||
if ($product['two_cate_id'] == 15268) {
|
||||
$lastNum = substr($data['price'], -1);
|
||||
if ($lastNum <= 2) {
|
||||
@ -383,20 +392,22 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
continue;
|
||||
}
|
||||
$baseRate = 100 + $v['rate'];
|
||||
$item = [
|
||||
'product_id' => $product['id'],
|
||||
'group_id' => $v['id'],
|
||||
'group_name' => $v['title'],
|
||||
'price' => bcmul($params['purchase'], $baseRate / 100, 2),
|
||||
'price_type' => 3,
|
||||
'base_rate' => $baseRate,
|
||||
];
|
||||
if (isset($storeProductGroupPrice[$v['id']])) {
|
||||
$item['base_rate'] = $storeProductGroupPrice[$v['id']]['base_rate'];
|
||||
$item['price'] = bcmul($params['purchase'], $item['base_rate'] / 100, 2);
|
||||
$item['id'] = $storeProductGroupPrice[$v['id']]['id'];
|
||||
if($purchase>0){
|
||||
$item = [
|
||||
'product_id' => $product['id'],
|
||||
'group_id' => $v['id'],
|
||||
'group_name' => $v['title'],
|
||||
'price' => bcmul($purchase, $baseRate / 100, 2),
|
||||
'price_type' => 3,
|
||||
'base_rate' => $baseRate,
|
||||
];
|
||||
if (isset($storeProductGroupPrice[$v['id']])) {
|
||||
$item['base_rate'] = $storeProductGroupPrice[$v['id']]['base_rate'];
|
||||
$item['price'] = bcmul($purchase, $item['base_rate'] / 100, 2);
|
||||
$item['id'] = $storeProductGroupPrice[$v['id']]['id'];
|
||||
}
|
||||
$priceConfig[] = $item;
|
||||
}
|
||||
$priceConfig[] = $item;
|
||||
}
|
||||
}
|
||||
$data['price_config'] = $priceConfig;
|
||||
|
Loading…
x
Reference in New Issue
Block a user