Делаает просроченным найденный счёт

@param $bill_id

@return Bill
485354
public static function doExpire($bill_id)
	{
		$isUpdate = Bill::whereBillId($bill_id)
			->whereStatus(self::C_STATUS_WAITING)
			->update(
				array('status' => self::C_STATUS_EXPIRED)
			);

		if ($isUpdate) {
			return true;
		}

		return false;
	}
908262
private function dataFromObj(Bill $bill)
	{
		$data = array();

		$data['bill_id'] = $bill->bill_id;
		$data['amount'] = $bill->amount;
		$data['ccy'] = $bill->ccy;
		$data['status'] = $bill->status;
		$data['user'] = $bill->user;
		$data['comment'] = $bill->comment;
		$data['lifetime'] = $bill->lifetime;
		$data['pay_source'] = $bill->pay_source;
		$data['prv_name'] = $bill->prv_name;

		foreach ($data as $key => $value) {
			if ($value === null) {
				unset($data[$key]);
			}
		}

		return $data;
	}
703290
public function deposit($card_id, $code = [])
    {
        if (!is_string($card_id) || !is_array($code)) {
            $this->setError('参数错误');

            return false;
        }

        $queryStr            = [];
        $queryStr['card_id'] = $card_id;
        $queryStr['code']    = $code;

        $this->apitype = 'card';
        $this->module  = 'code';
        $res           = $this->_post('deposit', $queryStr);

        return $res;
    }
273724
public function store($provider_id, $bill_id)
	{
		$data = Input::all();
		$data['bill_id'] = $bill_id;
		$validator = Validator::make($data, Validators::rulesForNewBill());

		//Если не пройдена валидация - отдаём ошибку формата
		if (!$validator->passes()) {
			$data['error'] = Catalog::C_WRONG_FORMAT;

			return $this->responseFromGate($data);
		}

		//Если сумма мала - отдаём ошибку маленькой суммы
		if ($data['amount'] < 10) {
			$data['error'] = Catalog::C_SMALL_AMOUNT;

			return $this->responseFromGate($data);
		}

		//Если сумма велика - отдаём ошибку большой суммы
		if ($data['amount'] > 15000) {
			$data['error'] = Catalog::C_BIG_AMOUNT;

			return $this->responseFromGate($data);
		}

		//Отдаём ошибку если счёт уже существует
		if (Bill::getBill($bill_id, $provider_id)) {
			$data = array('error' => Catalog::C_BILL_ALREADY_EXIST);

			return $this->responseFromGate($data);
		}

		//Создаём счёт и возвращаем его
		$bill = Bills::NewBill($data);
		if ($bill) {
			$data = $this->dataFromObj($bill);
			$data['error'] = 0;

			return $this->responseFromGate($data);
		}

		//Если не создан счёт, то отдаём техническую ошибку
		$data = array('error' => Catalog::C_TECHNICAL_ERROR);

		return $this->responseFromGate($data);
	}
907486
public function getdepositcount($card_id)
    {
        if (!is_string($card_id)) {
            $this->setError('参数错误');

            return false;
        }

        $queryStr            = [];
        $queryStr['card_id'] = $card_id;

        $this->apitype = 'card';
        $this->module  = 'code';
        $res           = $this->_post('getdepositcount', $queryStr);

        return $res;
    }
354722
public function getCardMemberCard($card_id, $code)
    {
        $data = ['card_id' => $card_id, 'code' => $code];
        $url = "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
600234
public static function isRefundExist($bill_id, $refund_id)
	{
		$existRefund = Refund::whereBillId($bill_id)
			->whereRefundId($refund_id)
			->first();
		if ($existRefund != null) {
			return true;
		}

		return false;
	}
697286
public static function jobBillToQueue($bill_id)
	{
		$bill = Bill::whereBillId($bill_id)->first();
		$merchant = $bill->merchant;
		$command = 'bill';
		$error = 0;
		$key = $merchant->key;
		$sign = '';
		if ('' != $key) {
			$signData = $bill->amount . '|' . $bill->bill_id . '|' . $bill->ccy . '|' . $command . '|' .
				$bill->comment . '|' . $error . '|' . $bill->prv_name . '|' . $bill->status . '|' . $bill->user;
			$sign = base64_encode(hash_hmac('sha1', $signData, $key));
		}
		Queue::connection('ff-qiwi-gate')->push('FintechFab\QiwiGate\Queue\SendCallback', array(
			'url'           => $merchant->callback_url,
			'merchant_id'   => $merchant->id,
			'merchant_pass' => $merchant->password,
			'bill_id'       => $bill->bill_id,
			'status'        => $bill->status,
			'error'         => $error,
			'amount'        => $bill->amount,
			'user'          => $bill->user,
			'prv_name'      => $bill->prv_name,
			'ccy'           => $bill->ccy,
			'comment'       => $bill->comment,
			'command'       => $command,
			'sign'          => $sign,
		));
	}
995522
public function customWxcard($card_id = '', $card_ext = [], $openid, $kf_account = '')
    {
        $queryStr                       = [];
        $queryStr['touser']             = $openid;
        $queryStr['msgtype']            = 'wxcard';
        $queryStr['wxcard']['card_id']  = $card_id;
        $queryStr['wxcard']['card_ext'] = $card_ext;

        $queryStr['customservice']['kf_account'] = $kf_account;

        $this->module = 'message';

        $res = $this->_post('custom/send', $queryStr);

        return $res;
    }
160195
public function update($provider_id, $bill_id, $refund_id)
	{
		$bill = Bill::getBill($bill_id, $provider_id);
		//Проверяем наличие счёта
		if (!$bill) {
			$data['error'] = Catalog::C_BILL_NOT_FOUND;

			return $this->responseFromGate($data);
		}

		//Проверяем refund_id на уникальность в этом счёте
		if (Refund::isRefundExist($bill_id, $refund_id)) {
			$data['error'] = Catalog::C_BILL_ALREADY_EXIST;

			return $this->responseFromGate($data);
		}

		//Проверяем статус
		if (!$bill->isPaid()) {
			$data['error'] = Catalog::C_BILL_NOT_FOUND;

			return $this->responseFromGate($data);
		}

		//Проверяем запрошенную сумму для отмены
		$amountQuery = Input::get('amount');
		$validator = Validator::make(
			array('amount' => $amountQuery),
			Validators::rulesForRefundBill()
		);
		if (!$validator->passes()) {
			$data['error'] = Catalog::C_WRONG_FORMAT;

			return $this->responseFromGate($data);
		}

		//Вычисляем сууму для возврата
		$refundAmount = Refunds::calculateAmount($bill, $amountQuery);

		$data = array(
			'bill_id'   => $bill_id,
			'refund_id' => $refund_id,
			'amount'    => $refundAmount,
			'status'    => 'processing',
		);
		Refunds::NewRefund($data);
		$data['user'] = $bill->user;
		$data['error'] = Catalog::C_WITHOUT_ERRORS;

		return $this->responseFromGate($data);

	}
131014
public function hasTerm($term_id) {
    $term = ($term_id instanceof Term) ? $term_id : Term::findOrFail($term_id);

    $term_relation = [
      'term_id' => $term->id,
      'vocabulary_id' => $term->vocabulary_id,
    ];

    return ($this->related()->where('term_id', $term_id)->count()) ? TRUE : FALSE;
  }
514761
public OvhDebt bill_billId_debt_GET(String billId) throws IOException {
		String qPath = "/me/bill/{billId}/debt";
		StringBuilder sb = path(qPath, billId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhDebt.class);
	}
391726
public function show($provider_id, $bill_id)
	{
		//Находим счёт
		$bill = Bill::getBill($bill_id, $provider_id);

		//Отдаём ошибку если счёт не найден
		if ($bill == null) {
			$data['error'] = Catalog::C_BILL_NOT_FOUND;

			return $this->responseFromGate($data);
		}

		//Если счёт стал просроченным - меняем статус, кидаем callback и обновляем счёт
		if ($bill->isExpired() && $bill->doExpire($bill_id)) {
			$this->sendCallback($bill_id);
			$bill = Bill::find($bill->id);
		}

		//Фотмируем ответ и возвращаем
		$data = $this->dataFromObj($bill);
		$data['error'] = 0;

		return $this->responseFromGate($data);
	}
1237408
def bills(self, member_id, type='introduced'):
        ""
        path = "members/{0}/bills/{1}.json".format(member_id, type)
        return self.fetch(path)
905156
public OvhBill bill_billId_GET(String billId) throws IOException {
		String qPath = "/me/bill/{billId}";
		StringBuilder sb = path(qPath, billId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhBill.class);
	}
661253
public function payGetOrder($order_id)
    {
        $url = "https://api.weixin.qq.com/card/pay/getorder?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['order_id' => $order_id]);
    }
1011750
public static function find($term_id)
    {
        $instance = Post\Factory::create(get_called_class());
        $instance->load($term_id);
        return $instance;
    }