Browse Source

Merge branch 'test' of 121.36.198.49:zy_duanju/duanju_manage into test

zqwang 1 year ago
parent
commit
6555e57300

+ 3 - 2
modules/Callback/Http/Controllers/CallbackLogController.php

@@ -42,15 +42,16 @@ class CallbackLogController extends CatchController
             })->when($userRanseStartAtBeginTime, function ($query, $userRanseStartAtBeginTime){
                 return $query->where('user_ranse_start_at', '>=', $userRanseStartAtBeginTime);
             })->when($userRanseStartAtEndTime, function ($query, $userRanseStartAtEndTime){
-                return $query->where('user_ranse_start_at', '<=', $userRanseStartAtEndTime);
+                return $query->where('user_ranse_start_at', '<=', $userRanseStartAtEndTime . ' 23:59:59');
             })->when($orderCreatedAtBeginTime, function ($query, $orderCreatedAtBeginTime){
                 return $query->where('order_created_at', '>=', $orderCreatedAtBeginTime);
             })->when($miniprogramId, function ($query, $miniprogramId){
                 return $query->where('miniprogram_id', $miniprogramId);
             })
             ->when($orderCreatedAtEndTime, function ($query, $orderCreatedAtEndTime) {
-                return $query->where('order_created_at', '<=', $orderCreatedAtEndTime);
+                return $query->where('order_created_at', '<=', $orderCreatedAtEndTime. ' 23:59:59');
             })->orderBy('created_at', 'desc');
+   
         if($isExport) {
             $result = $sql->get();
         } else {

+ 96 - 2
modules/Callback/Http/Controllers/JuliangAccountController.php

@@ -18,15 +18,48 @@ class JuliangAccountController extends CatchController
     public function list(Request $request) {
         $advAccountId = $request->input('account_id');
         $advAccountName = $request->input('account_name');
+        $unBind = $request->input('unbind', 0);
+        $alreadyBindConfigIds = null;
+        if($unBind) {
+            $alreadyBindConfigIds = DB::table('promotions')
+                ->where([
+                    'uid' => $this->getOptimizerUid(),
+                    'callback_type' => 1,
+                    'status' => 1,
+                    'is_enabled' => 1,
+                ])->where('callback_config_id' , '<>', 0)
+                ->distinct()
+                ->select('callback_config_id')
+                ->get()->pluck('callback_config_id')->toArray();
+        }
 
-        return DB::table('juliang_account_callback_config')
+        $list =  DB::table('juliang_account_callback_config')
             ->where(['company_uid' => $this->getOptimizerUid()])
             ->when($advAccountId, function ($query, $advAccountId) {
                 return $query->where('adv_account_id' , $advAccountId);
             })->when($advAccountName, function ($query, $advAccountName) {
                 return $query->where('adv_account_name', 'like', '%'. $advAccountName. '%');
-            })->orderBy('id', 'desc')
+            })->when($alreadyBindConfigIds, function ($query, $alreadyBindConfigIds) {
+                return $query->whereNotIn('id', $alreadyBindConfigIds);
+            })
+            ->orderBy('id', 'desc')
             ->paginate($request->input('limit', 30));
+        $ids = collect($list->items())->pluck('id');
+        $promotions = DB::table('promotions')
+            ->where([
+                'uid' => $this->getOptimizerUid(),
+                'callback_type' => 1,
+                'status' => 1,
+                'is_enabled' => 1,
+            ])->whereIn('callback_config_id', $ids)
+            ->select('name', 'id', 'callback_config_id')
+            ->get()->keyBy('callback_config_id');
+        foreach ($list as $item) {
+            $item->promotion_name = $promotions->get($item->id)->name ?? '';
+            $item->promotion_id = $promotions->get($item->id)->id ?? '';
+        }
+
+        return $list;
     }
 
     public function addAccount(Request $request) {
@@ -270,4 +303,65 @@ class JuliangAccountController extends CatchController
 
         return 'ok';
     }
+
+    /**
+     * 解绑推广
+     * @param Request $request
+     */
+    public function unbindPromotion(Request $request) {
+        $this->validate($request, [
+            'id' => 'required'
+        ]);
+
+        $config = DB::table('juliang_account_callback_config')
+            ->where([
+                'id' => $request->input('id'),
+                'company_uid' => $this->getOptimizerUid(),
+            ])->first();
+
+        if(!$config) {
+            CommonBusinessException::throwError(Errors::JULIANG_ACCOUNT_CONFIG_NOT_EXISTS);
+        }
+        $now = date('Y-m-d H:i:s');
+        $affected = DB::table('promotions')
+            ->where([
+                'callback_type' => 1,
+                'callback_config_id' => $request->input('id'),
+                'is_enabled' => 1,
+                'status' => 1,
+            ])->update([
+                'status' => 0,
+                'updated_at' => $now,
+            ]);
+        if($affected) {
+            DB::table('juliang_account_rate_config_log')
+                ->where('company_uid', $this->getOptimizerUid())
+                ->where('account_id', $config->adv_account_id)
+                ->where('is_enabled', 1)
+                ->update(['is_enabled' => 0, 'updated_at' => $now]);
+            DB::table('juliang_account_promotion_protect_record')
+                ->where('optimizer_uid', $this->getOptimizerUid())
+                ->where('advertiser_id', $config->adv_account_id)
+                ->where('is_enabled', 1)
+                ->update(['is_enabled' => 0, 'updated_at' => $now]);
+            DB::table('juliang_account_rate_config_log')
+                ->insert([
+                    'company_uid' => $this->getOptimizerUid(),
+                    'account_id' => $config->adv_account_id,
+                    'config_per' => $config->default_rate,
+                    'created_at' => $now,
+                    'updated_at' => $now,
+                ]);
+            // 让所有的时间区间比例配置,在定时任务中,重新执行一遍
+            DB::table('juliang_account_promotion_config_time')
+                ->where('is_enable',1)
+                ->where('company_uid',$this->getOptimizerUid())
+                ->where('account_id',$config->adv_account_id)
+                ->update(['next_exec_time' => date('Y-m-d'), 'updated_at' => $now]);
+        }
+
+
+        return 'ok';
+    }
+
 }

+ 1 - 0
modules/Callback/routes/route.php

@@ -10,6 +10,7 @@ Route::prefix('callback')->group(function () {
         Route::post('addAccount', [JuliangAccountController::class, 'addAccount']);
         Route::post('updateCallbackConfig', [JuliangAccountController::class, 'updateCallbackConfig']);
         Route::post('turnCallbackState', [JuliangAccountController::class, 'turnCallbackState']);
+        Route::post('unbindPromotion', [JuliangAccountController::class, 'unbindPromotion']);
         Route::get('log/list', [CallbackLogController::class, 'list']);
         Route::post('log/callbackAgain', [CallbackLogController::class, 'callbackAgain']);
     });

+ 1 - 1
modules/Common/Errors/Errors.php

@@ -21,7 +21,7 @@ class Errors
     public const  CALLBACK_RATE_TIME_RANGE_ERROR= [500102, '回传比例时间区间不合法'];
     public const  CALLBACK_RECORD_NOT_EXISTS= [500103, '回传日志不存在'];
     public const  CALLBACK_RECORD_LOG_ERROR= [500104, '回传日志补传信息缺失'];
-    public const  JULIANG_ACCOUNT_PROMOTION_UNIQUE = [500105, '巨量广告账户只允许绑定一个推广'];
+    public const  JULIANG_ACCOUNT_PROMOTION_UNIQUE = [500105, '巨量广告账户只允许绑定一个推广,请先解绑'];
     public const  JULIANG_ACCOUNT_CONFIG_NOT_EXISTS = [500106, '回传配置不存在'];
     public const  TIXIAN_YUE_BUZU = [500201, '提现余额不足'];
     public const  BANK_CARD_STATUS_ERROR = [500202, '银行卡不存在或当前状态不可提现'];

+ 53 - 0
modules/Common/Services/CommonConfigService.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace Modules\Common\Services;
+
+class CommonConfigService
+{
+    /**
+     * 获取首页列表类型映射
+     * @return mixed[]
+     * <pre>
+     * [
+     *   1 => [
+     *      'label' => 'xxx',
+     *      'value' => 1,
+     *   ],
+     * ]
+     * </pre>
+     */
+    public static function getFirstPageListTypeMap() {
+        return collect(config('common.common.firstPageListType'))->keyBy('value')->toArray();
+    }
+    /**
+     * 获取小程序类型映射
+     * @return mixed[]
+     * <pre>
+     * [
+     *   1 => [
+     *      'label' => 'xxx',
+     *      'value' => 1,
+     *   ],
+     * ]
+     * </pre>
+     */
+    public static function getMiniprogramTypeMap() {
+        return collect(config('common.common.miniprogramType'))->keyBy('value')->toArray();
+    }
+
+    /**
+     * 获取支付类型映射
+     * @return mixed[]
+     * <pre>
+     * [
+     *   1 => [
+     *      'label' => 'xxx',
+     *      'value' => 1,
+     *   ],
+     * ]
+     * </pre>
+     */
+    public static function getPayTypeMap() {
+        return collect(config('common.common.payType'))->keyBy('value')->toArray();
+    }
+}

+ 12 - 12
modules/Common/config/common.php

@@ -22,16 +22,16 @@ return [
      */
     'payType' => [
         [
-            'key' => 1,
-            'val' => '易宝支付',
+            'label' => '易宝支付',
+            'value' => 1,
         ],
         [
-            'key' => 2,
-            'val' => '微信原生支付',
+            'label' => '微信原生支付',
+            'value' => 2,
         ],
         [
-            'key' => 3,
-            'val' => '抖音支付'
+            'label' => '抖音支付',
+            'value' => 2,
         ],
     ],
     /**
@@ -39,12 +39,12 @@ return [
      */
     'miniprogramType' => [
         [
-            'key' => 1,
-            'val' => '微信'
+            'value' => 1,
+            'label' => '微信'
         ],
         [
-            'key' => 2,
-            'val' => '抖音'
+            'value' => 2,
+            'label' => '抖音'
         ]
     ],
     /**
@@ -53,11 +53,11 @@ return [
     'firstPageListType' => [
         [
             'label' => '本周精选',
-            'val' => 1
+            'value' => 1
         ],
         [
             'label' => '优选好剧',
-            'val' => 2
+            'value' => 2
         ],
     ],
 ];

+ 5 - 4
modules/Manage/Http/Controllers/PayConfigController.php

@@ -6,6 +6,7 @@ use Catch\Base\CatchController;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Modules\Common\Services\CommonConfigService;
 
 /**
  * 支付配置管理
@@ -53,11 +54,11 @@ class PayConfigController extends CatchController
             $result =  $sql->paginate($request->input('limit', 15));
         }
 
-        $payTypeMap = collect($commonConfig['payType'])->keyBy('key');
-        $miniprogramTypeMap = collect($commonConfig['miniprogramType'])->keyBy('key');
+        $payTypeMap = CommonConfigService::getPayTypeMap();
+        $miniprogramTypeMap = CommonConfigService::getMiniprogramTypeMap();
         foreach ($result as $item) {
-            $item->pay_type_str = $payTypeMap[$item->pay_type]['val'] ?? '';
-            $item->miniprogram_type_str = $miniprogramTypeMap[$item->miniprogram_type]['val'] ?? '';
+            $item->pay_type_str = $payTypeMap[$item->pay_type]['label'] ?? '';
+            $item->miniprogram_type_str = $miniprogramTypeMap[$item->miniprogram_type]['label'] ?? '';
         }
 
         return $result;

+ 15 - 4
modules/Operation/Http/Controllers/FirstPageController.php

@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Modules\Common\Errors\Errors;
 use Modules\Common\Exceptions\CommonBusinessException;
+use Modules\Common\Services\CommonConfigService;
 use Modules\User\Http\Controllers\UserTrait;
 
 class FirstPageController extends CatchController
@@ -19,13 +20,15 @@ class FirstPageController extends CatchController
      *  首页列表
      */
     public function list(Request $request) {
-        $firstPageListTypeMap = collect(config('common.common.firstPageListType'))->keyBy('val')->toArray();
+        $firstPageListTypeMap = CommonConfigService::getFirstPageListTypeMap();
+        $miniprogramTypeMap = CommonConfigService::getMiniprogramTypeMap();
         $result = DB::table('first_pages')
             ->orderBy('id', 'desc')
             ->paginate($request->input('limit', 15));
         foreach ($result as $item) {
             $item->type_str = $firstPageListTypeMap[$item->type]['label'] ?? '';
             $item->duanjus = collect(\json_decode($item->duanjus, true))->sortBy('sort');
+            $item->miniprogram_type_str = $miniprogramTypeMap[$item->miniprogram_type]['label'] ?? '';
         }
         return $result;
     }
@@ -39,13 +42,17 @@ class FirstPageController extends CatchController
     public function add(Request $request) {
         $this->validate($request, [
             'type' => 'required|in:1,2',
-            'status' => 'required|in:0,1'
+            'status' => 'required|in:0,1',
+            'miniprogram_type' => 'required|in:1,2'
         ]);
 
         $now = date('Y-m-d H:i:s');
         if(1 == $request->input('status')) {
             DB::table('first_pages')
-                ->where('type', $request->input('type'))
+                ->where([
+                    'type' => $request->input('type'),
+                    'miniprogram_type' => $request->input('miniprogram_type')
+                ])
                 ->update(['status' => 0, 'updated_at' => $now]);
         }
 
@@ -53,6 +60,7 @@ class FirstPageController extends CatchController
             ->insert([
                 'type' => $request->input('type'),
                 'status' => $request->input('status'),
+                'miniprogram_type' => $request->input('miniprogram_type'),
                 'created_at' => $now,
                 'updated_at' => $now,
             ]);
@@ -76,7 +84,10 @@ class FirstPageController extends CatchController
 
         $now = date('Y-m-d H:i:s');
         DB::table('first_pages')
-            ->where('type', $info->type)
+            ->where([
+                'type' => $info->type,
+                'miniprogram_type' => $info->miniprogram_type,
+            ])
             ->update(['status' => 0, 'updated_at' => $now]);
         DB::table('first_pages')
             ->where('id', $request->input('id'))

+ 4 - 2
modules/Tuiguang/Http/Controllers/PromotionController.php

@@ -54,9 +54,10 @@ class PromotionController extends CatchController
             })->orderBy('created_at', 'desc')
             ->select('promotions.id', 'promotions.name', 'promotions.created_at',
             'videos.name as video_name', 'promotions.series_sequence', 'promotions.callback_type',
-                'promotions.callback_config_id', 'promotions.video_id', 'promotions.remark')
+                'promotions.callback_config_id', 'promotions.video_id', 'promotions.remark', 'promotions.status')
             ->paginate($request->input('limit', 15));
         foreach ($result as $item) {
+            $item->status_str = $item->status ? '启用':'禁用';
             $item->series_sequence_name = '第'. $item->series_sequence . '集';
             $item->callback_type_str = $callbackTypeMap[$item->callback_type] ?? '';
             $item->promotion_path = config('tuiguang.tuiguang.url') . DIRECTORY_SEPARATOR . 'api/promotion/index?ranse_id='. $item->id;
@@ -131,7 +132,8 @@ class PromotionController extends CatchController
         if(1 == $request->input('callback_type')) {
             $exist = DB::table('promotions')
                 ->where(['is_enabled' => 1, 'callback_type' => $request->input('callback_type'),
-                    'callback_config_id' => $request->input('callback_config_id')])
+                    'callback_config_id' => $request->input('callback_config_id'),
+                    'status' => 1])
                 ->first();
             if($exist && $exist->id != $request->input('id')) {
                 CommonBusinessException::throwError(Errors::JULIANG_ACCOUNT_PROMOTION_UNIQUE);

+ 2 - 2
modules/Tuiguang/config/tuiguang.php

@@ -4,9 +4,9 @@ return [
     /**
      * 推广链接地址
      */
-    'url' => env('TUIGUAGN_URL', 'https://api.dududus.com'),
+    'url' => env('TUIGUAGN_URL', 'https://api.zhiyupa.com'),
     /**
      * 监测链接地址
      */
-    'trackUrl' => env('TUIGUAGN_TRACK_URL', 'https://track.dududus.com')
+    'trackUrl' => env('TUIGUAGN_TRACK_URL', 'https://track.zhiyupa.com')
 ];

+ 10 - 3
modules/Video/Http/Controllers/VideoController.php

@@ -28,6 +28,7 @@ class VideoController extends CatchController
         $categoryId = $request->input('categoryId');
         $videoId = $request->input('videoId');
         $shelfType = $request->input('shelfType');
+        $wechatPass = $request->input('wechatPass', 0);
 
         $videos = DB::table('videos')
             ->when($videoId, function ($query, $videoId){
@@ -41,7 +42,10 @@ class VideoController extends CatchController
                 return $query->where('update_type', $updateType);
             })->when($categoryId, function ($query, $categoryId){
                 return $query->where('category_id', $categoryId);
-            })->orderBy('id', 'desc')
+            })->when($wechatPass, function ($query, $wechatPass) {
+                return $query->where('wechat_pass', $wechatPass);
+            })
+            ->orderBy('id', 'desc')
             ->paginate($request->integer('limit', 15));
         $userContext = $this->getUserContext($request->input('operateUserId'));
         $allVideoCategory =  DB::table('video_category')
@@ -53,6 +57,7 @@ class VideoController extends CatchController
             $video->update_type_str = $video->update_type == 1 ? '连载中' : '完结';
             $video->cp_share_type_str = ([1 => '分成', 2=>'保底', 3=>'买断'])[$video->cp_share_type] ?? '';
             $video->channel = $allVideoCategory->get($video->category_id)->pid;
+            $video->wechat_pass_img = $video->wechat_pass ? config('common.common.logos.1') : '';
         }
 
         return $videos;
@@ -122,7 +127,8 @@ class VideoController extends CatchController
             'd_charge_coin' => 'required|integer|min:1',
             'cp_name' => 'required|string',
             'cp_share_type' => 'required|integer|in:1,2,3',
-            'cover_image' => 'required|string'
+            'cover_image' => 'required|string',
+            'note' => 'required',
         ]);
         $data = $request->all();
         $now = date('Y-m-d H:i:s');
@@ -155,7 +161,8 @@ class VideoController extends CatchController
             'd_charge_coin' => 'required|integer|min:1',
             'cp_name' => 'required|string',
             'cp_share_type' => 'required|integer|in:1,2,3',
-            'cover_image' => 'required|string'
+            'cover_image' => 'required|string',
+            'note' => 'required',
         ]);
         $id = $request->input('id');
         $data = $request->except('id', 'shelf_at');

+ 10 - 0
tests/Callback/Http/Controllers/JuliangAccountControllerTest.php

@@ -54,6 +54,7 @@ class JuliangAccountControllerTest extends UsedTestCase
             'Authorization' => 'Bearer '. $this->token,
         ])->json('get','http://localhost/api/callback/juliangAccount/list');
 
+        $res->dump();
         $this->dumpJson($res);
     }
 
@@ -66,4 +67,13 @@ class JuliangAccountControllerTest extends UsedTestCase
         ]);
         $res->dump();
     }
+
+    public function testunbindPromotion() {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/callback/juliangAccount/unbindPromotion', [
+            'id' => 5,
+        ]);
+        $res->dump();
+    }
 }

+ 17 - 0
tests/Common/Services/CommonConfigServiceTest.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace Tests\Common\Services;
+
+use Modules\Common\Services\CommonConfigService;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class CommonConfigServiceTest extends UsedTestCase
+{
+
+    public function testGetFirstPageListTypeMap()
+    {
+        $res  = CommonConfigService::getFirstPageListTypeMap();
+        dump($res);
+    }
+}

+ 2 - 2
tests/UsedTestCase.php

@@ -13,11 +13,11 @@ abstract class UsedTestCase extends BaseTestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $tokenInfo = $this->post('http://localhost/api/login', [
-            'email' => 'catch@admin.com',
+//            'email' => 'catch@admin.com',
             'remember' => false,
 //            'email' => 'xiaoli@qq.com',
             'password' => 'catchadmin',
-//            'email' => 'aa4@test.com',
+            'email' => 'aa4@test.com',
         ])->json();
         $this->token = $tokenInfo['data']['token'];
     }

+ 1 - 1
tests/Video/Http/Controllers/VideoControllerTest.php

@@ -62,7 +62,7 @@ class VideoControllerTest extends UsedTestCase
 //            'videoName' => '112',
 //        'updateType' => 2,
 //        'categoryId' => 4,
-            'operateUserId' =>10
+//            'operateUserId' =>10
         ]);
 //        $this->dumpJson($res);
         $res->dump();