find();; } /** * @name 追加消费金额和总订单数 * @param int|object $userId 会员ID * @param float $amount 变更金额 * @param int $orderCount 订单数量增量,默认为1 * @return boolean */ public static function consume($userId = 0, $amount, $orderCount = 1) { // 判断金额 if ($amount == 0) { return false; } $user = self::getUserById($userId); if (!$user) { throw new BusinessException('未找到用户'); } // 更新会员消费金额和订单数量 $user->setInc('total_consume', $amount); if ($orderCount > 0) { $user->setInc('order_count', $orderCount); } return true; } }