data; $userid = $user['id']; $res = Users::where('id', $userid)->first('timecoin'); return ApiResponse::success(200, $res); } /** * @Apidoc\Title("1.0 获取当前用户时间币记录") * @Apidoc\Url("api/v1/bank/get_back_log") * @Apidoc\Method("POST") */ public function get_back_log(Request $request) { $user = $request->data; $userid = $user['id']; $res = BankLog::where('userid', $userid)->orderBy('created_at', 'desc')->limit(3)->get(); return ApiResponse::success(200, $res); } /** * @Apidoc\Title("1.0 获取当前用户时间币所有记录") * @Apidoc\Url("api/v1/bank/get_back_log_all") * @Apidoc\Method("POST") */ public function get_back_log_all(Request $request) { $user = $request->data; $userid = $user['id']; $res = BankLog::where('userid', $userid)->orderBy('created_at', 'desc')->get(); return ApiResponse::success(200, $res); } /** * @Apidoc\Title("1.0 转账时间币到其他用户") * @Apidoc\Url("api/v1/bank/transfer") * @Apidoc\Param("amount", type="int",require=true, desc="金额",default="1") * @Apidoc\Param("phone", type="int",require=true, desc="收款人手机号",default="我是你爹") * @Apidoc\Method("POST") */ public function transfer(Request $request) { $data = $request->post(); $user = $request->data; $userid = $user['id']; $amount = $data['amount']; $phone = $data['phone']; $res = BankDao::transfer($userid, $phone, $amount); if($res['status']=='error'){ return ApiResponse::success(402, $res); } return ApiResponse::success(200, $res); } /** * @Apidoc\Title("1.0 增加时间币测试") * @Apidoc\Url("api/v1/bank/add") * @Apidoc\Param("amount", type="int",require=true, desc="金额",default="1") * @Apidoc\Param("remark", type="string",require=true, desc="备注",default="我是你爹") * @Apidoc\Method("POST") */ public function add(Request $request) { $data = $request->post(); $user = $request->data; $userid = $user['id']; $amount = $data['amount']; $remark = $data['remark']; BankDao::add($userid, $amount, $remark); return ApiResponse::success(200, []); } /** * @Apidoc\Title("1.0 搜索转账人") * @Apidoc\Url("api/v1/bank/search_user") * @Apidoc\Param("key", type="string",require=true, desc="关键词",default="1") * @Apidoc\Method("POST") */ public function search_user(Request $request) { $data = $request->post(); $users = Users::where('nickname', 'like', '%' . $data['key'] . '%') ->orWhere('phone', 'like', '%' . $data['key'] . '%') ->get(['id','nickname','phone']); return ApiResponse::success(200, $users); } }