示例#1
0
文件: Weixin.php 项目: andygoo/kohana
 public function action_sendredpack()
 {
     $phone = 13800000000;
     $params = array("openid" => 'W34SD#@#DSDSDSDSAAAAAA', "total_amount" => 100, "total_num" => 1, "mch_billno" => sprintf("10125753%s%11d", date('Ymd'), $phone), "act_name" => "卖车红包", "remark" => "卖车红包", "wishing" => "请爷收银子");
     $ret = WeixinPay::sendredpack($params);
     var_dump($ret);
 }
 public function NotifyProcess($message, &$msg)
 {
     if ($message['return_code'] == 'SUCCESS') {
         // 通过 out_trade_no 获取相应订单记录
         $pay_record = WeixinPay::where('trade_no', $message['out_trade_no'])->first();
         if (!isset($pay_record)) {
             $msg = 'Invalid out_trade_no';
             return false;
         }
         if ($pay_record->status != 'UNFINISHED') {
             $msg = 'Already processed';
             return true;
         }
         // 对比附加数据
         if ($pay_record->attach != $message['attach']) {
             $msg = 'Attach Error';
             return false;
         }
         return RegisterRecordController::create_record($pay_record, $message);
     } else {
         // if ( $message['return_code'] == 'FAIL' )
         return false;
     }
     return true;
 }
 public function modify_advice()
 {
     if (!Input::has('advice')) {
         return Response::json(array('error_code' => 2, 'message' => '不能为空'));
     }
     $advice = Input::get('advice');
     $record = RegisterRecord::find(Input::get('record_id'));
     if (!isset($record)) {
         return Response::json(array('error_code' => 3, 'message' => '不存在该挂号'));
     }
     // 检查该就诊记录是否该医生的
     if ($record->doctor_id != Session::get('doctor.id')) {
         return Response::json(array('error_code' => 4, 'message' => '无法修改该挂号'));
     }
     $record->advice = $advice;
     if (!$record->save()) {
         return Response::json(array('error_code' => 1, 'message' => '添加失败'));
     }
     // 通过微信公众号向永华发送模板消息
     $weixin_pay_order = WeixinPay::where('record_id', $record->id)->first();
     if (isset($weixin_pay_order) && $weixin_pay_order->status == 'FINISHED') {
         WeixinSDK::send_template_message(['touser' => $weixin_pay_order->open_id, 'template_id' => Config::get('weixin.template.advice'), 'topcolor' => '#FF00000', 'data' => array('first' => ['value' => '诊后医嘱提醒'], 'keyword1' => ['value' => $record->doctor->name], 'keyword2' => ['value' => $advice], 'remark' => ['value' => '请谨遵医嘱'])]);
     }
     return Response::json(array('error_code' => 0, 'message' => '添加成功'));
 }