wanghousheng 10 months ago
parent ff075cd559
commit 2ccae36c19
  1. 14
      app/common/model/server/Order.php
  2. 35
      app/store/controller/Server.php
  3. 6
      app/store/model/server/Server.php

@ -3,6 +3,7 @@ declare (strict_types=1);
namespace app\common\model\server;
use app\common\enum\payment\Method;
use app\common\enum\ServerEnum;
use app\common\model\UploadFile;
use cores\BaseModel;
@ -24,12 +25,23 @@ class Order extends BaseModel
*/
protected $append = [
'order_status_text', // 订单状态文字描述
'pay_method_text', //支付方式
];
public function serve(): BelongsTo
{
return $this->belongsTo(Server::class, 'id', 'server_id');
return $this->belongsTo(Server::class, 'server_id', 'server_id');
}
public function getPayMethodTextAttr($value, $data): string
{
// 订单状态
$result = Method::data();
if (!empty($result[$data['pay_method']]['name'])) {
return $result[$data['pay_method']]['name'];
}
return '未知';
}
/**

@ -165,8 +165,7 @@ class Server extends Controller
*/
public function deleteServer(array $serverId): Json
{
$model = new ServerModel;
if ($model->remove($serverId)) {
if (ServerModel::destroy($serverId)) {
return $this->renderSuccess('删除成功');
}
return $this->renderError('删除失败');
@ -235,6 +234,22 @@ class Server extends Controller
return $this->renderSuccess($data);
}
/**
* @notes:订单详情
* @return Json
* @author: wanghousheng
*/
public function orderDetail(): Json
{
$orderId = intval($this->request->post('orderId'));
$data = \app\common\model\server\Order::detail(['order_id' => $orderId], ['user', 'dealer', 'image']);
$data['server_info'] = null;
if (!empty($data['server_id'])) {
$data['server_info'] = ServerModel::detail($data['server_id'], ['category']);
}
return $this->renderSuccess(['detail' => $data]);
}
/**
* @notes:订单状态
* @return Json
@ -297,16 +312,18 @@ class Server extends Controller
/**
* 服务配置
*/
public function configList() {
public function configList()
{
$model = new StoreServerConfig();
$list = $model->with(['iconImage'])->hidden(['iconImage'])->order(['sort'=>'desc','create_time'=>'desc'])->paginate(10);
$list = $model->with(['iconImage'])->hidden(['iconImage'])->order(['sort' => 'desc', 'create_time' => 'desc'])->paginate(10);
return $this->renderSuccess(compact('list'));
}
/**
* 服务配置添加
*/
public function configAdd() {
public function configAdd()
{
$model = new StoreServerConfig();
if ($model->save(array_merge(['store_id' => $this->storeId], $this->postForm()))) {
return $this->renderSuccess('新增成功');
@ -317,7 +334,8 @@ class Server extends Controller
/**
* 服务配置编辑
*/
public function configEdit(int $id) {
public function configEdit(int $id)
{
$detail = StoreServerConfig::get($id);
if ($detail) {
if ($detail->save($this->postForm())) {
@ -330,9 +348,10 @@ class Server extends Controller
/**
* 删除服务配置
*/
public function configDel(int $id) {
public function configDel(int $id)
{
$detail = StoreServerConfig::get($id);
if($detail->delete()) {
if ($detail->delete()) {
return $this->renderSuccess('删除成功');
}
return $this->renderError('删除失败');

@ -36,12 +36,12 @@ class Server extends ServerModel
/**
* @notes:删除
* @param array $serverId
* @return bool
* @author: wanghousheng
*/
public function remove(array $serverId): bool
public function remove(array $serverId)
{
return static::whereIn('server_id', $serverId)->delete();
return $this->whereIn('server_id', $serverId)->delete();
}
/**

Loading…
Cancel
Save