public function index() { $this->auth(); $user = User::find(Session::get('uid')); foreach ($user->notices as $vv) { $vv->wish = Wish::find($vv->wishId); unset($vv->wishId); if (!$vv->wish) { continue; } $v = $vv->wish; $creator = User::find($v->creatorId); $creator->school; unset($creator->schoolId); $v->creatorUser = $creator; $picker = User::find($v->pickerId); if ($picker) { $picker->school; unset($picker->schoolId); $v->pickerUser = $picker; } } return $this->output(array('total' => Notice::where('userId', '=', $user->id)->count(), 'notices' => $user->notices)); }
/** * @param Request $request * @return Response * * @api {get} /yzh/notice/investment 投资结果通知 * @apiName GetNoticeInvestment * @apiGroup Notice * * @apiParam {String} UserId 用户ID * @apiParam {String} ProductName 理财产品名称 * @apiParam {String} Amount 投资金额 * @apiParam {String} DateTime 投资时间 * @apiParam {String} Ref 消息流水号 * * @apiSuccessExample Success-Response: * success */ public function noticeInvestment(Request $request) { $input = $request->all(); Logger::AuthorizationInfo('@YzhController noticeInvestment, start', $input); if (empty($input['sign'])) { Logger::AuthorizationError('@YzhController noticeInvestment, no sign'); return response('no sign'); } // sign if (!HMAC::compare($input, $this->getKey(), $input['sign'])) { Logger::AuthorizationError('@YzhController noticeInvestment, sign error'); return response('sign error'); } // duplicate $row = Notice::where('ref', $input['Ref'])->first(); if ($row) { Logger::AuthorizationInfo('@YzhController noticeInvestment, duplicate, return success'); return response('success'); } // data 记录通知数据,跟据业务再做处理 $notice = new Notice(); $notice->ref = $input['Ref']; $notice->type = Notice::T_INVEST; $notice->uid = $input['UserId']; $notice->result = json_encode($input); $notice->save(); // response Logger::AuthorizationInfo('@YzhController noticeInvestment, received, return success'); return response('success'); }