Commit 275ee02a authored by zhoujun's avatar zhoujun

货币查询

parent 96ce4dc9
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Throwable;
use Exception;
use Carbon\Carbon;
use Illuminate\Validation\Rule;
use App\Services\Account\IAccountService;
class AccountController extends BaseController
{
private $time;
private $accountService;
public function __construct(IAccountService $accountService)
{
$this->time = Carbon::now()->format('Y-m-d H:i:s');
$this->accountService = $accountService;
}
/**
* 平台列表
* @return array
* @date 2021/07/30
* @author live
*/
public function getPlatformList(Request $request)
{
$postData = $request->all();
try {
$data = $this->accountService->getPlatformList($postData);
return $this->getSuccessMsg($data);
} catch (Exception $e) {
return $this->getErrorMsg($e->getCode(), $e->getMessage());
}
}
/**
* 渠道列表
* @return array
* @date 2021/07/30
* @author live
*/
public function getChannelList(Request $request)
{
$postData = $request->all();
try {
$data = $this->accountService->getChannelList($postData);
return $this->getSuccessMsg($data);
} catch (Exception $e) {
return $this->getErrorMsg($e->getCode(), $e->getMessage());
}
}
/**
* 货币类型列表
* @return array
* @date 2021/07/30
* @author live
*/
public function getCurrencyList(Request $request)
{
$postData = $request->all();
try {
$data = $this->accountService->getCurrencyList($postData);
return $this->getSuccessMsg($data);
} catch (Exception $e) {
return $this->getErrorMsg($e->getCode(), $e->getMessage());
}
}
/**
* 货币列表
* @return array
* @date 2021/07/30
* @author live
*/
public function getAccountLog(Request $request)
{
$postData = $request->all();
try {
$data = $this->accountService->getAccountLog($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;
class SyceeLogModel extends BaseModel
{
public $timestamps = false;
protected $connection = 'mysql';
protected $table = 'sycee_log';
const CREATE_ROLE = 1; // 创建角色
const WATCH_ADVERT = 2; // 观看广告
const WITHDRAWAL = 3; // 提现
public static $source = [
self::CREATE_ROLE => '创建角色',
self::WATCH_ADVERT => '观看广告',
self::WITHDRAWAL => '提现元宝',
];
}
......@@ -15,6 +15,7 @@ class AppServiceProvider extends ServiceProvider
{
$this->app->bind('App\Services\User\IUserService', 'App\Services\User\UserService');
$this->app->bind('App\Services\White\IWhiteService', 'App\Services\White\WhiteService');
$this->app->bind('App\Services\Account\IAccountService', 'App\Services\Account\AccountService');
}
/**
......
<?php
namespace App\Services\Account;
use App\Services\Account\IAccountService;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use App\Models\SyceeLogModel;
use App\Models\AccountModel;
use Illuminate\Support\Facades\Cache;
class AccountService implements IAccountService
{
private $time;
public function __construct()
{
$this->time = Carbon::now()->format('Y-m-d H:i:s');
}
/**
* 平台列表
* @return araay
* @date 2021/07/30
* @author live
*/
public function getPlatformList($postData)
{
$array = ['0'=>'请选择'];
foreach(config(env('ENVIRONMENT') . '.PLATFORM') as $key=>$val) $array[$key] = $val;
return $array;
}
/**
* 渠道列表
* @return araay
* @date 2021/07/30
* @author live
*/
public function getChannelList($postData)
{
$array = ['0'=>'请选择'];
foreach(config(env('ENVIRONMENT') . '.CHANNEL') as $key=>$val) $array[$key] = $val;
return $array;
}
/**
* 货币类型列表
* @return araay
* @date 2021/07/30
* @author live
*/
public function getCurrencyList($postData)
{
$array = ['0'=>'请选择'];
foreach(config(env('ENVIRONMENT') . '.CURRENCY') as $key=>$val) $array[$key] = $val;
return $array;
}
/**
* 货币查询
* @return araay
* @date 2021/07/30
* @author live
*/
public function getAccountLog($postData)
{
$pagePerNum = $postData['pageSize'] ?? 20;
$currentPage = $postData['page'] ?? 1;
$start = $postData['startTime'] ?? '';
$end = $postData['endTime'] ?? '';
$platform = $postData['platform'] ?? 0;
$channel = $postData['channel'] ?? 0;
$logType = $postData['logType'] ?? 0;
$type = $postData['type'] ?? 0;
$uid = $postData['uid'] ?? '';
if($uid == '') return [];
$account = AccountModel::where(function ($query) use ($uid) {
return $query->where('user_id',$uid)->orWhere('platform_id',$uid);
})->when($platform > 0, function ($query) use ($platform) {
return $query->where('platform', $platform);
})->when($channel > 0, function ($query) use ($channel) {
return $query->where('channel', $channel);
})->select('user_id','sycee','platform','platform_id','channel')->first();
if(!$account) return [];
$array = [];
$logs = SyceeLogModel::where('user_id',$account->user_id)->when($start != '', function ($query) use ($start) {
$startTime = date('Y-m-d H:i:s',strtotime($start) - 1);
return $query->where('log_time', '>',$startTime);
})->when($end != '', function ($query) use ($end) {
$endTime = date('Y-m-d H:i:s',strtotime($end) + 1);
return $query->where('log_time', '<',$endTime);
})->when($logType > 0, function ($query) use ($logType) {
if($logType == 1) return $query->whereIn('op_code',[1,2]);
if($logType == 2) return $query->where('op_code',3);
})->select('id','op_code','sycee','sycee_pool','sycee_balance','sycee_pool_balance','log_time','extra')->orderBy('id','DESC')->paginate($pagePerNum, ['*'], 'currentPage',$currentPage);
$array['totalNum'] = $logs->total();
$array['totalPage'] = $logs->lastPage();
$platformArr = config(env('ENVIRONMENT') . '.PLATFORM');
$channelArr = config(env('ENVIRONMENT') . '.CHANNEL');
$sourceArr = SyceeLogModel::$source;
foreach($logs as $log){
$tem['uid'] = $account->platform_id;
$tem['openId'] = $account->user_id;
$tem['platformName'] = $platformArr[$account->platform] ?? '';
$tem['channelName'] = $channelArr[$account->channel] ?? '';
if($log->op_code == 3){
$tem['typeName'] = '消耗';
}else{
$tem['typeName'] = '产出';
}
$tem['beforeNum'] = $log->sycee_balance - $log->sycee;
$tem['optionNum'] = $log->sycee;
$tem['afterNum'] = $log->sycee_balance;
$tem['source'] = $sourceArr[$log->op_code];
$tem['logTime'] = $log->log_time;
$tem['remark'] = $log->extra;
$array['data'][] = $tem;
}
unset($users,$user,$user);
return $array;
}
}
\ No newline at end of file
<?php
namespace App\Services\Account;
interface IAccountService
{
public function getPlatformList($postData); //平台列表
public function getChannelList($postData);//渠道列表
public function getCurrencyList($postData);//货币类型列表
public function getAccountLog($postData); //货币查询
}
\ No newline at end of file
<?php
return [
'PAGE_NUM' => 20,
'PLATFORM' => [
'1009' => '安卓-橙橙'
],
'CHANNEL' => [
'1024' => '微信小程序渠道'
],
'CURRENCY' => [
'1' => '元宝'
],
];
\ No newline at end of file
<?php
return [
'PAGE_NUM' => 20,
'PLATFORM' => [
'1009' => '安卓-橙橙'
],
'CHANNEL' => [
'1024' => '微信小程序渠道'
],
'CURRENCY' => [
'1' => '元宝'
],
];
\ No newline at end of file
......@@ -38,5 +38,13 @@ Route::group(['namespace' => 'Api','middleware' => ['user.login']], function ()
Route::post('/set/status','WhiteController@getSetStatus');//设置白名单状态
});
Route::group(['prefix' => 'account'],function() {
Route::post('/platform/list','AccountController@getPlatformList');//平台列表
Route::post('/channel/list','AccountController@getChannelList');//渠道列表
Route::post('/currency/list','AccountController@getCurrencyList');//货币种类列表
Route::post('/log','AccountController@getAccountLog');//货币查询
});
});
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