Переглянути джерело

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

YanaDH 7 роки тому
батько
коміт
09178ec601

+ 29 - 3
server/app/Console/Commands/DreamDJS.php

xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Models\AccountLog;
 use App\Models\DreamInfoModel;
 use App\Models\SupportDreamModel;
 use App\Models\SystemInfoModel;
@@ -10,10 +11,12 @@ use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Auth;
 use App\Helper\JpushHelper;
 use Illuminate\Support\Facades\Log;
+use App\Helper\LogHelper;
+
 
 class DreamDJS extends Command
 {
-    use JpushHelper;
+    use JpushHelper,LogHelper;
     /**
      * The name and signature of the console command.
      *
@@ -47,13 +50,36 @@ class DreamDJS extends Command
     {
         //执行逻辑
         Log::info('------------通知消息begin-----------');
-
         $end_dream_info = DreamInfoModel::with('user')->where('end_time','<',date('Y-m-d H:i:s'))->get();
         if (count($end_dream_info)>0) {
             foreach ($end_dream_info as $item){
-//                (1)给梦想者发消息
+//                (1)给梦想者发消息   梦想结束记录日志account_logs
                 $dream_user = $item->user;
                 if (!empty($dream_user)) {
+                    $img = $item->img;  //梦想图片
+                    $arr = [
+                        'from_type'=>'梦想币',
+                        'from_id'=>$dream_user->id,
+                        'from_name'=>$dream_user->nickname,
+                        'op'=>'梦想结束',
+                        'from_amount'=>$item->get_coin,
+                        'to_type'=>'梦想币',
+                        'to_id'=>$dream_user->id,
+                        'to_name'=>$dream_user->nickname,
+                        'to_amount'=>$item->get_coin,
+                        'channel'=>'平台内',
+                        'avatar'=>empty($img) ? '' : $img->pic,
+                        'title'=>$item->name,
+                        'dream_id'=>$item->id,
+                    ];
+                    $exist = AccountLog::where('dream_id',$item->id)->first();
+                    if (empty($exist)) {
+//                        AccountLog::firstOrCreate($arr);
+                        AccountLog::create($arr);
+                    }
+
+
+
                     $message = "你的梦想《".$item->name."》已结束,点击了解接下来的步骤";
                     $info = $dream_user->nickname.'会以你提供的微信/电话联系你约好时间地点亲自感谢你给予的支持和鼓励。如果你不希望见面或
                             不想要梦想者拥有你的联系方式,请按《不需要见面》的按钮或联系客服。';

+ 0 - 1
server/app/Http/Controllers/Admin/Dream/InfoController.php

xqd
@@ -152,7 +152,6 @@ class InfoController extends Controller
             $arr[] = $pic['pic'];
         }
         $data->imgs = $arr;
-//        dd($data);
         $data['sign'] = explode(',',$data['sign']);
         $signs = BaseSettingsModel::where('category','sign')->orderBy('id')->get();
         return view('admin.dream.info.edit',compact('data','signs'));

+ 4 - 3
server/app/Http/Controllers/Api/V1/IndexController.php

xqd
@@ -127,15 +127,16 @@ class IndexController extends Controller
         $type = $request->type;
         if ($type == 'trend') {
             $banners = $this->getBanner();
-            $dreams = DreamInfoModel::where('end_time','>',date('Y-m-d H:i:s'))->orderBy('score','desc')->with('user')->whereNotIn('id', $id_arr1)->limit(100)->paginate(20);
+            $dreams = DreamInfoModel::where('end_time','>',date('Y-m-d H:i:s'))->whereBetween('created_at',[date('Y-m-d H:i:s'),date('Y-m-d H:i:s',time()+3*24*3600)])->orderBy('score','desc')->with('user')->whereNotIn('id', $id_arr1)->limit(100)->paginate(20);
             $this->dreams($dreams);
         } elseif ($type == 'news') {
             $banners = $this->getBanner();
-            $dreams = DreamInfoModel::where('end_time','>',date('Y-m-d H:i:s'))->orderBy('score','desc')->orderBy('created_at','desc')->with('user')->whereNotIn('id', $id_arr2)->limit(500)->paginate(20);
+            $dreams = DreamInfoModel::where('end_time','>',date('Y-m-d H:i:s'))->whereBetween('created_at',[date('Y-m-d H:i:s'),date('Y-m-d H:i:s',time()+24*3600)])->orderBy('score','desc')->orderBy('created_at','desc')->with('user')->whereNotIn('id', $id_arr2)->paginate(20);
             $this->dreams($dreams);
         } else{
+//            热门
             $banners = $this->getBanner();
-            $dreams = DreamInfoModel::where('end_time','>',date('Y-m-d H:i:s'))->orderBy('score','desc')->with('user')->limit(15)->paginate(15);
+            $dreams = DreamInfoModel::where('end_time','>',date('Y-m-d H:i:s'))->orderBy('score','desc')->with('user')->paginate(15);
             $this->dreams($dreams);
         }
         foreach ($dreams as $dream) {

+ 56 - 1
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd xqd xqd xqd
@@ -1117,6 +1117,7 @@ class MyController extends Controller
     {
         $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',
@@ -1167,6 +1168,7 @@ class MyController extends Controller
     {
         $data = $request->data;
         $user = $this->getUser();
+        if (empty($user)) return $this->error(ErrorCode::MERCHANT_NOT_EXIST);
         $validator = \Validator::make($request->all(),
             [
                 'data.type'  => 'required',
@@ -1280,6 +1282,7 @@ class MyController extends Controller
         );
         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');
@@ -1308,7 +1311,9 @@ class MyController extends Controller
 
         $ok =SystemInfoModel::create($arr);
         if ($ok) {
-            $this->jPush($user->nickname.'给你发了个私信哦~点击看看!','',$to_user_id);
+            if (!empty($to_user_id)) {
+                $this->jPush($user->nickname.'给你发了个私信哦~点击看看!','',$to_user_id);
+            }
             return $this->api('');
         }else{
             return $this->error(ErrorCode::OPERATION_FAILED);
@@ -1516,4 +1521,54 @@ class MyController extends Controller
         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);
+    }
+
 }

+ 9 - 0
server/app/Models/AccountLog.php

xqd
@@ -10,12 +10,21 @@ class AccountLog extends Model
 
     protected $fillable = [
         'from_type',
+        'from_name',
         'to_type',
         'from_id',
         'to_id',
+        'to_name',
         'op',
         'from_amount',
         'to_amount',
+        'transaction_id',
+        'avatar',
+        'channel',
+        'avatar',
+        'title',
+        'dream_id',
+        'note',
     ];
     //交易行为定义
     const OP_CHARGE         = 'CHARGE';

+ 1 - 1
server/app/Services/Base/ErrorCode.php

xqd
@@ -93,7 +93,7 @@ final class ErrorCode {
         self::ATTACHMENT_MIME_NOT_ALLOWED => '附件类型不允许',
         self::MEMBER_CREDIT_NOT_ENOUGH => '会员卡金不足',
         self::MERCHANT_CREDIT_NOT_ENOUGH => '商户卡金不足',
-        self::MERCHANT_NOT_EXIST => '户不存在',
+        self::MERCHANT_NOT_EXIST => '户不存在',
         self::FAVORITE_NOT_EXIST => '收藏不存在',
         self::MERCHANT_ADD_MEMBER_FAILED => '添加会员失败',
         self::MERCHANT_STATUS_NOT_OK => '申请成功,客服会在3个工作日内与您取得联系!',

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

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddTitleToAccountLogsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('account_logs', function (Blueprint $table) {
+            $table->string('title')->nullable()->comment('梦想标题')->after('avatar');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('account_logs', function (Blueprint $table) {
+            //
+        });
+    }
+}

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

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddDreamIdToAccountLogs extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('account_logs', function (Blueprint $table) {
+            $table->integer('dream_id')->nullable()->comment('梦想id')->after('title');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('account_logs', function (Blueprint $table) {
+            //
+        });
+    }
+}

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

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AlertImageToSystemInfoTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('system_info', function (Blueprint $table) {
+            $table->string('image')->default('')->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('system_info', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 4 - 0
server/routes/api.php

xqd
@@ -166,6 +166,10 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.lettershow',
         'uses' => 'MyController@letterShow',
     ]);
+    $api->get('/my/account_log', [
+        'as' => 'my.account_log',
+        'uses' => 'MyController@accountLog',
+    ]);
     $api->get('my/care', [
         'as' => 'my.care',
         'uses' => 'MyController@care',