浏览代码

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

admin 2 年之前
父节点
当前提交
ba00b12a49

+ 5 - 2
app/Console/Commands/ContentManage/ContentTest.php

@@ -2,8 +2,11 @@
 
 namespace App\Console\Commands\ContentManage;
 
+use http\Exception\RuntimeException;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Redis;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
 
 class ContentTest extends Command
 {
@@ -26,7 +29,7 @@ class ContentTest extends Command
      */
     public function handle(): void
     {
-        Redis::set('test-aa', 1132412);
-        $this->info(Redis::get('test-aa'));
+       myLog('kkkkk')->info(date('Y-m-d H:i:s'));
+       throw new RuntimeException('kljkjljkjkl');
     }
 }

+ 0 - 4
app/Exceptions/Handler.php

@@ -65,10 +65,6 @@ class Handler extends ExceptionHandler
     public function render($request, Throwable $e): JsonResponse|Response
     {
         $message = $e->getMessage();
-        echo "<pre><hr>";
-        var_export($message);
-        echo  "<hr>";
-        die();
         if (method_exists($e, 'getStatusCode')) {
             if ($e->getStatusCode() == Response::HTTP_NOT_FOUND) {
                 $message = '路由未找到或未注册';

+ 2 - 1
config/logging.php

@@ -4,6 +4,7 @@ use Monolog\Handler\NullHandler;
 use Monolog\Handler\StreamHandler;
 use Monolog\Handler\SyslogUdpHandler;
 
+$hostname = gethostname();
 return [
 
     /*
@@ -65,7 +66,7 @@ return [
 
         'daily' => [
             'driver' => 'daily',
-            'path' => storage_path('logs/laravel.log'),
+            'path' => storage_path('logs/'.$hostname. '/'. env('APP_NAME').'/system/laravel.log'),
             'level' => env('LOG_LEVEL', 'debug'),
             'days' => 14,
         ],

+ 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, '银行卡不存在或当前状态不可提现'];

+ 2 - 1
modules/Manage/Http/Controllers/MiniprogramController.php

@@ -88,6 +88,7 @@ class MiniprogramController extends CatchController
     {
         $validate_result = $request->validated();
         $validate_result['remark'] = $request->post('remark','') ?? '';
+        $validate_result['pay_merchant_id'] = $request->post('pay_merchant_id',0);
         if (getProp($validate_result,'pay_merchant_id',0)){
             $info = DB::table('pay_merchants')->where('id',$validate_result['pay_merchant_id'])->first();
             if (empty($info)){
@@ -109,7 +110,7 @@ class MiniprogramController extends CatchController
             $validate_result['pay_merchant_id'] = 0;
             $validate_result['pay_merchant_info'] = [];
         }
-
+        
         return $this->miniprogram->create($validate_result)->toArray();
 
     }

+ 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')
 ];

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

@@ -27,10 +27,13 @@ class VideoController extends CatchController
         $updateType = $request->input('updateType');
         $categoryId = $request->input('categoryId');
         $videoId = $request->input('videoId');
+        $shelfType = $request->input('shelfType');
 
         $videos = DB::table('videos')
             ->when($videoId, function ($query, $videoId){
                 return $query->where('id', $videoId);
+            })->when($shelfType, function ($query, $shelfType){
+                return $query->where('shelf_type', $shelfType);
             })
             ->when($videoName, function ($query, $videoName){
                return $query->where('name', 'like', '%'. $videoName . '%');

+ 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();
+    }
 }

+ 20 - 1
tests/Operation/Http/Controllers/FirstPageControllerTest.php

@@ -45,7 +45,26 @@ class FirstPageControllerTest extends UsedTestCase
             'Authorization' => 'Bearer '. $this->token,
         ])->json('post','http://localhost/api/operationManage/firstPage/setConfig', [
             'id' => 4,
-            'duanjus' => []
+            'duanjus' => [
+                [
+                    'sort' => 5,
+                    'id' => 9,
+                    'name' => 'xxx1',
+                ],
+                [
+                    'sort' => 1,
+                    'id' =>10,
+                    'name' => 'xxx2',
+                ],[
+                    'sort' => 3,
+                    'id' =>11,
+                    'name' => 'xxx3',
+                ],[
+                    'sort' => 4,
+                    'id' =>12,
+                    'name' => 'xxx4',
+                ],
+            ]
         ]);
         $res->dump();
         $this->dumpJson($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'];
     }