优化页面和模型
This commit is contained in:
@@ -8,13 +8,13 @@ use support\Response;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
* PlayX 领取记录(后台列表)
|
||||
* 领取记录(后台列表)
|
||||
*/
|
||||
class PlayxClaimLog extends Backend
|
||||
class ClaimLog extends Backend
|
||||
{
|
||||
/**
|
||||
* @var object|null
|
||||
* @phpstan-var \app\common\model\MallPlayxClaimLog|null
|
||||
* @phpstan-var \app\common\model\MallClaimLog|null
|
||||
*/
|
||||
protected ?object $model = null;
|
||||
|
||||
@@ -33,7 +33,7 @@ class PlayxClaimLog extends Backend
|
||||
public function initialize(): void
|
||||
{
|
||||
parent::initialize();
|
||||
$this->model = new \app\common\model\MallPlayxClaimLog();
|
||||
$this->model = new \app\common\model\MallClaimLog();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8,13 +8,13 @@ use support\Response;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
* PlayX 每日推送数据(后台列表)
|
||||
* 每日推送数据(后台列表)
|
||||
*/
|
||||
class PlayxDailyPush extends Backend
|
||||
class DailyPush extends Backend
|
||||
{
|
||||
/**
|
||||
* @var object|null
|
||||
* @phpstan-var \app\common\model\MallPlayxDailyPush|null
|
||||
* @phpstan-var \app\common\model\MallDailyPush|null
|
||||
*/
|
||||
protected ?object $model = null;
|
||||
|
||||
@@ -37,7 +37,7 @@ class PlayxDailyPush extends Backend
|
||||
public function initialize(): void
|
||||
{
|
||||
parent::initialize();
|
||||
$this->model = new \app\common\model\MallPlayxDailyPush();
|
||||
$this->model = new \app\common\model\MallDailyPush();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4,20 +4,20 @@ namespace app\admin\controller\mall;
|
||||
|
||||
use Throwable;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\model\MallPlayxOrder;
|
||||
use app\common\model\MallPlayxUserAsset;
|
||||
use app\common\model\MallOrder;
|
||||
use app\common\model\MallUserAsset;
|
||||
use support\think\Db;
|
||||
use support\Response;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
* PlayX 统一订单(后台列表)
|
||||
* 统一订单(后台列表)
|
||||
*/
|
||||
class PlayxOrder extends Backend
|
||||
class Order extends Backend
|
||||
{
|
||||
/**
|
||||
* @var object|null
|
||||
* @phpstan-var \app\common\model\MallPlayxOrder|null
|
||||
* @phpstan-var \app\common\model\MallOrder|null
|
||||
*/
|
||||
protected ?object $model = null;
|
||||
|
||||
@@ -53,7 +53,7 @@ class PlayxOrder extends Backend
|
||||
public function initialize(): void
|
||||
{
|
||||
parent::initialize();
|
||||
$this->model = new \app\common\model\MallPlayxOrder();
|
||||
$this->model = new \app\common\model\MallOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ class PlayxOrder extends Backend
|
||||
return $this->select($request);
|
||||
}
|
||||
|
||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||||
[$where, $alias, $limit, $order] = $this->queryBuilder();
|
||||
$res = $this->model
|
||||
->with(['mallItem' => function ($query) {
|
||||
$query->field('id,title');
|
||||
@@ -104,22 +104,22 @@ class PlayxOrder extends Backend
|
||||
}
|
||||
|
||||
$data = $request->post();
|
||||
$id = intval($data['id'] ?? 0);
|
||||
$shippingCompany = strval($data['shipping_company'] ?? '');
|
||||
$shippingNo = strval($data['shipping_no'] ?? '');
|
||||
$id = $data['id'] ?? 0;
|
||||
$shippingCompany = $data['shipping_company'] ?? '';
|
||||
$shippingNo = $data['shipping_no'] ?? '';
|
||||
|
||||
if ($id <= 0 || $shippingCompany === '' || $shippingNo === '') {
|
||||
if (!$id || $shippingCompany === '' || $shippingNo === '') {
|
||||
return $this->error(__('Missing required fields'));
|
||||
}
|
||||
|
||||
$order = MallPlayxOrder::where('id', $id)->find();
|
||||
$order = MallOrder::where('id', $id)->find();
|
||||
if (!$order) {
|
||||
return $this->error(__('Record not found'));
|
||||
}
|
||||
if ($order->type !== MallPlayxOrder::TYPE_PHYSICAL) {
|
||||
if ($order->type !== MallOrder::TYPE_PHYSICAL) {
|
||||
return $this->error(__('Order type not PHYSICAL'));
|
||||
}
|
||||
if ($order->status !== MallPlayxOrder::STATUS_PENDING) {
|
||||
if ($order->status !== MallOrder::STATUS_PENDING) {
|
||||
return $this->error(__('Order status must be PENDING'));
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class PlayxOrder extends Backend
|
||||
try {
|
||||
$order->shipping_company = $shippingCompany;
|
||||
$order->shipping_no = $shippingNo;
|
||||
$order->status = MallPlayxOrder::STATUS_SHIPPED;
|
||||
$order->status = MallOrder::STATUS_SHIPPED;
|
||||
$order->save();
|
||||
Db::commit();
|
||||
} catch (Throwable $e) {
|
||||
@@ -153,40 +153,40 @@ class PlayxOrder extends Backend
|
||||
}
|
||||
|
||||
$data = $request->post();
|
||||
$id = intval($data['id'] ?? 0);
|
||||
$rejectReason = strval($data['reject_reason'] ?? '');
|
||||
$id = $data['id'] ?? 0;
|
||||
$rejectReason = $data['reject_reason'] ?? '';
|
||||
|
||||
if ($id <= 0 || $rejectReason === '') {
|
||||
if (!$id || $rejectReason === '') {
|
||||
return $this->error(__('Missing required fields'));
|
||||
}
|
||||
|
||||
$order = MallPlayxOrder::where('id', $id)->find();
|
||||
$order = MallOrder::where('id', $id)->find();
|
||||
if (!$order) {
|
||||
return $this->error(__('Record not found'));
|
||||
}
|
||||
if ($order->type !== MallPlayxOrder::TYPE_PHYSICAL) {
|
||||
if ($order->type !== MallOrder::TYPE_PHYSICAL) {
|
||||
return $this->error(__('Order type not PHYSICAL'));
|
||||
}
|
||||
if ($order->status !== MallPlayxOrder::STATUS_PENDING) {
|
||||
if ($order->status !== MallOrder::STATUS_PENDING) {
|
||||
return $this->error(__('Order status must be PENDING'));
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$asset = MallPlayxUserAsset::where('playx_user_id', strval($order->user_id ?? ''))->find();
|
||||
$asset = MallUserAsset::where('playx_user_id', $order->user_id ?? '')->find();
|
||||
if (!$asset) {
|
||||
throw new \RuntimeException('User asset not found');
|
||||
}
|
||||
|
||||
$refund = intval($order->points_cost ?? 0);
|
||||
$refund = $order->points_cost ?? 0;
|
||||
if ($refund > 0) {
|
||||
$asset->available_points += $refund;
|
||||
$asset->save();
|
||||
}
|
||||
|
||||
$order->status = MallPlayxOrder::STATUS_REJECTED;
|
||||
$order->status = MallOrder::STATUS_REJECTED;
|
||||
$order->reject_reason = $rejectReason;
|
||||
$order->grant_status = MallPlayxOrder::GRANT_FAILED_FINAL;
|
||||
$order->grant_status = MallOrder::GRANT_FAILED_FINAL;
|
||||
$order->save();
|
||||
|
||||
Db::commit();
|
||||
@@ -212,26 +212,26 @@ class PlayxOrder extends Backend
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
|
||||
$id = intval($request->post('id', 0));
|
||||
if ($id <= 0) {
|
||||
$id = $request->post('id', 0);
|
||||
if (!$id) {
|
||||
return $this->error(__('Missing required fields'));
|
||||
}
|
||||
|
||||
$order = MallPlayxOrder::where('id', $id)->find();
|
||||
$order = MallOrder::where('id', $id)->find();
|
||||
if (!$order) {
|
||||
return $this->error(__('Record not found'));
|
||||
}
|
||||
if (!in_array($order->type, [MallPlayxOrder::TYPE_BONUS, MallPlayxOrder::TYPE_WITHDRAW], true)) {
|
||||
if (!in_array($order->type, [MallOrder::TYPE_BONUS, MallOrder::TYPE_WITHDRAW], true)) {
|
||||
return $this->error(__('Only BONUS/WITHDRAW can retry'));
|
||||
}
|
||||
if ($order->grant_status !== MallPlayxOrder::GRANT_FAILED_RETRYABLE) {
|
||||
if ($order->grant_status !== MallOrder::GRANT_FAILED_RETRYABLE) {
|
||||
return $this->error(__('Only FAILED_RETRYABLE can retry'));
|
||||
}
|
||||
if (intval($order->retry_count) >= 3) {
|
||||
if (($order->retry_count ?? 0) >= 3) {
|
||||
return $this->error(__('Retry count exceeded'));
|
||||
}
|
||||
|
||||
$order->grant_status = MallPlayxOrder::GRANT_NOT_SENT;
|
||||
$order->grant_status = MallOrder::GRANT_NOT_SENT;
|
||||
$order->save();
|
||||
|
||||
return $this->success(__('Retry queued'));
|
||||
@@ -7,13 +7,13 @@ use support\Response;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
* PlayX 用户资产(后台列表)
|
||||
* 用户资产(后台列表)
|
||||
*/
|
||||
class PlayxUserAsset extends Backend
|
||||
class UserAsset extends Backend
|
||||
{
|
||||
/**
|
||||
* @var object|null
|
||||
* @phpstan-var \app\common\model\MallPlayxUserAsset|null
|
||||
* @phpstan-var \app\common\model\MallUserAsset|null
|
||||
*/
|
||||
protected ?object $model = null;
|
||||
|
||||
@@ -42,7 +42,7 @@ class PlayxUserAsset extends Backend
|
||||
public function initialize(): void
|
||||
{
|
||||
parent::initialize();
|
||||
$this->model = new \app\common\model\MallPlayxUserAsset();
|
||||
$this->model = new \app\common\model\MallUserAsset();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ class PlayxUserAsset extends Backend
|
||||
return $response;
|
||||
}
|
||||
|
||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||||
[$where, $alias, $limit, $order] = $this->queryBuilder();
|
||||
$res = $this->model
|
||||
->field('id,username')
|
||||
->alias($alias)
|
||||
@@ -67,8 +67,8 @@ class PlayxUserAsset extends Backend
|
||||
foreach ($res->items() as $row) {
|
||||
$arr = $row->toArray();
|
||||
$list[] = [
|
||||
'id' => intval($arr['id'] ?? 0),
|
||||
'username' => strval($arr['username'] ?? ''),
|
||||
'id' => $arr['id'] ?? 0,
|
||||
'username' => $arr['username'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -79,3 +79,4 @@ class PlayxUserAsset extends Backend
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user