pull/1/head
wanghousheng 1 year ago
parent c347eb99ed
commit 3a1ef25c24
  1. 4
      app/api/controller/Server.php
  2. 15
      app/api/service/Identity.php
  3. 8
      app/common/model/User.php

@ -47,8 +47,8 @@ class Server extends Controller
{
$server_name = $this->request->post('server_name');
$category_id = intval($this->request->post('category_id'));
$order_field = $this->request->post('order_field');
$order_sort = $this->request->post('order_sort', 'desc');
$order_field = (string)$this->request->post('order_field');
$order_sort = (string)$this->request->post('order_sort', 'desc');
$where = [];
if ($server_name) {
$where[] = ['server.server_name', 'like', "%$server_name%"];

@ -82,23 +82,12 @@ class Identity extends BaseService
private function cheapPrice($data)
{
$one_data = [];
foreach ($data as $value) {
if ($value['month'] == 1) {
$one_data = $value;
break;
}
}
$one_data = $data[0];
foreach ($data as $key => $value) {
$data[$key]['cheap_price'] = 0;
if (!empty($one_data)) {
if ($value['month'] > 1) {
$price = $value['month'] * $one_data['price'];
$data[$key]['cheap_price'] = $price - $value['price'];
}
} else {
if ($key > 0) {
$price = $value['month'] * $data[$key - 1]['price'];
$price = $value['month'] * $one_data['price'];
$data[$key]['cheap_price'] = $price - $value['price'];
}
}

@ -52,9 +52,11 @@ class User extends BaseModel
public function getUserTypeTextAttr($value, $data): string
{
// 身份
$result = UserTypeEnum::data();
if (!empty($result[$data['user_type']]['name'])) {
return $result[$data['user_type']]['name'];
if (!empty($data['user_type'])) {
$result = UserTypeEnum::data();
if (!empty($result[$data['user_type']]['name'])) {
return $result[$data['user_type']]['name'];
}
}
return '未知';
}

Loading…
Cancel
Save