Commit 95564d73 authored by zhoujun's avatar zhoujun

预警接口

parent ac66175f
Pipeline #2072 passed with stage
in 0 seconds
......@@ -267,5 +267,22 @@ class WarnController extends BaseController
}
}
/**
* 预警日志
* @return array
* @date 2021/07/31
* @author live
*/
public function getWarnLog(Request $request)
{
$postData = $request->all();
try {
$data = $this->warnService->getWarnLog($postData);
return $this->getSuccessMsg($data);
} catch (Exception $e) {
return $this->getErrorMsg($e->getCode(), $e->getMessage());
}
}
}
\ No newline at end of file
<?php
namespace App\Models;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class WarnLogModel extends BaseModel
{
use SoftDeletes;
protected $connection = 'mysql';
protected $table = 'club_warn_log';
}
......@@ -24,4 +24,6 @@ interface IWarnService
public function getConfigSetStatus($postData); //设置预警配置状态
public function getConfigSetAllStatus($postData); //批量设置预警状态
public function getWarnLog($postData); //预警日志
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use App\Models\WarnPeopleModel;
use App\Models\WarnConfigModel;
use App\Models\WarnLogModel;
use Illuminate\Support\Facades\Cache;
class WarnService implements IWarnService
......@@ -79,7 +80,9 @@ class WarnService implements IWarnService
foreach ($lists as $list) {
$tem['id'] = $list->id;
$tem['platform'] = $platformArr[$list->platform] ?? '';
$tem['platformId'] = $list->platform;
$tem['channel'] = $channelArr[$list->channel] ?? '';
$tem['channelId'] = $list->channel;
$tem['name'] = $list->name;
$tem['phone'] = $list->phone;
$tem['status'] = $list->status;
......@@ -204,8 +207,11 @@ class WarnService implements IWarnService
foreach ($lists as $list) {
$tem['id'] = $list->id;
$tem['platform'] = $platformArr[$list->platform] ?? '';
$tem['platformId'] = $list->platform;
$tem['channel'] = $channelArr[$list->channel] ?? '';
$tem['channelId'] = $list->channel;
$tem['type'] = $typeArr[$list->type] ?? '';
$tem['typeId'] = $list->type;
$tem['oneWithdrawal'] = sprintf('%.2f',$list->one_withdrawal / 100);
$tem['dayWithdrawal'] = sprintf('%.2f',$list->day_withdrawal / 100);
$tem['userDayWithdrawal'] = sprintf('%.2f',$list->people_day_withdrawal / 100);
......@@ -311,4 +317,56 @@ class WarnService implements IWarnService
$array['msg'] = '总共操作'.$total.'条数据,其中成功'.$succuss.'条,失败'.$fail.'条';
return $array;
}
/**
* 预警日志
* @return araay
* @date 2021/07/31
* @author live
*/
public function getWarnLog($postData)
{
$start = $postData['startTime'] ?? '';
$end = $postData['endTime'] ?? '';
$platform = $postData['platform'] ?? 0;
$id = $postData['id'] ?? 0;
$pagePerNum = $postData['pageSize'] ?? 20;
$currentPage = $postData['page'] ?? 1;
$lists = WarnConfigModel::when($id > 0, function ($query) use ($id) {
return $query->where('id',$id);
})->when($platform > 0, function ($query) use ($platform) {
return $query->where('platform',$platform);
})->when($start > 0, function ($query) use ($start) {
$startTime = date('Y-m-d H:i:s',strtotime($start) - 1);
return $query->where('send_time','>',$startTime);
})->when($end > 0, function ($query) use ($end) {
$endTime = date('Y-m-d H:i:s',strtotime($end) + 1);
return $query->where('send_time','<',$endTime);
})->select('id','platform','channel','cash','status','config_id','people_id','msg','remark','send_time','created_at')->orderBy('id', 'DESC')->paginate($pagePerNum, ['*'], 'currentPage', $currentPage);
$array['totalNum'] = $lists->total();
$array['totalPage'] = $lists->lastPage();
$platformArr = config(env('ENVIRONMENT') . '.PLATFORM');
$channelArr = config(env('ENVIRONMENT') . '.CHANNEL');
$typeArr = config(env('ENVIRONMENT') . '.CURRENCY');
foreach ($lists as $list) {
$tem['id'] = $list->id;
$tem['platform'] = $platformArr[$list->platform] ?? '';
$tem['channel'] = $channelArr[$list->channel] ?? '';
$tem['type'] = $typeArr[$list->type] ?? '';
$tem['oneWithdrawal'] = sprintf('%.2f',$list->one_withdrawal / 100);
$tem['dayWithdrawal'] = sprintf('%.2f',$list->day_withdrawal / 100);
$tem['userDayWithdrawal'] = sprintf('%.2f',$list->people_day_withdrawal / 100);
$tem['status'] = $list->status;
$statusName = '停用';
if($list->status == 1) $statusName = '正常';
$tem['statusName'] = $statusName;
$tem['optionUser'] = $list->op_user;
$tem['createdAt'] = Carbon::parse($list->created_at)->format('Y-m-d H:i:s');
$array['data'][] = $tem;
}
unset($lists, $list);
return $array;
}
}
\ No newline at end of file
......@@ -51,6 +51,8 @@ Route::group(['namespace' => 'Api','middleware' => ['user.login']], function ()
Route::post('/config/del','WarnController@getConfigDel');//删除预警配置
Route::post('/config/set/status','WarnController@getConfigSetStatus');//设置预警配置状态
Route::post('/config/set/all/status','WarnController@getConfigSetAllStatus');//批量设置预警配置状态
Route::post('/log','WarnController@getWarnLog');//预警日志
});
Route::group(['prefix' => 'account'],function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment