APPLE 3 лет назад
Родитель
Сommit
1edd14b482
2 измененных файлов с 26 добавлено и 2 удалено
  1. 24 0
      app/Helpers/common.php
  2. 2 2
      app/Http/Controllers/Api/v1/TaskController.php

+ 24 - 0
app/Helpers/common.php

@@ -1110,6 +1110,30 @@ if (!function_exists('message')) {
     }
 }
 
+if (!function_exists('showJson')) {
+
+    /**
+     * 消息JSON
+     * @param string $msg 提示文字
+     * @param bool $success 是否成功true或false
+     * @param array $data 结果数据
+     * @param int $code 编码
+     * @return array 返回结果
+     * @author laravel开发员
+     * @date 2019/5/28
+     */
+    function showJson($msg = "1002", $success = true, $data = [], $code = 0)
+    {
+        $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data];
+        if ($success) {
+            $result['code'] = 0;
+        } else {
+            $result['code'] = $code ? $code : -1;
+        }
+        return json_encode($result, 256);
+    }
+}
+
 if (!function_exists('num2rmb')) {
 
     /**

+ 2 - 2
app/Http/Controllers/Api/v1/TaskController.php

@@ -17,10 +17,10 @@ class TaskController extends webApp
     {
         $key = request()->get('key');
         if($key != md5('clearTrade')){
-            return message(1006, false);
+            return showJson(1006, false);
         }
 
         $datas = TradeService::make()->clearByDay();
-        return message(1002, true, $datas);
+        return showJson(1002, true, $datas);
     }
 }