新增统计,小游戏,系统设置
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\admin\controller\user;
|
||||
|
||||
use app\admin\model\PromoReward;
|
||||
use app\common\service\Jk8Services;
|
||||
use Throwable;
|
||||
use app\common\controller\Backend;
|
||||
@@ -100,7 +101,10 @@ class User extends Backend
|
||||
} catch (Throwable $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
if (!empty($data['referrer_code'])) {
|
||||
$parentId = $this->model->where('jk_username', $data['referrer_code'])->value('id');
|
||||
$data['parent_id'] = $parentId;
|
||||
}
|
||||
$this->model->startTrans();
|
||||
try {
|
||||
$data['jk_user_id'] = $jkId;
|
||||
@@ -226,4 +230,96 @@ class User extends Backend
|
||||
$this->success('', $data);
|
||||
}
|
||||
|
||||
public function submittedReward()
|
||||
{
|
||||
$games = config('mini_game') ?: [];
|
||||
$rawStart = request()->param('start/s');
|
||||
$start = $rawStart ? strtotime($rawStart) : strtotime('today');
|
||||
$rawEnd = request()->param('end/s');
|
||||
$end = $rawEnd ? strtotime("$rawEnd +1 day") : strtotime('tomorrow');
|
||||
$status = $this->request->param('status');
|
||||
$username = $this->request->param('username');
|
||||
$gameId = $this->request->param('game_id');
|
||||
$limit = request()->param('limit/d') ?? 15;
|
||||
$where = [];
|
||||
if ($start > $end) {
|
||||
list($start, $end) = [$end, $start];
|
||||
}
|
||||
if (!empty($gameId)) {
|
||||
$where[] = ['game_type', '=', $gameId];
|
||||
}
|
||||
|
||||
if (!empty($status)) {
|
||||
$where[] = ['status', '=', $status];
|
||||
}
|
||||
|
||||
$query = PromoReward::with(['user']);
|
||||
|
||||
if (!empty($username)) {
|
||||
$has = UserModel::where('jk_username', 'LIKE', '%'. $username . '%');
|
||||
$query->hasWhere('user', $has);
|
||||
}
|
||||
|
||||
$list = $query->where($where)
|
||||
->whereBetweenTime('create_time', $start, $end)->order('create_time', 'desc')->paginate($limit);
|
||||
|
||||
$list->each(function($item) use ($games) {
|
||||
$item->submitted_time = date('Y-m-d H:i:s', $item->update_time);
|
||||
$item->username = $item->user->jk_username ?? 'Unknown';
|
||||
$gameName = $games[$item->game_type] ?? 'Game';
|
||||
$item->reward_claim = $gameName . ' AUD' . $item->amount;
|
||||
|
||||
if ($item->status == 1) {
|
||||
$item->status_text = 'Approve Reward (by JDK API (Manual))';
|
||||
} elseif ($item->status == 2){
|
||||
$item->status_text = 'Reject Reward';
|
||||
} else {
|
||||
$item->status_text = 'In process';
|
||||
}
|
||||
unset($item->user);
|
||||
});
|
||||
$this->success('', [
|
||||
'game_id' => $gameId,
|
||||
'games' => $games,
|
||||
'list' => $list
|
||||
]);
|
||||
}
|
||||
public function editReward()
|
||||
{
|
||||
$pk = $this->model->getPk();
|
||||
$id = $this->request->param($pk);
|
||||
$promoReward = new PromoReward();
|
||||
$row = $promoReward->find($id);
|
||||
if (!$row) {
|
||||
$this->error(__('Record not found'));
|
||||
}
|
||||
|
||||
$status = $this->request->post('status');
|
||||
|
||||
if (!$status || !in_array($status, [1, 2])) {
|
||||
$this->error(__('Parameter %s can not be empty', ['']));
|
||||
}
|
||||
|
||||
$result = false;
|
||||
$promoReward->startTrans();
|
||||
try {
|
||||
if ($status == 1) {
|
||||
$user = UserModel::find($row['user_id']);
|
||||
$this->jk8Services->setScore($user['jk_username'], $row['amount']);
|
||||
}
|
||||
$result = $row->save([
|
||||
'status' => (int)$status,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
$promoReward->commit();
|
||||
} catch (Throwable $e) {
|
||||
$promoReward->rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result !== false) {
|
||||
$this->success(__('Update successful'));
|
||||
} else {
|
||||
$this->error(__('No rows updated'));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user