Browse Source

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

zqwang 1 year ago
parent
commit
6a03242f05

+ 56 - 10
modules/Callback/Http/Controllers/CallbackLogController.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\Callback\Services\CallbackConst;
 use Modules\Callback\Services\TiktokEventReportService;
 use Modules\Common\Errors\Errors;
 use Modules\Common\Exceptions\CommonBusinessException;
@@ -30,10 +31,26 @@ class CallbackLogController extends CatchController
         $miniprogramId = $request->input('miniprogram_id');
         $isExport = $request->input('is_export', false);
 
+        $orderNo =  $request->input('order_no');
+        $orderPriceStart = $request->input('order_price_start');
+        $orderPriceEnd = $request->input('order_price_end');
+        $callbackType = $request->input('callback_type', 1);
+        $callbackConfigId = $request->input('callback_config_id');
+
         $sql = DB::table('callback_report_charge_record')
             ->where([
-                'optimizer_uid' => $this->getLoginUserId()
-            ])->when($advertiserId, function ($query, $advertiserId) {
+                'optimizer_uid' => $this->getLoginUserId(),
+                'callback_type' => $callbackType,
+            ])->when($orderNo, function ($query, $orderNo){
+                return $query->where('order_no', $orderNo);
+            })->when($callbackConfigId, function ($query, $callbackConfigId){
+                return $query->where('callback_config_id', $callbackConfigId);
+            })->when($orderPriceStart, function ($query, $orderPriceStart){
+                return $query->where('order_price', '>=', $orderPriceStart);
+            })->when($orderPriceEnd, function ($query, $orderPriceEnd){
+                return $query->where('order_price', '<', $orderPriceEnd);
+            })
+            ->when($advertiserId, function ($query, $advertiserId) {
                 return $query->where('advertiser_id', $advertiserId);
             })->when($uid, function ($query, $uid) {
                 return $query->where('uid', $uid);
@@ -51,23 +68,47 @@ class CallbackLogController extends CatchController
             ->when($orderCreatedAtEndTime, function ($query, $orderCreatedAtEndTime) {
                 return $query->where('order_created_at', '<=', $orderCreatedAtEndTime. ' 23:59:59');
             })->orderBy('created_at', 'desc');
-   
+
         if($isExport) {
             $result = $sql->get();
         } else {
             $result = $sql->paginate($request->integer('limit', 15));
         }
-        $advertisers = DB::table('juliang_account_callback_config')
-            ->where('company_uid', $this->getLoginUserId())
-            ->select('adv_account_id', 'adv_account_name')
-            ->get()->keyBy('adv_account_id');
         $reportSuccessStr = [
             0 => '回传失败',
             1 => '回传成功',
             2 => '补传成功',
         ];
+        $advertisers = $callbackNames = collect();
+        $currentUid = $this->getLoginUserId();
+        if(CallbackConst::TYPE_JL_ACCOUNT == $callbackType) {
+            $advertisers = DB::table('juliang_account_callback_config')
+                ->where('company_uid', $currentUid)
+                ->select('adv_account_id', 'adv_account_name')
+                ->get()->keyBy('adv_account_id');
+        } elseif (CallbackConst::TYPE_JL_EVENT_20 == $callbackType){
+            $callbackNames = DB::table('jl_event_callback_config')
+                ->where('user_id', $currentUid)
+                ->whereIn('id', $result->pluck('callback_config_id'))
+                ->select('id', 'name')->get()->keyBy('id');
+            $promotionNames = DB::table('promotions')
+                ->where('uid', $currentUid)
+                ->whereIn('id', $result->pluck('user_ranse_id'))
+                ->select('id', 'name')->get()->keyBy('id');
+        }
+
+
+
+
+
         foreach ($result as $item) {
-            $item->advertiser_name = $advertisers->get($item->advertiser_id ?? -1)->adv_account_name ?? '';
+            if(CallbackConst::TYPE_JL_ACCOUNT == $callbackType) {
+                $item->advertiser_name = $advertisers->get($item->advertiser_id ?? -1)->adv_account_name ?? '';
+            } elseif(CallbackConst::TYPE_JL_EVENT_20 == $callbackType) {
+                $item->callback_config_name = $callbackNames->get($item->callback_config_id ?? -1)->name ?? '';
+                $item->ranse_name = $promotionNames->get($item->user_ranse_id ?? -1)->name ?? '';
+            }
+
             if('ok' == $item->filter_type ) {
                 $item->filter_reason .= '-'. $reportSuccessStr[$item->report_success] ?? '';
             }
@@ -94,7 +135,7 @@ class CallbackLogController extends CatchController
 
         $record = DB::table('callback_report_charge_record')
             ->where('id', $logId)
-            ->select('report_param')
+            ->select('report_param', 'filter_type')
             ->first();
         if(!$record || !$record->report_param) {
             CommonBusinessException::throwError(Errors::CALLBACK_RECORD_NOT_EXISTS);
@@ -106,7 +147,12 @@ class CallbackLogController extends CatchController
         }
 
         $reportService = new TiktokEventReportService();
-        $result = $reportService->reportCharge($requestInfo);
+        if('roi_report_all' == $record->filter_type) {
+            $result = $reportService->roiReportCharge($requestInfo);
+        } else {
+            $result = $reportService->reportCharge($requestInfo);
+        }
+
         $reportSuccess = 0;
         if($result['result']) {
             $resultContent = \json_decode($result['content'], true);

+ 128 - 0
modules/Callback/Http/Controllers/JLEvent/JLEventController.php

@@ -0,0 +1,128 @@
+<?php
+
+namespace Modules\Callback\Http\Controllers\JLEvent;
+
+use Catch\Base\CatchController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Modules\Callback\Models\JLEventCallbackConfigModel;
+use Modules\Callback\Services\CallbackConst;
+use Modules\Callback\Services\JLEventService;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
+
+/**
+ * 巨量2.0事件-微信小程序
+ */
+class JLEventController extends CatchController
+{
+    use ValidatesRequests;
+    /**
+     * 回传配置列表
+     * @param Request $request
+     */
+    public function list(Request $request) {
+        $id = $request->input('id');
+        $name = $request->input('name');
+        $promotionId = $request->input('promotion_id');
+        $unbind = $request->input('unbind', 0);
+
+        $result =  DB::table('jl_event_callback_config as config')
+            ->leftJoin('promotions', 'promotions.callback_config_id', '=', 'config.id')
+            ->where([
+                'user_id' => $this->getLoginUserId(),
+            ])->when($id, function ($query, $id){
+                return $query->where('config.id', $id);
+            })->when($name, function ($query, $name){
+                return $query->where('config.name', 'like', '%' .$name. '%');
+            })->when($promotionId, function ($query, $promotionId){
+                return $query->where('promotions.id', $promotionId)
+                    ->where('promotions.callback_type' , CallbackConst::TYPE_JL_EVENT_20);
+            })->when(1 == $unbind, function ($query){
+                return $query->whereNull('promotions.id');
+            })
+            ->select('config.id', 'config.name', 'config.charge_type', 'config.updated_at',
+                'promotions.name as promotion_name', 'promotions.id as promotion_id',
+            'config.charge_money_map', 'config.is_roi')
+            ->orderBy('id', 'desc')
+            ->paginate($request->input('limit', 15));
+        foreach ($result as $item){
+            $item->charge_type_str = CallbackConst::CHARGE_TYPE_MAP[$item->charge_type] ?? '-';
+            $item->charge_money_map = \json_decode($item->charge_money_map) ?? [];
+        }
+        return $result;
+    }
+
+    /**
+     * 新增回传配置
+     * @param Request $request
+     */
+    public function add(Request $request) {
+        $this->validate($request, [
+            'name' => 'required|string|max:64',
+            // roi 全量上报:1-全量上报,2-不全量上报
+            'is_roi' => 'required|integer|in:1,2',
+            // 充值行为:1-首充,2-所有充值
+            'charge_type' => 'required_if:is_roi,2|integer|in:1,2',
+            // 金额项
+            'charge_money_map'  => 'required_if:is_roi,2|array',
+            'charge_money_map.*.min_money' => 'integer|min:0',
+        ]);
+        if(2 == $request->input('is_roi') &&
+            (!JLEventService::judgeChargeMoneyOk($request->input('charge_money_map')))) {
+            CommonBusinessException::throwError(Errors::CALLBACK_CHARGE_MONEY_MAP_ERROR);
+        }
+        $userId = $this->getLoginUserId();
+
+
+        $model = JLEventCallbackConfigModel::create(array_merge($request->only('name', 'is_roi', 'charge_type'), [
+            'charge_money_map' => \json_encode($request->input('charge_money_map')),
+            'user_id' => $userId,
+        ]));
+
+        JLEventService::saveRateConfigLog($userId, $model->id, $request->input('charge_money_map', []));
+
+        return 'ok';
+    }
+
+    /**
+     * 更新回传配置
+     * @param Request $request
+     */
+    public function update(Request $request) {
+        $this->validate($request, [
+            'ids' => 'required|array',
+            'ids.*' => 'integer',
+            // roi 全量上报:1-全量上报,2-不全量上报
+            'is_roi' => 'required|integer|in:1,2',
+            // 充值行为:1-首充,2-所有充值
+            'charge_type' => 'required_if:is_roi,2|integer|in:1,2',
+            // 金额项
+            'charge_money_map'  => 'required_if:is_roi,2|array',
+            'charge_money_map.*.min_money' => 'integer|min:0',
+        ]);
+
+        if(1 == count($request->input('ids'))) {
+            $updateData = $request->only('is_roi', 'charge_type', 'name');
+        } else {
+            $updateData = $request->only('is_roi', 'charge_type');
+        }
+        $now = date('Y-m-d H:i:s');
+        $userId = $this->getLoginUserId();
+        $configIds = DB::table('jl_event_callback_config')
+            ->whereIn('id', $request->input('ids'))
+            ->where('user_id', $userId)
+            ->select('id')->get()->pluck('id');
+        DB::table('jl_event_callback_config')
+            ->whereIn('id', $configIds)
+            ->update(array_merge($updateData, [
+                'charge_money_map' => \json_encode($request->input('charge_money_map', [])),
+                'updated_at' => $now,
+            ]));
+        foreach ($configIds as $configId) {
+            JLEventService::saveRateConfigLog($userId, $configId, $request->input('charge_money_map', []));
+        }
+        return 'ok';
+    }
+}

+ 8 - 6
modules/Callback/Http/Controllers/JuliangAccountController.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\Callback\Services\CallbackConst;
 use Modules\Common\Errors\Errors;
 use Modules\Common\Exceptions\CommonBusinessException;
 use Modules\User\Http\Controllers\UserTrait;
@@ -17,7 +18,7 @@ class JuliangAccountController extends CatchController
 
     public function list(Request $request) {
         $advAccountId = $request->input('account_id');
-        $advAccountName = $request->input('account_name');
+        $advAccountName = $request->input('name');
         $unBind = $request->input('unbind', 0);
         $id =  $request->input('id', 0);
         $alreadyBindConfigIds = null;
@@ -27,7 +28,7 @@ class JuliangAccountController extends CatchController
             $alreadyBindConfigIds = DB::table('promotions')
                 ->where([
                     'uid' => $this->getOptimizerUid(),
-                    'callback_type' => 1,
+                    'callback_type' => CallbackConst::TYPE_JL_ACCOUNT,
                     'status' => 1,
                     'is_enabled' => 1,
                 ])->where('callback_config_id' , '<>', 0)
@@ -41,7 +42,7 @@ class JuliangAccountController extends CatchController
                 ->where([
                     'uid' => $this->getOptimizerUid(),
                     'id' =>  $promotionId,
-                    'callback_type' => 1,
+                    'callback_type' => CallbackConst::TYPE_JL_ACCOUNT,
                     'status' => 1,
                     'is_enabled' => 1,
                 ])->where('callback_config_id' , '<>', 0)
@@ -73,7 +74,7 @@ class JuliangAccountController extends CatchController
         $promotions = DB::table('promotions')
             ->where([
                 'uid' => $this->getOptimizerUid(),
-                'callback_type' => 1,
+                'callback_type' => CallbackConst::TYPE_JL_ACCOUNT,
                 'status' => 1,
                 'is_enabled' => 1,
             ])->whereIn('callback_config_id', $ids)
@@ -82,6 +83,7 @@ class JuliangAccountController extends CatchController
         foreach ($list as $item) {
             $item->promotion_name = $promotions->get($item->id)->name ?? '';
             $item->promotion_id = $promotions->get($item->id)->id ?? '';
+            $item->name = $item->adv_account_name;
         }
 
         return $list;
@@ -111,7 +113,7 @@ class JuliangAccountController extends CatchController
         $now = date('Y-m-d H:i:s');
         $param = [
             'adv_account_id' => $request->input('account_id'),
-            'adv_account_name' => $request->input('account_name',''),
+            'adv_account_name' => $request->input('account_id',''),
             'state' => $request->input('state'),
             'protect_num' => $request->input('protect_num'),
             'default_rate' => $request->input('default_rate'),
@@ -354,7 +356,7 @@ class JuliangAccountController extends CatchController
         $now = date('Y-m-d H:i:s');
         $affected = DB::table('promotions')
             ->where([
-                'callback_type' => 1,
+                'callback_type' => CallbackConst::TYPE_JL_ACCOUNT,
                 'callback_config_id' => $request->input('id'),
                 'is_enabled' => 1,
                 'status' => 1,

+ 11 - 0
modules/Callback/Models/JLEventCallbackConfigModel.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace Modules\Callback\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class JLEventCallbackConfigModel extends  Model
+{
+    protected $table = 'jl_event_callback_config';
+    protected $guarded = [];
+}

+ 22 - 0
modules/Callback/Services/CallbackConst.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace Modules\Callback\Services;
+
+class CallbackConst
+{
+    /**
+     * 回传类型:巨量账户级
+     */
+    const TYPE_JL_ACCOUNT = 1;
+    /**
+     * 回传类型:巨量2.0事件
+     */
+    const TYPE_JL_EVENT_20 = 2;
+    /**
+     * 充值行为类型
+     */
+    const CHARGE_TYPE_MAP=  [
+        '1' => '首充',
+        '2' => '所有充值'
+    ];
+}

+ 100 - 0
modules/Callback/Services/JLEventService.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace Modules\Callback\Services;
+
+use Illuminate\Support\Facades\DB;
+use Modules\Permissions\Middlewares\PermissionGate;
+
+/**
+ * 巨量2.0事件-微信小程序
+ */
+class JLEventService
+{
+    /**
+     * 判断回传配置的金额项
+     * @param $chargeMoneyMap
+     * <pre>
+     * [
+     *      [
+     *          'min_money' => 1, // 最小金额
+     *          'max_money' => 2, // 最大金额(不包含)
+     *          'callback_type' => 1, // 回传参数,类型:1-全部回传,2-全部不回传,3-自定义
+     *          'callback_param' => '1:1', // callback_type == 3 时, 自定义,传几卡几
+     *      ]
+     * ]
+     * </pre>
+     */
+    public static function judgeChargeMoneyOk($chargeMoneyMap) {
+        $len = count($chargeMoneyMap);
+        for($i = 0; $i < $len; $i++) {
+            for($j = $i+1; $j < $len ; $j ++) {
+                if($chargeMoneyMap[$i]['min_money'] >= $chargeMoneyMap[$j]['max_money'] ||
+                    $chargeMoneyMap[$i]['max_money'] <= $chargeMoneyMap[$j]['min_money']) {
+                    continue;
+                } else {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 金额项的卡比例选项
+     * @return array
+     */
+    public static function listCustomCallBackRate() {
+        $arr = explode(',', config('callback.jlEvent.customRate'));
+        $result = [];
+        foreach ($arr as $item) {
+            $temp = explode(':', $item);
+            $result[$item] = '传'.$temp[0].'卡'.$temp[1];
+        }
+        return $result;
+    }
+
+    /**
+     * 回传配置的金额项的比例配置信息
+     * @param $userId 优化师id
+     * @param $configId 回传配置id
+     * @param $chargeMoneyMap
+     * <pre>
+     * [
+     *      [
+     *          'min_money' => 1, // 最小金额
+     *          'max_money' => 2, // 最大金额(不包含)
+     *          'callback_type' => 1, // 回传参数,类型:1-全部回传,2-全部不回传,3-自定义
+     *          'callback_param' => '1:1', // callback_type == 3 时, 自定义,传几卡几
+     *      ]
+     * ]
+     * </pre>
+     */
+    public static function saveRateConfigLog($userId, $configId, $chargeMoneyMap){
+        $now = date('Y-m-d H:i:s');
+        DB::table('jl_event_rate_config_log')
+            ->where([
+                'user_id' => $userId, 'config_id' => $configId,
+                'is_enabled' => 1,
+            ])->update([
+                'is_enabled' => 0, 'updated_at' => $now,
+            ]);
+
+        $insertData = [];
+        foreach ($chargeMoneyMap as $item) {
+            if(3 == $item['callback_type']) {
+                $insertData[] = [
+                    'user_id' => $userId,
+                    'config_id' => $configId,
+                    'rate_str' => $item['callback_param'],
+                    'created_at' => $now, 'updated_at' => $now,
+                    'min_money' => $item['min_money'],
+                    'max_money' => $item['max_money']
+                ];
+            }
+        }
+        if(count($insertData)) {
+            DB::table('jl_event_rate_config_log')
+                ->insert($insertData);
+        }
+    }
+}

+ 12 - 0
modules/Callback/Services/TiktokEventReportService.php

@@ -46,6 +46,18 @@ class TiktokEventReportService
 
     }
 
+    public function roiReportCharge($user) {
+        return $this->report($this->report_url, [
+            'event_type' => $this->purchase_roi_event_type,
+            'context' => [
+                'ad' => [
+                    'callback' => $user->callback
+                ]
+            ],
+            'timestamp' => time()
+        ]);
+    }
+
     /**
      * 付费上报
      */

+ 6 - 0
modules/Callback/config/jlEvent.php

@@ -0,0 +1,6 @@
+<?php
+
+return [
+    'customRate' => env('CALLBACK_JLEVENT_CUSTOM_RATE',
+        '1:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,1:2,2:1,1:3,1:4,2:3,1:5,1:6,1:9,1:7,1:8,3:4,3:5'),
+];

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

@@ -2,6 +2,7 @@
 
 use Illuminate\Support\Facades\Route;
 use Modules\Callback\Http\Controllers\CallbackLogController;
+use Modules\Callback\Http\Controllers\JLEvent\JLEventController;
 use Modules\Callback\Http\Controllers\JuliangAccountController;
 
 Route::prefix('callback')->group(function () {
@@ -14,5 +15,11 @@ Route::prefix('callback')->group(function () {
         Route::get('log/list', [CallbackLogController::class, 'list']);
         Route::post('log/callbackAgain', [CallbackLogController::class, 'callbackAgain']);
     });
+
+    Route::prefix('jlEvent')->group(function(){
+        Route::post('add', [JLEventController::class, 'add']);
+        Route::post('update', [JLEventController::class, 'update']);
+        Route::get('list', [JLEventController::class, 'list']);
+    });
 });
 

+ 0 - 5
modules/Channel/routes/route.php

@@ -62,11 +62,6 @@ Route::prefix('channel')->group(function () {
         Route::get('auth/{component_appid}/{user_id}', [WechatOpenPlatformController::class, 'auth'])->withoutMiddleware(config('catch.route.middlewares'));
         Route::get('preauth', [WechatOpenPlatformController::class, 'preauth'])->middleware(['roleCheck:company']);
     });
-
-
-    Route::prefix('companyUser')->group(function(){
-        Route::get('list', [CompanyUserController::class, 'list']);
-    });
 });
 
 /**

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

@@ -38,4 +38,5 @@ class Errors
     public const  OPENPLATFORM_COMPANY_INFO_NOT_EXISTS= [5000601, '公司没有对应的开放平台信息'];
     public const  OPENPLATFORM_OPTIMIZER_INFO_ERROR= [5000602, '优化师信息有误'];
     public const  WECHAT_CHECK_RECORD_NOT_EXISTS = [500305, '微信提审记录不存在'];
+    public const  CALLBACK_CHARGE_MONEY_MAP_ERROR = [500107, '金额项配置不合规'];
 }

+ 25 - 0
modules/Common/Repository/Options/JLEventCustomRate.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace Modules\Common\Repository\Options;
+
+use Modules\Callback\Services\JLEventService;
+
+/**
+ * 巨量2.0事件--金额项的卡比例选项
+ */
+class JLEventCustomRate implements OptionInterface
+{
+    public function get(): array
+    {
+        $list = JLEventService::listCustomCallBackRate();
+        $result = [];
+        foreach ($list as $value=>$label) {
+            $result[] = [
+                'label' => $label,
+                'value' => $value,
+            ];
+        }
+
+        return  $result;
+    }
+}

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

@@ -17,7 +17,8 @@ class PromotionController extends CatchController
     public function list(Request $request) {
         $callbackTypeMap = [
             '0' => '无',
-            '1' => '巨量账户级回传',
+            '1' => '头条-微信(账户级)',
+            '2' => '巨量2.0事件-微信小程序',
         ];
         $linkSourceMap = [
             '0' => '',
@@ -143,7 +144,7 @@ class PromotionController extends CatchController
     public function updateCallbackConfig(Request $request) {
         $this->validate($request, [
             'id' => 'required',
-            'callback_type' => 'required|in:1',
+            'callback_type' => 'required|in:1,2',
             'callback_config_id' => 'required',
             'remark' => 'nullable|string|max:140',
         ]);

+ 2 - 1
modules/User/Models/User.php

@@ -110,7 +110,8 @@ class User extends Model implements AuthenticatableContract
         $appModules = Modules::getAppModules();
         if(!is_null($appModules)) {
             $hiddenAppModuleNames = $appModules->reject(function ($module) use ($showApp) {
-                return $showApp == $module['name'];
+                $apps = explode(',', $showApp);
+                return in_array($module['name'], $apps);
             })->pluck('name');
         } else {
             $hiddenAppModuleNames = collect();

+ 71 - 0
tests/Callback/Http/Controllers/JLEvent/JLEventControllerTest.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace Tests\Callback\Http\Controllers\JLEvent;
+
+use Modules\Callback\Http\Controllers\JLEvent\JLEventController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class JLEventControllerTest extends UsedTestCase
+{
+
+    public function testAdd()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/callback/jlEvent/add', [
+            'name' => 'liuzj-test-'.rand(1, 100000),
+            'is_roi' => 2,
+            'charge_type' => 1,
+            'charge_money_map' => [
+                ['min_money' => 10, 'max_money' => 20, 'callback_type' => 3, 'callback_param' => '1:3'],
+                ['min_money' => 20, 'max_money' => 25, 'callback_type' => 2, 'callback_param' => ''],
+                ['min_money' => 25, 'max_money' => 30, 'callback_type' => 2, 'callback_param' => ''],
+            ]
+        ]);
+
+        $this->dumpJson($res);
+    }
+
+    public function testUpdate()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/callback/jlEvent/update', [
+            'ids' => [5, 6],
+            'name' => 'liuzj-test-'.rand(1, 100000),
+            'is_roi' => 1,
+            'charge_type' => 1,
+            'charge_money_map' => [
+                ['min_money' => 10, 'max_money' => 20, 'callback_type' => 1, 'callback_param' => ''],
+//                ['min_money' => 20, 'max_money' => 25, 'callback_type' => 2, 'callback_param' => ''],
+                ['min_money' => 25, 'max_money' => 30, 'callback_type' => 2, 'callback_param' => ''],
+                ['min_money' => 55, 'max_money' => 70, 'callback_type' => 3, 'callback_param' => '1:5'],
+            ]
+        ]);
+
+        $this->dumpJson($res);
+    }
+
+    public function testList()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/callback/jlEvent/list', [
+            'id' => 5,
+//            'name' => 'liuzj',
+//        'promotion_id' => 21
+        ]);
+
+        $this->dumpJson($res);
+    }
+    public function testlistCustomRate()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/callback/jlEvent/listCustomRate', [
+        ]);
+
+        $this->dumpJson($res);
+    }
+}

+ 31 - 0
tests/Callback/Services/JLEventServiceTest.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace Tests\Callback\Services;
+
+use Modules\Callback\Services\JLEventService;
+use PHPUnit\Framework\TestCase;
+
+class JLEventServiceTest extends \Tests\TestCase
+{
+
+    public function testJudgeChargeMoney()
+    {
+        $chargeMoneyMap = [
+            ['min_money' => 11, 'max_money' => 15],
+//            ['min_money' => 10, 'max_money' => 11],
+            ['min_money' => 15, 'max_money' => 16],
+            ['min_money' => 15, 'max_money' => 17],
+        ];
+        $res  = JLEventService::judgeChargeMoneyOk($chargeMoneyMap);
+        if($res) {
+            dump('check ok');
+        } else {
+            dump('check not ok');
+        }
+    }
+
+    public function testlistCustomCallBackRate() {
+        $res = JLEventService::listCustomCallBackRate();
+        dump(\json_encode($res, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
+    }
+}

+ 1 - 2
tests/Common/Http/Controllers/OptionControllerTest.php

@@ -13,8 +13,7 @@ class OptionControllerTest extends UsedTestCase
     {
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/options/CommonParams');
-        $res->dump();
+        ])->json('get','http://localhost/api/options/JLEventCustomRate');
         $this->dumpJson($res);
     }
 }

+ 3 - 3
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',
+//            'email' => 'xiaoli@qq.com',
             'password' => 'catchadmin',
-//            'email' => 'aa4@test.com',
+            'email' => 'aa4@test.com',
         ])->json();
         $this->token = $tokenInfo['data']['token'];
     }

+ 3 - 2
tests/User/Http/Controllers/UserControllerTest.php

@@ -36,7 +36,8 @@ class UserControllerTest extends \Tests\UsedTestCase
     public function testOnline() {
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/user/online');
-        $res->dump();
+        ])->json('get','http://localhost/api/user/online?app=k');
+
+        $this->dumpJson($res);
     }
 }