当前位置: 首页>>代码示例>>PHP>>正文


PHP Period::find方法代码示例

本文整理汇总了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));
 }
开发者ID:Jv-Juven,项目名称:hospital-register-system,代码行数:48,代码来源:PayController.php

示例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' => '取消成功'));
 }
开发者ID:Jv-Juven,项目名称:hospital-register-system,代码行数:37,代码来源:RegisterRecordController.php


注:本文中的Period::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。