0) { // $result['price'] = ceil($result['price'] * 10); // $result['price'] = bcdiv($result['price'], 10, 2); // } $lastNum = substr($result['vip_price'], -1); if ($lastNum > 0) { $result['vip_price'] = ceil($result['vip_price'] * 10); $result['vip_price'] = bcdiv($result['vip_price'], 10, 2); } return $result; } /** * @param $productId int 商品id * @param $percent bool 是否返回百分比 * @return array|int[] * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getProductPriceRate($productId, $percent = false) { $list = StoreProductPriceList::where('product_id', $productId)->findOrEmpty()->toArray(); $product = StoreProduct::where('id', $productId)->field('id,store_name,top_cate_id,cate_id')->find(); if (empty($list)) { if ($product->isSpecial()) { $list = [ 'supply_rate' => 102, 'merchant_rate' => 102, 'vip_rate' => 104, 'price_rate' => 108, ]; } else { $list = [ 'supply_rate' => 105, 'merchant_rate' => 105, 'vip_rate' => 108, 'price_rate' => 112, ]; } } if ($percent) { $list['supply_rate'] = $list['supply_rate'] / 100; $list['merchant_rate'] = $list['merchant_rate'] / 100; $list['vip_rate'] = $list['vip_rate'] / 100; $list['price_rate'] = $list['price_rate'] / 100; } return $list; } }