瀏覽代碼

Merge branch 'master' of http://git.derkj.com:9095/waibao/NN2025112501

# Conflicts:
#	app/Models/ComplaintModel.php
罗永浩 5 月之前
父節點
當前提交
e3aac1fd06
共有 44 個文件被更改,包括 2674 次插入1073 次删除
  1. 16 0
      .dockerignore
  2. 0 94
      .env
  3. 6 23
      .gitignore
  4. 二進制
      addons/admin/public/favicon.ico
  5. 二進制
      addons/admin/public/icon.png
  6. 21 3
      app/Helpers/common.php
  7. 3 1
      app/Http/Controllers/Admin/IndexController.php
  8. 1 1
      app/Http/Controllers/Admin/RoleController.php
  9. 1 1
      app/Http/Controllers/Api/UploadController.php
  10. 115 0
      app/Http/Controllers/Api/v1/AddressController.php
  11. 73 0
      app/Http/Controllers/Api/v1/AgentController.php
  12. 115 0
      app/Http/Controllers/Api/v1/CartController.php
  13. 33 0
      app/Http/Controllers/Api/v1/ComplaintController.php
  14. 12 12
      app/Http/Controllers/Api/v1/GoodsController.php
  15. 18 31
      app/Http/Controllers/Api/v1/IndexController.php
  16. 28 0
      app/Http/Controllers/Api/v1/LoginController.php
  17. 12 34
      app/Http/Controllers/Api/v1/MemberController.php
  18. 11 0
      app/Http/Controllers/Api/v1/OrderController.php
  19. 135 0
      app/Http/Controllers/Api/v1/StoreController.php
  20. 56 0
      app/Http/Validator/AddressValidator.php
  21. 47 0
      app/Http/Validator/AgentValidator.php
  22. 2 11
      app/Http/Validator/MemberValidator.php
  23. 55 0
      app/Http/Validator/StoreValidator.php
  24. 61 0
      app/Models/CartModel.php
  25. 7 1
      app/Models/ComplaintModel.php
  26. 12 59
      app/Models/GoodsModel.php
  27. 32 0
      app/Models/MemberAddressModel.php
  28. 10 32
      app/Models/MemberModel.php
  29. 34 2
      app/Models/StoreModel.php
  30. 153 0
      app/Services/Api/AgentService.php
  31. 263 0
      app/Services/Api/CartService.php
  32. 61 65
      app/Services/Api/ComplaintService.php
  33. 0 464
      app/Services/Api/DepositService.php
  34. 44 71
      app/Services/Api/GoodsService.php
  35. 284 0
      app/Services/Api/MemberAddressService.php
  36. 206 50
      app/Services/Api/MemberService.php
  37. 24 1
      app/Services/Api/OrderService.php
  38. 271 0
      app/Services/Api/StoreService.php
  39. 19 2
      app/Services/Common/MenuService.php
  40. 4 2
      app/Services/Common/RoleService.php
  41. 373 0
      app/Services/MpService.php
  42. 二進制
      public/favicon.ico
  43. 13 95
      resources/lang/zh-cn/api.php
  44. 43 18
      routes/api.php

+ 16 - 0
.dockerignore

@@ -0,0 +1,16 @@
+.git
+.gitignore
+.env
+.env.backup
+.phpunit.result.cache
+docker-compose.yml
+Dockerfile
+.dockerignore
+node_modules
+vendor
+storage
+bootstrap/cache
+*.md
+.vscode
+.idea
+

+ 0 - 94
.env

@@ -1,94 +0,0 @@
-APP_NAME=dshmp
-APP_ENV=local
-LOCAL_LANG=zh-cn
-APP_KEY=base64:5c43a8wcR8LOQtT3fxxtJ/Y4Hf4y4KdLsGF5Gi6v7SY=
-APP_DEBUG=true
-SHOW_MENU_MANAGE=true # 是否显示菜单管理
-API_KEY=DSHRPAPPE4CE092RO886
-APP_SIGN_KEY=dshApp&688
-APP_URL=https://dshmp.derkj.com/
-WEB_URL=https://dshmp.derkj.com/
-LOG_CHANNEL=stack
-ORDER_REPORT_STATUS=1
-
-# 短信调试
-SMS_DEBUG=true
-SMS_CODE=1221
-
-DB_CONNECTION=mysql
-DB_PREFIX=lev_
-#DB_DATABASE=NN2025062001
-#DB_HOST=127.0.0.1
-#DB_PORT=3306
-#DB_USERNAME=root
-#DB_PASSWORD=Login*123
-
-# DB_HOST=47.112.222.163
-# DB_PORT=63306
-# DB_USERNAME=NN2025062001
-# DB_DATABASE=nn2025062001
-# DB_PASSWORD=iG4xWTFiYNXiFzhK
-
-DB_HOST=47.112.222.163
-DB_PORT=63306
-DB_USERNAME=nn2025112501
-DB_DATABASE=nn2025112501
-DB_PASSWORD=kB8SXpiG7pa2iXe2
-
-FILESYSTEM_DRIVER=public # 文件系统
-
-BROADCAST_DRIVER=log
-QUEUE_DRIVER=redis
-QUEUE_CONNECTION=redis
-SESSION_DRIVER=file
-SESSION_LIFETIME=120
-
-# REDIS_PREFIX=null
-# REDIS_HOST=127.0.0.1
-# REDIS_PASSWORD=null
-# REDIS_PORT=16379
-# REDIS_DB=2
-
-REDIS_PREFIX=null
-REDIS_HOST=127.0.0.1
-REDIS_PASSWORD=Ghfjdksla123
-REDIS_PORT=6379
-REDIS_DB=2
-
-CACHE_DRIVER=redis
-#REDIS_PREFIX=null
-#REDIS_HOST=47.112.222.163
-#REDIS_PASSWORD=derkj&6688
-#REDIS_PORT=16379
-#REDIS_DB=2
-
-#socket
-SOCKET_PORT=8660
-
-# 微信
-WEIXIN_APP_ID=
-WEIXIN_SECRET=
-WEIXIN_REDIRECT_URL
-
-MAIL_DRIVER=smtp
-MAIL_HOST=smtp.163.com
-MAIL_PORT=25
-MAIL_USERNAME=
-MAIL_FROM_ADDRESS=
-MAIL_PASSWORD=
-MAIL_ENCRYPTION=tls
-
-PUSHER_APP_ID=
-PUSHER_APP_KEY=
-PUSHER_APP_SECRET=
-PUSHER_APP_CLUSTER=mt1
-
-MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
-MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
-
-SITE_NAME = UTC
-NICK_NAME = UTC
-VERSION = v1.2.0
-
-# 预览压缩尺寸和域名
-IMG_URL = https://dshmp.derkj.com/uploads

+ 6 - 23
.gitignore

@@ -1,28 +1,11 @@
-# ---> Laravel
-/bootstrap/compiled.php
+bootstrap/compiled.php
 .env.*.php
 .env.*.php
 .env.php
 .env.php
 .env
 .env
-/vendor
-/storage/logs
-/storage/framework/cache/data
-/storage/framework/sessions
-/storage/framework/views
-/storage/framework/testing
-/bootstrap/cache
-docker-compose-server.yml
-docker-compose.yml
-Dockerfile
-.dockerignore
+vendor/
 .vscode
 .vscode
-QUICKSTART.md
-README-DOCKER.md
-setup-storage.sh
-fix-permissions.sh
-check-permissions.sh
-check-php-extensions.sh
-check-network.sh
-check-network.md
-check-network.sh
-docker/
+addons/admin/node_modules/
+addons/mpapp/
+.idea/
+addons/
 node_modules/
 node_modules/

二進制
addons/admin/public/favicon.ico


二進制
addons/admin/public/icon.png


+ 21 - 3
app/Helpers/common.php

@@ -882,7 +882,7 @@ if (!function_exists('get_format_images')) {
      * @author laravel开发员
      * @author laravel开发员
      * @date 2019/6/6
      * @date 2019/6/6
      */
      */
-    function get_format_images($images, $key = 'url', $dataType = 'json')
+    function get_format_images($images, $key = '', $dataType = 'json')
     {
     {
         if (empty($images) || !is_array($images)) {
         if (empty($images) || !is_array($images)) {
             return '';
             return '';
@@ -1428,7 +1428,7 @@ if (!function_exists('showJson')) {
      */
      */
     function showJson($msg = "操作成功", $success = true, $data = [], $code = 0, $type = 'json')
     function showJson($msg = "操作成功", $success = true, $data = [], $code = 0, $type = 'json')
     {
     {
-        $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data,'stime'=>time()];
+        $result = ['success' => $success, 'msg' => lang($msg), 'data' => $success || env('APP_DEBUG')? $data :[],'stime'=>time()];
         if ($success) {
         if ($success) {
             $result['code'] = 0;
             $result['code'] = 0;
         } else {
         } else {
@@ -1652,6 +1652,22 @@ if (!function_exists('save_image')) {
     }
     }
 }
 }
 
 
+if(!function_exists('save_base64_image')){
+    /**
+     * 保存base64图片
+     * @param $base64
+     * @param string $save_dir
+     * @param string $ext
+     * @return false|string
+     */
+    function save_base64_image($base64, $save_dir = '', $ext='jpeg')
+    {
+        $content = str_replace('data:image/png;base64,','', urldecode(trim($base64)));
+        $save_path = create_image_path($save_dir, $ext);
+        return file_put_contents(ATTACHMENT_PATH . $save_path, base64_decode($content)) ? $save_path : false;
+    }
+}
+
 if (!function_exists('create_image_path')) {
 if (!function_exists('create_image_path')) {
 
 
     /**
     /**
@@ -1769,11 +1785,13 @@ if (!function_exists('upload_image')) {
      */
      */
     function upload_image($request, $form_name = 'file', $file_path = '', $userId = 0)
     function upload_image($request, $form_name = 'file', $file_path = '', $userId = 0)
     {
     {
+        ob_clean();
         // 检测请求中是否包含name=$form_name的上传文件
         // 检测请求中是否包含name=$form_name的上传文件
-        $params = $request->post();
         if (!$request->hasFile($form_name)) {
         if (!$request->hasFile($form_name)) {
             return message("请上传文件", false);
             return message("请上传文件", false);
         }
         }
+
+
         // 文件对象
         // 文件对象
         $file = $request->file($form_name);
         $file = $request->file($form_name);
         // 判断图片上传是否错误
         // 判断图片上传是否错误

+ 3 - 1
app/Http/Controllers/Admin/IndexController.php

@@ -103,9 +103,11 @@ class IndexController extends Backend
         RedisService::keyDel("caches:count*");
         RedisService::keyDel("caches:count*");
         RedisService::keyDel("caches:account*");
         RedisService::keyDel("caches:account*");
         RedisService::keyDel("caches:article*");
         RedisService::keyDel("caches:article*");
+        RedisService::keyDel("caches:agents*");
         RedisService::keyDel("caches:member*");
         RedisService::keyDel("caches:member*");
         RedisService::keyDel("caches:config*");
         RedisService::keyDel("caches:config*");
-        RedisService::keyDel("caches:deposit*");
+        RedisService::keyDel("caches:stores*");
+        RedisService::keyDel("caches:jobs*");
         RedisService::keyDel("caches:order*");
         RedisService::keyDel("caches:order*");
         RedisService::keyDel(env('APP_NAME') . "_cache:*");
         RedisService::keyDel(env('APP_NAME') . "_cache:*");
         //Cache::flush();
         //Cache::flush();

+ 1 - 1
app/Http/Controllers/Admin/RoleController.php

@@ -53,7 +53,7 @@ class RoleController extends Backend
      */
      */
     public function getPermissionList()
     public function getPermissionList()
     {
     {
-        $result = $this->service->getPermissionList();
+        $result = $this->service->getPermissionList($this->userId);
         return $result;
         return $result;
     }
     }
 
 

+ 1 - 1
app/Http/Controllers/Api/UploadController.php

@@ -49,7 +49,7 @@ class UploadController extends webApp
         }
         }
 
 
         // 返回结果
         // 返回结果
-        return showJson(MESSAGE_OK, true, ['url'=> $file_path, 'path'=> $result['data']['img_path']]);
+        return showJson('上传成功', true, ['url'=> $file_path, 'path'=> $result['data']['img_path']]);
     }
     }
 
 
     /**
     /**

+ 115 - 0
app/Http/Controllers/Api/v1/AddressController.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace App\Http\Controllers\Api\v1;
+
+use App\Http\Controllers\Api\webApp;
+use App\Http\Validator\AddressValidator;
+use App\Services\Api\MemberAddressService;
+use App\Services\RedisService;
+
+/**
+ * 收货地址
+ * Class AddressController
+ * @package App\Http\Controllers\Api
+ */
+class AddressController extends webApp
+{
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $params =request()->post();
+        $pageSize = request()->post('pageSize', 15);
+        $params['user_id'] = $this->userId;
+        $datas = MemberAddressService::make()->getDataList($params, $pageSize);
+        return showJson(1010, true, $datas);
+    }
+
+    /**
+     * 详情
+     * @param AddressValidator $validator
+     * @return array
+     */
+    public function info()
+    {
+        $params = request()->all();
+        $id = isset($params['id'])? $params['id'] : 0;
+        try {
+            if(!$result = MemberAddressService::make()->getInfo($id, $this->userId)){
+                return showJson(1009, false);
+            }else{
+                return showJson(1010, true, $result);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 添加
+     * @param AddressValidator $validator
+     * @return array
+     */
+    public function save(AddressValidator $validator)
+    {
+        $params = request()->all();
+        $params = $validator->check($params, 'save');
+        if (!is_array($params)) {
+            return showJson($params, false);
+        }
+
+       try {
+           if(!$result = MemberAddressService::make()->saveData($this->userId, $params)){
+               return showJson(MemberAddressService::make()->getError(), false);
+           }else{
+               return showJson(MemberAddressService::make()->getError(), true, $result);
+           }
+       } catch (\Exception $exception) {
+           $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+           return showJson(1046, false, $error);
+       }
+    }
+
+    /**
+     * 添加
+     * @param AddressValidator $validator
+     * @return array
+     */
+    public function setDefault(AddressValidator $validator)
+    {
+        $params = request()->all();
+        $params = $validator->check($params, 'default');
+        if (!is_array($params)) {
+            return showJson($params, false);
+        }
+
+        try {
+            if(!$result = MemberAddressService::make()->setDefault($this->userId, $params)){
+                return showJson(MemberAddressService::make()->getError(), false,111);
+            }else{
+                return showJson(MemberAddressService::make()->getError(), true, $result);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 删除
+     * @return array|mixed
+     */
+    public function delete()
+    {
+        if(!MemberAddressService::make()->delete()){
+            return showJson(MemberAddressService::make()->getError(), false);
+        }else{
+            return showJson(MemberAddressService::make()->getError(), true);
+        }
+    }
+
+}

+ 73 - 0
app/Http/Controllers/Api/v1/AgentController.php

@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Http\Controllers\Api\v1;
+
+use App\Http\Controllers\Api\webApp;
+use App\Http\Validator\AgentValidator;
+use App\Services\Api\AgentService;
+
+/**
+ * 代理
+ * @package App\Http\Controllers\Api
+ */
+class AgentController extends webApp
+{
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $params =request()->post();
+        $pageSize = request()->post('pageSize', 15);
+        $datas = AgentService::make()->getDataList($params, $pageSize);
+        return showJson(1010, true, $datas);
+    }
+
+
+    /**
+     * 详情
+     * @return array
+     */
+    public function info()
+    {
+        try {
+            if(!$result = AgentService::make()->getInfo($this->userId)){
+                return showJson(1009, false);
+            }else{
+                return showJson(1010, true, $result);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+
+    /**
+     * 入驻
+     * @param AgentValidator $validator
+     * @return array
+     */
+    public function apply(AgentValidator $validator)
+    {
+        $params = request()->all();
+        $params = $validator->check($params, 'apply');
+        if (!is_array($params)) {
+            return showJson($params, false);
+        }
+
+       try {
+           if(!$result = AgentService::make()->apply($this->userId, $params)){
+               return showJson(AgentService::make()->getError(), false);
+           }else{
+               return showJson(AgentService::make()->getError(), true, $result);
+           }
+       } catch (\Exception $exception) {
+           $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+           return showJson(1046, false, $error);
+       }
+    }
+
+}

+ 115 - 0
app/Http/Controllers/Api/v1/CartController.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace App\Http\Controllers\Api\v1;
+
+use App\Http\Controllers\Api\webApp;
+use App\Services\Api\CartService;
+use App\Services\Api\GoodsService;
+use App\Services\Api\MemberService;
+
+/**
+ * 购物车管理
+ * @package App\Http\Controllers\Api
+ */
+class CartController extends webApp
+{
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $params = request()->post();
+        $pageSize = request()->post('pageSize', 12);
+        $params['user_id'] = $this->userId;
+        $datas = CartService::make()->getDataList($params, $pageSize);
+        return message(1010, true, $datas);
+    }
+
+    /**
+     * 添加购物车
+     */
+    public function add()
+    {
+        $params = request()->all();
+        $id = isset($params['id']) ? intval($params['id']) : 0;
+        $skuId = isset($params['sku_id']) ? intval($params['sku_id']) : 0;
+        $num = isset($params['num']) && $params['num']? intval($params['num']) : 1;
+        if (empty($id)) {
+            return message(1036, false);
+        }
+        try {
+
+            if ($result = CartService::make()->add($this->userId, $id, $skuId, $num)) {
+                return message(CartService::make()->getError(), true, $result);
+            } else {
+                return message(CartService::make()->getError(), false);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 更新购物车
+     */
+    public function update()
+    {
+        $params = request()->all();
+        $id = isset($params['id']) ? intval($params['id']) : 0;
+        if (empty($id)) {
+            return message(1036, false);
+        }
+        try {
+
+            if ($result = CartService::make()->update($this->userId, $id)) {
+                return message(CartService::make()->getError(), true, $result);
+            } else {
+                return message(CartService::make()->getError(), false);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 删除购物车
+     */
+    public function delete()
+    {
+        $params = request()->all();
+        $ids = isset($params['ids']) && $params['ids']? $params['ids'] : [];
+        try {
+
+            if ($result = CartService::make()->deleteCart($this->userId, $ids)) {
+                return message(CartService::make()->getError(), true, $result);
+            } else {
+                return message(CartService::make()->getError(), false);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 购物车数量
+     */
+    public function count()
+    {
+        try {
+
+            if ($result = CartService::make()->getCount($this->userId)) {
+                return message(CartService::make()->getError(), true, $result);
+            } else {
+                return message(CartService::make()->getError(), false);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+}

+ 33 - 0
app/Http/Controllers/Api/v1/ComplaintController.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Http\Controllers\Api\v1;
+
+use App\Http\Controllers\Api\webApp;
+use App\Services\Api\ComplaintService;
+
+/**
+ * 投诉建议
+ * Class ComplaintController
+ * @package App\Http\Controllers\Api
+ */
+class ComplaintController extends webApp
+{
+
+    /**
+     * 提交
+     */
+    public function submit()
+    {
+        $params = request()->post();
+        try {
+            if (ComplaintService::make()->submit($this->userId, $params)) {
+                return showJson(ComplaintService::make()->getError(), true);
+            } else {
+                return showJson(ComplaintService::make()->getError(), false);
+            }
+        }  catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+}

+ 12 - 12
app/Http/Controllers/Api/v1/GoodsController.php

@@ -21,23 +21,23 @@ class GoodsController extends webApp
     {
     {
         $params =request()->post();
         $params =request()->post();
         $pageSize = request()->post('pageSize', 12);
         $pageSize = request()->post('pageSize', 12);
-        $params['picker_status'] = 1;
-        $params['user_id'] = $this->userId;
-        $userInfo = MemberService::make()->getInfo($this->userId,[], true);
-        $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
-        $pickerStatus = isset($userInfo['picker_status'])? $userInfo['picker_status'] : 0;
-        if($confirmStatus != 1){
-            return message(2043, false,[],405);
-        }
-
-        if($pickerStatus!= 1){
-            return message(2063, false,[],406);
-        }
         $datas = GoodsService::make()->getDataList($params, $pageSize);
         $datas = GoodsService::make()->getDataList($params, $pageSize);
         return message(1010, true, $datas);
         return message(1010, true, $datas);
     }
     }
 
 
     /**
     /**
+     * 分类
+     * @return array
+     */
+    public function categorys()
+    {
+        $params =request()->post();
+        $pageSize = request()->post('pageSize', 12);
+        $datas = GoodsService::make()->getCategoryList($params, $pageSize);
+        return message(1010, true, $datas);
+    }
+
+    /**
      * 详情
      * 详情
      */
      */
     public function info()
     public function info()

+ 18 - 31
app/Http/Controllers/Api/v1/IndexController.php

@@ -3,9 +3,7 @@
 namespace App\Http\Controllers\Api\v1;
 namespace App\Http\Controllers\Api\v1;
 
 
 use App\Http\Controllers\Api\webApp;
 use App\Http\Controllers\Api\webApp;
-use App\Services\Api\AccountService;
-use App\Services\Api\MemberService;
-use App\Services\Api\OrderService;
+use App\Services\Common\AdService;
 use App\Services\Common\NoticeService;
 use App\Services\Common\NoticeService;
 use App\Services\ConfigService;
 use App\Services\ConfigService;
 use App\Services\RedisService;
 use App\Services\RedisService;
@@ -29,22 +27,17 @@ class IndexController extends webApp
             $cacheKey = "caches:config:app_{$appSources}";
             $cacheKey = "caches:config:app_{$appSources}";
             $config = RedisService::get($cacheKey);
             $config = RedisService::get($cacheKey);
             if (empty($config)) {
             if (empty($config)) {
-                $depositConfig = ConfigService::make()->getConfigByGroup(5);
                 $config = [
                 $config = [
                     'app_name' => ConfigService::make()->getConfigByCode('app_name'),
                     'app_name' => ConfigService::make()->getConfigByCode('app_name'),
                     'app_logo' => get_image_url(ConfigService::make()->getConfigByCode('app_logo')),
                     'app_logo' => get_image_url(ConfigService::make()->getConfigByCode('app_logo')),
                     'app_version' => ConfigService::make()->getConfigByCode('app_version'),
                     'app_version' => ConfigService::make()->getConfigByCode('app_version'),
                     'app_android_url' => ConfigService::make()->getConfigByCode('app_android_url'),
                     'app_android_url' => ConfigService::make()->getConfigByCode('app_android_url'),
-                    'deposit_money' => isset($depositConfig['deposit_money']['value'])? floatval($depositConfig['deposit_money']['value']) : 0,
-                    'deposit_desc' => isset($depositConfig['deposit_desc']['value'])? format_content($depositConfig['deposit_desc']['value']) : '',
-                    'deposit_refund_desc' => isset($depositConfig['deposit_refund_desc']['value'])? format_content($depositConfig['deposit_refund_desc']['value']) : '',
-                    'alipay_open' => ConfigService::make()->getConfigByCode('alipay_open', 1),
-                    'wxpay_open' => ConfigService::make()->getConfigByCode('wxpay_open', 1),
-                    'withdraw_open' => ConfigService::make()->getConfigByCode('withdraw_open', 1),
+                    'alipay_open' => ConfigService::make()->getConfigByCode('alipay_open', 0),
+                    'agent_apply_desc' => ConfigService::make()->getConfigByCode('agent_apply_desc', ''),
+                    'wxpay_open' => ConfigService::make()->getConfigByCode('wxpay_open', 0),
+                    'withdraw_open' => ConfigService::make()->getConfigByCode('withdraw_open', 0),
                     'withdraw_min' => ConfigService::make()->getConfigByCode('withdraw_min', 0),
                     'withdraw_min' => ConfigService::make()->getConfigByCode('withdraw_min', 0),
                     'withdraw_fee' => ConfigService::make()->getConfigByCode('withdraw_fee', 0),
                     'withdraw_fee' => ConfigService::make()->getConfigByCode('withdraw_fee', 0),
-                    'imchat_url' => ConfigService::make()->getConfigByCode('imchat_url', ''),
-                    'img_compress'=> ConfigService::make()->getConfigByCode('preview_img_compress', ''),
                     'notices' => NoticeService::make()->getRecommandList(),
                     'notices' => NoticeService::make()->getRecommandList(),
                 ];
                 ];
                 RedisService::set($cacheKey, $config, 3600);
                 RedisService::set($cacheKey, $config, 3600);
@@ -52,8 +45,8 @@ class IndexController extends webApp
 
 
             return showJson(1010, true, $config);
             return showJson(1010, true, $config);
         } catch (\Exception $exception) {
         } catch (\Exception $exception) {
-            RedisService::set("caches:request:error_config", ['trace' => $exception->getTrace()], 7200);
-            return showJson(1018, false, ['error' => env('APP_DEBUG') ? $exception->getMessage() : '']);
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
         }
         }
     }
     }
 
 
@@ -63,25 +56,19 @@ class IndexController extends webApp
      */
      */
     public function data()
     public function data()
     {
     {
-        $userInfo = MemberService::make()->getInfo($this->userId);
-        $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
-        $pickerStatus = isset($userInfo['picker_status'])? $userInfo['picker_status'] : 0;
-        if($confirmStatus != 1){
-            return message(2043, false,[],405);
-        }
+        try {
+            $data = [
+                // 公告
+                'notices' => NoticeService::make()->getRecommandList(),
 
 
-        if($pickerStatus!= 1){
-            return message(2063, false,[],406);
+                // 轮播
+                'banners' => AdService::make()->getListByPosition(1),
+            ];
+            return showJson(1010, true, $data);
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
         }
         }
-
-        $data = [
-            // 首页数据
-            'counts' => [
-                'dayIncome' => AccountService::make()->getTotalByDay($this->userId, 1),
-                'dayOrder' => OrderService::make()->getCountByDay($this->userId, 3),
-            ],
-        ];
-        return showJson(1010, true, $data);
     }
     }
 
 
     /**
     /**

+ 28 - 0
app/Http/Controllers/Api/v1/LoginController.php

@@ -39,6 +39,34 @@ class LoginController extends webApp
     }
     }
 
 
     /**
     /**
+     * 小程序授权登录
+     * @param MemberValidator $validator
+     * @return array
+     */
+    public function mpAuth(MemberValidator $validator)
+    {
+        $params = request()->all();
+        try {
+            $params = $validator->check($params, 'mp');
+            if (!is_array($params)) {
+                return showJson($params, false);
+            }
+
+            $code = isset($params['code']) ? $params['code'] : '';
+            if ($result = MemberService::make()->mpAuth($code, $params)) {
+                return showJson(MemberService::make()->getError(), true, $result);
+            }else{
+                return showJson(MemberService::make()->getError(), false);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            RedisService::set("caches:members:loginError", ['params'=>$params, 'error'=>$error], 600);
+            return showJson(1046, false, $error);
+        }
+    }
+
+
+    /**
      * 账号注册
      * 账号注册
      * @return array
      * @return array
      */
      */

+ 12 - 34
app/Http/Controllers/Api/v1/MemberController.php

@@ -30,46 +30,24 @@ class MemberController extends webApp
     }
     }
 
 
     /**
     /**
-     * 注册资料
+     * 设置资料
      * @return array
      * @return array
      */
      */
-    public function profile()
+    public function setEntry()
     {
     {
-        $userId = request()->post('user_id', 0);
-        $field = ['id', 'user_type', 'realname', 'mobile', 'nickname','balance','deposit','car_type','car_number','driving_license','confirm_at','confirm_remark','confirm_status','drivers_license','create_time', 'code', 'openid', 'status', 'avatar'];
-        $info = MemberService::make()->getInfo($userId ? $userId : $this->userId, $field);
-        if ($info) {
-            return showJson(1010, true, $info);
-        } else {
-            return showJson(1004, false, [], '403');
+        try {
+            $params = request()->all();
+            if (!MemberService::make()->setEntry($this->userId, $params)) {
+                return showJson(MemberService::make()->getError(), false);
+            } else {
+                return showJson(1019, true);
+            }
+        } catch (\Exception $exception){
+            $error = ['data'=>$exception->getTrace(),'err'=>$exception->getMessage()];
+            return showJson(1046, false, $error);
         }
         }
     }
     }
 
 
-    /**
-     * 注册资料重新提交
-     * @return array
-     */
-    public function profileModify()
-    {
-        $params = request()->all();
-        if (!MemberService::make()->profileModify($this->userId, $params)) {
-            return showJson(MemberService::make()->getError(), false);
-        } else {
-            return showJson(1013, true);
-        }
-    }
-
-    /**
-     * 用户账号列表
-     * @return array
-     */
-    public function index()
-    {
-        $params =request()->post();
-        $pageSize = request()->post('pageSize', 12);
-        $datas = MemberService::make()->getDataList($params, $pageSize);
-        return message(1010, true, $datas);
-    }
 
 
     /**
     /**
      * 更新修改头像
      * 更新修改头像

+ 11 - 0
app/Http/Controllers/Api/v1/OrderController.php

@@ -53,6 +53,17 @@ class OrderController extends webApp
         }
         }
     }
     }
 
 
+    /**
+     * 数量
+     * @return array
+     */
+    public function count()
+    {
+        $status =  request()->post('status', 1);
+        $data = OrderService::make()->getCountByStatus($this->userId, $status);
+        return showJson(1010, true, $data);
+    }
+
 
 
     /**
     /**
      * 详情
      * 详情

+ 135 - 0
app/Http/Controllers/Api/v1/StoreController.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace App\Http\Controllers\Api\v1;
+
+use App\Http\Controllers\Api\webApp;
+use App\Http\Validator\StoreValidator;
+use App\Services\Api\StoreService;
+
+/**
+ * 商家
+ * @package App\Http\Controllers\Api
+ */
+class StoreController extends webApp
+{
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $params =request()->post();
+        $pageSize = request()->post('pageSize', 15);
+        $datas = StoreService::make()->getDataList($params, $pageSize);
+        return showJson(1010, true, $datas);
+    }
+
+    /**
+     * 主页店铺商品
+     * @return array
+     */
+    public function goods()
+    {
+        $params =request()->post();
+        $pageSize = request()->post('pageSize', 15);
+        try {
+            $datas = StoreService::make()->getGoodsList($params, $pageSize);
+            return showJson(1010, true, $datas);
+        }catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 行业分类
+     * @return array
+     */
+    public function categorys()
+    {
+        $datas = StoreService::make()->getCategoryList();
+        return showJson(1010, true, $datas);
+    }
+
+    /**
+     * 详情
+     * @return array
+     */
+    public function info()
+    {
+        $params = request()->all();
+        $id = isset($params['id'])? $params['id'] : 0;
+        try {
+            if(!$result = StoreService::make()->getInfo($id)){
+                return showJson(1009, false);
+            }else{
+                return showJson(1010, true, $result);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 详情
+     * @return array
+     */
+    public function applyInfo()
+    {
+        $params = request()->all();
+        $uid = isset($params['uid'])? $params['uid'] : 0;
+        $uid = $uid? $uid : $this->userId;
+        try {
+            if(!$result = StoreService::make()->getApplyInfo($uid)){
+                return showJson(1009, false);
+            }else{
+                return showJson(1010, true, $result);
+            }
+        } catch (\Exception $exception) {
+            $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+            return showJson(1046, false, $error);
+        }
+    }
+
+    /**
+     * 添加
+     * @param StoreValidator $validator
+     * @return array
+     */
+    public function apply(StoreValidator $validator)
+    {
+        $params = request()->all();
+        $params = $validator->check($params, 'apply');
+        if (!is_array($params)) {
+            return showJson($params, false);
+        }
+
+       try {
+           if(!$result = StoreService::make()->apply($this->userId, $params)){
+               return showJson(StoreService::make()->getError(), false);
+           }else{
+               return showJson(StoreService::make()->getError(), true, $result);
+           }
+       } catch (\Exception $exception) {
+           $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
+           return showJson(1046, false, $error);
+       }
+    }
+
+
+    /**
+     * 删除
+     * @return array|mixed
+     */
+    public function delete()
+    {
+        if(!StoreService::make()->delete()){
+            return showJson(StoreService::make()->getError(), false);
+        }else{
+            return showJson(StoreService::make()->getError(), true);
+        }
+    }
+
+}

+ 56 - 0
app/Http/Validator/AddressValidator.php

@@ -0,0 +1,56 @@
+<?php
+namespace App\Http\Validator;
+class AddressValidator extends BaseValidator
+{
+    // 当前模型所有验证规则
+    public static $rules = [
+        'id' => 'required',
+        'realname' => 'required|max:20',
+        'mobile' => 'required|mobile|max:30',
+        'province' => 'required|max:30',
+        'city' => 'required|max:30',
+        'district' => 'max:30',
+        'codes' => 'required|max:200',
+        'type' => 'required',
+        'status' => 'required',
+    ];
+    public static $msgs = [
+        'required' => ':attribute不能为空',
+        'string' => ':attribute必须是字符串',
+        'min' => ':attribute长度不能小于:min位',
+        'max' => ':attribute长度不能大于:max位',
+        'exists' => ':attribute不存在',
+        'rule' => ':attribute格式不正确',
+        'mobile' => ':attribute格式不正确',
+    ];
+
+    // 当前模型所有验证字段
+    public static $fields = [
+        'id' => 'ID',
+        'realname' => '收货人姓名',
+        'mobile' => '收货人手机号',
+        'province' => '地址省份',
+        'city' => '地址城市',
+        'district' => '地址区县',
+        'address' => '详细地址',
+    ];
+
+    // 当前模型所有验证场景
+    public static $scenes = [
+        'add'=> ['realname','mobile','province','city','district','codes','address','is_default'],
+        'save'=> ['id','realname','mobile','province','city','district','codes','address','is_default'],
+        'default'=> ['id','is_default'],
+        'del'=> ['id'],
+    ];
+
+    /**
+     * 验证
+     * @param $request
+     * @param string $scene
+     * @return int|mixed
+     */
+    public static function check($request, $scene=''){
+        $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes);
+        return $validator->checkParams($request, $scene);
+    }
+}

+ 47 - 0
app/Http/Validator/AgentValidator.php

@@ -0,0 +1,47 @@
+<?php
+namespace App\Http\Validator;
+class AgentValidator extends BaseValidator
+{
+    // 当前模型所有验证规则
+    public static $rules = [
+        'id' => 'required',
+        'real_name' => 'required|max:20',
+        'phone' => 'required|mobile|max:30',
+        'idcard' => 'required|max:20',
+    ];
+    public static $msgs = [
+        'required' => ':attribute不能为空',
+        'string' => ':attribute必须是字符串',
+        'min' => ':attribute长度不能小于:min位',
+        'max' => ':attribute长度不能大于:max位',
+        'exists' => ':attribute不存在',
+        'rule' => ':attribute格式不正确',
+        'mobile' => ':attribute格式不正确',
+    ];
+
+    // 当前模型所有验证字段
+    public static $fields = [
+        'id' => 'ID',
+        'real_name' => '姓名',
+        'phone' => '手机号码',
+        'idcard' => '身份证号码',
+    ];
+
+    // 当前模型所有验证场景
+    public static $scenes = [
+        'apply'=> ['real_name','phone','idcard'],
+        'save'=> ['id','real_name','phone','idcard'],
+        'del'=> ['id'],
+    ];
+
+    /**
+     * 验证
+     * @param $request
+     * @param string $scene
+     * @return int|mixed
+     */
+    public static function check($request, $scene=''){
+        $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes);
+        return $validator->checkParams($request, $scene);
+    }
+}

+ 2 - 11
app/Http/Validator/MemberValidator.php

@@ -12,10 +12,6 @@ class MemberValidator extends BaseValidator
         'sms_code' => 'required|min:4|max:6',
         'sms_code' => 'required|min:4|max:6',
         'password' => 'required|pwd|min:6|max:30',
         'password' => 'required|pwd|min:6|max:30',
         'realname' => 'required|min:2|max:30',
         'realname' => 'required|min:2|max:30',
-        'car_number' => 'required|min:2|max:30',
-        'car_type' => 'required|min:2|max:50',
-        'driving_license' => 'required',
-        'drivers_license' => 'required',
         'scene' => 'required',
         'scene' => 'required',
         'access_token' => 'required',
         'access_token' => 'required',
 
 
@@ -44,20 +40,15 @@ class MemberValidator extends BaseValidator
         'mobile' => '手机账号',
         'mobile' => '手机账号',
         'realname' => '姓名',
         'realname' => '姓名',
         'sms_code' => '验证码',
         'sms_code' => '验证码',
-        'car_number' => '车牌号码',
-        'car_type' => '车型',
-        'driving_license' => '驾驶证',
-        'drivers_license' => '行驶证',
     ];
     ];
 
 
     // 当前模型所有验证场景
     // 当前模型所有验证场景
     public static $scenes = [
     public static $scenes = [
         'info'=> ['id'],
         'info'=> ['id'],
+        'mp'=> ['code'],
         'wx_login'=> ['openid','access_token'],
         'wx_login'=> ['openid','access_token'],
         'login'=> ['mobile','password'],
         'login'=> ['mobile','password'],
-        'register'=> ['mobile','sms_code','password','realname','car_number','car_type','driving_license','drivers_license'],
-        'confirm'=> ['mobile','realname','car_number','car_type','driving_license','drivers_license'],
-        'modify'=> ['id'],
+        'register'=> ['mobile','sms_code','password'],
         'sms'=> ['mobile','scene'],
         'sms'=> ['mobile','scene'],
         'reset_password'=> ['mobile','password','sms_code'],
         'reset_password'=> ['mobile','password','sms_code'],
     ];
     ];

+ 55 - 0
app/Http/Validator/StoreValidator.php

@@ -0,0 +1,55 @@
+<?php
+namespace App\Http\Validator;
+class StoreValidator extends BaseValidator
+{
+    // 当前模型所有验证规则
+    public static $rules = [
+        'id' => 'required',
+        'name' => 'required|max:100',
+        'real_name' => 'required|max:20',
+        'phone' => 'required|mobile|max:30',
+        'address' => 'required|max:200',
+        'category_id' => 'required|max:10',
+        'logo' => 'required|max:250',
+        'business_license' => 'required|max:250',
+    ];
+    public static $msgs = [
+        'required' => ':attribute不能为空',
+        'string' => ':attribute必须是字符串',
+        'min' => ':attribute长度不能小于:min位',
+        'max' => ':attribute长度不能大于:max位',
+        'exists' => ':attribute不存在',
+        'rule' => ':attribute格式不正确',
+        'mobile' => ':attribute格式不正确',
+    ];
+
+    // 当前模型所有验证字段
+    public static $fields = [
+        'id' => 'ID',
+        'name' => '店铺名称',
+        'real_name' => '姓名',
+        'phone' => '电话',
+        'address' => '店铺地址',
+        'category_id' => '行业分类',
+        'logo' => '店铺门头',
+        'business_license' => '营业执照',
+    ];
+
+    // 当前模型所有验证场景
+    public static $scenes = [
+        'apply'=> ['name','real_name','phone','address','category_id','business_license','logo'],
+        'save'=> ['id','name','real_name','phone','address','category_id','business_license','logo'],
+        'del'=> ['id'],
+    ];
+
+    /**
+     * 验证
+     * @param $request
+     * @param string $scene
+     * @return int|mixed
+     */
+    public static function check($request, $scene=''){
+        $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes);
+        return $validator->checkParams($request, $scene);
+    }
+}

+ 61 - 0
app/Models/CartModel.php

@@ -0,0 +1,61 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+/**
+ * 购物车管理-模型
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Models
+ */
+class CartModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'carts';
+
+    /**
+     * 用户
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function member()
+    {
+        return $this->hasOne(MemberModel::class, 'id', 'user_id')
+            ->select(['id', 'realname', 'nickname', 'mobile', 'status']);
+    }
+
+    /**
+     * 商品
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function goods()
+    {
+        return $this->hasOne(GoodsModel::class, 'id', 'goods_id');
+    }
+
+    /**
+     * 商家
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function store()
+    {
+        return $this->hasOne(StoreModel::class, 'id', 'store_id');
+    }
+
+    /**
+     * SKU
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function skus()
+    {
+        return $this->hasOne(GoodsSkuModel::class, 'id', 'sku_id');
+    }
+}

+ 7 - 1
app/Models/ComplaintModel.php

@@ -1,5 +1,4 @@
 <?php
 <?php
-
 namespace App\Models;
 namespace App\Models;
 
 
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Model;
@@ -47,4 +46,11 @@ class ComplaintModel extends Model
     {
     {
         return $this->belongsTo(MemberModel::class, 'user_id', 'id');
         return $this->belongsTo(MemberModel::class, 'user_id', 'id');
     }
     }
+
+    // 图
+    public function getThumbAttribute($value)
+    {
+        $value = $value ? get_format_images($value,'url', 'array') : [];
+        return $value;
+    }
 }
 }

+ 12 - 59
app/Models/GoodsModel.php

@@ -35,68 +35,30 @@ class GoodsModel extends BaseModel
         return $value ? get_image_path($value) : '';
         return $value ? get_image_path($value) : '';
     }
     }
 
 
-    public function getInfo($id)
-    {
-        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
-        if ($info) {
-
-            $info['shipper_area'][] = isset($info['shipper_province_id']) ? $info['shipper_province_id'] : 0;
-            $info['shipper_area'][] = isset($info['shipper_city_id']) ? $info['shipper_city_id'] : 0;
-            $info['shipper_area'][] = isset($info['shipper_district_id']) ? $info['shipper_district_id'] : 0;
-
-            $info['receiver_area'][] = isset($info['receiver_province_id']) ? $info['receiver_province_id'] : 0;
-            $info['receiver_area'][] = isset($info['receiver_city_id']) ? $info['receiver_city_id'] : 0;
-            $info['receiver_area'][] = isset($info['receiver_district_id']) ? $info['receiver_district_id'] : 0;
-        }
-
-        return $info;
-    }
-
     /**
     /**
-     * 订单信息
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     * 图册
+     * @param $value
+     * @return array|string
      */
      */
-    public function order()
+    public function getAlbumsAttribute($value)
     {
     {
-        return $this->hasOne(OrderModel::class, 'goods_id', 'id')
-            ->where(['mark' => 1])
-            ->whereIn('status', [2, 3]);
+        $value = $value ? get_format_images($value,'url','array') : [];
+        return $value;
     }
     }
 
 
-    /**
-     * 寄货城市
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
-     */
-    public function shipperCity()
-    {
-        return $this->hasOne(CityModel::class, 'citycode', 'shipper_city_id');
-    }
-
-    /**
-     * 寄货县/区
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
-     */
-    public function shipperDistrict()
-    {
-        return $this->hasOne(CityModel::class, 'citycode', 'shipper_district_id');
-    }
-
-    /**
-     * 收货城市
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
-     */
-    public function receiverCity()
+    public function getInfo($id)
     {
     {
-        return $this->hasOne(CityModel::class, 'citycode', 'receiver_city_id');
+        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
+        return $info;
     }
     }
 
 
     /**
     /**
-     * 收货县/区
+     * 商家店铺
      * @return \Illuminate\Database\Eloquent\Relations\HasOne
      * @return \Illuminate\Database\Eloquent\Relations\HasOne
      */
      */
-    public function receiverDistrict()
+    public function store()
     {
     {
-        return $this->hasOne(CityModel::class, 'citycode', 'receiver_district_id');
+        return $this->hasOne(StoreModel::class, 'id', 'store_id');
     }
     }
 
 
     /**
     /**
@@ -109,15 +71,6 @@ class GoodsModel extends BaseModel
     }
     }
 
 
     /**
     /**
-     * 关联商家店铺
-     */
-    public function store()
-    {
-        return $this->hasOne(StoreModel::class, 'id', 'store_id')
-            ->select(['id', 'name', 'status']);
-    }
-
-    /**
      * 关联商品规格(多规格)
      * 关联商品规格(多规格)
      */
      */
     public function skus()
     public function skus()

+ 32 - 0
app/Models/MemberAddressModel.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+/**
+ * 用户地址管理-模型
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class MemberAddressModel
+ * @package App\Models
+ */
+class MemberAddressModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'member_address';
+
+    public function getCodesAttribute($value)
+    {
+        $value = $value ? explode(',',$value) : [];
+        return $value;
+    }
+
+}

+ 10 - 32
app/Models/MemberModel.php

@@ -24,25 +24,23 @@ class MemberModel extends BaseModel
     protected $table = 'member';
     protected $table = 'member';
 
 
     /**
     /**
-     * 仓库
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     * 代理信息
+     * @return \Illuminate\Database\Eloquent\Relations\hasOne
      */
      */
-    public function stock()
+    public function agent()
     {
     {
-        return $this->belongsTo(StockModel::class, 'stock_id','stock_id')
-            ->where(['mark'=>1])
-            ->select(['stock_id','stock_name','status']);
+        return $this->hasOne(AgentModel::class, 'user_id','id')
+            ->where(['mark'=>1]);
     }
     }
 
 
     /**
     /**
-     * 线路
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     * 商家信息
+     * @return \Illuminate\Database\Eloquent\Relations\hasOne
      */
      */
-    public function line()
+    public function store()
     {
     {
-        return $this->belongsTo(LineModel::class, 'line_id','line_id')
-            ->where(['mark'=>1])
-            ->select(['line_id','line_name','status']);
+        return $this->hasOne(StoreModel::class, 'user_id','id')
+            ->where(['mark'=>1]);
     }
     }
 
 
     /**
     /**
@@ -55,26 +53,6 @@ class MemberModel extends BaseModel
             ->select(['id', 'nickname', 'username', 'mobile', 'status']);
             ->select(['id', 'nickname', 'username', 'mobile', 'status']);
     }
     }
 
 
-    /**
-     * 订单
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany
-     */
-    public function order1()
-    {
-        return $this->hasMany(OrderModel::class, 'user_id','id')
-            ->where(['mark'=>1])->where('status','>=', 1);
-    }
-
-    /**
-     * 待捡货订单
-     * @return \Illuminate\Database\Eloquent\Relations\hasMany
-     */
-    public function order2()
-    {
-        return $this->hasMany(OrderModel::class, 'user_id','id')
-            ->where(['mark'=>1])->where('status', 2);
-    }
-
 
 
     /**
     /**
      * 获取会员信息
      * 获取会员信息

+ 34 - 2
app/Models/StoreModel.php

@@ -25,8 +25,8 @@ class StoreModel extends BaseModel
     // 封面图
     // 封面图
     public function getLogoAttribute($value)
     public function getLogoAttribute($value)
     {
     {
-        $thumb = $value ? get_image_url($value) : get_image_url('/images/store/logo.jpeg');
-        return $thumb;
+        $value = $value ? get_image_url($value) : '';
+        return $value;
     }
     }
 
 
     public function setLogoAttribute($value)
     public function setLogoAttribute($value)
@@ -34,11 +34,28 @@ class StoreModel extends BaseModel
 
 
         return $value ? get_image_path($value) : '';
         return $value ? get_image_path($value) : '';
     }
     }
+
+    // 营业执照
+    public function getBusinessLicenseAttribute($value)
+    {
+        $value = $value ? get_image_url($value) : '';
+        return $value;
+    }
+
+
+    // 其他证件
+    public function getOtherPhotoAttribute($value)
+    {
+        $value = $value ? get_image_url($value) : '';
+        return $value;
+    }
+
     public function user()
     public function user()
     {
     {
         return $this->hasOne(UserModel::class, 'id', 'user_id')
         return $this->hasOne(UserModel::class, 'id', 'user_id')
             ->select(['id', 'realname', 'nickname', 'status']);
             ->select(['id', 'realname', 'nickname', 'status']);
     }
     }
+
     public function member()
     public function member()
     {
     {
         return $this->hasOne(MemberModel::class, 'id', 'user_id')
         return $this->hasOne(MemberModel::class, 'id', 'user_id')
@@ -46,6 +63,19 @@ class StoreModel extends BaseModel
     }
     }
 
 
     /**
     /**
+     * 商家商品
+     */
+    public function goods()
+    {
+        return $this->hasMany(GoodsModel::class, 'store_id', 'id')
+            ->with(['category'])
+            ->where(['status'=>1,'mark'=>1])
+            ->select(['id','goods_name','category_id','store_id','price','thumb','sales','sku_type','unit','status'])
+            ->orderBy('sort','desc')
+            ->orderBy('id','desc');
+    }
+
+    /**
      * 关联商家分类
      * 关联商家分类
      */
      */
     public function category()
     public function category()
@@ -53,6 +83,8 @@ class StoreModel extends BaseModel
         return $this->hasOne(StoreCategoryModel::class, 'id', 'category_id')
         return $this->hasOne(StoreCategoryModel::class, 'id', 'category_id')
             ->select(['id', 'name', 'status']);
             ->select(['id', 'name', 'status']);
     }
     }
+
+
     public function getInfoByUserId($userId)
     public function getInfoByUserId($userId)
     {
     {
         return $this->where(['user_id' => $userId, 'mark' => 1])->first();
         return $this->where(['user_id' => $userId, 'mark' => 1])->first();

+ 153 - 0
app/Services/Api/AgentService.php

@@ -0,0 +1,153 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Api;
+
+use App\Models\AgentModel;
+use App\Services\BaseService;
+use App\Services\RedisService;
+
+/**
+ * 代理管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class AgentService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new AgentModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 15)
+    {
+        $where = ['a.mark' => 1];
+        $status = isset($params['status']) ? $params['status'] : 0;
+        if ($status > 0) {
+            $where['a.status'] = $status;
+        }
+        $list = $this->model->with(['user'])->from('agent as a')
+            ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
+            ->where($where)
+            ->where(function ($query) use ($params) {
+                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
+                if ($keyword) {
+                    $query->where('a.real_name', 'like', "%{$keyword}%")
+                        ->orWhere('a.phone', 'like', "%{$keyword}%");
+                }
+            })
+            ->select(['a.*'])
+            ->orderBy('a.create_time', 'desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total' => isset($list['total']) ? $list['total'] : 0,
+            'list' => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 申请
+     * @param $userId
+     * @param $params
+     * @return mixed
+     */
+    public function apply($userId, $params)
+    {
+        $realname = isset($params['real_name']) ? trim($params['real_name']) : '';
+        $phone = isset($params['phone']) ? trim($params['phone']) : '';
+        $idcard = isset($params['idcard']) && $params['idcard']? trim($params['idcard']) : '';
+
+        $data = [
+            'user_id' => $userId,
+            'real_name' => $realname,
+            'phone' => $phone,
+            'idcard' => $idcard,
+            'income' => 0,
+            'balance' => 0,
+            'withdraw_total' => 0,
+            'order_count' => 0,
+            'confirm_remark' => '',
+            'create_time' => time(),
+            'update_time' => time(),
+            'status' => 2,
+            'mark' => 1,
+        ];
+
+
+        if($id = $this->model->where(['user_id'=>$userId])->value('id')){
+            $this->model->where(['id'=>$id])->update($data);
+        }else{
+            if (!$id = $this->model->insertGetId($data)) {
+                $this->error = '代理申请失败';
+                return false;
+            }
+        }
+
+        RedisService::keyDel("caches:members:info_*");
+        RedisService::keyDel("caches:agents:info*");
+        $this->error = '代理申请成功,请耐心等候审核~';
+        return ['id' => $id];
+    }
+
+    /**
+     * 代理信息
+     * @param $id
+     * @param $userId
+     * @return array|mixed
+     */
+    public function getInfo($uid)
+    {
+        $cacheKey = "caches:agents:info_{$uid}";
+        $info = RedisService::get($cacheKey);
+        if($info){
+            return $info;
+        }
+        $where = ['user_id'=> $uid,'mark'=>1];
+        $info = $this->model->with(['user'])->where($where)->first();
+        $info = $info? $info->toArray() : [];
+        if($info){
+            RedisService::set($cacheKey, $info, rand(5, 10));
+        }
+
+        return $info;
+    }
+}

+ 263 - 0
app/Services/Api/CartService.php

@@ -0,0 +1,263 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Api;
+
+use App\Models\CartModel;
+use App\Models\GoodsCategoryModel;
+use App\Models\GoodsModel;
+use App\Services\BaseService;
+use App\Services\RedisService;
+
+/**
+ * 购物车管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Api
+ */
+class CartService extends BaseService
+{
+// 静态对象
+    protected static $instance = null;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new CartModel();
+    }
+
+    /**
+     * 静态入口
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = new static();
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 列表数据
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 15)
+    {
+        $cacheKey = "caches:goods:cartList_{$pageSize}_" . ($params ? md5(json_encode($params)) : 0);
+        $datas = RedisService::get($cacheKey);
+        if (empty($datas)) {
+            $query = $this->getQuery($params)
+                ->orderBy('a.create_time', 'desc')
+                ->orderBy('a.id', 'desc');
+
+            $field = ["a.*"];
+            $list = $query->select($field)
+                ->paginate($pageSize > 0 ? $pageSize : 9999999);
+            $list = $list ? $list->toArray() : [];
+            if ($list) {
+                $datas = [
+                    'pageSize' => $pageSize,
+                    'total' => isset($list['total']) ? $list['total'] : 0,
+                    'list' => isset($list['data']) ? $list['data'] : []
+                ];
+
+                RedisService::set($cacheKey, $datas, rand(3, 5));
+            }
+        }
+
+        return $datas;
+    }
+
+
+    /**
+     * 查询条件
+     * @param $params
+     * @return mixed
+     */
+    public function getQuery($params)
+    {
+        $where = ['a.status' => 1, 'a.mark' => 1];
+        $status = isset($params['status']) ? $params['status'] : 1;
+        if ($status > 0) {
+            $where['a.status'] = $status;
+        } else {
+            unset($where['a.status']);
+        }
+
+        $model = $this->model->with(['store', 'goods', 'skus'])
+            ->from('carts as a')
+            ->leftJoin('goods as b', 'b.id', '=', 'a.goods_id')
+            ->where($where)
+            ->where(function ($query) use ($params) {
+                // 商品
+                $goodsId = isset($params['goods_id']) ? intval($params['goods_id']) : 0;
+                if ($goodsId > 0) {
+                    $query->where('a.goods_id', $goodsId);
+                }
+
+                $userId = isset($params['user_id']) ? intval($params['user_id']) : 0;
+                if ($userId > 0) {
+                    $query->where('a.user_id', $userId);
+                }
+
+                // 店铺
+                $storeId = isset($params['store_id']) ? intval($params['store_id']) : 0;
+                if ($storeId > 0) {
+                    $query->where('a.store_id', $storeId);
+                }
+
+                $keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
+                if ($keyword) {
+                    $query->where(function ($query) use ($keyword) {
+                        $query->where('b.goods_name', 'like', "%{$keyword}%")
+                            ->orWhere('b.tags', 'like', "%{$keyword}%");
+                    });
+                }
+
+            });
+
+        return $model;
+    }
+
+    /**
+     * 添加购物车
+     * @param $userId
+     * @param $goodsId
+     * @param int $skuId
+     * @return array|false
+     */
+    public function add($userId, $goodsId, $skuId=0, $num=1)
+    {
+        $cacheKey = "caches:goods:addCart:{$userId}_{$goodsId}_{$skuId}";
+        if(RedisService::get($cacheKey.'_lock')){
+            $this->error = '处理中~';
+            return false;
+        }
+        RedisService::set($cacheKey.'_lock', ['goods_id'=>$goodsId,'sku_id'=>$skuId], rand(3,5));
+        $goodsInfo = GoodsModel::with(['skus'])
+            ->where(['id' => $goodsId, 'status' => 1, 'mark' => 1])
+            ->select(['id', 'sku_type', 'store_id'])
+            ->first();
+        $storeId = isset($goodsInfo['store_id']) ? $goodsInfo['store_id'] : 0;
+        $skuType = isset($goodsInfo['sku_type']) ? $goodsInfo['sku_type'] : 0;
+        $skus = isset($goodsInfo['skus']) ? $goodsInfo['skus'] : [];
+        $skuId = $skuId? $skuId : (isset($skus[0]) ? $skus[0]['id'] : 0);
+        if (empty($goodsInfo)) {
+            RedisService::clear($cacheKey.'_lock');
+            $this->error = '商品已下架';
+            return false;
+        }
+
+        // 去除其他店铺购物车
+        $this->model->where(['user_id' => $userId, 'mark' => 1])->whereNotIn('store_id', $storeId)->update(['mark' => 0, 'update_time' => time()]);
+
+        // 添加购物型
+        if ($id = $this->model->where(['user_id' => $userId, 'goods_id' => $goodsId])->value('id')) {
+            $this->model->where(['id' => $id])->update(['store_id' => $storeId,'num'=> $num, 'sku_id' => $skuType == 1 ? 0 : $skuId, 'status' => 1, 'mark' => 1, 'create_time' => time()]);
+        } else {
+            $data = [
+                'user_id' => $userId,
+                'goods_id' => $goodsId,
+                'store_id' => $storeId,
+                'num'=> $num,
+                'sku_id' => $skuType == 1 ? 0 : $skuId,
+                'create_time' => time(),
+                'status' => 1,
+                'mark' => 1,
+            ];
+            $id = $this->model->insertGetId($data);
+        }
+
+        RedisService::clear($cacheKey.'_lock');
+        RedisService::clear("caches:goods:cartCount:{$userId}");
+        return ['id' => $id, 'count' => $this->getCount($userId)];
+    }
+
+    /**
+     * 更新购物车
+     * @param $userId
+     * @param $cartId
+     * @return array|false
+     */
+    public function update($userId, $cartId, $num=1)
+    {
+        $cacheKey = "caches:goods:updateCart:{$userId}_{$cartId}";
+        if(RedisService::get($cacheKey.'_lock')){
+            $this->error = '处理中~';
+            return false;
+        }
+
+        RedisService::set($cacheKey.'_lock', ['cart_id'=>$cartId], rand(3,5));
+        // 去除其他店铺购物车
+        $info = $this->model->where(['id'=>$cartId, 'user_id' => $userId, 'mark' => 1])->first();
+        if(empty($info)){
+            RedisService::clear($cacheKey.'_lock');
+            $this->error = '数据不存在';
+            return false;
+        }
+
+        if($num<=0){
+            $this->model->where(['id' => $cartId])->update(['mark'=>0,'update_time'=>time()]);
+        }else{
+            $this->model->where(['id' => $cartId])->update(['num' => $num,'update_time' => time()]);
+        }
+
+        RedisService::clear($cacheKey.'_lock');
+        RedisService::clear("caches:goods:cartCount:{$userId}");
+        return ['id' => $cartId, 'count' => $this->getCount($userId)];
+    }
+
+    /**
+     * 删除购物车
+     * @param $userId
+     * @param $cartId
+     * @return array|false
+     */
+    public function deleteCart($userId, $ids=[])
+    {
+        if($ids){
+            $this->model->where(['user_id'=>$userId,'mark'=>1])->whereIn('id', $ids)->update(['mark'=>0,'update_time'=>time()]);
+        }else{
+            $this->model->where(['user_id'=>$userId,'mark'=>1])->update(['mark' => 0,'update_time' => time()]);
+        }
+
+        RedisService::clear("caches:goods:cartCount:{$userId}");
+        return ['ids' => $ids, 'count' => $this->getCount($userId)];
+    }
+
+
+    /**
+     * 购物车数量
+     * @param $userId
+     * @return array|mixed
+     */
+    public function getCount($userId)
+    {
+        $cacheKey ="caches:goods:cartCount:{$userId}";
+        $data = RedisService::get($cacheKey);
+        if($data){
+            return $data;
+        }
+
+       $count = $this->model->where(['user_id' => $userId, 'status' => 1, 'mark' => 1])->count('id');
+        if($count){
+            RedisService::set($cacheKey, $count, 300);
+        }
+
+        return $count;
+    }
+}

+ 61 - 65
app/Services/Api/ComplaintService.php

@@ -55,93 +55,89 @@ class ComplaintService extends BaseService
     public function getDataList($params, $pageSize = 15)
     public function getDataList($params, $pageSize = 15)
     {
     {
         $where = ['a.mark' => 1];
         $where = ['a.mark' => 1];
-        $status = isset($params['status'])? $params['status'] : 0;
-        $type = isset($params['type'])? $params['type'] : 0;
-        $userType = isset($params['user_type'])? $params['user_type'] : 0;
-        if($status>0){
-            $where['a.status'] = $status;
-        }
-        if($type>0){
-            $where['a.type'] = $type;
+        $status = isset($params['status']) ? $params['status'] : 0;
+        $userId = isset($params['user_id']) ? $params['user_id'] : 0;
+        if ($userId > 0) {
+            $where['a.user_id'] = $userId;
         }
         }
-        if($userType>0){
-            $where['a.user_type'] = $userType;
+        if ($status > 0) {
+            $where['a.status'] = $status;
         }
         }
         $list = $this->model->from('complaint as a')
         $list = $this->model->from('complaint as a')
-            ->leftJoin('member as b', 'b.id','=','a.user_id')
+            ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
             ->where($where)
             ->where($where)
-            ->where(function ($query) use($params){
-                $keyword = isset($params['keyword'])? $params['keyword'] : '';
-                if($keyword){
-                    $query->where('a.content','like',"%{$keyword}%");
+            ->where(function ($query) use ($params) {
+                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
+                if ($keyword) {
+                    $query->where('a.content', 'like', "%{$keyword}%");
                 }
                 }
             })
             })
             ->select(['a.*'])
             ->select(['a.*'])
-            ->orderBy('a.create_time','desc')
+            ->orderBy('a.create_time', 'desc')
             ->paginate($pageSize > 0 ? $pageSize : 9999999);
             ->paginate($pageSize > 0 ? $pageSize : 9999999);
-        $list = $list? $list->toArray() :[];
-        if($list){
-            foreach($list['data'] as &$item){
-                $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H.i.s') : '';
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
             }
             }
         }
         }
 
 
         return [
         return [
-            'pageSize'=> $pageSize,
-            'total'=>isset($list['total'])? $list['total'] : 0,
-            'list'=> isset($list['data'])? $list['data'] : []
+            'pageSize' => $pageSize,
+            'total' => isset($list['total']) ? $list['total'] : 0,
+            'list' => isset($list['data']) ? $list['data'] : []
         ];
         ];
     }
     }
 
 
 
 
     /**
     /**
-     * 获取文章详情
-     * @param $id
-     * @return array|mixed
+     * 提交内容
+     * @param $userId
+     * @param $params
+     * @return mixed
      */
      */
-    public function getInfo($id)
+    public function submit($userId, $params)
     {
     {
-        $cacheKey = "caches:aomplaint:info_{$id}";
-        $info = RedisService::get($cacheKey);
-        if($info){
-            return $info;
+        $albums = isset($params['albums']) ? get_format_images($params['albums'], '') : '';
+        $realname = isset($params['realname']) ? trim($params['realname']) : '';
+        $mobile = isset($params['mobile']) ? trim($params['mobile']) : '';
+        $content = isset($params['content']) ? trim($params['content']) : '';
+        if (empty($realname)) {
+            $this->error = '请填写姓名';
+            return false;
+        }
+        if (empty($mobile)) {
+            $this->error = '请填写联系方式';
+            return false;
+        }
+        if (empty($content)) {
+            $this->error = '请填写您的问题';
+            return false;
+        }
+        $cacheKey = "caches:members:complaint:{$userId}";
+        if (RedisService::get($cacheKey)) {
+            $this->error = '您近期已经提交过,请30秒后重试';
+            return false;
         }
         }
 
 
-        $info = $this->model->where(['id'=> $id,'mark'=>1])
-            ->select(['id','title','albums','user_id','type','content'])
-            ->first();
-        $info = $info? $info->toArray() : [];
-        if($info){
-            $info['albums'] = $info['albums']? get_images_preview($info['albums']) : [];
-            $info['content'] = htmlspecialchars_decode($info['content']);
-            RedisService::set($cacheKey, $info, rand(5,10));
+        $data = [
+            'user_id' => $userId,
+            'realname' => $realname,
+            'mobile' => $mobile,
+            'content' => $content,
+            'albums' => $albums,
+            'create_time' => time(),
+            'update_time' => time(),
+            'status' => 1,
+            'mark' => 1,
+        ];
+        if (!$id = $this->model->insertGetId($data)) {
+            $this->error = '提交失败';
+            return false;
         }
         }
 
 
-        return $info;
+        $this->error = '提交成功';
+        RedisService::set($cacheKey, $data, 30);
+        return ['id' => $id];
     }
     }
-
-    /**
-     * 提交内容
-     * @param $userId
-     * @param $params
-     * @return mixed
-     */
-   public function submit($userId, $params)
-   {
-       $albums = isset($params['albums'])? get_format_images($params['albums'],'') : '';
-       $data = [
-           'user_id'=> $userId,
-           'title'=> isset($params['title'])? trim($params['title']) : '',
-           'user_type'=> isset($params['user_type']) && $params['user_type']? intval($params['user_type']) : 1,
-           'mobile'=> isset($params['mobile'])? trim($params['mobile']) : '',
-           'content'=> isset($params['content'])? trim($params['content']) : '',
-           'type'=> isset($params['type'])? intval($params['type']) : 1,
-           'albums'=>  $albums,
-           'create_time'=> time(),
-           'update_time'=> time(),
-           'status'=> 1,
-           'mark'=> 1,
-       ];
-       return $this->model->insertGetId($data);
-   }
 }
 }

+ 0 - 464
app/Services/Api/DepositService.php

@@ -1,464 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services\Api;
-
-use App\Models\AccountLogModel;
-use App\Models\ActionLogModel;
-use App\Models\DepositModel;
-use App\Models\MemberModel;
-use App\Models\OrderModel;
-use App\Services\BaseService;
-use App\Services\ConfigService;
-use App\Services\PaymentService;
-use App\Services\RedisService;
-use App\Services\SmsService;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 保证金订单管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Api
- */
-class DepositService extends BaseService
-{
-    // 静态对象
-    protected static $instance = null;
-
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function __construct()
-    {
-        $this->model = new DepositModel();
-    }
-
-    /**
-     * 静态入口
-     */
-    public static function make()
-    {
-        if (!self::$instance) {
-            self::$instance = new static();
-        }
-        return self::$instance;
-    }
-
-    /**
-     * 列表数据
-     * @param $params
-     * @param int $pageSize
-     * @return array
-     */
-    public function getDataList($params, $pageSize = 15)
-    {
-        $cacheKey = "caches:deposit:{$pageSize}_" . ($params ? md5(json_encode($params)) : 0);
-        $datas = RedisService::get($cacheKey);
-        if (empty($datas)) {
-            $query = $this->getQuery($params)
-                ->orderBy('a.refund_status', 'asc')
-                ->orderBy('a.id', 'desc');
-
-            $field = ["a.*"];
-            $list = $query->select($field)
-                ->paginate($pageSize > 0 ? $pageSize : 9999999);
-            $list = $list ? $list->toArray() : [];
-            if ($list) {
-                foreach ($list['data'] as &$item){
-                    $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H:i:s') : '';
-                    $item['time_text'] = $item['create_time']? datetime($item['create_time'],'Y年m月d日') : '';
-                }
-                $datas = [
-                    'pageSize' => $pageSize,
-                    'total' => isset($list['total']) ? $list['total'] : 0,
-                    'list' => isset($list['data']) ? $list['data'] : []
-                ];
-
-                RedisService::set($cacheKey, $datas, rand(3, 5));
-            }
-        }
-
-        return $datas;
-    }
-
-
-    /**
-     * 查询条件
-     * @param $params
-     * @return mixed
-     */
-    public function getQuery($params)
-    {
-        $where = ['a.status' => 0, 'a.mark' => 1];
-        $status = isset($params['status']) ? $params['status'] : 0;
-        if ($status > 0) {
-            $where['a.status'] = $status;
-        } else {
-            unset($where['a.status']);
-        }
-
-        $model = $this->model->with(['user'])->from('deposit_orders as a')
-            ->leftJoin('member as b','b.id','=','a.user_id')
-            ->where($where)
-            ->where(function ($query) use ($params) {
-                $keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
-                $refund = isset($params['refund']) ? intval($params['refund']) : 0;
-                if($refund == 1){
-                    if ($keyword) {
-                        $query->where('a.refund_no', 'like', "%{$keyword}%");
-                    }
-
-                    $query->where(['a.status'=>3])->where('a.refund_status','>',0);
-                }else{
-                    if ($keyword) {
-                        $query->where('a.order_no', 'like', "%{$keyword}%");
-                    }
-                }
-
-                // 用户
-                $account = isset($params['account']) ? trim($params['account']) : '';
-                if ($account) {
-                    $query->where(function ($query) use ($account) {
-                        $query->where('b.mobile', 'like', "%{$account}%")
-                            ->orWhere('b.nickname', 'like', "%{$account}%")
-                            ->orWhere('b.id', intval($account));
-                    });
-
-                }
-
-                $userId = isset($params['user_id']) ? intval($params['user_id']) : 0;
-                if ($userId>0) {
-                    $query->where('a.user_id', $userId);
-                }
-            });
-
-        return $model;
-    }
-
-    /**
-     * 详情信息
-     * @param $id
-     * @return mixed
-     */
-    public function getInfo($id)
-    {
-        $cacheKey = "caches:deposit:info_{$id}";
-        $info = RedisService::get($cacheKey);
-        if($info){
-            return $info;
-        }
-
-        $info = $this->model->with(['user'])->where(['id' => $id])->first();
-        $info = $info? $info->toArray() :[];
-        if($info){
-            RedisService::set($cacheKey, $info, rand(5,10));
-        }
-        return $info;
-    }
-
-    /**
-     * 充值保证金
-     * @param $userId
-     * @param $params
-     * @return array|false
-     */
-    public function pay($userId, $params)
-    {
-        // 参数验证
-        $deposit = isset($params['money'])? floatval($params['money']) : 0;
-        $payType = isset($params['pay_type'])? intval($params['pay_type']) : 0;
-        $depositMoney = ConfigService::make()->getConfigByCode('deposit_money',0);
-        if($deposit<=0 || $deposit != $depositMoney){
-            RedisService::clear("caches:config:app_ios");
-            RedisService::clear("caches:config:app_android");
-            $this->error = 2054;
-            return false;
-        }
-
-        if(!in_array($payType,[10,20])){
-            $this->error = 2055;
-            return false;
-        }
-
-        $cacheLockKey = "caches:members:deposit_pay:{$userId}";
-        if(RedisService::get($cacheLockKey)){
-            $this->error = 1034;
-            return false;
-        }
-
-        // 判断用户账号状态
-        RedisService::set($cacheLockKey, ['user_id'=>$userId,'params'=>$params], rand(10,20));
-        $userInfo = MemberService::make()->getInfo($userId,[], true);
-        $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
-        $status = isset($userInfo['status'])? $userInfo['status'] : 0;
-        if(empty($userInfo) || $status != 1){
-            $this->error = 2016;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 账号审核情况
-        if($confirmStatus != 1){
-            $this->error = 2042;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 判断用户保证金缴纳情况
-        $userDeposit = isset($userInfo['deposit'])? floatval($userInfo['deposit']) : 0;
-        $depositTotal = $this->getPayDeposit($userId);
-        if($depositTotal>0 && $userDeposit && ($userDeposit >= $depositMoney && $depositTotal >= $depositMoney)){
-            $this->error = 2053;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 是否有退保申请
-        if($this->model->where(['user_id'=>$userId,'refund_status'=>1,'pay_status'=>2,'status'=>3,'mark'=>1])->value('id')){
-            $this->error = 2644;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-
-        // 创建订单
-        $order = [
-            'order_no'=> get_order_num('DE'),
-            'user_id'=> $userId,
-            'money'=> $deposit,
-            'type'=> 1,
-            'pay_type'=> $payType,
-            'pay_status'=> 1,
-            'create_time'=> time(),
-            'status'=> 1,
-            'mark'=>1
-        ];
-
-        DB::beginTransaction();
-        if(!$orderId = $this->model->insertGetId($order)){
-            $this->error = 2056;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        /* TODO 支付处理 */
-        $payOrder = [
-            'type'=> 1,
-            'order_no'=> $order['order_no'],
-            'pay_money'=> $deposit,
-            'body'=> '充值保证金',
-        ];
-
-        // 调起支付
-        switch($payType){
-            case 20: // 支付宝
-                $payment = PaymentService::make()->aliPay($userInfo, $payOrder,'deposit');
-                if(empty($payment)){
-                    DB::rollBack();
-                    RedisService::clear($cacheLockKey);
-                    $this->error = PaymentService::make()->getError();
-                    return false;
-                }
-                break;
-            case 10: // 微信支付
-                $payment = PaymentService::make()->wechatPay($userInfo, $payOrder,'deposit');
-                if(empty($payment)){
-                    DB::rollBack();
-                    RedisService::clear($cacheLockKey);
-                    $this->error = PaymentService::make()->getError();
-                    return false;
-                }
-                break;
-            default:
-                RedisService::clear($cacheLockKey);
-                $this->error = 2035;
-                return false;
-        }
-
-        // 用户操作记录
-        DB::commit();
-        $this->error = 2122;
-        RedisService::clear($cacheLockKey);
-        return [
-            'order_id'=> $orderId,
-            'payment'=> $payment,
-            'total'=> $payOrder['pay_money'],
-            'pay_type'=> $payType,
-        ];
-    }
-
-    /**
-     * 实际有效保证金金额
-     * @param $userId 用户ID
-     * @return array|mixed
-     */
-    public function getPayDeposit($userId)
-    {
-        $cacheKey = "caches:members:deposit_check:{$userId}";
-        $data = RedisService::get($cacheKey);
-        if($data){
-            return $data;
-        }
-
-        $depositTotal = $this->model->where(['type'=>1,'user_id'=> $userId, 'pay_status'=>2,'status'=>3,'mark'=>1])
-            ->whereIn('refund_status',[0,3])
-            ->sum('money');
-        RedisService::set($cacheKey, $depositTotal, rand(5,10));
-        return $depositTotal;
-    }
-
-
-    /**
-     * 退保申请
-     * @param $userId
-     * @param $params
-     * @return false|int[]
-     */
-    public function refund($userId, $params)
-    {
-        // 参数验证
-        $depositId = isset($params['id'])? intval($params['id']) : 0;
-        $deposit = isset($params['money'])? floatval($params['money']) : 0;
-        $remark = isset($params['remark'])? trim($params['remark']) : '';
-        $cacheLockKey = "caches:members:deposit_refund:{$userId}";
-        if(RedisService::get($cacheLockKey)){
-            $this->error = 1034;
-            return false;
-        }
-
-        // 判断用户账号状态
-        RedisService::set($cacheLockKey, ['user_id'=>$userId,'params'=>$params], rand(10,20));
-        $userInfo = MemberService::make()->getInfo($userId,[], true);
-        $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
-        $status = isset($userInfo['status'])? $userInfo['status'] : 0;
-        if(empty($userInfo) || $status != 1){
-            $this->error = 2016;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 账号审核情况
-        if($confirmStatus != 1){
-            $this->error = 2042;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 验证码验证(不传不验证)
-        $mobile = isset($params['mobile'])? trim($params['mobile']) : '';
-        $smsCode = isset($params['sms_code'])? trim($params['sms_code']) : '';
-        if (!$depositId && isset($params['sms_code']) && !SmsService::make()->check($mobile, $smsCode, 'refund')) {
-            $this->error = SmsService::make()->getError();
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 判断用户保证金缴纳情况
-        $userDeposit = isset($userInfo['deposit'])? floatval($userInfo['deposit']) : 0;
-        if($depositId){
-            $depositInfo = $this->model->where(['id'=> $depositId,'type'=>1,'user_id'=> $userId, 'pay_status'=>2,'status'=>3,'mark'=>1])
-                ->whereIn('refund_status',[0,3])->orderBy('create_time','desc')->first();
-        }else{
-            $depositInfo = $this->model->where(['type'=>1,'user_id'=> $userId, 'pay_status'=>2,'status'=>3,'mark'=>1])
-                ->whereIn('refund_status',[0,3])->orderBy('create_time','desc')->first();
-            $depositId = isset($depositInfo['id'])? $depositInfo['id'] : 0;
-        }
-
-        $depositInfo = $depositInfo? $depositInfo->toArray() : [];
-        $depositTotal = isset($depositInfo['money'])? floatval($depositInfo['money']) : 0;
-        if(empty($depositInfo) || $depositId<=0 || $depositTotal<=0 || $userDeposit<=0){
-            $this->error = 2057;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        if($userDeposit > $depositTotal || $deposit != $userDeposit){
-            $this->error = 2058;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // 是否有进行中订单
-        if(OrderModel::whereIn('status',[1,2])->where(['user_id'=>$userId,'mark'=>1])->value('id')){
-            $this->error = 2062;
-            RedisService::clear($cacheLockKey);
-            return false;
-        }
-
-        // TODO 退保处理
-        DB::beginTransaction();
-
-        // 扣除
-        $updateData = [
-            'deposit'=> 0,
-            'update_time'=>time()
-        ];
-        if(!MemberModel::where(['id'=> $userId])->update($updateData)){
-            $this->error = 2059;
-            RedisService::clear($cacheLockKey);
-            DB::rollBack();
-            return false;
-        }
-
-        // 退款单数据更新
-        $depositOrderNo = $depositInfo['pay_type'] == 10? $depositInfo['order_no']: get_order_num('DR');
-        $order = [
-            'refund_at'=> date('Y-m-d H:i:s'),
-            'remark'=> $remark,
-            'refund_confirm_remark'=>'',
-            'refund_no'=> $depositOrderNo,
-            'refund_money'=> $deposit,
-            'refund_mobile'=> $mobile,
-            'refund_status'=> 1,
-            'update_time'=>time(),
-        ];
-
-        if(!$this->model->where(['id'=>$depositId])->update($order)){
-            $this->error = 2061;
-            RedisService::clear($cacheLockKey);
-            DB::rollBack();
-            return false;
-        }
-
-        $log = [
-            'user_id' => $userId,
-            'source_order_no' => $depositOrderNo,
-            'type' => 3,
-            'money' => $deposit,
-            'before_money' => $userDeposit,
-            'date'=> date('Y-m-d'),
-            'create_time' => time(),
-            'remark' => '退保申请',
-            'status' => 1,
-            'mark' => 1,
-        ];
-        if(!AccountLogModel::insertGetId($log)){
-            $this->error = 2061;
-            RedisService::clear($cacheLockKey);
-            DB::rollBack();
-            return false;
-        }
-
-        $this->error = 2060;
-        DB::commit();
-
-        // 操作日志
-        ActionLogModel::setRecord($userId,['type'=>2,'title'=>'申请退保','content'=>"手机号:{$mobile},退保金额:{$deposit}元,单号:{$depositOrderNo}",'module'=>'deposit']);
-        ActionLogModel::record();
-
-        RedisService::clear($cacheLockKey);
-        RedisService::clear("caches:deposit:info_{$depositId}");
-        return ['id'=> $depositId,'order_no'=>$depositOrderNo,'money'=>$userDeposit];
-    }
-}

+ 44 - 71
app/Services/Api/GoodsService.php

@@ -11,14 +11,13 @@
 
 
 namespace App\Services\Api;
 namespace App\Services\Api;
 
 
+use App\Models\GoodsCategoryModel;
 use App\Models\GoodsModel;
 use App\Models\GoodsModel;
-use App\Models\OrderModel;
 use App\Services\BaseService;
 use App\Services\BaseService;
 use App\Services\RedisService;
 use App\Services\RedisService;
-use wxkxklmyt\Scws;
 
 
 /**
 /**
- * 货物商品管理-服务类
+ * 商品管理-服务类
  * @author laravel开发员
  * @author laravel开发员
  * @since 2020/11/11
  * @since 2020/11/11
  * @package App\Services\Api
  * @package App\Services\Api
@@ -57,7 +56,7 @@ class GoodsService extends BaseService
      */
      */
     public function getDataList($params, $pageSize = 15)
     public function getDataList($params, $pageSize = 15)
     {
     {
-        $cacheKey = "caches:goods:picker:{$pageSize}_" . ($params ? md5(json_encode($params)) : 0);
+        $cacheKey = "caches:goods:list_{$pageSize}_" . ($params ? md5(json_encode($params)) : 0);
         $datas = RedisService::get($cacheKey);
         $datas = RedisService::get($cacheKey);
         if (empty($datas)) {
         if (empty($datas)) {
             $query = $this->getQuery($params)
             $query = $this->getQuery($params)
@@ -69,12 +68,6 @@ class GoodsService extends BaseService
                 ->paginate($pageSize > 0 ? $pageSize : 9999999);
                 ->paginate($pageSize > 0 ? $pageSize : 9999999);
             $list = $list ? $list->toArray() : [];
             $list = $list ? $list->toArray() : [];
             if ($list) {
             if ($list) {
-                foreach ($list['data'] as &$item) {
-                    $item['shipper_phone_text'] = $item['shipper_phone'] ? format_mobile($item['shipper_phone']) : '';
-                    $item['receiver_phone_text'] = $item['receiver_phone'] ? format_mobile($item['receiver_phone']) : '';
-                    $item['shipper_address'] = isset($item['shipper_address']) ? get_address($item['shipper_address']) : '';
-                    $item['receiver_address'] = isset($item['receiver_address']) ? get_address($item['receiver_address']) : '';
-                }
                 $datas = [
                 $datas = [
                     'pageSize' => $pageSize,
                     'pageSize' => $pageSize,
                     'total' => isset($list['total']) ? $list['total'] : 0,
                     'total' => isset($list['total']) ? $list['total'] : 0,
@@ -103,77 +96,62 @@ class GoodsService extends BaseService
         } else {
         } else {
             unset($where['a.status']);
             unset($where['a.status']);
         }
         }
-        $model = $this->model->from('goods as a')
+
+        $model = $this->model->with(['store','category'])
+            ->from('goods as a')
             ->where($where)
             ->where($where)
             ->where(function ($query) use ($params) {
             ->where(function ($query) use ($params) {
-                $pickerStatus = isset($params['picker_status']) ? $params['picker_status'] : 1;
-                $userId = isset($params['user_id']) ? $params['user_id'] : 0;
-                if ($pickerStatus) {
-                    $query->where(function ($query) use ($pickerStatus, $userId) {
-                        $goodsIds = OrderModel::where(function ($query) use ($userId) {
-                                $query->whereIn('status', [2, 3]);
-                                if($userId){
-                                    $query->orWhere(function($query) use($userId){
-                                        $query->where(['user_id' => $userId, 'status' => 1]);
-                                    });
-                                }
-                            })
-                            ->where('mark', 1)
-                            ->where('create_time', '>=', time() - 30 * 86400)
-                            ->pluck('goods_id');
-                        $goodsIds = $goodsIds ? array_unique($goodsIds->toArray()) : [];
-                        $query->where('a.picker_status', $pickerStatus);
-                        if ($goodsIds) {
-                            $query->whereNotIn('a.id', $goodsIds);
-                        }
+                // 分类
+                $categoryId = isset($params['category_id'])? intval($params['category_id']) : 0;
+                if($categoryId>0){
+                    $query->where('a.category_id', $categoryId);
+                }
 
 
-                    });
+                // 店铺
+                $storeId = isset($params['store_id'])? intval($params['store_id']) : 0;
+                if($storeId>0){
+                    $query->where('a.store_id', $storeId);
                 }
                 }
 
 
                 $keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
                 $keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
                 if ($keyword) {
                 if ($keyword) {
-                    $scws = new Scws();
-                    $kws = $scws->scws($keyword, 3, false);
-                    if (count($kws) > 1) {
-                        $query->where(function ($query) use ($kws) {
-                            foreach ($kws as $kw) {
-                                $kw = trim($kw);
-                                $query->where('a.goods_name', 'like', "%{$kw}%")
-                                    ->orWhere('a.car_type', 'like', "%{$kw}%");
-                            }
-                        });
-                    } else {
-                        $query->where(function ($query) use ($keyword) {
-                            $query->where('a.goods_name', 'like', "%{$keyword}%")
-                                ->orWhere('a.car_type', 'like', "%{$keyword}%");
-                        });
-                    }
-                }
-
-                // 取货人
-                $shipper = isset($params['shipper']) ? trim($params['shipper']) : '';
-                if ($shipper) {
-                    $query->where(function ($query) use ($shipper) {
-                        $query->where('a.shipper_name', 'like', "%{$shipper}%")
-                            ->orWhere('a.shipper_phone', 'like', "%{$shipper}%");
+                    $query->where(function ($query) use ($keyword) {
+                        $query->where('a.goods_name', 'like', "%{$keyword}%")
+                            ->orWhere('a.tags','like',"%{$keyword}%");
                     });
                     });
-
                 }
                 }
 
 
-                // 收货人
-                $receiver = isset($params['receiver']) ? trim($params['receiver']) : '';
-                if ($receiver) {
-                    $query->where(function ($query) use ($receiver) {
-                        $query->where('a.receiver_name', 'like', "%{$receiver}%")
-                            ->orWhere('a.receiver_phone', 'like', "%{$receiver}%");
-                    });
-                }
             });
             });
 
 
         return $model;
         return $model;
     }
     }
 
 
     /**
     /**
+     * 分类
+     * @return array|mixed
+     */
+    public function getCategoryList()
+    {
+        $cacheKey = "caches:goods:categoryList";
+        $datas = RedisService::get($cacheKey);
+        if($datas){
+            return $datas;
+        }
+
+        $datas = GoodsCategoryModel::where(['pid'=>0,'status'=>1,'mark'=>1])
+            ->select(['id','name','icon','pid','sort'])
+            ->orderBy('sort','desc')
+            ->orderBy('id','desc')
+            ->get();
+        $datas = $datas? $datas->toArray() : [];
+        if($datas){
+            RedisService::set($cacheKey, $datas, rand(300,600));
+        }
+
+        return $datas;
+    }
+
+    /**
      * 详情信息
      * 详情信息
      * @param $id
      * @param $id
      * @return mixed
      * @return mixed
@@ -186,14 +164,9 @@ class GoodsService extends BaseService
             return $info;
             return $info;
         }
         }
 
 
-        $info = $this->model->where(['id' => $id])->first();
+        $info = $this->model->with(['store','category'])->where(['id' => $id])->first();
         $info = $info ? $info->toArray() : [];
         $info = $info ? $info->toArray() : [];
         if ($info) {
         if ($info) {
-            $info['bonus'] = isset($info['price']) ? $info['price'] : 0;
-            $info['shipper_phone_text'] = isset($info['shipper_phone']) ? format_mobile($info['shipper_phone']) : '';
-            $info['receiver_phone_text'] = isset($info['receiver_phone']) ? format_mobile($info['receiver_phone']) : '';
-            $info['shipper_address'] = isset($info['shipper_address']) ? get_address($info['shipper_address']) : '';
-            $info['receiver_address'] = isset($info['receiver_address']) ? get_address($info['receiver_address']) : '';
             RedisService::set($cacheKey, $info, rand(10, 20));
             RedisService::set($cacheKey, $info, rand(10, 20));
         }
         }
         return $info;
         return $info;

+ 284 - 0
app/Services/Api/MemberAddressService.php

@@ -0,0 +1,284 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Api;
+
+use App\Models\MemberAddressModel;
+use App\Services\BaseService;
+use App\Services\RedisService;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 用户地址管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class MemberAddressService
+ * @package App\Services\Common
+ */
+class MemberAddressService extends BaseService
+{
+    // 静态对象
+    protected static $instance = null;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * MemberAddressService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new MemberAddressModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 列表数据
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 15)
+    {
+        $where = ['a.mark' => 1,'a.status'=>1];
+        $status = isset($params['status']) ? $params['status'] : 0;
+        if ($status > 0) {
+            $where['a.status'] = $status;
+        }
+        $userId = isset($params['user_id']) ? $params['user_id'] : 0;
+        if ($userId > 0) {
+            $where['a.user_id'] = $userId;
+        }
+        $list = $this->model->from('member_address as a')
+            ->where($where)
+            ->select(['a.*'])
+            ->orderBy('a.is_default', 'asc')
+            ->orderBy('a.id', 'desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
+                $address = [];
+                if($item['province']){
+                    $address[] = $item['province'];
+                }
+                if($item['city']){
+                    $address[] = $item['city'];
+                }
+                if($item['district']){
+                    $address[] = $item['district'];
+                }
+                if($item['address']){
+                    $address[] = $item['address'];
+                }
+                $item['address_text'] = $address? implode(' ',$address) : '';
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total' => isset($list['total']) ? $list['total'] : 0,
+            'list' => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 保存数据
+     * @param $userId
+     * @param $params
+     * @return mixed
+     */
+    public function saveData($userId, $params)
+    {
+        $id = isset($params['id']) ? $params['id'] : 0;
+        $isDefault = isset($params['is_default']) ? $params['is_default'] : 2;
+        $data = [
+            'user_id'=> $userId,
+            'mobile'=> isset($params['mobile'])? $params['mobile'] : '',
+            'realname'=> isset($params['realname'])? $params['realname'] : '',
+            'province'=> isset($params['province'])? $params['province'] : '',
+            'city'=> isset($params['city'])? $params['city'] : '',
+            'district'=> isset($params['district'])? $params['district'] : '',
+            'codes'=> isset($params['codes'])? $params['codes'] : '',
+            'address'=> isset($params['address'])? $params['address'] : '',
+            'is_default'=> $isDefault==1? 1: 2,
+            'status'=> isset($params['status'])? $params['status'] : 1,
+            'update_time'=> time(),
+            'mark'=> 1,
+        ];
+
+        DB::beginTransaction();
+        if($isDefault==1){
+            $this->model->where(['user_id'=> $userId])->update(['is_default'=> 2,'update_time'=> time()]);
+        }
+
+        RedisService::keyDel("caches:members:address:{$userId}*");
+        if($id && $id = $this->model->where(['id'=> $id])->value('id')){
+            $this->model->where(['id'=> $id])->update($data);
+            $this->error = '保存成功';
+            DB::commit();
+            return ['id'=>$id];
+        }else{
+            $data['create_time'] = time();
+            if(!$id = $this->model->insertGetId($data)){
+                DB::rollBack();
+                $this->error = '添加失败';
+                return false;
+            }
+
+            DB::commit();
+            $this->error = '添加成功';
+            return ['id'=>$id];
+        }
+    }
+
+    /**
+     * 默认
+     * @param $userId
+     * @param $params
+     * @return mixed
+     */
+    public function setDefault($userId, $params)
+    {
+        $id = isset($params['id']) ? $params['id'] : 0;
+        $isDefault = isset($params['is_default']) ? $params['is_default'] : 2;
+        $data = [
+            'user_id'=> $userId,
+            'is_default'=> $isDefault==1? 1: 2,
+            'update_time'=> time(),
+        ];
+
+
+        if($isDefault==1){
+            $this->model->where(['user_id'=> $userId])->update(['is_default'=> 2,'update_time'=> time()]);
+        }
+
+        $this->model->where(['id'=> $id])->update($data);
+        $this->error = '保存成功';
+        RedisService::keyDel("caches:members:address:{$userId}*");
+        return ['id'=>$id];
+    }
+
+    /**
+     * @param $id
+     * @param $userId
+     * @return array|mixed
+     */
+    public function getInfo($id, $userId)
+    {
+        $cacheKey = "caches:members:address:{$userId}_info_".($id?'_'.$id:'');
+        $info = RedisService::get($cacheKey);
+        if($info){
+            return $info;
+        }
+        $where = ['id'=> $id,'user_id'=> $userId,'mark'=>1,'status'=>1];
+        if($id<=0){
+            unset($where['id']);
+        }
+        $info = $this->model->where($where)->first();
+        $info = $info? $info->toArray() : [];
+        if($info){
+            $address = [];
+            $info['mobile_text'] = format_mobile($info['mobile']);
+            if(isset($info['province']) && $info['province']){
+                $address[] = $info['province'];
+            }
+            if(isset($info['city']) && $info['city']){
+                $address[] = $info['city'];
+            }
+            if(isset($info['district']) && $info['district']){
+                $address[] = $info['district'];
+            }
+
+            $info['area'] = $address? implode('/', $address) : '';
+            if($info['address']){
+                $address[] = $info['address'];
+            }
+            $info['address_text'] = $address? implode(' ', $address) : '';
+            RedisService::set($cacheKey, $info, rand(5, 10));
+        }
+
+        return $info;
+    }
+
+    /**
+     * @param $userId
+     * @return array|mixed
+     */
+    public function getBindInfo($userId, $addressId=0)
+    {
+        $cacheKey = "caches:members:address:{$userId}".($addressId?'_'.$addressId:'');
+        $info = RedisService::get($cacheKey);
+        if($info){
+            return $info;
+        }
+
+        $where = ['id'=> $addressId,'user_id'=> $userId,'mark'=>1,'status'=>1];
+        if($addressId<=0){
+            unset($where['id']);
+        }
+        $info = $this->model->where($where)
+            ->orderBy('is_default','asc')
+            ->orderBy('id','desc')
+            ->first();
+        $info = $info? $info->toArray() : [];
+        if($info){
+            $address = [];
+            $info['mobile_text'] = format_mobile($info['mobile']);
+            if(isset($info['province']) && $info['province']){
+                $address[] = $info['province'];
+            }
+            if(isset($info['city']) && $info['city']){
+                $address[] = $info['city'];
+            }
+            if(isset($info['district']) && $info['district']){
+                $address[] = $info['district'];
+            }
+            $info['area'] = $address? implode('/', $address) : '';
+            if($info['address']){
+                $address[] = $info['address'];
+            }
+            $info['address_text'] = $address? implode(' ', $address) : '';
+            RedisService::set($cacheKey, $info, rand(5, 10));
+        }
+
+        return $info;
+    }
+
+    /**
+     * @return array|false
+     */
+    public function delete()
+    {
+        // 参数
+        $id = request()->post('id');
+        if (empty($id)) {
+            $this->error = 2014;
+            return false;
+        }
+
+        $this->error = 1002;
+        $this->model->where(['id'=> $id,'mark'=>0])->where('update_time','<=', time() - 3*86400)->delete();
+        return $this->model->where(['id'=> $id])->update(['mark'=> 0, 'update_time'=> time()]);
+    }
+}

+ 206 - 50
app/Services/Api/MemberService.php

@@ -14,10 +14,10 @@ namespace App\Services\Api;
 use App\Helpers\Jwt;
 use App\Helpers\Jwt;
 use App\Models\ActionLogModel;
 use App\Models\ActionLogModel;
 use App\Models\BalanceLogModel;
 use App\Models\BalanceLogModel;
-use App\Models\DepositModel;
 use App\Models\MemberModel;
 use App\Models\MemberModel;
 use App\Models\OrderModel;
 use App\Models\OrderModel;
 use App\Services\BaseService;
 use App\Services\BaseService;
+use App\Services\MpService;
 use App\Services\RedisService;
 use App\Services\RedisService;
 use App\Services\SmsService;
 use App\Services\SmsService;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
@@ -142,6 +142,151 @@ class MemberService extends BaseService
     }
     }
 
 
     /**
     /**
+     * 授权登录
+     * @param $code
+     * @param array $params
+     * @return array|false
+     */
+    public function mpAuth($code, $params = [])
+    {
+        // 账号登录
+        if (empty($code)) {
+            $this->error = 1041;
+            return false;
+        }
+
+        // 获取授权用户信息
+        $phone = '';
+        $pcode = isset($params['pcode']) ? $params['pcode'] : '';
+        if ($pcode) {
+            $phoneData = MpService::make()->getPhoneNumber($pcode);
+            $phoneData = isset($phoneData['phone_info']) ? $phoneData['phone_info'] : [];
+            $phone = isset($phoneData['phoneNumber']) ? $phoneData['phoneNumber'] : '';
+        }
+
+        if (empty($phone)) {
+            $this->error = MpService::make()->getError();
+            return false;
+        }
+        
+        $userInfo = MpService::make()->getUserInfo($code);
+        $openid = isset($userInfo['openid']) ? $userInfo['openid'] : '';
+        if (empty($userInfo)) {
+            $this->error = MpService::make()->getError();
+            return false;
+        }
+
+        if (empty($openid)) {
+            $this->error = 1042;
+            return false;
+        }
+
+        // 验证是否注册,没有则注册
+        $where = ['mobile' => $phone];
+        $data = $this->model->where($where)
+            ->select(['id', 'openid', 'mobile', 'user_type', 'nickname','avatar', 'code', 'status','mark'])
+            ->first();
+        $data = $data ? $data->toArray() : [];
+        $userId = isset($data['id']) ? $data['id'] : 0;
+        $avatar = isset($data['avatar']) ? $data['avatar'] : '';
+        $nickName = isset($data['nickname']) ? $data['nickname'] : '';
+        $status = isset($data['status']) ? $data['status'] : 0;
+        $mark = isset($data['mark']) ? $data['mark'] : 0;
+        if ($data && $userId && $status != 1 && $mark==1) {
+            $this->error = 2011;
+            return false;
+        }
+
+
+        $system = isset($params['system']) ? $params['system'] : [];
+        $system = $system && !is_array($system) ? json_decode($system, true) : $system;
+        $appSources = isset($system['app_sources']) && $system['app_sources'] ? $system['app_sources'] : 'ios';
+        $uuid = isset($system['uuid']) ? $system['uuid'] : '';
+        $version = isset($system['app_version']) ? $system['app_version'] : '';
+        if (empty($data)) {
+            $userId = $this->model->max('id') + 1;
+
+            // 推荐人
+            $rid = isset($params['rid'])? intval($params['rid']) : 0;
+            $parents = '';
+            if($rid){
+                $inviteInfo = $this->model->where(['id'=> $rid,'mark'=>1])
+                    ->select(['id','parent_id','parents','status'])
+                    ->first();
+                $parents = isset($inviteInfo['parents'])? $inviteInfo['parents'] : '';
+                if($inviteInfo){
+                    $parents = $parents? $parents.$rid.',' : ",{$rid},";
+                }
+            }
+
+
+            $data = [
+                'nickname' => $phone ? '用户' . substr($phone, -6, 6) : '用户' . $userId,
+                'openid' => $openid,
+                'mobile' => $phone,
+                'avatar' => '',
+                'parent_id' => $rid,
+                'parents' => $parents,
+                'code' => get_random_code(9, 'S', $userId),
+                'password' => $phone ? get_password(substr($phone, -6, 6)) : get_password('123456'),
+                'login_ip' => get_client_ip(),
+                'create_time' => time(),
+                'login_time' => time(),
+                'login_count' => DB::raw("login_count+1"),
+                'app_version' => $version,
+                'app_uuid' => $uuid,
+                'device' => $appSources == 'ios' ? 1 : 2,
+            ];
+            if (!$userId = $this->model->insertGetId($data)) {
+                $this->error = 2012;
+                return false;
+            }
+        } // 更新登录信息
+        else if ($mark==0 || !RedisService::get("caches:members:login_{$userId}")) {
+            $updateData = [
+                'login_ip' => get_client_ip(),
+                'create_time' => time(),
+                'login_time' => time(),
+                'app_uuid' => $uuid,
+                'login_count' => DB::raw("login_count+1"),
+                'app_version' => $version,
+                'device' => $appSources == 'ios' ? 1 : 2,
+                'mark' => 1,
+            ];
+            if ($openid) {
+                $updateData['openid'] = $openid;
+            }
+
+            if($mark==0){
+                $data['mobile'] = $phone;
+                $data['openid'] = $openid;
+                $avatar = '';
+                $nickName = '';
+            }
+            $this->model->where(['id' => $userId])->update($updateData);
+            RedisService::set("caches:members:login_{$userId}", $updateData, rand(180, 300));
+        }
+
+        // 获取登录授权token
+        $jwt = new Jwt('jwt_jd_app');
+        $token = $jwt->getToken($userId);
+
+        // 结果返回
+        $result = [
+            'access_token' => $token,
+            'info' => ['uid' => $userId, 'openid' => $openid, 'has_info' => $avatar && $nickName?1 :0, 'nickname' => $data['nickname']],
+        ];
+
+        // 用户缓存信息
+        $this->error = 2013;
+        $data['token'] = $token;
+        unset($data['mobile']);
+        RedisService::set("auths:info:{$userId}", $data, 24 * 3600);
+        return $result;
+
+    }
+
+    /**
      * 重置密码
      * 重置密码
      * @param $params
      * @param $params
      * @return array|false
      * @return array|false
@@ -280,6 +425,61 @@ class MemberService extends BaseService
         return $result;
         return $result;
     }
     }
 
 
+    /**
+     * 设置资料
+     * @param $userId
+     * @param $params
+     * @return bool
+     */
+    public function setEntry($userId, $params)
+    {
+        $cacheLockKey = "caches:members:profile_{$userId}";
+        if (RedisService::get($cacheLockKey)) {
+            $this->error = 1034;
+            return false;
+        }
+
+        // 用户验证
+        RedisService::set($cacheLockKey, ['user_id' => $userId, 'params' => $params], rand(2, 3));
+        $info = $this->model->where(['id' => $userId, 'mark' => 1])
+            ->select(['id', 'password', 'status'])
+            ->first();
+        if (!$info || $info['status'] != 1) {
+            $this->error = 1043;
+            RedisService::clear($cacheLockKey);
+            return false;
+        }
+
+        // 获取头像
+        $avatar = '';
+        if(isset($params['avatar']) && $params['avatar']){
+           $avatar = save_base64_image($params['avatar'],'avatar');
+        }
+
+        //
+        $data = [
+            'avatar' => $avatar,
+            'nickname' => isset($params['nickname']) ? trim($params['nickname']) : '',
+            'update_time' => time()
+        ];
+
+        if (isset($params['province']) && $params['city']) {
+            $data['province'] = isset($params['province']) ? trim($params['province']) : '';
+            $data['city'] = isset($params['city']) ? trim($params['city']) : '';
+            $data['district'] = isset($params['district']) ? trim($params['district']) : '';
+        }
+
+        if (!$this->model->where(['id' => $userId])->update($data)) {
+            $this->error = 1020;
+            RedisService::clear($cacheLockKey);
+            return false;
+        }
+
+        $this->error = 1019;
+        RedisService::clear($cacheLockKey);
+        return true;
+    }
+
 
 
     /**
     /**
      * 注册资料重新提交
      * 注册资料重新提交
@@ -334,38 +534,6 @@ class MemberService extends BaseService
             $data['realname'] = $realname;
             $data['realname'] = $realname;
         }
         }
 
 
-        $carType = isset($params['car_type']) ? trim($params['car_type']) : '';
-        if (isset($params['car_type']) && $carType) {
-            $data['car_type'] = $carType;
-        }
-
-        $carNumber = isset($params['car_number']) ? trim($params['car_number']) : '';
-        if (isset($params['car_number']) && $carNumber) {
-            $data['car_number'] = $carNumber;
-        }
-
-        // 驾驶证
-        $drivingLicense = isset($params['driving_license']) && $params['driving_license']? get_image_path($params['driving_license']) : '';
-        if (isset($params['driving_license'])){
-            if(empty($drivingLicense)) {
-                $this-> error = 2007;
-                return false;
-            }
-
-            $data['driving_license'] = $drivingLicense;
-        }
-
-        // 行驶证
-        $driversLicense = isset($params['drivers_license']) && $params['drivers_license']? get_image_path($params['drivers_license'])  : '';
-        if(isset($params['drivers_license'])){
-            if (empty($driversLicense)) {
-                $this-> error = 2008;
-                return false;
-            }
-
-            $data['drivers_license'] = $driversLicense;
-        }
-
         if (!$this->model->where(['id' => $userId])->update($data)) {
         if (!$this->model->where(['id' => $userId])->update($data)) {
             $this->error = 2010;
             $this->error = 2010;
             RedisService::clear($cacheLockKey);
             RedisService::clear($cacheLockKey);
@@ -395,12 +563,12 @@ class MemberService extends BaseService
             return $info;
             return $info;
         }
         }
 
 
-        $defaultField = ['id', 'user_type', 'realname', 'mobile', 'nickname','balance','deposit', 'code', 'openid','picker_status','confirm_status', 'status', 'avatar'];
+        $defaultField = ['id', 'user_type', 'realname', 'mobile', 'nickname','balance', 'code', 'openid', 'status', 'avatar'];
         $field = $field ? $field : $defaultField;
         $field = $field ? $field : $defaultField;
         if (is_array($where)) {
         if (is_array($where)) {
-            $info = $this->model->where(['mark' => 1])->where($where)->select($field)->first();
+            $info = $this->model->with(['store','agent'])->where(['mark' => 1])->where($where)->select($field)->first();
         } else {
         } else {
-            $info = $this->model->where(['mark' => 1])->where(['id' => (int)$where])->select($field)->first();
+            $info = $this->model->with(['store','agent'])->where(['mark' => 1])->where(['id' => (int)$where])->select($field)->first();
         }
         }
 
 
         $info = $info ? $info->toArray() : [];
         $info = $info ? $info->toArray() : [];
@@ -409,14 +577,6 @@ class MemberService extends BaseService
                 $info['avatar'] = $info['avatar'] ? get_image_url($info['avatar']) : '';
                 $info['avatar'] = $info['avatar'] ? get_image_url($info['avatar']) : '';
             }
             }
 
 
-            if (isset($info['driving_license'])) {
-                $info['driving_license'] = $info['driving_license'] ? get_image_url($info['driving_license']) : '';
-            }
-
-            if (isset($info['drivers_license'])) {
-                $info['drivers_license'] = $info['drivers_license'] ? get_image_url($info['drivers_license']) : '';
-            }
-
             if (isset($info['mobile'])) {
             if (isset($info['mobile'])) {
                 $info['mobile_text'] = $info['mobile'] ? format_mobile($info['mobile']) : '';
                 $info['mobile_text'] = $info['mobile'] ? format_mobile($info['mobile']) : '';
             }
             }
@@ -425,12 +585,8 @@ class MemberService extends BaseService
                 $info['create_at'] = datetime(strtotime($info['create_time']));
                 $info['create_at'] = datetime(strtotime($info['create_time']));
             }
             }
 
 
-            if(isset($info['confirm_remark'])){
-                $info['confirm_remark'] = $info['confirm_remark']?format_content($info['confirm_remark']):'';
-            }
-
-            $info['unread_count'] = intval(MessageService::make()->getUnreadCount($info['id']));
-
+            $info['store'] = isset($info['store'])? $info['store'] : [];
+            $info['agent'] = isset($info['agent'])? $info['agent'] : [];
             RedisService::set($cacheKey, $info, rand(30, 60));
             RedisService::set($cacheKey, $info, rand(30, 60));
         }
         }
 
 

+ 24 - 1
app/Services/Api/OrderService.php

@@ -315,7 +315,7 @@ class OrderService extends BaseService
      */
      */
     public function getCountByDay($userId, $status=3)
     public function getCountByDay($userId, $status=3)
     {
     {
-        $cacheKey = "caches:accounts:count_{$userId}_{$status}";
+        $cacheKey = "caches:orders:count_day_{$userId}_{$status}";
         $data = RedisService::get($cacheKey);
         $data = RedisService::get($cacheKey);
         if($data){
         if($data){
             return $data;
             return $data;
@@ -332,6 +332,29 @@ class OrderService extends BaseService
     }
     }
 
 
     /**
     /**
+     * 订单数
+     * @param $userId
+     * @param int $status
+     * @return array|mixed
+     */
+    public function getCountByStatus($userId, $status=3)
+    {
+        $cacheKey = "caches:orders:count_status_{$userId}_{$status}";
+        $data = RedisService::get($cacheKey);
+        if($data){
+            return $data;
+        }
+
+        $data = $this->model->where(['user_id'=> $userId,'status'=>$status,'mark'=>1])
+            ->count('id');
+        if($data){
+            RedisService::set($cacheKey, $data, rand(5,10));
+        }
+
+        return $data;
+    }
+
+    /**
      * 获取订单审核状态
      * 获取订单审核状态
      * @param $userId
      * @param $userId
      * @return array|mixed
      * @return array|mixed

+ 271 - 0
app/Services/Api/StoreService.php

@@ -0,0 +1,271 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Api;
+
+use App\Models\StoreCategoryModel;
+use App\Models\StoreModel;
+use App\Services\BaseService;
+use App\Services\RedisService;
+
+/**
+ * 商家管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Services\Common
+ */
+class StoreService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        $this->model = new StoreModel();
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 15)
+    {
+        $where = ['a.mark' => 1];
+        $status = isset($params['status']) ? $params['status'] : 0;
+        if ($status > 0) {
+            $where['a.status'] = $status;
+        }
+        $list = $this->model->with(['user'])->from('stores as a')
+            ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
+            ->where($where)
+            ->where(function ($query) use ($params) {
+                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
+                if ($keyword) {
+                    $query->where('a.name', 'like', "%{$keyword}%");
+                }
+            })
+            ->select(['a.*'])
+            ->orderBy('a.create_time', 'desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
+            }
+        }
+
+        return [
+            'pageSize' => $pageSize,
+            'total' => isset($list['total']) ? $list['total'] : 0,
+            'list' => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 商品列表
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getGoodsList($params, $pageSize = 15)
+    {
+        $page = request()->post('page',1);
+        $cacheKey = "caches:goods:index_{$page}_{$pageSize}:".md5(json_encode($params));
+        $list = RedisService::get($cacheKey);
+        if($list){
+            return [
+                'pageSize' => $pageSize,
+                'total' => isset($list['total']) ? $list['total'] : 0,
+                'list' => isset($list['data']) ? $list['data'] : []
+            ];
+        }
+        $where = ['a.mark' => 1];
+        $status = isset($params['status']) && $params['status']>0 ? $params['status'] : 1;
+        if ($status > 0) {
+            $where['a.status'] = $status;
+        }
+        $list = $this->model->with(['goods'])->from('stores as a')
+            ->leftJoin('goods as b', function($join){
+                $join->on('b.store_id', '=', 'a.id')->where(['b.status'=>1,'b.mark'=>1]);
+            })
+            ->where($where)
+            ->where('b.id','>',0)
+            ->where(function ($query) use ($params) {
+                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
+                if ($keyword) {
+                    $query->where('a.name', 'like', "%{$keyword}%")
+                        ->orWhere('b.goods_name', 'like', "%{$keyword}%")
+                        ->orWhere('b.tags', 'like', "%{$keyword}%");
+                }
+            })
+            ->select(['a.id','a.logo','a.name','a.user_id','a.status','b.id as goods_id'])
+            ->groupBy('a.id')
+            ->orderBy('a.sort', 'desc')
+            ->orderBy('a.id', 'desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
+            foreach ($list['data'] as &$item) {
+                $item['goods'] = isset($item['goods']) && $item['goods'] ? array_slice($item['goods'],0,6) : [];
+            }
+        }
+        $total = isset($list['total']) ? $list['total'] : 0;
+        if($total){
+            RedisService::set($cacheKey, $list, rand(5,10));
+        }
+        return [
+            'pageSize' => $pageSize,
+            'total' => isset($list['total']) ? $list['total'] : 0,
+            'list' => isset($list['data']) ? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 行业分类
+     * @return array|mixed
+     */
+    public function getCategoryList()
+    {
+        $cacheKey = "caches:stores:categoryList";
+        $datas = RedisService::get($cacheKey);
+        if($datas){
+            return $datas;
+        }
+
+        $datas = StoreCategoryModel::where(['pid'=>0,'status'=>1,'mark'=>1])
+            ->select(['id','name','pid','sort'])
+            ->orderBy('sort','desc')
+            ->orderBy('id','desc')
+            ->get();
+        $datas = $datas? $datas->toArray() : [];
+        if($datas){
+            RedisService::set($cacheKey, $datas, rand(300,600));
+        }
+
+        return $datas;
+    }
+
+
+    /**
+     * 申请
+     * @param $userId
+     * @param $params
+     * @return mixed
+     */
+    public function apply($userId, $params)
+    {
+        $name = isset($params['name']) ? trim($params['name']) : '';
+        $realname = isset($params['real_name']) ? trim($params['real_name']) : '';
+        $phone = isset($params['phone']) ? trim($params['phone']) : '';
+        $address = isset($params['address']) ? trim($params['address']) : '';
+        $categoryId = isset($params['category_id']) ? intval($params['category_id']) : 0;
+        $logo = isset($params['logo']) && $params['logo']? get_image_path($params['logo']) : '';
+        $businessLicense = isset($params['business_license']) && $params['business_license']? get_image_path($params['business_license']) : '';
+        $otherPhoto = isset($params['other_photo']) && $params['other_photo']? get_image_path($params['other_photo']) : '';
+
+        $data = [
+            'user_id' => $userId,
+            'name' => $name,
+            'real_name' => $realname,
+            'phone' => $phone,
+            'address' => $address,
+            'category_id' => $categoryId,
+            'logo' => $logo,
+            'business_license' => $businessLicense,
+            'other_photo' => $otherPhoto,
+            'order_count' => 0,
+            'order_total' => 0,
+            'confirm_remark' => '',
+            'create_time' => time(),
+            'update_time' => time(),
+            'status' => 2,
+            'mark' => 1,
+        ];
+
+
+        if($id = $this->model->where(['user_id'=>$userId])->value('id')){
+            $this->model->where(['id'=>$id])->update($data);
+        }else{
+            if (!$id = $this->model->insertGetId($data)) {
+                $this->error = '申请入驻失败';
+                return false;
+            }
+        }
+
+        RedisService::keyDel("caches:members:info_*");
+        RedisService::keyDel("caches:stores:info*");
+        $this->error = '申请入驻成功,请耐心等候审核~';
+        return ['id' => $id];
+    }
+
+    /**
+     * 入驻信息
+     * @param $id
+     * @param $userId
+     * @return array|mixed
+     */
+    public function getApplyInfo($userId)
+    {
+        $cacheKey = "caches:stores:info_u{$userId}";
+        $info = RedisService::get($cacheKey);
+        if($info){
+            return $info;
+        }
+        $where = ['user_id'=> $userId,'mark'=>1];
+        $info = $this->model->with(['category'])->where($where)->first();
+        $info = $info? $info->toArray() : [];
+        if($info){
+            $info['category_name'] = isset($info['category']) && $info['category']?$info['category']['name'] : '';
+            RedisService::set($cacheKey, $info, rand(5, 10));
+        }
+
+        return $info;
+    }
+
+    /**
+     * 店铺详情
+     * @param $id
+     * @param $userId
+     * @return array|mixed
+     */
+    public function getInfo($id)
+    {
+        $cacheKey = "caches:stores:info_{$id}";
+        $info = RedisService::get($cacheKey);
+        if($info){
+            return $info;
+        }
+        $where = ['id'=> $id,'mark'=>1];
+        $info = $this->model->with(['category'])->where($where)->first();
+        $info = $info? $info->toArray() : [];
+        if($info){
+            $info['category_name'] = isset($info['category']) && $info['category']?$info['category']['name'] : '';
+            RedisService::set($cacheKey, $info, rand(5, 10));
+        }
+
+        return $info;
+    }
+}

+ 19 - 2
app/Services/Common/MenuService.php

@@ -13,6 +13,9 @@ namespace App\Services\Common;
 
 
 
 
 use App\Models\MenuModel;
 use App\Models\MenuModel;
+use App\Models\ActionLogModel;
+use App\Models\RoleModel;
+use App\Models\UserRoleModel;
 use App\Services\BaseService;
 use App\Services\BaseService;
 
 
 /**
 /**
@@ -216,7 +219,8 @@ class MenuService extends BaseService
     public function getPermissionList($userId)
     public function getPermissionList($userId)
     {
     {
         $list = [];
         $list = [];
-        if ($userId == 1) {
+        $check = UserRoleModel::where(['user_id'=>$userId,'role_id'=>1])->value('role_id');
+        if ($userId == 1 || $check) {
             // 管理员拥有全部权限
             // 管理员拥有全部权限
             $list = $this->model->getChilds(0);
             $list = $this->model->getChilds(0);
         } else {
         } else {
@@ -271,7 +275,8 @@ class MenuService extends BaseService
     public function getPermissionsList($userId)
     public function getPermissionsList($userId)
     {
     {
         $list = [];
         $list = [];
-        if ($userId == 1) {
+        $check = UserRoleModel::where(['user_id'=>$userId,'role_id'=>1])->value('role_id');
+        if ($userId == 1 && $check) {
             // 管理员拥有全部权限
             // 管理员拥有全部权限
             $permissionList = $this->model
             $permissionList = $this->model
                 ->select("permission")
                 ->select("permission")
@@ -301,4 +306,16 @@ class MenuService extends BaseService
         return array_filter(array_values($list));
         return array_filter(array_values($list));
     }
     }
 
 
+    /**
+     * 删除七天之前标记软删除的数据
+     */
+    public function delete()
+    {
+        // 设置日志标题
+        ActionLogModel::setRecord(session('userId'), ['type' => 1, 'title' => "删除菜单信息", 'content' => json_encode(request()->post(), 256), 'module' => 'admin']);
+        ActionLogModel::record();
+        $this->model->where('mark', 0)->where('update_time', '<=', time() - 7 * 86400)->delete();
+        return parent::delete();
+    }
+
 }
 }

+ 4 - 2
app/Services/Common/RoleService.php

@@ -14,6 +14,7 @@ namespace App\Services\Common;
 use App\Models\MenuModel;
 use App\Models\MenuModel;
 use App\Models\RoleMenuModel;
 use App\Models\RoleMenuModel;
 use App\Models\RoleModel;
 use App\Models\RoleModel;
+use App\Models\UserRoleModel;
 use App\Services\BaseService;
 use App\Services\BaseService;
 
 
 /**
 /**
@@ -59,7 +60,7 @@ class RoleService extends BaseService
      * @since 2020/11/11
      * @since 2020/11/11
      * @author laravel开发员
      * @author laravel开发员
      */
      */
-    public function getPermissionList()
+    public function getPermissionList($userId=0)
     {
     {
         // 请求参数
         // 请求参数
         $param = request()->all();
         $param = request()->all();
@@ -82,8 +83,9 @@ class RoleService extends BaseService
             $roleMenuModel = new RoleMenuModel();
             $roleMenuModel = new RoleMenuModel();
             $roleMenuList = $roleMenuModel->where("role_id", $roleId)->get("menu_id")->toArray();
             $roleMenuList = $roleMenuModel->where("role_id", $roleId)->get("menu_id")->toArray();
             $menuIdList = array_key_value($roleMenuList, "menu_id");
             $menuIdList = array_key_value($roleMenuList, "menu_id");
+            $check = UserRoleModel::where(['user_id'=>$userId,'role_id'=>1])->value('role_id');
             foreach ($menuList as &$val) {
             foreach ($menuList as &$val) {
-                if (in_array($val['id'], $menuIdList)) {
+                if (in_array($val['id'], $menuIdList) || $check) {
                     $val['checked'] = true;
                     $val['checked'] = true;
                     $val['open'] = true;
                     $val['open'] = true;
                 }
                 }

+ 373 - 0
app/Services/MpService.php

@@ -0,0 +1,373 @@
+<?php
+
+namespace App\Services;
+
+/**
+ * 微信服务管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class WechatService
+ * @package App\Services
+ */
+class MpService extends BaseService
+{
+    // 静态对象
+    protected static $instance = null;
+
+    protected $debug = true;
+    protected $expireTime = 7200; // 缓存日志时长
+    protected $mpAppid = '';
+    protected $mpAppSecret = '';
+
+    // 接口地址
+    protected $apiUrls = [
+        // 授权登录
+        'auth'=> 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code',
+        // 授权跳转地址
+        'authorize'=>'https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=%s#wechat_redirect',
+        // 获取token
+        'getToken'=>'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s',
+        // 获取二维码
+        'getQrcode'=>'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%s&scene=%s&page=%s&env_version=%s',
+        // 获取用户信息
+        'getUserInfo'=>'https://api.weixin.qq.com/sns/jscode2session',
+        // 获取手机号
+        'getPhoneNumber'=>'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s',
+    ];
+
+
+    public function __construct()
+    {
+        $this->mpAppid = ConfigService::make()->getConfigByCode('wechat_mp_appid');
+        $this->mpAppSecret = ConfigService::make()->getConfigByCode('wechat_mp_appsecret');
+    }
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if (!self::$instance) {
+            self::$instance = new static();
+        }
+
+        return self::$instance;
+    }
+
+    /**
+     * web 授权
+     * @param $code
+     * @return array|false|mixed|string|string[]
+     */
+    public function auth($code)
+    {
+        try {
+
+
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            // 没有code参数
+            if(empty($code)){
+                $uri=urlencode(env("WEB_URL")."/v1/mpAuth");
+                $state=get_random_code(16);
+                $url= sprintf($this->apiUrls['authorize'], $this->mpAppid, $this->mpAppSecret, $uri, $state);
+                return redirect($url);
+            }
+
+            $cacheKey = "caches:mpApp:mp_{$this->mpAppid}:";
+            $url = sprintf($this->apiUrls['auth'],$this->mpAppid, $this->mpAppSecret, $code);
+            $result = httpRequest($url, '', 'get','',5);
+            $this->saveLog($cacheKey.'auth:request', ['url'=>$url,'code'=>$code,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            if(empty($result)){
+                $this->error = '授权登录失败';
+                return "<script>alert('微信授权失败');window.close()</script>";
+            }
+            return $result;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'auth:error', ['code'=>$code,'error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+    /**
+     * 获取 access_token
+     * @param false $refresh
+     * @return false|mixed|string
+     */
+    public function getAccessToken($refresh = false)
+    {
+        try {
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            $cacheKey = "caches:mpApp:mp_{$this->mpAppid}:";
+            $tokenData = RedisService::get($cacheKey.'access_token');
+            $token = isset($tokenData['access_token'])? $tokenData['access_token'] : '';
+            if($token && !$refresh){
+                return $token;
+            }
+
+            $url = sprintf($this->apiUrls['getToken'], $this->mpAppid, $this->mpAppSecret);
+            $result = httpRequest($url,'', 'get','',5);
+            $this->saveLog($cacheKey.'tokens:request', ['url'=>$url,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            $token = isset($result['access_token'])? $result['access_token'] : '';
+            if(empty($result) || empty($token)){
+                $this->error = '获取小程序TOKEN失败';
+                return false;
+            }
+
+            $result['date'] = date('Y-m-d H:i:s');
+            RedisService::set($cacheKey.'access_token', $result, 7000);
+            return $token;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'tokens:error', ['error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+    /**
+     * 小程序二维码
+     * @param $page 页面
+     * @param $scene 场景参数
+     * @param string $version 类型:release-永久
+     * @param false $refresh
+     * @return false|string
+     */
+    public function getMiniQrcode($page, $scene, $version='release', $refresh=false)
+    {
+        if (!in_array($version,['release','trial','develop'])) {
+            $version='release';
+        }
+
+        try {
+            if(empty($page) || empty($scene)){
+                $this->error = '缺少二维码参数';
+                return false;
+            }
+
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            if(!$token = $this->getAccessToken())
+            {
+                $this->error = '获取token失败';
+                return false;
+            }
+
+            $cacheKey = "caches:mpQrcode:mp_{$this->mpAppid}:";
+            $filePath = base_path('public/uploads');
+            $qrFile = '/qrcodes/mp_'.date("YmdHis")."_".md5($page.$scene).".png";
+            $qrKey = md5($qrFile);
+            if(RedisService::get($cacheKey.$qrKey) && file_exists($filePath.'/'.$qrFile) && !$refresh){
+                return $qrFile;
+            }
+
+            if(!is_dir($filePath.'/qrcodes/')){
+                @mkdirs($filePath.'/qrcodes/');
+            }
+
+            $url = sprintf($this->apiUrls['getQrcode'], $token, $scene, $page, $version);
+            $result = curl_post($url, '');
+            $datas = $result? json_decode($result, true) : [];
+            $this->saveLog($cacheKey.'qrcode:request', ['page'=>$page,'scene'=>$scene,'url'=>$url,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            $errcode = isset($datas['errcode'])? $datas['errcode'] : '';
+            $errmsg = isset($datas['errmsg'])? $datas['errmsg'] : '';
+            if($errcode){
+                $this->error = $errmsg? $errmsg : '获取二维码失败';
+                return false;
+            }
+
+            file_put_contents($filePath.'/'.$qrFile, $result);
+            if(!file_exists($filePath.'/'.$qrFile)){
+                $this->error = '保存二维码失败';
+                return false;
+            }
+
+            $result['date'] = date('Y-m-d H:i:s');
+            RedisService::set($cacheKey.$qrKey, ['page'=>$page,'scene'=>$scene,'qrcode'=>$qrFile,'date'=>date('Y-m-d H:i:s')], 30 * 86400);
+            return $qrFile;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'qrcode:error', ['page'=>$page,'scene'=>$scene,'error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+    /**
+     * 获取用户信息
+     * @param $code
+     * @return array|false|mixed|string[]
+     */
+    public function getUserinfo($code)
+    {
+        try {
+            if(empty($code)){
+                $this->error = '缺少授权参数';
+                return false;
+            }
+
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            $data=[
+                'appid' => $this->mpAppid,
+                'secret'=> $this->mpAppSecret,
+                'js_code'=>$code,
+                'grant_type'=>'authorization_code'
+            ];
+            $cacheKey = "caches:mpApp:mp_{$this->mpAppid}:";
+            $url = $this->apiUrls['getUserInfo'];
+            $result = httpRequest($url, $data,'get','',5);
+            $this->saveLog($cacheKey.'userInfo:request', ['code'=>$code,'url'=>$url,'query'=>$data,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            if(empty($result)){
+                $this->error = '获取用户信息失败';
+                return false;
+            }
+            return $result;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'userInfo:error', ['code'=>$code,'error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+    /**
+     * 获取用户手机号码
+     * @param $code
+     * @return array|false|mixed|string[]
+     */
+    public function getPhoneNumber($code)
+    {
+        try {
+            if(empty($code)){
+                $this->error = '缺少授权参数';
+                return false;
+            }
+
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            if(!$token = $this->getAccessToken())
+            {
+                $this->error = '获取token失败';
+                return false;
+            }
+
+            $cacheKey = "caches:mpApp:mp_{$this->mpAppid}:";
+            $url = sprintf($this->apiUrls['getPhoneNumber'], $token);
+            $result = httpRequest($url, json_encode(['code'=>$code],256),'post','',5);
+            $this->saveLog($cacheKey.'phone:request', ['code'=>$code,'url'=>$url,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            if(empty($result)){
+                $this->error = '获取用户手机号失败';
+                return false;
+            }
+            return $result;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'phone:error', ['code'=>$code,'error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+    /**
+     * 获取 客服接口 access_token
+     * @param false $refresh
+     * @return false|mixed|string
+     */
+    public function getServiceToken($refresh = false)
+    {
+        try {
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            $cacheKey = "caches:mpApp:mp_{$this->mpAppid}:";
+            $tokenData = RedisService::get($cacheKey.'kf_access_token');
+            $token = isset($tokenData['access_token'])? $tokenData['access_token'] : '';
+            if($token && !$refresh){
+                return $token;
+            }
+
+            $url = sprintf($this->apiUrls['getServiceToken'], $this->mpAppid, $this->mpAppSecret);
+            $result = httpRequest($url,'', 'get','',5);
+            $this->saveLog($cacheKey.'kfTokens:request', ['url'=>$url,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            $token = isset($result['access_token'])? $result['access_token'] : '';
+            if(empty($result) || empty($token)){
+                $this->error = '获取小程序客服TOKEN失败';
+                return false;
+            }
+
+            $result['date'] = date('Y-m-d H:i:s');
+            RedisService::set($cacheKey.'kf_access_token', $result, 7000);
+            return $token;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'kfTokens:error', ['error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+    /**
+     * 获取客服地址
+     * @return array|false|mixed|string[]
+     */
+    public function getServiceUrl()
+    {
+        try {
+            if(empty($this->mpAppid) || empty($this->mpAppSecret)){
+                $this->error = '小程序参数未配置';
+                return false;
+            }
+
+            if(!$token = $this->getServiceToken())
+            {
+                $this->error = '获取token失败';
+                return false;
+            }
+
+            $cacheKey = "caches:mpApp:mp_{$this->mpAppid}:";
+            $url = sprintf($this->apiUrls['getServiceUrl'], $token);
+            $result = httpRequest($url, '','post','',5);
+            $this->saveLog($cacheKey.'service:request', ['url'=>$url,'result'=>$result,'date'=>date('Y-m-d H:i:s')]);
+            if(empty($result)){
+                $this->error = '获取小程序客服地址失败';
+                return false;
+            }
+            return $result;
+        }catch (\Exception $e){
+            $this->error = $e->getMessage();
+            $this->saveLog($cacheKey.'service:error', ['error'=>$this->error,'trace'=>$e->getTrace(),'date'=>date('Y-m-d H:i:s')]);
+            return false;
+        }
+    }
+
+
+    /**
+     * 保存日志
+     * @param $cackekey
+     * @param $data
+     * @param $time
+     */
+    public function saveLog($cackekey, $data, $time=0)
+    {
+        if($this->debug){
+            RedisService::set($cackekey, $data, $time?$time : $this->expireTime);
+        }
+    }
+
+}

二進制
public/favicon.ico


+ 13 - 95
resources/lang/zh-cn/api.php

@@ -22,8 +22,8 @@ return [
     '1020' => '设置失败',
     '1020' => '设置失败',
     '1021' => '参数类型错误',
     '1021' => '参数类型错误',
     '1022' => '参数值错误',
     '1022' => '参数值错误',
-    '1023' => '发布成功',
-    '1024' => '发布失败',
+    '1023' => '提交成功',
+    '1024' => '提交失败',
     '1025' => '删除成功',
     '1025' => '删除成功',
     '1026' => '删除失败',
     '1026' => '删除失败',
     '1027' => '添加成功',
     '1027' => '添加成功',
@@ -36,90 +36,20 @@ return [
     '1038' => '账号未注册',
     '1038' => '账号未注册',
     '1039' => '请输入新密码',
     '1039' => '请输入新密码',
     '1040' => '账号被使用',
     '1040' => '账号被使用',
-    '1041' => '请填写账号或密码',
+    '1041' => '缺少微信授权码',
+    '1042' => '授权登录错误',
+    '1043' => '操作失败,请返回重试~',
+    '1045' => '操作失败,该账户已被冻结,请联系客服~',
+    '1046' => '服务器错误',
 
 
     // 账户
     // 账户
-    '2001' => '账号错误',
-    '2002' => '账号已注册',
-    '2003' => '注册失败',
-    '2004' => '注册成功',
-    '2005' => '短信验证码发送成功',
-    '2006' => '短信验证码发送失败',
-    '2007' => '请先上传驾驶证',
-    '2008' => '请先上传行驶证',
-    '2009' => '修改注册资料成功,请等候审核~',
-    '2010' => '修改注册资料失败',
-    '2011' => '请不要频繁发送,稍后重试~',
-    '2012' => '短信验证码已失效',
-    '2013' => '短信验证码错误',
-    '2014' => '账号或密码错误',
-    '2015' => '账号已被冻结暂无法登录,请联系客服或管理员',
-    '2016' => '账号已被冻结无法操作,请联系客服或管理员',
-    '2017' => '登录密码错误',
-    '2018' => '登录失败',
-    '2019' => '登录成功',
-    '2030' => '密码重置失败',
-    '2031' => '密码重置成功',
-    '2041' => '账号资料已审核,无法操作',
-    '2042' => '账号资料待审核中,无法操作',
-    '2043' => '账号资料待审核中~',
-    '2044' => '账号不存在或已注销~',
-    '2045' => '您的账号有未完成的订单,请先处理完成后重试~',
-    '2046' => '您的账号有未处理的保证金订单,请先处理完成后重试~',
-    '2047' => '您的账号有未处理的提现申请,请先处理完成后重试~',
-    '2048' => '账号注销成功',
-    '2049' => '账号注销失败',
-    '2050' => '账号不存在或已注销',
-
-
-    '2051'=> '保证金充值成功',
-    '2052'=> '保证金充值失败',
-    '2053'=> '保证金已缴纳',
-    '2054'=> '保证金金额错误,请刷新重试',
-    '2055'=> '保证金缴纳支付方式错误',
-    '2056'=> '创建充值订单失败,请刷新重试',
-    '2057'=> '您没有可退保金额',
-    '2058'=> '退保金额错误,请刷新重试或联系客服',
-    '2059'=> '退保申请处理失败,请刷新重试',
-    '2060'=> '退保申请成功,请耐心等候审核~',
-    '2061'=> '退保申请失败,请刷新重试',
-    '2062'=> '退保申请失败,请先处理完所有订单后操作~',
-    '2063' => '您的账号已被暂停接单,请联系客服开启~',
-
-
-    '2171'=> '保证金退款处理失败',
-    '2172'=> '保证金微信退款处理失败',
-    '2173'=> '保证金支付宝退款处理失败',
-    '2174'=> '保证金余额退款处理失败',
-    '2175'=> '订单已确认完成',
-    '2176'=> '退款请求成功',
-    '2177'=> '该订单已支付',
-    '2178'=> '订单请求支付失败',
-    '2179'=> '退款类型错误',
-    '2180'=> '账户明细处理错误',
-    '2181'=> '保证金入账失败',
-
-    '2201'=>'接单信息不存在或已下架',
-    '2202'=>'该货物订单已在进行中,无法抢单',
-    '2203'=>'该货物订单已完成',
-    '2204'=>'该货物订单运费金额错误,请联系客服',
-    '2205'=>'您的账号暂无法接单,请联系客服',
-    '2206'=>'请先充值缴纳保证金即可抢单',
-    '2207'=>'接单失败,请刷新后重试',
-    '2208'=>'接单成功接单中,目前有:num个司机正在抢单,请耐心等候审核~',
-    '2209'=>'您有进行中的订单,请先完成再抢单~',
-    '2210'=>'抢单中,请稍后~',
-
-    '2301'=>'请输入提现金额',
-    '2302'=>'请输入姓名或收款账号',
-    '2303'=>'可提现金额不足',
-    '2304'=>'提现功能暂未开放,请联系客服',
-    '2305'=>'最低提现金额为:money元',
-    '2306'=>'余额提现账户处理失败',
-    '2307'=>'余额提现申请失败',
-    '2308'=>'余额提现申请成功,请耐心等候审核打款~',
+    '2011'=>"授权登录失败,用户账号被冻结",
+    '2012'=>"授权登录失败",
+    '2013'=>"授权登录成功",
+    '2014'=>"手机号获取失败",
 
 
 
 
+    '2614'=> '支付用户OPENID缺少',
     '2615'=> '支付金额错误',
     '2615'=> '支付金额错误',
     '2616'=> '微信支付参数未配置',
     '2616'=> '微信支付参数未配置',
     '2617'=> '微信支付调用成功',
     '2617'=> '微信支付调用成功',
@@ -143,17 +73,5 @@ return [
     '2635'=> '支付回调处理失败',
     '2635'=> '支付回调处理失败',
     '2636'=> '订单不存在或参数错误',
     '2636'=> '订单不存在或参数错误',
     '2637'=> '订单支付信息错误,请联系客服',
     '2637'=> '订单支付信息错误,请联系客服',
-    '2638'=> '退还保证金处理失败,请联系客服',
-    '2639'=> '退还保证金审核状态参数错误',
-    '2640'=> '订单参数错误',
-    '2642'=> '保证金订单处理错误',
-    '2643'=> '退还保证金失败,请刷新重试~',
-    '2644'=> '请等候退保申请处理完后再操作~',
-
-    '2646'=> '提现账户不存在或不可用~',
-    '2647'=> '保证金余额不足,请确认后重试~',
-    '2648'=> '收入余额不足,请确认后重试~',
-    '2652'=> '订单已处理',
-
-
+    '2638'=> '支付回调处理成功',
 ];
 ];

+ 43 - 18
routes/api.php

@@ -19,6 +19,7 @@ use Illuminate\Support\Facades\Route;
 Route::prefix('v1')->group(function() {
 Route::prefix('v1')->group(function() {
     // 登录
     // 登录
     Route::post('/login', [\App\Http\Controllers\Api\v1\LoginController::class, 'login']);
     Route::post('/login', [\App\Http\Controllers\Api\v1\LoginController::class, 'login']);
+    Route::post('/mpAuth', [\App\Http\Controllers\Api\v1\LoginController::class, 'mpAuth']);
     // 注册
     // 注册
     Route::post('/register', [\App\Http\Controllers\Api\v1\LoginController::class, 'register']);
     Route::post('/register', [\App\Http\Controllers\Api\v1\LoginController::class, 'register']);
     Route::post('/forget', [\App\Http\Controllers\Api\v1\LoginController::class, 'forget']);
     Route::post('/forget', [\App\Http\Controllers\Api\v1\LoginController::class, 'forget']);
@@ -30,12 +31,17 @@ Route::prefix('v1')->group(function() {
 
 
     // 配置和首页数据
     // 配置和首页数据
     Route::get('/config', [\App\Http\Controllers\Api\v1\IndexController::class, 'config']);
     Route::get('/config', [\App\Http\Controllers\Api\v1\IndexController::class, 'config']);
+    Route::get('/index/data', [\App\Http\Controllers\Api\v1\IndexController::class, 'data']);
 
 
     // 文章
     // 文章
     Route::post('/article/index', [\App\Http\Controllers\Api\v1\ArticleController::class, 'index']);
     Route::post('/article/index', [\App\Http\Controllers\Api\v1\ArticleController::class, 'index']);
     Route::get('/article/info', [\App\Http\Controllers\Api\v1\ArticleController::class, 'info']);
     Route::get('/article/info', [\App\Http\Controllers\Api\v1\ArticleController::class, 'info']);
     Route::get('/article/page', [\App\Http\Controllers\Api\v1\ArticleController::class, 'page']);
     Route::get('/article/page', [\App\Http\Controllers\Api\v1\ArticleController::class, 'page']);
 
 
+    // 主页店铺商品
+    Route::post('/store/goods', [\App\Http\Controllers\Api\v1\StoreController::class, 'goods']);
+    Route::post('/goods/category/list', [\App\Http\Controllers\Api\v1\GoodsController::class, 'categorys']);
+
 });
 });
 
 
 
 
@@ -43,16 +49,10 @@ Route::prefix('v1')->group(function() {
 // 用户端路由组
 // 用户端路由组
 Route::prefix('v1')->middleware('web.login')->group(function() {
 Route::prefix('v1')->middleware('web.login')->group(function() {
     Route::get('/logout', [\App\Http\Controllers\Api\v1\LoginController::class, 'logout']);
     Route::get('/logout', [\App\Http\Controllers\Api\v1\LoginController::class, 'logout']);
-    Route::get('/index/data', [\App\Http\Controllers\Api\v1\IndexController::class, 'data']);
-
-    // 货物/接单信息
-    Route::post('/picker/index', [\App\Http\Controllers\Api\v1\GoodsController::class, 'index']);
-    Route::post('/picker/info', [\App\Http\Controllers\Api\v1\GoodsController::class, 'info']);
 
 
     // 用户信息
     // 用户信息
     Route::get('/user/info', [\App\Http\Controllers\Api\v1\MemberController::class, 'info']);
     Route::get('/user/info', [\App\Http\Controllers\Api\v1\MemberController::class, 'info']);
-    Route::get('/user/profile', [\App\Http\Controllers\Api\v1\MemberController::class, 'profile']);
-    Route::post('/user/profile/modify', [\App\Http\Controllers\Api\v1\MemberController::class, 'profileModify']);
+    Route::post('/user/setEntry', [\App\Http\Controllers\Api\v1\MemberController::class, 'setEntry']);
     Route::post('/user/modify', [\App\Http\Controllers\Api\v1\MemberController::class, 'modify']);
     Route::post('/user/modify', [\App\Http\Controllers\Api\v1\MemberController::class, 'modify']);
     Route::post('/user/logOff', [\App\Http\Controllers\Api\v1\MemberController::class, 'logOff']);
     Route::post('/user/logOff', [\App\Http\Controllers\Api\v1\MemberController::class, 'logOff']);
 
 
@@ -61,27 +61,52 @@ Route::prefix('v1')->middleware('web.login')->group(function() {
     Route::post('/account/withdraw', [\App\Http\Controllers\Api\v1\AccountController::class, 'withdraw']);
     Route::post('/account/withdraw', [\App\Http\Controllers\Api\v1\AccountController::class, 'withdraw']);
     Route::post('/account/balance', [\App\Http\Controllers\Api\v1\AccountController::class, 'balance']);
     Route::post('/account/balance', [\App\Http\Controllers\Api\v1\AccountController::class, 'balance']);
 
 
-    // 保证金
-    Route::post('/deposit/index', [\App\Http\Controllers\Api\v1\DepositController::class, 'index']);
-    Route::post('/deposit/pay', [\App\Http\Controllers\Api\v1\DepositController::class, 'pay']);
-    Route::post('/deposit/refund', [\App\Http\Controllers\Api\v1\DepositController::class, 'refund']);
-    Route::post('/deposit/info', [\App\Http\Controllers\Api\v1\DepositController::class, 'info']);
-
     // 订单列表
     // 订单列表
     Route::post('/order/index', [\App\Http\Controllers\Api\v1\OrderController::class, 'index']);
     Route::post('/order/index', [\App\Http\Controllers\Api\v1\OrderController::class, 'index']);
     Route::get('/order/info', [\App\Http\Controllers\Api\v1\OrderController::class, 'info']);
     Route::get('/order/info', [\App\Http\Controllers\Api\v1\OrderController::class, 'info']);
-    Route::post('/order/check', [\App\Http\Controllers\Api\v1\OrderController::class, 'check']);
+    Route::post('/order/count', [\App\Http\Controllers\Api\v1\OrderController::class, 'count']);
     Route::post('/order/submit', [\App\Http\Controllers\Api\v1\OrderController::class, 'submit']);
     Route::post('/order/submit', [\App\Http\Controllers\Api\v1\OrderController::class, 'submit']);
 
 
-    // 消息列表
-    Route::post('/message/index', [\App\Http\Controllers\Api\v1\MessageController::class, 'index']);
-    Route::post('/message/history', [\App\Http\Controllers\Api\v1\MessageController::class, 'history']);
+    // 购物车
+    Route::post('/cart/index', [\App\Http\Controllers\Api\v1\CartController::class, 'index']);
+    Route::post('/cart/add', [\App\Http\Controllers\Api\v1\CartController::class, 'add']);
+    Route::post('/cart/update', [\App\Http\Controllers\Api\v1\CartController::class, 'update']);
+    Route::post('/cart/delete', [\App\Http\Controllers\Api\v1\CartController::class, 'delete']);
+    Route::post('/cart/count', [\App\Http\Controllers\Api\v1\CartController::class, 'count']);
+
+    // 商品
+    Route::post('/goods/index', [\App\Http\Controllers\Api\v1\GoodsController::class, 'index']);
+    Route::post('/goods/info', [\App\Http\Controllers\Api\v1\GoodsController::class, 'info']);
+
+    // 店铺
+    Route::post('/store/index', [\App\Http\Controllers\Api\v1\StoreController::class, 'index']);
+    Route::post('/store/info', [\App\Http\Controllers\Api\v1\StoreController::class, 'info']);
+    Route::post('/store/applyInfo', [\App\Http\Controllers\Api\v1\StoreController::class, 'applyInfo']);
+    Route::post('/store/category/list', [\App\Http\Controllers\Api\v1\StoreController::class, 'categorys']);
+    Route::post('/store/apply', [\App\Http\Controllers\Api\v1\StoreController::class, 'apply']);
+    Route::post('/store/delete', [\App\Http\Controllers\Api\v1\StoreController::class, 'delete']);
+
+    // 收货地址
+    Route::post('/address/index', [\App\Http\Controllers\Api\v1\AddressController::class, 'index']);
+    Route::post('/address/info', [\App\Http\Controllers\Api\v1\AddressController::class, 'info']);
+    Route::post('/address/default', [\App\Http\Controllers\Api\v1\AddressController::class, 'setDefault']);
+    Route::post('/address/save', [\App\Http\Controllers\Api\v1\AddressController::class, 'save']);
+    Route::post('/address/delete', [\App\Http\Controllers\Api\v1\AddressController::class, 'delete']);
+
+    // 举报
+    Route::post('/complaint/submit', [\App\Http\Controllers\Api\v1\ComplaintController::class, 'submit']);
+
+    // 代理
+    Route::post('/agent/index', [\App\Http\Controllers\Api\v1\AgentController::class, 'index']);
+    Route::post('/agent/info', [\App\Http\Controllers\Api\v1\AgentController::class, 'info']);
+    Route::post('/agent/apply', [\App\Http\Controllers\Api\v1\AgentController::class, 'apply']);
+
+
 
 
 });
 });
 
 
 // 回调处理
 // 回调处理
 Route::match(['get','post'],'/notify/refund/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'refund']);
 Route::match(['get','post'],'/notify/refund/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'refund']);
-Route::match(['get','post'],'/notify/depositRefund/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'depositRefund']);
 Route::match(['get','post'],'/notify/{scene}/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'callback']);
 Route::match(['get','post'],'/notify/{scene}/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'callback']);
 
 
 Route::match(['get','post'],'/test/check', [\App\Http\Controllers\Api\v1\TestController::class, 'check']);
 Route::match(['get','post'],'/test/check', [\App\Http\Controllers\Api\v1\TestController::class, 'check']);