|
@@ -12,14 +12,14 @@ use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 配置
|
|
* 配置
|
|
|
-*/
|
|
|
|
|
-class ConfigService extends BaseService
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+class ConfigService extends BaseService
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
* @description: 模型
|
|
* @description: 模型
|
|
|
* @return {string}
|
|
* @return {string}
|
|
|
- */
|
|
|
|
|
- public static function model() :string
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function model(): string
|
|
|
{
|
|
{
|
|
|
return Config::class;
|
|
return Config::class;
|
|
|
}
|
|
}
|
|
@@ -27,8 +27,8 @@ class ConfigService extends BaseService
|
|
|
/**
|
|
/**
|
|
|
* @description: 枚举
|
|
* @description: 枚举
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
- */
|
|
|
|
|
- public static function enum() :string
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function enum(): string
|
|
|
{
|
|
{
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -37,25 +37,25 @@ class ConfigService extends BaseService
|
|
|
* @description: 获取查询条件
|
|
* @description: 获取查询条件
|
|
|
* @param {array} $search 查询内容
|
|
* @param {array} $search 查询内容
|
|
|
* @return {array}
|
|
* @return {array}
|
|
|
- */
|
|
|
|
|
- public static function getWhere(array $search = []) :array
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function getWhere(array $search = []): array
|
|
|
{
|
|
{
|
|
|
$where = [];
|
|
$where = [];
|
|
|
- if(isset($search['field']) && !empty($search['field'])){
|
|
|
|
|
|
|
+ if (isset($search['field']) && !empty($search['field'])) {
|
|
|
$where[] = ['field', '=', $search['field']];
|
|
$where[] = ['field', '=', $search['field']];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(isset($search['group_id']) && !empty($search['group_id'])){
|
|
|
|
|
|
|
+ if (isset($search['group_id']) && !empty($search['group_id'])) {
|
|
|
$where[] = ['group_id', '=', $search['group_id']];
|
|
$where[] = ['group_id', '=', $search['group_id']];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(isset($search['id']) && !empty($search['id'])){
|
|
|
|
|
|
|
+ if (isset($search['id']) && !empty($search['id'])) {
|
|
|
$where[] = ['id', '=', $search['id']];
|
|
$where[] = ['id', '=', $search['id']];
|
|
|
}
|
|
}
|
|
|
return $where;
|
|
return $where;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
|
|
+ /**
|
|
|
* @description: 查询单条数据
|
|
* @description: 查询单条数据
|
|
|
* @param array $search
|
|
* @param array $search
|
|
|
* @return \App\Models\Coin|null
|
|
* @return \App\Models\Coin|null
|
|
@@ -82,29 +82,30 @@ class ConfigService extends BaseService
|
|
|
*/
|
|
*/
|
|
|
public static function paginate(array $search = [])
|
|
public static function paginate(array $search = [])
|
|
|
{
|
|
{
|
|
|
- $limit = isset($search['limit'])?$search['limit']:15;
|
|
|
|
|
|
|
+ $limit = isset($search['limit']) ? $search['limit'] : 15;
|
|
|
$paginator = self::model()::where(self::getWhere($search))->paginate($limit);
|
|
$paginator = self::model()::where(self::getWhere($search))->paginate($limit);
|
|
|
return ['total' => $paginator->total(), 'data' => $paginator->items()];
|
|
return ['total' => $paginator->total(), 'data' => $paginator->items()];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @description:
|
|
|
|
|
|
|
+ * @description:
|
|
|
* @param {*} $params
|
|
* @param {*} $params
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
- */
|
|
|
|
|
|
|
+ */
|
|
|
public static function submit($params = [])
|
|
public static function submit($params = [])
|
|
|
{
|
|
{
|
|
|
$result = false;
|
|
$result = false;
|
|
|
$msg['code'] = self::NOT;
|
|
$msg['code'] = self::NOT;
|
|
|
$msg['msg'] = '';
|
|
$msg['msg'] = '';
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 2. 判断是否是更新
|
|
// 2. 判断是否是更新
|
|
|
if (!empty($params['id'])) {
|
|
if (!empty($params['id'])) {
|
|
|
// 更新
|
|
// 更新
|
|
|
- $info = self::findOne(['id'=>$params['id']] );
|
|
|
|
|
|
|
+ $info = self::findOne(['id' => $params['id']]);
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
|
$msg['msg'] = '配置不存在!';
|
|
$msg['msg'] = '配置不存在!';
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ unset($params['field']);
|
|
|
$result = $info->update($params);
|
|
$result = $info->update($params);
|
|
|
$id = $params['id'];
|
|
$id = $params['id'];
|
|
|
}
|
|
}
|
|
@@ -113,13 +114,13 @@ class ConfigService extends BaseService
|
|
|
$result = $info = self::model()::create($params);
|
|
$result = $info = self::model()::create($params);
|
|
|
$id = $result->id;
|
|
$id = $result->id;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if($result){
|
|
|
|
|
- $msg['code'] = self::YES;
|
|
|
|
|
- $msg['msg'] = '设置成功';
|
|
|
|
|
- }else{
|
|
|
|
|
- $msg['msg'] = empty($msg['msg']) ?'操作失败':$msg['msg'];
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if ($result) {
|
|
|
|
|
+ $msg['code'] = self::YES;
|
|
|
|
|
+ $msg['msg'] = '设置成功';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $msg['msg'] = empty($msg['msg']) ? '操作失败' : $msg['msg'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $msg;
|
|
return $msg;
|
|
@@ -138,7 +139,7 @@ class ConfigService extends BaseService
|
|
|
]));
|
|
]));
|
|
|
$result = json_decode($result, true);
|
|
$result = json_decode($result, true);
|
|
|
$rate = number_format($result['usd']['cnh'], 2);
|
|
$rate = number_format($result['usd']['cnh'], 2);
|
|
|
- $info = self::findOne(['field'=>'exchange_rate_rmb']);
|
|
|
|
|
|
|
+ $info = self::findOne(['field' => 'exchange_rate_rmb']);
|
|
|
$info->val = $rate;
|
|
$info->val = $rate;
|
|
|
$info->save();
|
|
$info->save();
|
|
|
return $result;
|
|
return $result;
|