* @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function goods(): BelongsTo { return $this->belongsTo(Goods::class); } /** * Notes : 当前规格是否可购买 * * @Date : 2021/5/14 10:08 * @Author : Mr.wang * @param int $qty * @return bool */ public function canBuy(int $qty = 1): bool { if ($this->goods->channel == Goods::CHANNEL_FREE) { return true; } if ($this->goods->status == Goods::STATUS_UP && $this->stock >= $qty) { return true; } return false; } /** * @Notes : 检测商品价格,给出最低售价 * * @Date : 2022/6/30 11:41 * @param float $cost * @param float $price * @return float * @author : Mr.wang */ public static function verifyPrice(float $cost, float $price): float { return 0; $costPercent = app('Conf_mall')['cost_percent'] ?? 70; $up = ceil(bcdiv($cost, bcdiv($costPercent, 100, 4), 2)); if ($price < $up) { return $up; } else { return 0; } } }