1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630 |
- <?php
- namespace App\Http\Controllers\Api\V1;
- use App\Models\AccountLog;
- use App\Models\BaseDictionaryOptionModel;
- use App\Models\BaseSettingsModel;
- use App\Models\CommentInfoModel;
- use App\Models\DreamInfoModel;
- use App\Models\InteractionInfo;
- use App\Models\SearchInfoModel;
- use App\Models\Suggest;
- use App\Models\SupportDreamModel;
- use App\Models\SystemInfoModel;
- use App\Models\UserBank;
- use App\Models\UserCareDream;
- use App\Models\UserCareUser;
- use App\Models\UserCashOut;
- use App\Models\UserInfoModel;
- use Illuminate\Http\Request;
- use App\Services\Base\ErrorCode;
- use App\Helper\JpushHelper;
- use Illuminate\Support\Facades\Log;
- class MyController extends Controller
- {
- use JpushHelper;
- /**
- * @api {get} /api/my/show 个人首页
- * @apiDescription 个人首页
- * @apiGroup My
- * @apiPermission Passport
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 O* "status": true,
- {
- "status": true,
- "status_code": 0,
- "message": "",
- "data": {
- "id": 1,
- "phone": "13880642880",
- "nickname": "name1",
- "avatar": "/upload/user/20170629/e77068cc14c82086fb6b16e5bb7c3dd1.jpg",
- "birthday": "2000-06-21",
- "sign": 0,
- "money": 0,
- "coin": 308,
- "sex": 1,
- "signture": "我的个性签名1",
- "height": 170,
- "work": "网红",
- "emotion": 1,
- "address": "",
- "city": "上海",
- "detail_address": "",
- "status": 1,
- "wechat": "",
- "weibo": "",
- "remember_token": "",
- "created_at": "2017-06-25 10:27:08",
- "updated_at": "2017-08-19 13:24:29",
- "deleted_at": null,
- "care_number": 0, 关注
- "fans_number": 0, 粉丝
- "dreams_number": 9, 梦想
- "collection_number": 0, 收藏
- "interaction_number": 0, 发帖
- "huitie": 1, 回复
- }
- }
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": {
- * "user": null
- * }
- *}
- */
- public function show()
- {
- $user = $this->getUser();
- /*
- * 我的关注人数,我的粉丝,收藏
- * 点赞?徽章?
- * */
- $care_num = $user->UserCareUser;
- $user->care_number = count($care_num);
- $fens = UserCareUser::where('other_user_id',$user->id)->get();
- $user->fans_number = count($fens);
- $dreams = $user->dreams;
- $user->dreams_number = count($dreams);
- $collection = $user->collection;
- $user->collection_number = count($collection);
- $interaction_infos = $user->allInteraction;
- $user->interaction_number = count($interaction_infos);
- $huitie = CommentInfoModel::where('user_id',$user->id)->orWhere('to_user_id',$user->id)->get()->groupBy('interaction_id');
- $user->huitie = count($huitie);
- return $this->api($user);
- }
- /**
- * @api {get} /api/my/edit 修改个人信息
- * @apiDescription 修改个人信息
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- "data": {
- "emotion": [
- {
- "value": "1",
- "name": "未婚"
- },
- {
- "value": "2",
- "name": "已婚"
- },
- {
- "value": "3",
- "name": "离异"
- }
- ],
- "sex": [
- {
- "value": "0",
- "name": "男"
- },
- {
- "value": "1",
- "name": "女"
- }
- ]
- }
- * }
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- * {
- * "status": false,
- * "status_code": 1500,
- * "message": "会员不存在",
- * "data": null
- * }
- */
- public function edit()
- {
- $sex = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
- where('dictionary_code','sex')->get();
- $emotion = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
- where('dictionary_code','emotion')->get();
- return $this->api(compact('emotion','sex'));
- }
- /**
- * @api {post} /api/my/update 保存个人信息
- * @apiDescription 保存个人信息
- * @apiParam {string} pic 头像
- * @apiParam {int} sex 性别
- * @apiParam {string} signture 个性签名
- * @apiParam {int} emotion 情感状态
- * @apiParam {string} work 职业
- * @apiParam {int} height 身高
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- *{
- * "status": false,
- * "status_code": 600,
- * "message": "保存用户数据失败",
- * "data": null
- * }
- */
- public function update(Request $request)
- {
- $user = $this->getUser();
- $data = $request->except('_token');
- $ok = $user->update($data);
- if ($ok == true) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::SAVE_USER_FAILED);
- }
- }
- /**
- * 极光推送接口
- * @param Request $request
- * @return mixed
- */
- public function jpush(Request $request)
- {
- $user = $this->getUser();
- $data = $request->except('_token');
- $ok = $user->update($data);
- if ($ok == true) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::SAVE_USER_FAILED);
- }
- }
- /**
- * @api {post} /api/my/recharge 充值
- * @apiDescription 充值
- * @apiGroup My
- * @apiParam {int} coin 充值金额
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function recharge(Request $request)
- {
- $validator = \Validator::make($request->all(),
- [
- 'coin' => 'required|integer',
- ],
- [
- 'coin.required' => '请填写金额',
- 'coin.integer' => '请输入整数',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $user = $this->getUser();
- $user->coin += $request->coin;
- $user->save();
- return $this->api('');
- }
- /**
- * @api {get} /api/my/dream_info 梦想消息
- * @apiDescription 梦想消息
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": [
- * {
- * ....
- * }
- * ]
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function dreamInfo()
- {
- // 梦想消息分为 1支持 2收藏 3互动 4提现 5梦想暂停 6结束
- $user = $this->getUser();
- $data1 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',1)->orderBy('id','desc')->get()->toArray();
- $new_data1 = [] ;
- // 取消合并
- /* if (count($data1) > 0) {
- if (count($data1) >= 5) {
- $data1[0]['message'] = "已经有".count($data1)."个人支持了你的梦想!";
- $data2[0]['is_url'] = 1;
- $data2[0]['is_reply'] = 0;
- $new_data1[] = $data1[0];
- }else{
- $new_data1 = $data1;
- }
- }*/
- $new_data1 = $data1;
- $data2 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',2)->orderBy('id','desc')->get()->toArray();
- $new_data2 = [] ;
- if (count($data2) > 0) {
- if (count($data2) >= 5) {
- $data2[0]['message'] = "已经有".count($data2)."个人收藏了你的梦想!";
- $data2[0]['is_url'] = 1;
- $data2[0]['is_reply'] = 0;
- $new_data2[] = $data2[0];
- }else{
- $new_data2 = $data2;
- }
- }
- $data3 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->where('attr_id',3)->orderBy('id','desc')->get()->toArray();
- $new_data3 = [] ;
- if (count($data3) > 0) {
- if (count($data3) >= 5) {
- $data3[0]['message'] = "你的互动已经有".count($data3)."个留言啦!快点击看看!";
- $data2[0]['is_url'] = 1;
- $data2[0]['is_reply'] = 0;
- $new_data3[] = $data3[0];
- }else{
- $new_data3 = $data3;
- }
- }
- $data456 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)
- ->where(function ($query) {
- $query->where('attr_id',4)->orWhere('attr_id',5)->orWhere('attr_id',6);
- })->orderBy('id','desc')->get()->toArray();
- $data = array_merge($new_data1,$new_data2,$new_data3,$data456);
- if (!empty($data)) {
- foreach ($data as $key => $row) {
- $volume[$key] = $row['id'];
- }
- array_multisort($volume, SORT_DESC, $data);
- }
- SystemInfoModel::where('to_user_id',$user->id)->where('type_id',1)->update(['is_read' => 1]);
- return $this->api($data);
- // foreach ($data as $item){ //访问接口 标记已读
- // $item->update(['is_read'=>0]);
- // $info = InteractionInfo::find($item->interaction_id);
- // $dream_id =empty($info) ? 0 : $info->dream_id;
- // $item->dreamid = $dream_id;
- // }
- }
- /**
- * @api {get} /api/my/sup_info 支持消息
- * @apiDescription 支持消息
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": [
- * {
- * ....
- * }
- * ]
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function supInfo()
- {
- // 支持消息有 7私信 8@ 9梦想倒计时 10排名 梦想结束
- $user = $this->getUser();
- $data8 = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->where('attr_id',8)->orderBy('id','desc')->get()->toArray();
- // 计算interaction_id出现的次数
- // dd(array_column($data8,"interaction_id"));
- $count = array_count_values(array_filter(array_column($data8,"interaction_id")));
- $new_data8 = [] ;
- if (!empty($count)) {
- foreach ($count as $interaction_id => $value) {
- $interaction = InteractionInfo::find($interaction_id);
- $dream_id = empty($interaction) ? '0':$interaction->dream_id;
- if ($value>=5) {
- $message =empty($interaction) ? '': $interaction->title."互动上已经提起了你".($value)."次!你还不去瞧一瞧?你也太大牌啦!";
- }else{
- $message =empty($interaction) ? '': $interaction->title."提起了你哦~点击看看!";
- }
- if (!empty($message)) {
- $new_data8[] = [
- 'id'=>1000000, //排首
- 'dream_id'=>$dream_id,
- 'interaction_id'=>$interaction_id,
- 'message'=>$message,
- "attr_id" => 8,
- "is_reply" => 0,
- "is_max" => 0,
- "is_ok" => 0,
- "is_end" => 0,
- "is_url" => 1,
- "type_id" => 2,
- ];
- }
- }
- }
- $data9 = SystemInfoModel::with('user')->where('to_user_id',$user->id)->where('type_id',2)->where('attr_id','!=',8)->orderBy('id','desc')->get()->toArray();
- $data = array_merge($new_data8,$data9);
- if (!empty($data)) {
- foreach ($data as $key => $row) {
- $volume[$key] = $row['id'];
- }
- array_multisort($volume, SORT_DESC, $data);
- }
- SystemInfoModel::where('to_user_id',$user->id)->where('type_id',2)->update(['is_read' => 1]);
- return $this->api($data);
- }
- /**
- * @api {get} /api/my/system_info 通知消息
- * @apiDescription 通知消息
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": [
- * {
- * ....
- * }
- * ]
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function systemInfo()
- {
- $user = $this->getUser();
- $data = SystemInfoModel::where('to_user_id',$user->id)->where('type_id',0)->orderBy('id','desc')->get()->toArray();
- SystemInfoModel::where('to_user_id',$user->id)->where('type_id',0)->update(['is_read' => 1]);
- return $this->api($data);
- }
- /**
- * @api {get} /api/my/info 消息中心
- * @apiDescription 消息中心
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": {
- * "dream_info": {
- * "number": 3,
- * },
- * "sup_info": {
- * "number": 0,
- * },
- * "system_info": {
- * "number": 3,
- * }
- * }
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function info()
- {
- $user = $this->getUser();
- /* $systemInfo1 = SystemInfoModel::where('user_id',$user->id)->whereNull('to_user_id')->orderBy('id','desc')->get();
- $systemInfo2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
- ->whereNull('to_user_id')->orderBy('id','desc')->get();
- $letter1 = SystemInfoModel::where('user_id',$user->id)->whereNotNull('to_user_id')->orderBy('id','desc')->get();
- $letter2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
- ->whereNotNull('to_user_id')->orderBy('id','desc')->get();
- $comments1 = CommentInfoModel::where('to_user_id',$user->id)->orderBy('id','desc')->get();
- $comments2 = CommentInfoModel::where('to_user_id',$user->id)->where('is_read','1')->orderBy('id','desc')->get();
- $arr = [];
- $arr['systemInfo']['number'] = count($systemInfo1) ;
- $arr['systemInfo']['is_read'] = count($systemInfo2) ;
- $arr['letter']['number'] = count($letter1) ;
- $arr['letter']['is_read'] = count($letter2) ;
- $arr['reply']['number'] = count($comments1) ;
- $arr['reply']['is_read'] = count($comments2) ;*/
- // 梦想消息 支持消息 通知消息
- $user_id = $user->id;
- $dream_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',1)->where('is_read',0)->orderBy('id','desc')->get();
- $sup_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',2)->where('is_read',0)->orderBy('id','desc')->get();
- $system_info = SystemInfoModel::where('to_user_id',$user_id)->where('type_id',0)->where('is_read',0)->orderBy('id','desc')->get();
- $arr['dream_info']['number'] = count($dream_info) ;
- $arr['sup_info']['number'] = count($sup_info) ;
- $arr['system_info']['number'] = count($system_info) ;
- return $this->api($arr);
- }
- /**
- * @api {get} /api/my/read 设为已读
- * @apiDescription 设为已读
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- * {
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function read()
- {
- $user = $this->getUser();
- $id = $user->id;
- $system_infos = SystemInfoModel::where(function ($query) use($id){
- $query->where('user_id',$id)->where('is_read','0');
- })->orWhere(function ($query) use($id){
- $query->where('to_user_id',$id)->where('is_read','0');
- })->orderBy('id','desc')->get();
- $comments = CommentInfoModel::where('user_id',$user->id)->where('is_read','0')->orderBy('id','desc')->get();
- foreach ($system_infos as $system_info){
- $system_info->update(['is_read'=>1]);
- }
- foreach ($comments as $comment){
- $comment->update(['is_read'=>1]);
- }
- if (count($system_infos) > 0 || count($comments) > 0) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- }
- /**
- * @api {get} /api/my/pay/article 支付说明
- * @apiDescription 支付说明
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- *"data": {
- * "key": "23453423453", 标题
- * "value": "<p><span style=\"color: rgb(255, 0, 0);\">42352345234534是大法官地方<
- * img src=\"/ueditor/php/upload/image/20170815/1502779635.jpg\" title=\"1502779635.jpg\" alt=\"a1.jpg\"/>234534</span><
- * br/></p>", 内容
- *}
- * ]
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function payArticle()
- {
- $data = BaseSettingsModel::where('category','pay_article')->first();
- return $this->api($data);
- }
- /**
- * @api {post} /api/my/cash 提现
- * @apiDescription 提现
- * @apiGroup My
- * @apiParam {int} data[bank_id] 银行卡号id
- * @apiParam {int} data[cash] 提现金额
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": false,
- * "status_code": 1413,
- * "message": "系统审核中",
- * "data": null
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function cash(Request $request)
- {
- $data = $request->data;
- $user = $this->getUser();
- $validator = \Validator::make($request->all(),
- [
- 'data.bank_id' => 'required|integer',
- 'data.cash' => 'required',
- ],
- [
- 'data.bank_id.required' => '请选择提现账号',
- 'data.bank_id.integer' => '提现账号不存在',
- 'data.cash.required' => '请输入金额',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- // $info = [] ;
- // $info['from_type'] = '余额';
- // $info['from_id'] = $user->id;
- // $info['from_name'] = $user->name;
- // $info['op'] = '提现';
- // $info['from_amount'] = $data['coin'];
- // $info['to_type'] = '现金';
- // $info['to_id'] = $user->id;
- // $info['to_name'] = $data['account']; //账号
- // $info['note'] = $data['type'].$data['name'];
- // $ok = AccountLog::create($info);
- if($data['cash']>$user->coin) return $this->error(ErrorCode::COIN_NOT_ENOUGH);
- $transaction_id = date('YmdHis') . mt_rand(1000, 9999);
- $data['user_id'] = $user->id;
- $data['status'] = 1;
- $data['number'] = $transaction_id;
- $ok = UserCashOut::create($data);
- // $message = '你提现的¥'.$data["cash"].'已经到账啦,去实现梦想吧!喵~ ';
- $message = '你提现的申请已经提交,我们会第一时间审核哦';
- $info = [
- 'user_id' => $user->id,
- 'message' => $message,
- 'attr_id' => 4,
- 'type_id' => 1,
- ];
- SystemInfoModel::create($info);
- // 长连接
- $this->jPush($message,'',$user->id);
- if ($ok) {
- return $this->api(ErrorCode::verify);
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- }
- // 联系客服
- /**
- * @api {post} /api/my/suggest 联系客服
- * @apiDescription 联系客服
- * @apiGroup My
- * @apiParam {string} data[content] 内容
- * @apiParam {string} data[email] 邮箱
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function suggest(Request $request)
- {
- $data = $request->data;
- $user = $this->getUser();
- $validator = \Validator::make($request->all(),
- [
- 'data.content' => 'required',
- 'data.email' => 'required|email',
- ],
- [
- 'data.content.required' => '请输入你遇到的问题',
- 'data.email.required' => '请输入正确的邮箱地址',
- 'data.email.email' => '请输入正确的邮箱地址',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $data['user_id'] = $user->id;
- $ok =Suggest::create($data);
- if ($ok) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- }
- // 回复我的
- // public function replyMy()
- // {
- //
- // $user = $this->getUser();
- //// 梦想
- // $dreams = $user->UserDream;
- //
- // $data = $user->allInteraction;
- // foreach ($data as $item) {
- // $item->get_money = $item->dream->get_money;
- // $item->money = $item->dream->money;
- // }
- // dd($data) ;
- // if (count($dreams) == 0)
- // return $this->error(ErrorCode::DREAM_NOT_EXIST);
- // $comments_infos = [];
- // foreach ($dreams as $dream){
- // $comments_info = $dream->DreamInfo;
- // if (count($comments_info) > 0) {
- // foreach ($comments_info as $k => $value) {
- // $value->dream_name = $dream->dream;
- // $value->dream_about = $dream->about;
- // $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
- // $value->progress = $dream->money == 0 ? 0 : floor($dream->get_money/$dream->money);
- // $value->reviewer = $value->CommentUser->nickname;
- // $value->reviewer_pic = $value->CommentUser->pic;
- // }
- // $comments_infos[] = $comments_info;
- // }
- // }
- //
- // return $this->api(compact('comments_infos'));
- // }
- /**
- * @api {get} /api/my/dream 我的梦想
- * @apiDescription 我的梦想
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- {
- "status": true,
- "status_code": 0,
- "message": "",
- "data": {
- "current_page": 1,
- "data": [
- {
- "id": 32,
- "user_id": 1,
- "name": "name",
- "about": "13880642880",
- "coin": 100,
- "end_time": "0000-00-00 00:00:00",
- "get_coin": 2017,
- "mark": 100,
- "status": 127,
- "video": "0",
- "score": 0,
- "type_name": 已完成,
- "sign": "158730",
- "code": "http://www.miao.com/qrcodes/WECHATPAY_201708191324294255.png",
- "parameter": 0,
- "created_at": "2017-08-19 05:22:12",
- "updated_at": "2017-08-19 05:24:30",
- "img": {
- "title": "",
- "pic": "http://q8.9026.com/upload/dream/20170629/79c11614cc8a9d37f747e3974d055331.jpg"
- }
- },
- ],
- "from": 1,
- "last_page": 4,
- "next_page_url": "http://www.miao.com/api/my/dream?page=2",
- "path": "http://www.miao.com/api/my/dream",
- "per_page": 10,
- "prev_page_url": null,
- "to": 10,
- "total": 36
- }
- }
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function dream()
- {
- $user = $this->getUser();
- $dreams = DreamInfoModel::where('user_id',$user->id)->orderBy('created_at','desc')->with('img')->paginate();
- foreach ($dreams as $dream) {
- if (strtotime($dream->end_time) > time()) {
- if ($dream->status==2) {
- $dream->type_name = '暂停';
- }else{
- $dream->type_name = '进行中';
- }
- }else{
- if ($dream->get_coin >=$dream->coin) {
- $dream->type_name = '已完成';
- }else{
- $dream->type_name = '未完成';
- }
- }
- }
- return $this->api($dreams);
- }
- /**
- * @api {get} /api/my/collection 我的收藏
- * @apiDescription 我的收藏
- * @apiGroup My
- * @apiPermission Passport
- * @apiParam {string} [keyword] 关键字可选
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": {
- * "data": [
- * { 梦想详情
- * "id": 12,
- * "user_id": 2,
- * "name": "用户2梦想标题166",
- * "about": "用户2梦想介绍666",
- * "coin": 2500,
- * "time": 21,
- * "get_coin": 0,
- * "status": 0,
- * "video": null,
- * "sign": "",
- * },
- * "img": {
- * "title": "",
- * "pic": "https://f12f.jpg" 梦想封面图片
- * }
- * ],
- * "users": {
- * "2": "https://xxx.jpeg" ID号和头像
- * }
- * }
- *}
- * keyword存在
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": [
- * {
- * "id": 2,
- * "user_id": 1,
- * "dream_id": 12,
- * "dream_user_id": 2,
- * "interaction_number": 0,
- * "created_at": "2017-06-25 13:11:45",
- * "updated_at": "2017-06-25 13:11:45",
- * "dreams": [ 梦想
- * {
- * "id": 12,
- * "user_id": 2,
- * "name": "用户2梦想标题166",
- * "about": "用户2梦想介绍666",
- * "coin": 2500,
- * "end_time": 72000,
- * "get_coin": 792,
- * "mark": 5484,
- * "status": 0,
- * "video": "e",
- * "score": 158730,
- * "sign": "梦想达人",
- * "created_at": "2017-06-25 13:10:56",
- * "updated_at": "2017-06-28 16:53:39"
- * "img": { 图片
- * "title": "",
- * "pic": "https://timgsa.baidu.com/timg9&di2f.jpg"
- * },
- * "user": {
- *
- * }
- * }
- * ]
- * }
- * ]
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function collection(Request $request)
- {
- $user = $this->getUser();
- if ($request->keyword) {
- $keyword ='%'.$request->keyword.'%';
- $data = UserCareDream::where('user_id',$user->id)->
- whereHas('dreams',function ($query) use($keyword){
- $query->where('end_time','>=',time())->where('name','like',$keyword);
- })->with('dreams')->get();
- foreach ($data as $item) {
- foreach ($item->dreams as $dream) {
- $dream->img;
- }
- }
- $this->insertSearchTable($user->id,$request->keyword);
- return $this->api($data);
- }else{
- $dreams = $user->collection;
- // $users = [];
- foreach ($dreams as $item) {
- /* if ($item->pivot->interaction_number > 0) {
- $user_info = UserInfoModel::find($item->pivot->dream_user_id);
- $avatar = $user_info ? $user_info->avatar : '';
- if (!array_key_exists($item->pivot->dream_user_id,$users)) {
- $users[$item->pivot->dream_user_id] = $avatar;
- }
- }*/
- $item->img;
- $item->user;
- if (strtotime($item->end_time) > time()) {
- if ($item->status==2) {
- $item->type_name = '暂停';
- }else{
- $item->type_name = '进行中';
- }
- }else{
- if ($item->get_coin >=$item->coin) {
- $item->type_name = '已完成';
- }else{
- $item->type_name = '未完成';
- }
- }
- }
- return $this->api(compact('dreams'));
- }
- }
- /**
- * @api {get} /api/my/miao 关于喵喵
- * @apiDescription 关于喵喵
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": {
- * "key": "2511789", 电话
- * "value": "关于喵喵介绍" 关于喵喵
- * }
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function aboutMiao()
- {
- $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
- return $this->api($data);
- }
- /**
- * @api {get} /api/my/care 我关注的用户
- * @apiDescription 我关注的用户
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data":[] or
- * "data": [
- * {
- * "id": 2,
- * "phone": "13880642881",
- * "nickname": "name2",
- * "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
- * "birthday": "2000-06-21",
- * "sign": 0,
- * "money": 0,
- * "coin": 800,
- * "sex": 1,
- * "signture": "我的个性签名2",
- * "height": 200,
- * "work": "兼职",
- * "emotion": 2,
- * "address": "370105",
- * "city": "成都",
- * "detail_address": "",
- * "status": 1,
- * "wechat": "",
- * "weibo": "",
- * "remember_token": "",
- * "created_at": "2017-06-25 10:42:06",
- * "updated_at": "2017-06-30 09:15:04",
- * "deleted_at": null,
- * }
- * ]
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function care()
- {
- $user = $this->getUser();
- $users =$user->UserCareUser;
- return $this->api($users);
- }
- /**
- * @api {get} /api/my/careme 关注我的用户
- * @apiDescription 关注我的用户
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data":[] or
- * "data": [
- * {
- * "id": 2,
- * "phone": "13880642881",
- * "nickname": "name2",
- * "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
- * "birthday": "2000-06-21",
- * "sign": 0,
- * "money": 0,
- * "coin": 800,
- * "sex": 1,
- * "signture": "我的个性签名2",
- * "height": 200,
- * "work": "兼职",
- * "emotion": 2,
- * "address": "370105",
- * "city": "成都",
- * "detail_address": "",
- * "status": 1,
- * "wechat": "",
- * "weibo": "",
- * "remember_token": "",
- * "created_at": "2017-06-25 10:42:06",
- * "updated_at": "2017-06-30 09:15:04",
- * "deleted_at": null,
- * }
- * ]
- *}
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function careMe()
- {
- $user = $this->getUser();
- $users =$user->UserCareMe;
- return $this->api($users);
- }
- public function insertSearchTable($id,$keyword)
- {
- $info = SearchInfoModel::where('user_id',$id)->
- where('search',trim($keyword))->first();
- if (count($info) == 0) {
- SearchInfoModel::create(['user_id'=>$id,'search'=>trim($keyword),'times'=>1]);
- }else{
- $info->times += 1;
- $info->save();
- }
- }
- //我的银行账户
- /**
- * @api {get} /api/my/bank/list 我的银行账户
- * @apiDescription 我的银行账户
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data":[] or
- * "data": [
- * {
- * "id": 1,
- * "user_id": 1,
- * "bank_name": "1",
- * "bank_number": "1", /账号
- * "bank_phone": "1",
- * "bank_user": "" 用户名/
- * "type": 微信, 微信(支付宝)二维码
- * "url": wwww.ddf, 二维码地址
- * "is_img": 1,
- * }
- *]
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function bankList()
- {
- $user = $this->getUser();
- $data = UserBank::where('user_id',$user->id)->orderBy('id','desc')->get();
- return $this->api($data);
- }
- /**
- * @api {get} /api/my/bank/account 账户余额
- * @apiDescription 账户余额
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data":[] or
- * "data": {
- * "coin": 508, 余额
- * }
- *]
- * @apiErrorExample {json} Error-Response:
- * HTTP/1.1 400 Bad Request
- */
- public function account()
- {
- $user = $this->getUser();
- return $this->api($user);
- }
- // 添加银行卡
- /**
- * @api {post} /api/my/bank/create 添加银行卡
- * @apiDescription 添加银行卡
- * @apiGroup My
- * @apiParam {string} data[bank_name] 银行名称
- * @apiParam {string} data[bank_number] 银行卡号
- * @apiParam {int} data[bank_phone] 银行卡绑定手机号
- * @apiParam {string} data[bank_user] 银行卡用户姓名
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function bankCreate(Request $request)
- {
- $data = $request->data;
- $user = $this->getUser();
- if (empty($user)) return $this->error(ErrorCode::MERCHANT_NOT_EXIST);
- $validator = \Validator::make($request->all(),
- [
- 'data.bank_name' => 'required',
- 'data.bank_number' => 'required',
- 'data.bank_phone' => 'required',
- 'data.bank_user' => 'required',
- ],
- [
- 'data.bank_name.required' => '请选择账号类型',
- 'data.bank_number.required' => '请输入账号',
- 'data.bank_phone.required' => '请输入账号绑定手机号码',
- 'data.bank_user.required' => '请输入账号绑定用户姓名',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $data['user_id'] = $user->id;
- $ok =UserBank::create($data);
- if ($ok) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- } /**
- * @api {post} /api/my/bank/qrcode 添加二维码
- * @apiDescription 添加二维码
- * @apiGroup My
- * @apiParam {string} data[type] 类型
- * @apiParam {string} data[qrcode] 二维码图片
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function bankImgCreate(Request $request)
- {
- $data = $request->data;
- $user = $this->getUser();
- if (empty($user)) return $this->error(ErrorCode::MERCHANT_NOT_EXIST);
- $validator = \Validator::make($request->all(),
- [
- 'data.type' => 'required',
- 'data.qrcode' => 'required',
- ],
- [
- 'data.type.required' => '请选择账号类型',
- 'data.qrcode.required' => '请上传二维码图片',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $data['user_id'] = $user->id;
- /* $data['bank_user'] = '';
- $data['bank_phone'] = '';
- $data['bank_number'] = '';
- $data['bank_name'] = '';*/
- $info = UserBank::whereNotNull('qrcode')->where('user_id',$user->id)
- ->where('type',$data['type'])->first(); //定义为二维码
- if (empty($info)) {
- $ok =UserBank::create($data);
- }else{
- $ok = $info->update($data);
- }
- if ($ok) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- }
- /**
- * @api {get} /api/my/bank/delete 删除银行卡
- * @apiDescription 删除银行卡
- * @apiGroup My
- * @apiParam {int} id 银行卡id
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function bankDelete(Request $request)
- {
- $id = $request->id;
- $validator = \Validator::make($request->all(),
- [
- 'id' => 'required',
- ],
- [
- 'id.required' => '银行账号不存在',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $ok =UserBank::destroy($id);
- if ($ok) {
- return $this->api('');
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- }
- // 发私信
- /**
- * @api {post} /api/my/letter/store 发送私信
- * @apiDescription 发送私信
- * @apiGroup My
- * @apiParam {string} content 私信内容
- * @apiParam {array} [image] 图片
- * @apiParam {string} [video] 视频
- * @apiParam {int} to_user_id 私信对象
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function letterStore(Request $request)
- {
- $validator = \Validator::make($request->all(),
- [
- 'content' => 'required',
- 'to_user_id' => 'required',
- ],
- [
- 'content.required' => '私信内容不存在',
- 'to_user_id.required' => '私信对象不存在',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $user = $this->getUser();
- if (empty($user)) return $this->error(ErrorCode::MERCHANT_NOT_EXIST);
- $user_id = $user->id;
- $info = $request->input('content');
- $video = $request->input('video');
- $img = $request->input('image');
- if (is_array($img)&&!empty($img)) {
- $image = $img[0];
- }else{
- $image = '';
- }
- $to_user_id = $request->input('to_user_id');
- // 链接到最近的一个梦想
- $dream = DreamInfoModel::where('user_id',$user_id)->orderBy('id','desc')->first();
- $dream_id = empty($dream) ? 0 : $dream->id;
- $arr = [
- 'user_id'=>$user_id,
- 'info'=>$info,
- 'message'=>$user->nickname.'给你发了个私信哦~点击看看!',
- 'to_user_id'=>$to_user_id,
- 'dream_id'=>$dream_id,
- 'video'=>$video,
- 'image'=>$image,
- 'type_id'=>2,
- 'is_url'=>1,
- 'attr_id'=>7,
- ];
- $ok =SystemInfoModel::create($arr);
- if ($ok) {
- if (!empty($to_user_id)) {
- $this->jPush($user->nickname.'给你发了个私信哦~点击看看!','',$to_user_id);
- }
- return $this->api('');
- }else{
- return $this->error(ErrorCode::OPERATION_FAILED);
- }
- }
- /**
- * @api {get} /api/my/letter/show 查看私信
- * @apiDescription 查看私信
- * @apiGroup My
- * @apiParam {int} id 私信主键id
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function letterShow(Request $request)
- {
- $validator = \Validator::make($request->all(),
- [
- 'id' => 'required',
- ],
- [
- 'id.required' => '私信id不存在',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $user = $this->getUser();
- $user_id = $user->id;
- $id = $request->input('id');
- $data = SystemInfoModel::find($id);
- return $this->api($data);
- }
- // 梦想结束时梦想者是否同意见面
- /**
- * @api {get} /api/my/sure_meet 梦想者是否同意见面
- * @apiDescription 梦想结束时梦想者是否同意见面
- * @apiGroup My
- * @apiParam {int} dream_id 梦想id
- * @apiParam {int} value 0取消1确定
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": 0 0表示并没有人支持你
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function isOk(Request $request)
- {
- $validator = \Validator::make($request->all(),
- [
- 'value' => 'required',
- 'dream_id' => 'required',
- ],
- [
- 'value.required' => '参数错误',
- 'dream_id.required' => '梦想不存在',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $dream_id = $request->input('dream_id');
- $value = $request->input('value');
- $dream = DreamInfoModel::find($dream_id);
- if (empty($dream)) return $this->error(ErrorCode::DREAM_NOT_EXIST);
- $support_dream = SupportDreamModel::where('dream_id',$dream_id)->get();
- $top = [] ;
- foreach ($support_dream as $item) {
- if (!array_key_exists($item->user_id,$top)) {
- $top[$item->user_id] = $item->score;
- }else{
- $top[$item->user_id] += $item->score;
- }
- }
- arsort($top);
- $new_arr = array_values($top);
- if (!empty($top)) {
- $top_user = array_search($new_arr[0],$top);
- }else{
- $top_user = 0;
- }
- if ($value==1) {
- // 同意见面
- $dream->is_ok = 1;
- $dream->save();
- $message = "你支持的《".$dream->name."》梦想者已经同意见面啦";
- }else{
- $dream->is_ok = 0;
- $dream->save();
- $message = "你支持的梦想者拒绝了本次见面,你支持的梦想资金将会退还给您";
- // 退款逻辑
- }
- Log::info('is_max:'.$top_user);
- if (!empty($top_user)) {
- // 给最大支持者发送消息
- $arr = [
- 'user_id'=>0,
- 'message'=>$message,
- 'to_user_id'=>$top_user,
- 'dream_id'=>$dream_id,
- 'attr_id'=>6,
- 'is_end'=>0,
- 'type_id'=>2,
- 'is_max'=>1,
- ];
- SystemInfoModel::firstOrCreate($arr);
- }
- return $this->api($top_user);
- }
- // 梦想结束时梦主是否同意见面
- /**
- * @api {get} /api/my/sure_meet2 梦主是否同意见面
- * @apiDescription 梦想结束时梦主是否同意见面
- * @apiGroup My
- * @apiParam {int} to_user_id 梦想者id(数据中的user_id)
- * @apiParam {int} value 0取消1确定
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- *{
- * "status": true,
- * "status_code": 0,
- * "message": "",
- * "data": ""
- *}
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function isOk2(Request $request)
- {
- $user = $this->getUser();
- $validator = \Validator::make($request->all(),
- [
- 'value' => 'required',
- 'to_user_id' => 'required',
- ],
- [
- 'value.required' => '参数错误',
- 'to_user_id.required' => '梦想者不存在',
- ]
- );
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
- $value = $request->input('value');
- $to_user_id = $request->input('to_user_id');
- $to_user_info = UserInfoModel::find($to_user_id);
- if ($value==1) {
- $message = '您的梦主同意见面了,赶快准备一下吧';
- // 同意见面会收到一条提示信息
- if (!empty($to_user_info)) {
- $arr = [
- 'user_id'=>0,
- 'message'=>$to_user_info->nickname.'会第一时间联系你!见面时需要你扫一扫他提供的二维码哦',
- // 'info'=>$to_user_info->nickname.'会第一时间联系你!见面时需要你扫一扫他提供的二维码哦',
- 'to_user_id'=>$user->id,
- 'is_end'=>1,
- 'attr_id'=>6,
- 'type_id'=>2,
- ];
- SystemInfoModel::firstOrCreate($arr);
- }
- }else{
- $message = '您的梦主拒绝了你们的见面,喵~';
- }
- $arr = [
- 'user_id'=>0,
- 'message'=>$message,
- 'to_user_id'=>$to_user_id,
- 'is_end'=>1,
- 'attr_id'=>5,
- 'type_id'=>1,
- ];
- SystemInfoModel::firstOrCreate($arr);
- return $this->api('');
- }
- /**
- * @api {get} /api/my/account_log 支付列表
- * @apiDescription 支付列表
- * @apiGroup My
- * @apiPermission Passport
- * @apiVersion 0.1.0
- * @apiSuccessExample {json} Success-Response:
- * HTTP/1.1 200 OK
- {
- "status": true,
- "status_code": 0,
- "message": "",
- "data": [
- {
- "id": 1,
- "from_type": "1",
- "from_id": 1,
- "from_name": "1",
- "op": "",
- "from_amount": 2,
- "to_type": "2",
- "to_id": 1,
- "to_name": null,
- "to_amount": 2,
- "channel": "1",
- "avatar": null,
- "transaction_id": null,
- "note": null,
- "created_at": null,
- "updated_at": null,
- "deleted_at": null
- }
- ]
- }
- * @apiErrorExample {json} Error-Response:
- *{
- * "status": false,
- * "status_code": 700,
- * "message": "操作失败",
- * "data": null
- *}
- */
- public function accountLog()
- {
- $user = $this->getUser();
- $data = AccountLog::where('to_id',$user->id)->orWhere('from_id',$user->id)->orderBy('id','desc')->get();
- return $this->api($data);
- }
- }
|