本文整理汇总了PHP中Period::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Period::find方法的具体用法?PHP Period::find怎么用?PHP Period::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Period
的用法示例。
在下文中一共展示了Period::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wxpay_app
public function wxpay_app()
{
$period_id = Input::get('period_id');
$period = Period::find($period_id);
// 判断时间段有效性
if (!isset($period)) {
return Response::json(array('error_code' => 2, 'message' => '无该时间段,请重新选择'));
}
if ($period->current >= $period->total) {
return Response::json(array('error_code' => 3, 'message' => '已满人,请重新选择'));
}
$schedule = $period->schedule;
$doctor = $schedule->doctor;
$user_id = Session::get('user.id');
// 选择指定挂号账户
if (Input::has('account_id')) {
$account_id = Input::get('account_id');
$account = RegisterAccount::find($account_id);
if (!isset($account)) {
return Response::json(array('error_code' => 4, 'message' => '不存在该挂号账户'));
}
if ($account->user_id != $user_id) {
return Response::json(array('error_code' => 5, 'message' => '无效账户'));
}
} else {
$account = RegisterAccount::where('user_id', $user_id)->first();
if (!isset($account)) {
return Response::json(array('error_code' => 6, 'message' => '请先申请挂号账户'));
}
$account_id = $account->id;
}
$user_id = Session::get('user.id');
$attach = array('period_id' => (int) Input::get('period_id'), 'account_id' => $account_id);
try {
$period = Period::find(Input::get('period_id'));
$schedule = $period->schedule;
$doctor = $schedule->doctor;
$order = $this->create_order($user_id, 'APP', json_encode($attach), (int) ($doctor->register_fee * 100));
$para = array('appid' => $order['appid'], 'partnerid' => WxPayConfig::MCHID, 'prepayid' => $order['prepay_id'], 'package' => 'Sign=WXPay', 'noncestr' => WxPayApi::getNonceStr(), 'timestamp' => time());
$wxpay_result = new WxPayResults();
$wxpay_result->FromArray($para);
$wxpay_result->SetSign();
$package = $wxpay_result->GetValues();
} catch (Exception $e) {
return Response::json(array('error_code' => 1, 'message' => $e->getMessage()));
}
return Response::json(array('error_code' => 0, 'package' => $package));
}
示例2: cancel
public function cancel()
{
$record_id = Input::get('record_id');
$record = RegisterRecord::find($record_id);
// 是否存在该记录
if (!isset($record)) {
return Response::json(array('error_code' => 2, 'message' => '不存在该挂号'));
}
$register_account = RegisterAccount::find($record->account_id);
// 检查该就诊记录是否该用户的
if ($register_account->user_id != Session::get('user.id')) {
return Response::json(array('error_code' => 3, 'message' => '无法取消该挂号'));
}
// 检查就诊状态
if ($record->status) {
return Response::json(array('error_code' => 4, 'message' => '已就诊无法取消'));
}
// 取消同时将对应时间段挂号人数减1
try {
DB::transaction(function () use($record) {
$period = Period::find($record->period_id);
$period->current -= 1;
$period->save();
$record->delete();
$message = new Message();
$message->from_uid = $record->user_id;
$message->to_uid = $record->doctor->user_id;
$message->content = $record->user->real_name . '取消挂号';
$message->timestamp = time();
$message->status = 3;
$message->save();
});
} catch (Exception $e) {
return Response::json(array('error_code' => -1, 'message' => $e->getMessage()));
}
return Response::json(array('error_code' => 0, 'message' => '取消成功'));
}