瀏覽代碼

Merge branch 'gq' of http://git.9026.com/roobe/miao

Mike 7 年之前
父節點
當前提交
5ec2bcfee7

+ 2 - 1
miaomiao/package.json

xqd xqd
@@ -34,6 +34,7 @@
     "bower": "^1.3.3",
     "gulp-sass": "^2.3.2",
     "gulp-util": "^2.2.14",
+    "ionic": "3.7.0",
     "shelljs": "^0.3.0"
   },
   "cordovaPlugins": [
@@ -89,4 +90,4 @@
       }
     }
   }
-}
+}

+ 87 - 4
server/app/Http/Controllers/Api/V1/HomeController.php

xqd xqd xqd
@@ -4,9 +4,11 @@ namespace App\Http\Controllers\Api\V1;
 
 use App\Models\BaseDictionaryOptionModel;
 
+use App\Models\BaseSettingsModel;
 use App\Models\DreamInfoModel;
 use App\Models\MeetInfoModel;
 use App\Models\SupportDreamModel;
+use App\Models\SystemInfoModel;
 use App\Models\UserCareUser;
 use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
@@ -67,9 +69,10 @@ class HomeController extends Controller
         $imgs =$user->allImgs;
 //        曾经的梦想
         $dreams = $user->UserDream;
-
-        foreach ($dreams as $dream){
-            $dream->dream_imgs = $dream->imgs;
+        if (!empty($dreams)) {
+            foreach ($dreams as $dream){
+                $dream->dream_imgs = $dream->imgs;
+            }
         }
 
         $user->score = 1000;//自定义 算法
@@ -83,11 +86,91 @@ class HomeController extends Controller
         foreach ($sup_dreams as $sup_dream){
             $sup_dream->pics = $sup_dream->imgs;
         }
+        $is_care = UserCareUser::where('other_user_id',$user_id)->where('user_id',$user->id)->first();
+        $is_care = empty($is_care) ? 0 : 1 ;
+
+        return $this->api(compact('user','near_dream','sup_dreams','imgs','dreams','score','is_care'));
+
+    }
+
+    //    关注用户
+    /**
+     * @api {get} /api/user/care 关注用户
+     * @apiDescription 关注用户
+     * @apiGroup Dream
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int} id 用户ID
+     * @apiParam {int} is_care 0取消关注 1关注
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     *{
+     *      "status": true,
+     *      "status_code": 0,
+     *      "message": "",
+     *     "data": {
+     *           1       1已关注 0 未关注
+     *      }
+     *}
+     * @apiErrorExample {json} Error-Response:
+     *HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     *
+     */
+    public function care(Request $request)
+    {
+
+        $validator = \Validator::make($request->all(),
+            [
+                'id'  => 'required',
+                'is_care'  => 'required',
+            ],
+            [
+                'id.required'  => '关注id不能为空',
+                'is_care.required'  => '关注值不存在',
+            ]
+        );
+        if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+
+        $user = $this->getUser();
+        if(!$obj = UserInfoModel::find($request->id)){
+            $this->error(ErrorCode::USER_DOES_NOT_EXIST);
+        }
 
-        return $this->api(compact('user','near_dream','sup_dreams','imgs','dreams','score'));
+        $data = [
+            'user_id' =>$user->id,
+            'other_user_id' =>$request->id,
+        ];
+        $is_care = empty($request->is_care) ? 0 : $request->is_care;
+        $user_care_user = UserCareUser::where('user_id',$user->id)->
+        where('other_user_id',$request->id)->first();
+        if ($is_care) {
+            if (empty($user_care_user)) {
+                UserCareUser::create($data);
+//                关注成功发送私信
+                $message = BaseSettingsModel::where('category','message')->first();
+                $message = empty($message) ? '' : $message->value;
+                $info = [
+                    'user_id'=>$request->id,
+                    'to_user_id' => $user->id,
+                    'message' =>$message
+                ];
+                SystemInfoModel::create($info);
+            }
+        }else{
+            UserCareUser::where('user_id',$user->id)->
+            where('other_user_id',$request->id)->delete();
+        }
+        return $this->api($is_care);
 
     }
 
+
 //    见面
     /**
      * @api {get} /api/user/meet/ 见面

+ 269 - 0
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd xqd
@@ -2,12 +2,16 @@
 
 namespace App\Http\Controllers\Api\V1;
 
+use App\Models\AccountLog;
 use App\Models\BaseDictionaryOptionModel;
 use App\Models\BaseSettingsModel;
 use App\Models\DreamInfoModel;
 use App\Models\SearchInfoModel;
+use App\Models\Suggest;
 use App\Models\SystemInfoModel;
+use App\Models\UserBank;
 use App\Models\UserCareDream;
+use App\Models\UserCashOut;
 use App\Models\UserInfoModel;
 use Illuminate\Http\Request;
 use App\Services\Base\ErrorCode;
@@ -243,6 +247,125 @@ class MyController extends Controller
         return $this->api(compact('data'));
     }
 
+
+    /**
+     * @api {post} /api/my/cash 提现
+     * @apiDescription 提现
+     * @apiGroup My
+     *    @apiParam {int} data[cash]       提现金额
+     *    @apiParam {string} data[type]       选择类型
+     *    @apiParam {string} data[account]       提现账号
+     *    @apiParam {string} data[name]       账号姓名
+     * @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.cash'  => 'required|integer',
+                'data.type'  => 'required',
+                'data.account'  => 'required',
+                'data.name'  => 'required',
+            ],
+            [
+                'data.cash.required'  => '请输入金额',
+                'data.type.required'  => '请选择类型',
+                'data.account.required'  => '请输入提现账号',
+                'data.name.required'  => '请输入账号姓名',
+                'data.cash.integer'  => '请输入整数',
+            ]
+        );
+        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);
+        $data['user_id'] = $user->id;
+        $data['status'] = 0;
+        $ok = UserCashOut::create($data);
+        if ($ok) {
+            return $this->error(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": false,
+     *  "status_code": 200,
+     *  "message": "操作成功",
+     *  "data": null
+     *}
+     * @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->error(ErrorCode::OPERATION_SUCCESS);
+        }else{
+            return $this->error(ErrorCode::OPERATION_FAILED);
+        }
+    }
+
 //    回复我的
 //    public function replyMy()
 //    {
@@ -464,6 +587,59 @@ class MyController extends Controller
         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);
+
+    }
+
     public function insertSearchTable($id,$keyword)
     {
         $info = SearchInfoModel::where('user_id',$id)->
@@ -477,4 +653,97 @@ class MyController extends Controller
 
     }
 
+
+    //我的银行账户
+
+
+    /**
+     * @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": "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 {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": false,
+     *  "status_code": 200,
+     *  "message": "操作成功",
+     *  "data": null
+     *}
+     * @apiErrorExample {json} Error-Response:
+     *{
+     *  "status": false,
+     *  "status_code": 700,
+     *  "message": "操作失败",
+     *  "data": null
+     *}
+     */
+    public function bankCreate(Request $request)
+    {
+        $data = $request->data;
+        $user = $this->getUser();
+        $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->error(ErrorCode::OPERATION_SUCCESS);
+        }else{
+            return $this->error(ErrorCode::OPERATION_FAILED);
+        }
+    }
+
 }

+ 16 - 0
server/app/Models/Suggest.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Suggest extends Model
+{
+    protected $table = 'suggest';
+    protected $fillable = [
+        'user_id',
+        'content',
+        'reply',
+        'email',
+    ];
+}

+ 17 - 0
server/app/Models/UserBank.php

xqd
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class UserBank extends Model
+{
+    protected $table = 'user_banks';
+    protected $fillable = [
+        'user_id',
+        'bank_name',
+        'bank_number',
+        'bank_phone',
+        'bank_user',
+    ];
+}

+ 5 - 0
server/app/Models/UserCareUser.php

xqd
@@ -7,4 +7,9 @@ use Illuminate\Database\Eloquent\Model;
 class UserCareUser extends Model
 {
     protected $table = 'user_care_user';
+    protected $fillable = [
+        'user_id',
+        'other_user_id',
+        'dream_number',
+    ];
 }

+ 29 - 0
server/app/Models/UserCashOut.php

xqd
@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class UserCashOut extends Model
+{
+    use SoftDeletes;
+    public $table = 'user_cash_out';
+
+    protected $guarded = [];
+
+    /**
+     * 账户关联
+     * */
+//    public function user() {
+//        return $this->belongsTo('App\User', 'user_id');
+//    }
+//
+//    /**
+//     * 提现方式关联
+//     * */
+//    public function user_banks() {
+//        return $this->belongsTo('App\Models\UserBanks', 'bank_id');
+//    }
+
+}

+ 1 - 1
server/app/Models/UserInfoModel.php

xqd
@@ -58,7 +58,7 @@ class UserInfoModel extends Authenticatable
 
     public function UserCareUser()
     {
-        return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id')->withPivot('dream_num');
+        return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id');
     }
     public function UserCareDream()
     {

+ 4 - 0
server/app/Services/Base/ErrorCode.php

xqd xqd xqd
@@ -71,6 +71,8 @@ final class ErrorCode {
     const SUP_TOP = 1410;
     const SUP_ERROR = 1411;
     const DREAM_STATUS = 1412;
+    const verify = 1413;
+    const OPERATION_SUCCESS = 200;
 
     //错误常量枚举
     private static $_msg = [
@@ -109,6 +111,7 @@ final class ErrorCode {
         self::CANT_ADD_SERVICE_SAME_MERCHANT => '服务发出方与创建方一致',
         self::MERCHANT_SERVICE_EXPIRED => '服务已过期',
         self::OPERATION_FAILED => '操作失败',
+        self::OPERATION_SUCCESS => '操作成功',
         self::REMOVE_MODEL_FAILED => '删除模型失败',
         self::MODEL_NOT_EXIST => '模型不存在',
         self::ATTACHMENT_UPLOAD_FAILED => '附件上传失败',
@@ -129,6 +132,7 @@ final class ErrorCode {
         self::CLIENT_WRONG_PARAMS => '输入不正确',
         self::LOCK_USER=> '当前账号已被封号,请联系管理员',
         self::KEY_ERROR => '参数错误',
+        self::verify => '系统审核中',
     ];
 
     public static function message($code) {

+ 40 - 0
server/database/migrations/2017_08_14_113214_create_user_banks_table.php

xqd
@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+/**
+ * Migration auto-generated by Sequel Pro Laravel Export
+ * @see https://github.com/cviebrock/sequel-pro-laravel-export
+ */
+class CreateUserBanksTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_banks', function (Blueprint $table) {
+            $table->increments('id')->comment('绑定银行卡,支付方式的id');
+            $table->unsignedInteger('user_id')->comment('关联用户id, users.id');
+            $table->string('bank_name', 60)->comment('银行名称, 支付方式名称');
+            $table->string('bank_number', 120)->comment('银行卡号码, 支付宝帐号, 微信帐号');
+            $table->string('bank_phone', 120)->comment('银行卡 网上支付绑定的手机号');
+            $table->string('bank_user', 60)->comment('银行卡用户姓名');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_banks');
+    }
+}

+ 35 - 0
server/database/migrations/2017_08_14_140447_create_suggest_table.php

xqd
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSuggestTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('suggest', function (Blueprint $table) {
+            $table->increments('id');
+            $table->integer('user_id')->comment('用户ID');
+            $table->string('content')->comment('建议');
+            $table->string('email')->comment('收信邮箱');
+            $table->string('reply')->comment('回复内容')->default('');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('suggest');
+    }
+}

+ 32 - 0
server/database/migrations/2017_08_14_170315_add_to_user_id_to_system_info.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddToUserIdToSystemInfo extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('system_info', function (Blueprint $table) {
+            $table->integer('to_user_id')->after('message')->nullable()->comment('私信对象id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('system_info', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 49 - 0
server/database/migrations/2017_08_26_113215_create_user_cash_out_table.php

xqd
@@ -0,0 +1,49 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+/**
+ * Migration auto-generated by Sequel Pro Laravel Export
+ * @see https://github.com/cviebrock/sequel-pro-laravel-export
+ */
+class CreateUserCashOutTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_cash_out', function (Blueprint $table) {
+            $table->increments('id')->comment('提现记录id');
+            $table->unsignedInteger('user_id')->comment('提现用户id');
+            $table->unsignedInteger('bank_id')->comment('绑定的提现方式id');
+            $table->string('type')->comment('提现类型');
+            $table->string('account')->comment('提现账号');
+            $table->string('name')->comment('账号姓名');
+            $table->decimal('cash', 8, 2)->comment('提现金额');
+            $table->text('comments')->nullable()->comment('审核未通过原因, 备注等');
+            $table->tinyInteger('status')->comment('提现状态: 0, 申请提现; 1,审核通过; 2,已打款; 3,审核未通过');
+            $table->nullableTimestamps();
+
+
+            
+
+            
+
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_cash_out');
+    }
+}

+ 28 - 0
server/routes/api.php

xqd
@@ -136,20 +136,48 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.dream',
         'uses' => 'MyController@dream',
     ]);
+    $api->get('my/care', [
+        'as' => 'my.care',
+        'uses' => 'MyController@care',
+    ]);
 //    我的收藏
     $api->get('my/collection', [
         'as' => 'my.collection',
         'uses' => 'MyController@collection',
     ]);
+//    关于喵喵
     $api->get('my/setting', [
         'as' => 'my.setting',
         'uses' => 'MyController@setting',
     ]);
+    //    联系客服
+    $api->post('my/suggest', [
+        'as' => 'my.suggest',
+        'uses' => 'MyController@suggest',
+    ]);
+//    提现
+    $api->post('my/cash', [
+        'as' => 'my.cash',
+        'uses' => 'MyController@cash',
+    ]);
+    $api->get('my/bank/list', [
+        'as' => 'my.bank_list',
+        'uses' => 'MyController@bankList',
+    ]);
+    $api->post('my/bank/create', [
+        'as' => 'my.bank_create',
+        'uses' => 'MyController@bankCreate',
+    ]);
 //    用户信息
     $api->get('user/show', [
         'as' => 'user.show',
         'uses' => 'HomeController@show',
     ]);
+    //    关注用户
+    $api->get('user/care', [
+        'as' => 'user.care',
+        'uses' => 'HomeController@care',
+    ]);
 //    见面
     $api->get('user/meet', [
         'as' => 'user.meet',