瀏覽代碼

Weenier 168otc项目部署 0630

wesmiler 3 年之前
父節點
當前提交
a34a51dc93
共有 3 個文件被更改,包括 30 次插入4 次删除
  1. 1 0
      app/Helpers/common.php
  2. 25 0
      app/Helpers/function.php
  3. 4 4
      app/Http/Controllers/Api/TaskController.php

+ 1 - 0
app/Helpers/common.php

@@ -1134,6 +1134,7 @@ if (!function_exists('message')) {
     }
 }
 
+
 if (!function_exists('num2rmb')) {
 
     /**

+ 25 - 0
app/Helpers/function.php

@@ -179,3 +179,28 @@ if (!function_exists('formatTime')) {
         return date('Y-m-d', $interval);
     }
 }
+
+
+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);
+    }
+}

+ 4 - 4
app/Http/Controllers/Api/TaskController.php

@@ -26,7 +26,7 @@ class TaskController extends webApp
         $key = md5('OTC');
         $checkKey = request()->get('key');
         if($checkKey != $key){
-            return message(1003, false);
+            return showJson(1003, false);
         }
 
         $page = RedisService::get("caches:wallet:catchPage");
@@ -35,7 +35,7 @@ class TaskController extends webApp
         $members = MemberService::make()->getCatchMember($page, 500);
         if(empty($members)){
             RedisService::set("caches:wallet:catchPage", 1, 600);
-            return message(1019, false);
+            return showJson(1019, false);
         }
 
         $count = 0;
@@ -54,9 +54,9 @@ class TaskController extends webApp
 
         RedisService::set("caches:wallet:catchPage", $page+1, 600);
         if($count>0){
-            return message(1020, true,['success'=> $count,'fail'=> $failedCount]);
+            return showJson(1020, true,['success'=> $count,'fail'=> $failedCount]);
         }else{
-            return message(1021, false);
+            return showJson(1021, false);
         }
     }