Browse Source

添加 api 文档,代码格式整理

joe 4 năm trước cách đây
mục cha
commit
a780894293
46 tập tin đã thay đổi với 908 bổ sung723 xóa
  1. 3 5
      app/admin/controller/PublicAdmin.php
  2. 1 2
      app/admin/controller/Test.php
  3. 1 2
      app/admin/controller/order/StoreOrder.php
  4. 8 8
      app/api/controller/AuthController.php
  5. 53 37
      app/api/controller/PublicController.php
  6. 70 84
      app/api/controller/admin/StoreOrderController.php
  7. 1 2
      app/api/controller/board/UserBoardController.php
  8. 28 11
      app/api/controller/coin/UserCoinController.php
  9. 83 86
      app/api/controller/order/StoreOrderController.php
  10. 4 5
      app/api/controller/publics/ArticleCategoryController.php
  11. 16 14
      app/api/controller/publics/ArticleController.php
  12. 6 0
      app/api/controller/store/CategoryController.php
  13. 20 22
      app/api/controller/store/StoreCartController.php
  14. 44 39
      app/api/controller/store/StoreProductController.php
  15. 51 17
      app/api/controller/user/StoreService.php
  16. 66 63
      app/api/controller/user/UserBillController.php
  17. 213 119
      app/api/controller/user/UserController.php
  18. 30 28
      app/api/controller/user/UserExtractController.php
  19. 12 10
      app/api/controller/user/UserLevelController.php
  20. 18 3
      app/api/controller/user/UserNoticeController.php
  21. 17 14
      app/api/controller/user/UserRechargeController.php
  22. 39 30
      app/api/controller/wechat/AuthController.php
  23. 20 21
      app/api/controller/wechat/WechatController.php
  24. 8 0
      app/common.php
  25. 3 4
      app/models/store/StoreOrder.php
  26. 1 2
      app/models/store/StorePink.php
  27. 20 10
      app/models/store/StoreService.php
  28. 8 4
      app/models/store/StoreServiceLog.php
  29. 5 6
      app/models/user/UserBill.php
  30. 3 4
      app/models/user/UserExtract.php
  31. 2 3
      app/models/user/UserNotice.php
  32. 2 3
      crmeb/repositories/CustomerRepository.php
  33. 2 6
      crmeb/repositories/NoticeRepositories.php
  34. 1 2
      crmeb/services/template/storage/Subscribe.php
  35. 1 3
      crmeb/services/template/storage/Wechat.php
  36. 1 6
      crmeb/services/workerman/chat/ChatHandle.php
  37. 1 4
      crmeb/subscribes/MessageSubscribe.php
  38. 17 9
      crmeb/subscribes/ProductSubscribe.php
  39. 1 2
      crmeb/subscribes/SystemSubscribe.php
  40. 2 3
      crmeb/subscribes/TimerSubscribe.php
  41. 8 10
      crmeb/subscribes/UserSubscribe.php
  42. 2 2
      docs/apidoc.json
  43. 3 2
      route/api/route.php
  44. 3 4
      tw/async/tasks/Task.php
  45. 8 9
      tw/async/tasks/UserTaskClass.php
  46. 2 3
      tw/async/tasks/WechatNotify.php

+ 3 - 5
app/admin/controller/PublicAdmin.php

@@ -6,8 +6,6 @@ use app\admin\model\system\SystemAttachment;
 use app\admin\model\system\SystemAttachmentCategory;
 use app\Request;
 use crmeb\services\UtilService;
-use think\facade\Log;
-
 
 class PublicAdmin
 {
@@ -97,15 +95,15 @@ class PublicAdmin
                             $ok = SystemAttachment::attachmentAdd($fileInfo['name'], $fileInfo['size'], $fileInfo['type'], $fileInfo['dir'], $fileInfo['thumb_path'], $pid, $upload_type, $fileInfo['time']);
                             if(!$ok) {
                                 $has_error = true;
-                                Log::warning('upload image failed:' . $url . ' name:' . $pdt['name']);
+                                warnlog('upload image failed:' . $url . ' name:' . $pdt['name']);
                             }
                         } catch (\Exception $e) {
                             $has_error = true;
-                            Log::warning('upload image exception:' . $url . 'name:' . $pdt['name'] . ' exception:' . $e->getMessage());
+                            warnlog('upload image exception:' . $url . 'name:' . $pdt['name'] . ' exception:' . $e->getMessage());
                         }                        
                     }else {
                         $has_error = true;
-                        Log::warning('get image info failed:' . $url . ' name:' . $pdt['name']);
+                        warnlog('get image info failed:' . $url . ' name:' . $pdt['name']);
                     }
                 }
             }

+ 1 - 2
app/admin/controller/Test.php

@@ -3,7 +3,6 @@
 namespace app\admin\controller;
 
 use crmeb\utils\Redis;
-use think\facade\Log;
 use app\api\controller\board\UserBoardController;
 use app\models\redis\SystemCarousel;
 use app\models\system\SystemPool;
@@ -37,7 +36,7 @@ class Test
     }
 
     protected function test_board() {
-        Log::warning("board updated.");
+        warnlog("board updated.");
         $ctl = new UserBoardController();
         $ctl->cache_board();
     }

+ 1 - 2
app/admin/controller/order/StoreOrder.php

@@ -32,7 +32,6 @@ use crmeb\basic\BaseModel;
 use think\facade\Route as Url;
 use app\admin\model\order\StoreOrder as StoreOrderModel;
 use crmeb\services\YLYService;
-use think\facade\Log;
 use app\models\store\StoreOrder as StoreOrderModels;
 
 /**
@@ -126,7 +125,7 @@ class StoreOrder extends AuthController
                 return JsonService::fail('打印失败');
             }
         } catch (\Exception $e) {
-            Log::error('小票打印出现错误,错误原因:' . $e->getMessage());
+            errlog('小票打印出现错误,错误原因:' . $e->getMessage());
             return JsonService::fail($e->getMessage());
         }
     }

+ 8 - 8
app/api/controller/AuthController.php

@@ -31,7 +31,7 @@ class AuthController
     /**
      * @api {post} /login H5账号登陆
      * @apiName Login
-     * @apiGroup Login
+     * @apiGroup Public
      * 
      * @apiBody {string} account 輸入帐号.
      * @apiBody {string} password 輸入密碼(明文).
@@ -105,7 +105,7 @@ class AuthController
     /**
      * @api {get} /verify_code 获取发短信的 KEY
      * @apiName GetVerificationCode
-     * @apiGroup Login 
+     * @apiGroup Public 
      *
      * @apiSuccessExample Success-Response:
      * {
@@ -127,7 +127,7 @@ class AuthController
     /**
      * @api {get} /sms_captcha 获取发送短信的验证码
      * @apiName GetSmsCaptcha
-     * @apiGroup Login
+     * @apiGroup Public
      * 
      * @apiSuccessExample Success-Response:
      * 二进制图片信息
@@ -177,7 +177,7 @@ class AuthController
     /**
      * @api {post} /register/verify 验证码发送SMS
      * @apiName PostRegisterVerify
-     * @apiGroup Login
+     * @apiGroup Public
      * 
      * @apiBody {string} phone 手机号
      * @apiBody {string="register","login"} type
@@ -260,7 +260,7 @@ class AuthController
     /**
      * @api {post} /register H5注册新用户
      * @apiName PostRegister
-     * @apiGroup Login
+     * @apiGroup Public
      * 
      * @apiBody {string} account 帐号,手机号
      * @apiBody {string} captcha    短信验证码
@@ -307,7 +307,7 @@ class AuthController
     /**
      * @api {post} /register/reset 重置密码
      * @apiName PostRegisterReset
-     * @apiGroup Login
+     * @apiGroup Public
      * 
      * @apiBody {string} account 帐号手机号
      * @apiBody {string} captcha 短信验证码
@@ -352,7 +352,7 @@ class AuthController
     /**
      * @api {post} /login/mobile 手机号登录
      * @apiName PostLoginMobile
-     * @apiGroup Login
+     * @apiGroup Public
      * 
      * @apiBody {string} phone: 手机号
      * @apiBody {string} captcha: 验证码
@@ -548,7 +548,7 @@ class AuthController
     /** 
      * @api {get} /notifications 不登录模拟推送
      * @apiName GetNotifications
-     * @apiGroup Message
+     * @apiGroup Public
      * 
      * @apiSuccessExample Succeed
      * {

+ 53 - 37
app/api/controller/PublicController.php

@@ -32,11 +32,10 @@ use app\models\redis\SystemCarousel;
 class PublicController
 {
     /**
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /index 首页
+     * @apiName GetIndex
+     * @apiGroup Public
+     * 
      */
     public function index(Request $request)
     {
@@ -98,8 +97,11 @@ class PublicController
     }
 
     /**
-     * 获取分享配置
-     * @return mixed
+     * @api {get} /share 获取分享配置
+     * @apiName GetShare
+     * @apiGroup Public
+     * 
+     * 
      */
     public function share()
     {
@@ -113,12 +115,10 @@ class PublicController
 
 
     /**
-     * 获取个人中心菜单
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /menu/user 获取个人中心菜单
+     * @apiName GetMenuUser
+     * @apiGroup User
+     * 
      */
     public function menu_user(Request $request)
     {
@@ -147,11 +147,10 @@ class PublicController
     }
 
     /**
-     * 热门搜索关键字获取
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /search/keyword 热门搜索关键字获取
+     * @apiName GetSearchKeyword
+     * @apiGroup Public
+     * 
      */
     public function search()
     {
@@ -167,10 +166,19 @@ class PublicController
 
 
     /**
-     * 图片上传
-     * @param Request $request
-     * @return mixed
-     * @throws \Psr\SimpleCache\InvalidArgumentException
+     * @api {post} upload/image 图片上传
+     * @apiName UploadImage
+     * @apiGroup User
+     * 
+     * @apiBody {string} filename 文件名
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * 
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function upload_image(Request $request)
     {
@@ -230,10 +238,11 @@ class PublicController
     }
 
     /**
-     * 短信购买异步通知
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {post} /sms/pay/notify 短信购买异步通知
+     * @apiName PostSmsPayNotify
+     * @apiGroup Public
+     * 
+     * @apiDeprecated
      */
     public function sms_pay_notify(Request $request)
     {
@@ -267,9 +276,10 @@ class PublicController
     }
 
     /**
-     * 获取图片base64
-     * @param Request $request
-     * @return mixed
+     * @api {post} /image_base64 获取图片base64
+     * @apiName PostImageBase64
+     * @apiGroup Public
+     * 
      */
     public function get_image_base64(Request $request)
     {
@@ -298,8 +308,10 @@ class PublicController
     }
 
     /**
-     * 门店列表
-     * @return mixed
+     * @api {get} /store_list 门店列表
+     * @apiName GetStoreList
+     * @apiGroup Public
+     * 
      */
     public function store_list(Request $request)
     {
@@ -317,9 +329,10 @@ class PublicController
     }
 
     /**
-     * 查找城市数据
-     * @param Request $request
-     * @return mixed
+     * @api {get} /city_list 获取城市列表
+     * @apiName GetCityList
+     * @apiGroup Public
+     * 
      */
     public function city_list(Request $request)
     {
@@ -348,8 +361,11 @@ class PublicController
     }
 
     /**
-     * 获取拼团数据
-     * @return mixed
+     * @api {get} /pink 获取拼团数据
+     * @apiName GetPink
+     * @apiGroup Public
+     * 
+     * @apiDeprecated
      */
     public function pink()
     {
@@ -363,7 +379,7 @@ class PublicController
     /**
      * @api {get} /activities 开奖结果 JsonP 接口,供第三方使用,透明化开奖结果
      * @apiName Activities
-     * @apiGroup Activity
+     * @apiGroup Public
      * 
      * @apiQuery {string} callback 回调函数名称
      * @apiQuery {string} begin 起始时间

+ 70 - 84
app/api/controller/admin/StoreOrderController.php

@@ -4,15 +4,22 @@ namespace app\api\controller\admin;
 
 use app\Request;
 use app\models\user\{
-    User, UserBill
+    User,
+    UserBill
 };
 use crmeb\repositories\OrderRepository;
 use crmeb\repositories\ShortLetterRepositories;
 use crmeb\services\{
-    MiniProgramService, UtilService, WechatService
+    MiniProgramService,
+    UtilService,
+    WechatService
 };
 use app\models\store\{
-    StoreCart, StoreOrder, StoreOrderStatus, StorePink, StoreService
+    StoreCart,
+    StoreOrder,
+    StoreOrderStatus,
+    StorePink,
+    StoreService
 };
 use app\models\system\SystemStoreStaff;
 
@@ -24,9 +31,15 @@ use app\models\system\SystemStoreStaff;
 class StoreOrderController
 {
     /**
-     *  订单数据统计
-     * @param Request $request
-     * @return mixed
+     * @api {get} admin/order/statistics 订单数据统计
+     * @apiName AdminOrderStatistics
+     * @apiGroup Admin
+     * 
+     * @apiParam none None
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * 
      */
     public function statistics(Request $request)
     {
@@ -40,9 +53,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单每月统计数据
-     * @param Request $request
-     * @return mixed
+     * @api {get} admin/order/data 订单每月统计数据
+     * @apiName AdminOrderData
+     * @apiGroup Admin
      */
     public function data(Request $request)
     {
@@ -62,9 +75,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} admin/order/list 订单列表
+     * @apiName AdminOrderList
+     * @apiGroup Admin
      */
     public function lst(Request $request)
     {
@@ -85,14 +98,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单详情
-     * @param Request $request
-     * @param $orderId
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} admin/order/detail/:orderId 订单详情
+     * @apiName AdminOrderDetails
+     * @apiGroup Admin
      */
     public function detail(Request $request, $orderId)
     {
@@ -110,14 +118,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单发货获取订单信息
-     * @param Request $request
-     * @param $orderId
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} admin/order/delivery/gain/:orderId 订单发货获取订单信息
+     * @apiName AdminOrderDeliveryGain
+     * @apiGroup Admin
      */
     public function delivery_gain(Request $request, $orderId)
     {
@@ -135,12 +138,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单发货
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} admin/order/delivery/keep 订单发货
+     * @apiName AdminOrderDeliveryKeep
+     * @apiGroup Admin
      */
     public function delivery_keep(Request $request)
     {
@@ -188,12 +188,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单改价
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} admin/order/price 订单改价
+     * @apiName AdminOrderPrice
+     * @apiGroup Admin
      */
     public function price(Request $request)
     {
@@ -228,12 +225,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单备注
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} admin/order/remark 订单备注
+     * @apiName AdminOrderRemark
+     * @apiGroup Admin
      */
     public function remark(Request $request)
     {
@@ -254,9 +248,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单交易额/订单数量时间统计
-     * @param Request $request
-     * @return bool
+     * @api {get} admin/order/time 订单交易额/订单数量时间统计
+     * @apiName AdminOrderTime
+     * @apiGroup Admin
      */
     public function time(Request $request)
     {
@@ -276,32 +270,32 @@ class StoreOrderController
             $stop = $start;
             $start = $middle;
         }
-        $space = bcsub($stop, $start, 0);//间隔时间段
-        $front = bcsub($start, $space, 0);//第一个时间段
-        if ($type == 1) {//销售额
-            $frontPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($front, $start);
-            $afterPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($start, $stop);
+        $space = bcsub($stop, $start, 0); //间隔时间段
+        $front = bcsub($start, $space, 0); //第一个时间段
+        if ($type == 1) { //销售额
+            $frontPrice = StoreOrder::getOrderTimeBusinessVolumePrice($front, $start);
+            $afterPrice = StoreOrder::getOrderTimeBusinessVolumePrice($start, $stop);
             $chartInfo = StoreOrder::chartTimePrice($start, $stop);
-            $data['chart'] = $chartInfo;//营业额图表数据
-            $data['time'] = $afterPrice;//时间区间营业额
+            $data['chart'] = $chartInfo; //营业额图表数据
+            $data['time'] = $afterPrice; //时间区间营业额
             $increase = (float)bcsub($afterPrice, $frontPrice, 2); //同比上个时间区间增长营业额
             $growthRate = abs($increase);
             if ($growthRate == 0) $data['growth_rate'] = 0;
             else if ($frontPrice == 0) $data['growth_rate'] = $growthRate;
-            else $data['growth_rate'] = (int)bcmul(bcdiv($growthRate, $frontPrice, 2), 100, 0);//时间区间增长率
+            else $data['growth_rate'] = (int)bcmul(bcdiv($growthRate, $frontPrice, 2), 100, 0); //时间区间增长率
             $data['increase_time'] = abs($increase); //同比上个时间区间增长营业额
             $data['increase_time_status'] = $increase >= 0 ? 1 : 2; //同比上个时间区间增长营业额增长 1 减少 2
-        } else {//订单数
-            $frontNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($front, $start);
-            $afterNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($start, $stop);
+        } else { //订单数
+            $frontNumber = StoreOrder::getOrderTimeBusinessVolumeNumber($front, $start);
+            $afterNumber = StoreOrder::getOrderTimeBusinessVolumeNumber($start, $stop);
             $chartInfo = StoreOrder::chartTimeNumber($start, $stop);
-            $data['chart'] = $chartInfo;//订单数图表数据
-            $data['time'] = $afterNumber;//时间区间订单数
+            $data['chart'] = $chartInfo; //订单数图表数据
+            $data['time'] = $afterNumber; //时间区间订单数
             $increase = (int)bcsub($afterNumber, $frontNumber, 0); //同比上个时间区间增长订单数
             $growthRate = abs($increase);
             if ($growthRate == 0) $data['growth_rate'] = 0;
             else if ($frontNumber == 0) $data['growth_rate'] = $growthRate;
-            else $data['growth_rate'] = (int)bcmul(bcdiv($growthRate, $frontNumber, 2), 100, 0);//时间区间增长率
+            else $data['growth_rate'] = (int)bcmul(bcdiv($growthRate, $frontNumber, 2), 100, 0); //时间区间增长率
             $data['increase_time'] = abs($increase); //同比上个时间区间增长营业额
             $data['increase_time_status'] = $increase >= 0 ? 1 : 2; //同比上个时间区间增长营业额增长 1 减少 2
         }
@@ -309,12 +303,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单支付
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} admin/order/offline' 订单支付
+     * @apiName AdminOrderOffline
+     * @apiGroup Admin
      */
     public function offline(Request $request)
     {
@@ -332,13 +323,9 @@ class StoreOrderController
     }
 
     /**
-     * 订单退款
-     * @param Request $request
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} admin/order/refund 订单退款
+     * @apiName AdminOrderRefund
+     * @apiGroup Admin
      */
     public function refund(Request $request)
     {
@@ -369,20 +356,20 @@ class StoreOrderController
         $refundData['pay_price'] = $orderInfo['pay_price'];
         $refundData['refund_price'] = $price;
         if ($orderInfo['pay_type'] == 'weixin') {
-            if ($orderInfo['is_channel'] == 1) {// 小程序
+            if ($orderInfo['is_channel'] == 1) { // 小程序
                 try {
                     MiniProgramService::payOrderRefund($orderInfo['order_id'], $refundData);
                 } catch (\Exception $e) {
                     return app('json')->fail($e->getMessage());
                 }
-            } else {// 公众号
+            } else { // 公众号
                 try {
                     WechatService::payOrderRefund($orderInfo['order_id'], $refundData);
                 } catch (\Exception $e) {
                     return app('json')->fail($e->getMessage());
                 }
             }
-        } else if ($orderInfo['pay_type'] == 'yue') {//余额
+        } else if ($orderInfo['pay_type'] == 'yue') { //余额
             StoreOrder::beginTrans();
             $userInfo = User::getUserInfo($orderInfo['uid'], 'now_money');
             if (!$userInfo) {
@@ -450,8 +437,9 @@ class StoreOrderController
     }
 
     /**
-     * 门店核销
-     * @param Request $request
+     * @api {post} order/order_verific 门店核销
+     * @apiName AdminOrderVerify
+     * @apiGroup Admin
      */
     public function order_verific(Request $request)
     {
@@ -494,6 +482,4 @@ class StoreOrderController
             return app('json')->fail($e->getMessage());
         }
     }
-
-
-}
+}

+ 1 - 2
app/api/controller/board/UserBoardController.php

@@ -5,7 +5,6 @@ namespace app\api\controller\board;
 use crmeb\services\UtilService;
 use app\models\board\UserBoard;
 use \think\facade\Config;
-use crmeb\utils\Redis;
 use tw\redis\BoardRds;
 
 /**
@@ -23,7 +22,7 @@ class UserBoardController
     /**
      * @api {get} /boards 获取排行榜
      * @apiName GetBoards
-     * @apiGroup Activity
+     * @apiGroup Public
      * 
      * @apiParam {int=1,2} type 1|2 日榜单|周榜单
      * 

+ 28 - 11
app/api/controller/coin/UserCoinController.php

@@ -10,9 +10,14 @@ use app\Request;
 use crmeb\services\{UtilService, JsonService};
 use think\facade\Config;
 use think\facade\Cache;
-use think\facade\Log;
 
 class UserCoinController {
+    /**
+     * @api {get} /coin/status 挖矿当前状态
+     * @apiName GetCoinStatus
+     * @apiGroup User.Coin
+     * 
+     */
     public function status(Request $request) {
         // 是否开启挖矿
         $symbol = Config::get('app.mining_symbo');
@@ -36,7 +41,7 @@ class UserCoinController {
         ];
 
         if (!$symbol) {
-            Log::warning('mining disabled: $symbol');
+            warnlog('mining disabled: $symbol');
             return app('json')->successful($defStatus);
         }
 
@@ -86,7 +91,7 @@ class UserCoinController {
             !isset($p['stop']) || 
             !isset($p['step']) || 
             !isset($p['progress'])) {
-            Log::warning('error format.');
+                warnlog('error format.');
             return $p;
         }
 
@@ -112,7 +117,7 @@ class UserCoinController {
             UserCoinTransfer::checkTrans($r1 && $r2);
             if (!$r1 || !$r2) {
                 $amount = $p['progress'];
-                Log::error("user<$uid> save transfer failed, amount<$amount>");
+                errlog("user<$uid> save transfer failed, amount<$amount>");
                 return $p;
             }
             // -- save to db
@@ -130,7 +135,10 @@ class UserCoinController {
     }
 
     /**
-     * 启动
+     * @api {post} /coin/boot 启动挖矿
+     * @apiName PostCoinBoot
+     * @apiGroup User.Coin
+     * 
      */
     public function boot(Request $request) {
         $uid = $request->uid();
@@ -167,7 +175,7 @@ class UserCoinController {
         $balance = UserCoin::where('uid', $uid)->where('symbol', $symbol)->value('balance') ?? 0.0;
         $hours = Config::get('app.mining_time');
         if (count($hours) != 2 || $hours[0] > $hours[1]) {
-            Log::warning('app.mining_time config error.');
+            warnlog('app.mining_time config error.');
             return app('json')->fail('启动失败,请联系客服');;
         }
         $hour = random_int($hours[0], $hours[1]);
@@ -202,7 +210,10 @@ class UserCoinController {
     }
 
     /**
-     * 请求转账记录
+     * @api {get} /coin/history 请求转账记录
+     * @apiName GetCoinHistory
+     * @apiGroup User.Coin
+     * 
      */
     public function history(Request $request) {
         [$page, $limit] = UtilService::getMore([
@@ -214,8 +225,11 @@ class UserCoinController {
         return app('json')->successful($rows);
     }
 
-    /*
-     * 更新钱包地址
+    /**
+     * @api {post} /coin/addr 更新钱包地址
+     * @apiName PostCoinAddr
+     * @apiGroup User.Coin
+     * 
      */
     public function updateAddr(Request $request) {
         list($symbol, $addr) = UtilService::postMore([
@@ -237,8 +251,11 @@ class UserCoinController {
         return app('json')->successful();
     }
 
-    /*
-     * 提现
+    /**
+     * @api {post} /coin/transfer 提现
+     * @apiName PostCoinTransfer
+     * @apiGroup User.Coin
+     * 
      */
     public function transfer(Request $request) {
         list($symbol, $amount) = UtilService::postMore([

+ 83 - 86
app/api/controller/order/StoreOrderController.php

@@ -26,7 +26,7 @@ use app\models\system\SystemStore;
 use app\models\user\UserAddress;
 use app\models\user\UserLevel;
 use app\Request;
-use think\facade\{Cache, Log};
+use think\facade\{Cache};
 use crmeb\services\{
     CacheService,
     ExpressService,
@@ -42,9 +42,10 @@ use crmeb\services\{
 class StoreOrderController
 {
     /**
-     * 订单确认
-     * @param Request $request
-     * @return mixed
+     * @api {post} /order/confirm 订单确认
+     * @apiName PostOrderConfirm
+     * @apiGroup User.Order
+     * 
      */
     public function confirm(Request $request)
     {
@@ -116,14 +117,10 @@ class StoreOrderController
     }
 
     /**
-     * 计算订单金额
-     * @param Request $request
-     * @param $key
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /order/computed/:key 计算订单金额
+     * @apiName PostOrderComputed
+     * @apiGroup User.Order
+     * 
      */
     public function computedOrder(Request $request, $key)
     {
@@ -178,14 +175,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单创建
-     * @param Request $request
-     * @param $key
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /order/create/:key 订单创建
+     * @apiName PostOrderCreate
+     * @apiGroup User.Order
+     * 
      */
     public function create(Request $request, $key)
     {
@@ -272,7 +265,7 @@ class StoreOrderController
                                 $jsConfig = OrderRepository::wxPay($orderId);
                             }
                         } catch (\Exception $e) {
-                            Log::error("weixin pay error:" . $e->getMessage());
+                            errlog("weixin pay error:" . $e->getMessage());
                             return app('json')->status('pay_error', $e->getMessage(), $info);
                         }
                         $info['jsConfig'] = $jsConfig;
@@ -305,15 +298,11 @@ class StoreOrderController
         }
     }
 
-        /**
-     * 计算订单金额
-     * @param Request $request
-     * @param $key
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+    /**
+     * @api {post} /order/v2/computed/:key 计算订单金额
+     * @apiName PostOrderComputedV2
+     * @apiGroup User.Order
+     * 
      */
     public function computedOrder_v2(Request $request, $key)
     {
@@ -368,14 +357,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单创建, 支持子订单版本
-     * @param Request $request
-     * @param $key
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /order/v2/create/:key 订单创建, 支持子订单版本
+     * @apiName PostOrderCreateV2
+     * @apiGroup User.Order
+     * 
      */
     public function create_v2(Request $request, $key)
     {
@@ -466,7 +451,7 @@ class StoreOrderController
                                 $jsConfig = OrderRepository::wxPayBatch($porderId);
                             }
                         } catch (\Exception $e) {
-                            Log::error("weixin pay error:" . $e->getMessage());
+                            errlog("weixin pay error:" . $e->getMessage());
                             return app('json')->status('pay_error', $e->getMessage(), $info);
                         }
                         $info['jsConfig'] = $jsConfig;
@@ -500,9 +485,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单 再次下单
-     * @param Request $request
-     * @return mixed
+     * @api {post} /order/again 订单 再次下单
+     * @apiName PostOrderAgain
+     * @apiGroup User.Order
+     * 
      */
     public function again(Request $request)
     {
@@ -531,9 +517,10 @@ class StoreOrderController
 
 
     /**
-     * 订单支付
-     * @param Request $request
-     * @return mixed
+     * @api {post} /order/pay 订单支付
+     * @apiName PostOrderPay
+     * @apiGroup User.Order
+     * 
      */
     public function pay(Request $request)
     {
@@ -586,7 +573,7 @@ class StoreOrderController
                         $jsConfig = OrderRepository::wxPay($order);
                     }
                 } catch (\Exception $e) {
-                    Log::error('weixin pay error:' . $e->getMessage());
+                    errlog('weixin pay error:' . $e->getMessage());
                     return app('json')->fail($e->getMessage());
                 }
 
@@ -627,9 +614,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} /order/list 订单列表
+     * @apiName GetOrderList
+     * @apiGroup User.Order
+     * 
      */
     public function lst(Request $request)
     {
@@ -643,8 +631,12 @@ class StoreOrderController
     }
 
     /**
-     * 订单详情 v2 
-     * 订单支持子订单之后,订单详情协议传过来的 $uni 有可能是子订单的,也有可能是主订单的
+     * @api {get} /order/v2/detail/:uni 订单详情 v2 
+     * @apiName GetOrderDetailsV2
+     * @apiGroup User.Order
+     * 
+     * @apiDescription 订单支持子订单之后,订单详情协议传过来的 $uni 有可能是子订单的,也有可能是主订单的
+     * 
      */
     public function detail_v2(Request $request, $uni)
     {
@@ -674,10 +666,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单详情
-     * @param Request $request
-     * @param $uni
-     * @return mixed
+     * @api {get} /order/detail/:uni 订单详情
+     * @apiName GetOrderDetails
+     * @apiGroup User.Order
+     * 
      */
     public function detail(Request $request, $uni)
     {
@@ -729,9 +721,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单删除
-     * @param Request $request
-     * @return mixed
+     * @api {post} /order/del 订单删除
+     * @apiName PostOrderDel
+     * @apiGroup User.Order
+     * 
      */
     public function del(Request $request)
     {
@@ -747,9 +740,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单收货
-     * @param Request $request
-     * @return mixed
+     * @api {post} /order/take 订单收货
+     * @apiName PostOrderTake
+     * @apiGroup User.Order
+     * 
      */
     public function take(Request $request)
     {
@@ -777,10 +771,10 @@ class StoreOrderController
 
 
     /**
-     * 订单 查看物流
-     * @param Request $request
-     * @param $uni
-     * @return mixed
+     * @api {get} /order/express/:uni 订单 查看物流
+     * @apiName GetOrderExpress
+     * @apiGroup User.Order
+     * 
      */
     public function express(Request $request, $uni)
     {
@@ -826,12 +820,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单评价
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /order/comment 订单评价
+     * @apiName PostOrderComment
+     * @apiGroup User.Order
+     * 
      */
     public function comment(Request $request)
     {
@@ -896,9 +888,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单统计数据
-     * @param Request $request
-     * @return mixed
+     * @api {get} /order/data 订单统计数据
+     * @apiName GetOrderData
+     * @apiGroup User.Order
+     * 
      */
     public function data(Request $request)
     {
@@ -906,8 +899,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单退款理由
-     * @return mixed
+     * @api {get} /order/refund/reason 订单退款理由
+     * @apiName GetOrderRefundReason
+     * @apiGroup User.Order
+     * 
      */
     public function refund_reason()
     {
@@ -918,9 +913,10 @@ class StoreOrderController
     }
 
     /**
-     * 订单退款审核
-     * @param Request $request
-     * @return mixed
+     * @api {post} /order/refund/verify 订单退款审核
+     * @apiName PostOrderRefundVerify
+     * @apiGroup User.Order
+     * 
      */
     public function refund_verify(Request $request)
     {
@@ -961,12 +957,10 @@ class StoreOrderController
 
 
     /**
-     * 订单产品信息
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /order/product 订单产品信息
+     * @apiName PostOrderProduct
+     * @apiGroup User.Order
+     * 
      */
     public function product(Request $request)
     {
@@ -993,7 +987,10 @@ class StoreOrderController
     }
 
     /**
-     * 首页获取未支付订单
+     * @api {get} /order/nopay 首页获取未支付订单
+     * @apiName GetOrderNopay
+     * @apiGroup User.Order
+     * 
      */
     public function get_noPay(Request $request)
     {

+ 4 - 5
app/api/controller/publics/ArticleCategoryController.php

@@ -11,11 +11,10 @@ use app\models\article\ArticleCategory;
 class ArticleCategoryController
 {
     /**
-     * 文章分类列表
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /article/category/list 文章分类列表
+     * @apiName GetArticleCategoryList
+     * @apiGroup Article
+     * 
      */
    public function lst()
    {

+ 16 - 14
app/api/controller/publics/ArticleController.php

@@ -14,10 +14,10 @@ use crmeb\services\UtilService;
 class ArticleController
 {
     /**
-     * 文章列表
-     * @param Request $request
-     * @param $cid
-     * @return mixed
+     * @api {get} /article/list/:cid 文章列表
+     * @apiName GetArticleList
+     * @apiGroup Article
+     * 
      */
     public function lst(Request $request, $cid)
     {
@@ -30,12 +30,10 @@ class ArticleController
         return app('json')->successful($list);
     }
     /**
-     * 文章详情
-     * @param $id
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /article/details/:id 文章详情
+     * @apiName GetArticleDetails
+     * @apiGroup Article
+     * 
      */
    public function details($id)
    {
@@ -49,8 +47,10 @@ class ArticleController
    }
 
     /**
-     * 文章 热门
-     * @return mixed
+     * @api {get} /article/hot/list 文章 热门
+     * @apiName GetArticleHotList
+     * @apiGroup Article
+     * 
      */
     public function hot()
     {
@@ -60,8 +60,10 @@ class ArticleController
     }
 
     /**
-     * 文章 banner
-     * @return mixed
+     * @api {get} /article/banner/list 文章 banner
+     * @apiName GetArticleBannerList
+     * @apiGroup Article
+     * 
      */
     public function banner()
     {

+ 6 - 0
app/api/controller/store/CategoryController.php

@@ -8,6 +8,12 @@ use think\facade\Config;
 
 class CategoryController
 {
+    /**
+     * @api {get} /category 获取产品分类类
+     * @apiName GetCategory
+     * @apiGroup Product
+     * 
+     */
     public function category(Request $request)
     {
         $category = StoreCategory::with('children')->where('is_show', 1)->order('sort desc,id desc')->where('pid', 0)->select();

+ 20 - 22
app/api/controller/store/StoreCartController.php

@@ -15,9 +15,10 @@ class StoreCartController
 {
 
     /**
-     * 购物车 列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} /cart/list 购物车列表
+     * @apiName GetCartList
+     * @apiGroup User.Cart
+     * 
      */
     public function lst(Request $request)
     {
@@ -25,12 +26,10 @@ class StoreCartController
     }
 
     /**
-     * 购物车 添加
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /cart/add 购物车 添加
+     * @apiName PostCartAdd
+     * @apiGroup User.Cart
+     * 
      */
     public function add(Request $request)
     {
@@ -51,9 +50,10 @@ class StoreCartController
     }
 
     /**
-     * 购物车 删除产品
-     * @param Request $request
-     * @return mixed
+     * @api {post} /cart/del 购物车 删除产品
+     * @apiName PostCartDel
+     * @apiGroup User.Cart
+     * 
      */
     public function del(Request $request)
     {
@@ -68,13 +68,10 @@ class StoreCartController
     }
 
     /**
-     * 购物车 修改产品数量
-     * @param Request $request
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /cart/num 购物车 修改产品数量
+     * @apiName PostCartNum
+     * @apiGroup User.Cart
+     * 
      */
     public function num(Request $request)
     {
@@ -89,9 +86,10 @@ class StoreCartController
     }
 
     /**
-     * 购物车 获取数量
-     * @param Request $request
-     * @return mixed
+     * @api {get} /cart/count 购物车 获取数量
+     * @apiName GetCartCount
+     * @apiGroup User.Cart
+     * 
      */
     public function count(Request $request)
     {

+ 44 - 39
app/api/controller/store/StoreProductController.php

@@ -27,9 +27,10 @@ use crmeb\services\upload\Upload;
 class StoreProductController
 {
     /**
-     * 商品列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} /products 商品列表
+     * @apiName GetProducts
+     * @apiGroup Product
+     * 
      */
     public function lst(Request $request)
     {
@@ -48,10 +49,21 @@ class StoreProductController
     }
 
     /**
-     * 产品分享二维码 推广员
-     * @param Request $request
-     * @param $id
-     * @return mixed
+     * @api {get} product/code/:id 产品分享二维码 推广员
+     * @apiName getProductCode
+     * @apiGroup User
+     * 
+     * @apiParam {int} id 产品ID
+     * @apiQuery {string="wechat","routine",""} user_type 用户类型
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
+     * @apiErrorExample Failed
+     * {
+     *  
+     * }
      */
     public function code(Request $request, $id)
     {
@@ -113,11 +125,10 @@ class StoreProductController
     }
 
     /**
-     * 产品详情
-     * @param Request $request
-     * @param $id
-     * @param int $type
-     * @return mixed
+     * @api {get} /product/detail/:id/[:type] 产品详情
+     * @apiName GetProductDetails
+     * @apiGroup Product
+     * 
      */
     public function detail(Request $request, $id, $type = 0)
     {
@@ -141,11 +152,11 @@ class StoreProductController
             $productAttr = [];
             $productValue = [];
         }
-//        //对规格进行排序
-//        $prices = array_column($productValue, 'price');
-//        array_multisort($prices, SORT_ASC, SORT_NUMERIC, $productValue);
-//        $keys = array_keys($productValue);
-//        $productValue = array_combine($keys, $productValue);
+        // 对规格进行排序
+        // $prices = array_column($productValue, 'price');
+        // array_multisort($prices, SORT_ASC, SORT_NUMERIC, $productValue);
+        // $keys = array_keys($productValue);
+        // $productValue = array_combine($keys, $productValue);
         StoreVisit::setView($uid, $id, 'product',$storeInfo['cate_id'], 'viwe');
         $data['storeInfo'] = StoreProduct::setLevelPrice($storeInfo, $uid, true);
         $data['similarity'] = StoreProduct::cateIdBySimilarityProduct($storeInfo['cate_id'], 'id,store_name,image,price,sales,ficti', 4);
@@ -189,13 +200,10 @@ class StoreProductController
     }
 
     /**
-     * 为你推荐
-     *
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /product/hot 为你推荐
+     * @apiName GetProductHot
+     * @apiGroup Product
+     * 
      */
     public function product_hot(Request $request)
     {
@@ -214,13 +222,10 @@ class StoreProductController
     }
 
     /**
-     * 获取首页推荐不同类型产品的轮播图和产品
-     * @param Request $request
-     * @param $type
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /groom/list/:type 获取首页推荐不同类型产品的轮播图和产品
+     * @apiName GetGroomList
+     * @apiGroup Product
+     * 
      */
     public function groom_list(Request $request, $type)
     {
@@ -247,9 +252,10 @@ class StoreProductController
     }
 
     /**
-     * 产品评价数量和好评度
-     * @param $id
-     * @return mixed
+     * @api {get} /reply/config/:id 产品评价数量和好评度
+     * @apiName GetReplyConfig
+     * @apiGroup Product
+     * 
      */
     public function reply_config($id)
     {
@@ -258,11 +264,10 @@ class StoreProductController
     }
 
     /**
-     * 获取产品评论
-     * @param Request $request
-     * @param $id
-     * @param $type
-     * @return mixed
+     * @api {get} /reply/list/:id 获取产品评论
+     * @apiName GetReplyList
+     * @apiGroup Product
+     * 
      */
     public function reply_list(Request $request, $id)
     {

+ 51 - 17
app/api/controller/user/StoreService.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\api\controller\user;
 
 use app\models\store\StoreServiceLog;
@@ -15,37 +16,70 @@ class StoreService
 {
 
     /**
-     * 客服列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} user/service/list 获取客服列表
+     * @apiName GetUserServiceList
+     * @apiGroup User
+     * 
+     * @apiQuery {int} page 分页
+     * @apiQuery {int} limit
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     *   "data": [{
+     *      "id": 1,
+     *      "uid": 123,
+     *      "avatar": "http://icon.png",
+     *      "nickname": "john",
+     *      "customer": 0
+     *   }]
+     * }
+     * // 失败返回空数组
+     * 
      */
     public function lst(Request $request)
     {
-        list($page, $limit) = UtilService::getMore([['page',0],['limit',0]], $request, true);
-//        if(!$page || !$limit) return app('json')->successful([]);
+        list($page, $limit) = UtilService::getMore([['page', 0], ['limit', 0]], $request, true);
+        if (!$page || !$limit) {
+            return app('json')->successful([]);
+        }
         $serviceInfoList = StoreServiceModel::lst($page, $limit);
-        if(!count($serviceInfoList)) return app('json')->successful([]);
+        if (!count($serviceInfoList)) {
+            return app('json')->successful([]);
+        }
         return app('json')->successful($serviceInfoList->hidden(['notify', 'status', 'mer_id', 'add_time'])->toArray());
     }
 
     /**
-     * 客服聊天记录
-     * @param Request $request
-     * @param $toUid
-     * @return array
+     * @api {get} user/service/record/:toUid 获取客服聊天记录
+     * @apiName GetUserServiceRecord
+     * @apiGroup User
+     * 
+     * @apiParam {int} toUid 聊天对象
+     * @apiQuery {int} page 分页
+     * @apiQuery {int} limit
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function record(Request $request, $toUid)
     {
-        list($page, $limit) = UtilService::getMore([['page',0],['limit',0]], $request, true);
-        if(!$toUid) return app('json')->fail('参数错误');
+        list($page, $limit) = UtilService::getMore([['page', 0], ['limit', 0]], $request, true);
+        if (!$toUid) {
+            return app('json')->fail('参数错误');
+        }
         $uid = $request->uid();
-        if(!$limit || !$page) return app('json')->successful([]);
+        if (!$limit || !$page) {
+            return app('json')->successful([]);
+        }
         $serviceLogList = StoreServiceLog::lst($uid, $toUid, $page, $limit);
-        if(!$serviceLogList) return app('json')->successful([]);
+        if (!$serviceLogList) {
+            return app('json')->successful([]);
+        }
         $serviceLogList = $serviceLogList->hidden(['mer_id'])->toArray();
         $idArr = array_column($serviceLogList, 'id');
-        array_multisort($idArr,SORT_ASC,$serviceLogList);
+        array_multisort($idArr, SORT_ASC, $serviceLogList);
         return app('json')->successful($serviceLogList);
     }
-
-}
+}

+ 66 - 63
app/api/controller/user/UserBillController.php

@@ -10,11 +10,8 @@ use app\models\user\User;
 use app\models\user\UserBill;
 use app\models\user\UserExtract;
 use app\Request;
-use crmeb\services\GroupDataService;
-use crmeb\services\SystemConfigService;
 use crmeb\services\UtilService;
 use crmeb\services\upload\Upload;
-use think\facade\Log;
 
 /**
  * 账单类
@@ -24,26 +21,27 @@ use think\facade\Log;
 class UserBillController
 {
     /**
-     * 推广数据    昨天的佣金   累计提现金额  当前佣金
-     * @param Request $request
-     * @return mixed
+     * @api {get} /commission 推广数据 昨天的佣金 累计提现金额 当前佣金
+     * @apiName GetCommission
+     * @apiGroup User.Bill
+     * 
      */
     public function commission(Request $request)
     {
         $uid = $request->uid();
-        $lastDayCount = UserBill::yesterdayCommissionSum($uid);//昨天的佣金
-        $extractCount = UserExtract::extractSum($uid);//累计提现金额
-        $commissionCount = UserBill::getBrokerage($uid);//获取总佣金
+        $lastDayCount = UserBill::yesterdayCommissionSum($uid); //昨天的佣金
+        $extractCount = UserExtract::extractSum($uid); //累计提现金额
+        $commissionCount = UserBill::getBrokerage($uid); //获取总佣金
         if ($commissionCount > 0) {
-            $rechargeCount = UserBill::getRecharge($uid);//累计充值
-            $orderYuePrice = StoreOrder::getOrderStatusYueSum($uid);//余额累计消费
-            $systemAdd = UserBill::getSystemAdd($uid);//后台添加余额
-            $yueCount = bcadd($rechargeCount, $systemAdd, 2);// 后台添加余额 + 累计充值  = 非佣金的总金额
-            $orderYuePrice = $yueCount > $orderYuePrice ? 0 : bcsub($orderYuePrice, $yueCount, 2);// 余额累计消费(使用佣金消费的金额)
-            $commissionCount = bcsub($commissionCount, $extractCount, 2);//减去已提现金额
+            $rechargeCount = UserBill::getRecharge($uid); //累计充值
+            $orderYuePrice = StoreOrder::getOrderStatusYueSum($uid); //余额累计消费
+            $systemAdd = UserBill::getSystemAdd($uid); //后台添加余额
+            $yueCount = bcadd($rechargeCount, $systemAdd, 2); // 后台添加余额 + 累计充值  = 非佣金的总金额
+            $orderYuePrice = $yueCount > $orderYuePrice ? 0 : bcsub($orderYuePrice, $yueCount, 2); // 余额累计消费(使用佣金消费的金额)
+            $commissionCount = bcsub($commissionCount, $extractCount, 2); //减去已提现金额
             $extractPriceCount = UserExtract::userExtractTotalPrice($uid, 0);
-            $commissionCount = $extractPriceCount < $commissionCount ? bcsub($commissionCount, $extractPriceCount, 2) : 0;//减去审核中的提现金额
-            $commissionCount = $commissionCount > $orderYuePrice ? bcsub($commissionCount, $orderYuePrice, 2) : 0;//减掉余额支付
+            $commissionCount = $extractPriceCount < $commissionCount ? bcsub($commissionCount, $extractPriceCount, 2) : 0; //减去审核中的提现金额
+            $commissionCount = $commissionCount > $orderYuePrice ? bcsub($commissionCount, $orderYuePrice, 2) : 0; //减掉余额支付
         }
         $data['lastDayCount'] = $lastDayCount;
         $data['extractCount'] = $extractCount;
@@ -53,19 +51,21 @@ class UserBillController
 
 
     /**
-     * 推荐用户
-     * @param Request $request
-     * @return mixed
-     *
-     * grade == 0  获取一级推荐人
-     * grade == 1  获取二级推荐人
-     *
-     * keyword 会员名称查询
-     *
-     * sort  childCount ASC/DESC  团队排序   numberCount ASC/DESC  金额排序  orderCount  ASC/DESC  订单排序
+     * @api {post} /spread/people 推荐用户
+     * @apiName PostSpreadPeople
+     * @apiGroup User.Bill
+     * 
      */
     public function spread_people(Request $request)
     {
+        /*
+        * grade == 0  获取一级推荐人
+        * grade == 1  获取二级推荐人
+        *
+        * keyword 会员名称查询
+        *
+        * sort  childCount ASC/DESC  团队排序   numberCount ASC/DESC  金额排序  orderCount  ASC/DESC  订单排序
+        */
         $spreadInfo = UtilService::postMore([
             ['page', 1],
             ['limit', 20],
@@ -81,9 +81,10 @@ class UserBillController
     }
 
     /**
-     * 推广订单
-     * @param Request $request
-     * @return mixed
+     * @api {post} /spread/order 推广订单
+     * @apiName PostSpreadOrder
+     * @apiGroup User.Bill
+     * 
      */
     public function spread_order(Request $request)
     {
@@ -108,13 +109,14 @@ class UserBillController
     }
 
     /**
-     * 推广佣金明细
-     * @param Request $request
-     * @param $type 0 全部  1 消费  2 充值  3 返佣  4 提现
-     * @return mixed
+     * @api {get} /spread/commission/:type 推广佣金明细
+     * @apiName GetSpreadCommission
+     * @apiGroup User.Bill
+     * 
      */
     public function spread_commission(Request $request, $type)
     {
+        // $type 0 全部  1 消费  2 充值  3 返佣  4 提现
         list($page, $limit) = UtilService::getMore([
             ['page', 0],
             ['limit', 0],
@@ -123,20 +125,21 @@ class UserBillController
     }
 
     /**
-     * 推广 佣金/提现 总和
-     * @param Request $request
-     * @param $type 3 佣金  4 提现
-     * @return mixed
+     * @api {get} /spread/count/:type 推广 佣金/提现 总和
+     * @apiName GetSpreadCount
+     * @apiGroup User.Bill
+     * 
      */
     public function spread_count(Request $request, $type)
     {
+        // $type 3 佣金  4 提现
         $count = 0;
-        if ($type == 3) {
+        if ($type == BILL_BROKERAGE) {
             $count1 = UserBill::getRecordCount($request->uid(), 'now_money', 'brokerage');
             $count2 = UserBill::getRecordCount($request->uid(), 'now_money', 'brokerage', '', true);
             $count = $count1 - $count2;
-        } else if ($type == 4) {
-            $count = UserExtract::userExtractTotalPrice($request->uid());//累计提现
+        } else if ($type == BILL_EXTRACT) {
+            $count = UserExtract::userExtractTotalPrice($request->uid()); //累计提现
         }
         $count = $count ? $count : 0;
         return app('json')->successful(['count' => $count]);
@@ -144,9 +147,10 @@ class UserBillController
 
 
     /**
-     * 分销二维码海报生成
-     * @param Request $request
-     * @return mixed
+     * @api {get} /spread/banner 分销二维码海报生成
+     * @apiName GetSpreadBanner
+     * @apiGroup User.Bill
+     * 
      */
     public function spread_banner(Request $request)
     {
@@ -158,15 +162,15 @@ class UserBillController
         $qiniu_path = 'user_share_qrcode';
 
         try {
-            $resRoutine = true;//小程序
-            $resWap = true;//公众号
+            $resRoutine = true; //小程序
+            $resWap = true; //公众号
             $siteUrl = sys_config('site_url');
             // 配置的海报背景模板
             $routineSpreadBanner = sys_data('routine_spread_banner');
             if (!count($routineSpreadBanner)) {
                 return app('json')->fail('暂无海报');
             }
-            
+
             if ($type == 1) {
                 // 直接获取用户海报
                 foreach ($routineSpreadBanner as &$item) {
@@ -196,9 +200,11 @@ class UserBillController
                 $imageInfo = SystemAttachment::getInfo($name, 'name');
                 //检测远程文件是否存在
                 // 20210722 注释掉,太卡
-                if (isset($imageInfo['att_dir']) && 
-                    strstr($imageInfo['att_dir'], 'http') !== false && 
-                    curl_file_exist($imageInfo['att_dir']) === false) {
+                if (
+                    isset($imageInfo['att_dir']) &&
+                    strstr($imageInfo['att_dir'], 'http') !== false &&
+                    curl_file_exist($imageInfo['att_dir']) === false
+                ) {
                     $imageInfo = null;
                     SystemAttachment::where(['name' => $name])->delete();
                 }
@@ -214,7 +220,7 @@ class UserBillController
                         'storageRegion' => sys_config('storage_region'),
                     ]);
                     // 上传分享二维码 [ qiniu 添加一个子路径]
-                    $remoteName = $uploadType == 2 ?  $qiniu_path. '/' . $name : $name;
+                    $remoteName = $uploadType == 2 ?  $qiniu_path . '/' . $name : $name;
                     $uploadRes = $upload->to('routine/spread/code')->validate()->stream($res['res'], $remoteName);
                     if ($uploadRes === false) {
                         return app('json')->fail($upload->getError());
@@ -239,7 +245,7 @@ class UserBillController
                     'Normal' => 'static' . DS . 'font' . DS . 'Alibaba-PuHuiTi-Regular.otf',
                 ];
                 if (!file_exists($filelink['Bold'])) {
-                     return app('json')->fail('缺少字体文件Bold');
+                    return app('json')->fail('缺少字体文件Bold');
                 }
                 if (!file_exists($filelink['Normal'])) {
                     return app('json')->fail('缺少字体文件Normal');
@@ -281,7 +287,7 @@ class UserBillController
                             )
                         ),
                         'background' => $item['pic'],
-                        'name' => $qiniu_path. '/' . $user['uid'] . '_' . $user['is_promoter'] . '_' . $item['id'] . '_user_routine_poster.jpg',
+                        'name' => $qiniu_path . '/' . $user['uid'] . '_' . $user['is_promoter'] . '_' . $item['id'] . '_user_routine_poster.jpg',
                     );
                     $resRoutine = $resRoutine && $posterInfo = UtilService::setSharePoster($config, 'routine/spread/poster');
                     if (!is_array($posterInfo)) {
@@ -308,7 +314,7 @@ class UserBillController
                     SystemAttachment::where(['name' => $name])->delete();
                 }
                 if (!$imageInfo) {
-                    $codeUrl = set_http_type($siteUrl . '?spread=' . $user['uid'], $request->isSsl() ? 0 : 1);//二维码链接
+                    $codeUrl = set_http_type($siteUrl . '?spread=' . $user['uid'], $request->isSsl() ? 0 : 1); //二维码链接
                     $imageInfo = UtilService::getQRCodePath($codeUrl, $name);
                     if (is_string($imageInfo)) return app('json')->fail('二维码生成失败', ['error' => $imageInfo]);
                     SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
@@ -374,19 +380,17 @@ class UserBillController
             if ($resRoutine && $resWap) return app('json')->successful($routineSpreadBanner);
             else return app('json')->fail('生成图片失败');
         } catch (\Exception $e) {
-            Log::error('生成图片时,系统错误:' . $e->getMessage());
+            errlog('生成图片时,系统错误:' . $e->getMessage());
             return app('json')->fail('生成图片时,系统错误', ['line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]);
         }
     }
 
 
     /**
-     * 积分记录
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /integral/list 积分记录
+     * @apiName GetIntegralList
+     * @apiGroup User.Bill
+     * 
      */
     public function integral_list(Request $request)
     {
@@ -394,6 +398,5 @@ class UserBillController
             [['page', 'd'], 0], [['limit', 'd'], 0]
         ], $request, true);
         return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit));
-
     }
-}
+}

+ 213 - 119
app/api/controller/user/UserController.php

@@ -30,11 +30,12 @@ class UserController
 {
 
     /**
-     * 获取用户信息
-     * @param Request $request
-     * @return mixed
+     * @api {get} /userinfo 获取用户信息
+     * @apiName GetUserinfo
+     * @apiGroup User
+     * 
      */
-    public function userInfo(Request $request)
+    public function userinfo(Request $request)
     {
         $info = $request->user()->toArray();
         $broken_time = intval(sys_config('extract_time'));
@@ -59,21 +60,22 @@ class UserController
     }
 
     /**
-     * 用户资金统计
-     * @param Request $request
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /user/balance 用户资金统计
+     * @apiName GetUserBalance
+     * @apiGroup User
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function balance(Request $request)
     {
         $uid = $request->uid();
 
-        $user['now_money'] = User::getUserInfo($uid, 'now_money')['now_money'];//当前总资金
-        $user['recharge'] = UserBill::getRecharge($uid);//累计充值
-        $user['orderStatusSum'] = StoreOrder::getOrderStatusSum($uid);//累计消费
+        $user['now_money'] = User::getUserInfo($uid, 'now_money')['now_money']; //当前总资金
+        $user['recharge'] = UserBill::getRecharge($uid); //累计充值
+        $user['orderStatusSum'] = StoreOrder::getOrderStatusSum($uid); //累计消费
         $coins = UserCoin::alias('uc')
             ->join('dict_coin dc', 'uc.symbol=dc.symbol')->field('uc.symbol, dc.icon, uc.addr, uc.balance as total')
             ->where('uid', $uid)->select();
@@ -83,9 +85,15 @@ class UserController
     }
 
     /**
-     * 个人中心
-     * @param Request $request
-     * @return mixed
+     * @api {get} /user 个人中心
+     * @apiName GetUser
+     * @apiGroup User
+     * 
+     * @apiParam none None
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
      */
     public function user(Request $request)
     {
@@ -95,11 +103,11 @@ class UserController
         $user['like'] = StoreProductRelation::getUserIdCollect($user['uid']);
         $user['orderStatusNum'] = StoreOrder::getOrderData($user['uid']);
         $user['notice'] = UserNotice::getNotice($user['uid']);
-//        $user['brokerage'] = UserBill::getBrokerage($user['uid']);//获取总佣金
-        $user['recharge'] = UserBill::getRecharge($user['uid']);//累计充值
-        $user['orderStatusSum'] = StoreOrder::getOrderStatusSum($user['uid']);//累计消费
-        $user['extractTotalPrice'] = UserExtract::userExtractTotalPrice($user['uid']);//累计提现
-        $user['extractPrice'] = $user['brokerage_price'];//可提现
+        // $user['brokerage'] = UserBill::getBrokerage($user['uid']);//获取总佣金
+        $user['recharge'] = UserBill::getRecharge($user['uid']); //累计充值
+        $user['orderStatusSum'] = StoreOrder::getOrderStatusSum($user['uid']); //累计消费
+        $user['extractTotalPrice'] = UserExtract::userExtractTotalPrice($user['uid']); //累计提现
+        $user['extractPrice'] = $user['brokerage_price']; //可提现
         $user['statu'] = (int)sys_config('store_brokerage_statu');
         $broken_time = intval(sys_config('extract_time'));
         $search_time = time() - 86400 * $broken_time;
@@ -147,8 +155,8 @@ class UserController
             }
         }
         $user['yesterDay'] = UserBill::yesterdayCommissionSum($user['uid']);
-        $user['recharge_switch'] = (int)sys_config('recharge_switch');//充值开关
-        $user['adminid'] = (boolean)\app\models\store\StoreService::orderServiceStatus($user['uid']);
+        $user['recharge_switch'] = (int)sys_config('recharge_switch'); //充值开关
+        $user['adminid'] = (bool)\app\models\store\StoreService::orderServiceStatus($user['uid']);
         if ($user['phone'] && $user['user_type'] != 'h5') {
             $user['switchUserInfo'][] = $request->user();
             if ($h5UserInfo = User::where('account', $user['phone'])->where('user_type', 'h5')->find()) {
@@ -170,13 +178,15 @@ class UserController
     }
 
     /**
-     * 地址 获取单个
-     * @param Request $request
-     * @param $id
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /address/detail/:id 地址获取单个
+     * @apiName GetAddress
+     * @apiGroup User.Address
+     * 
+     * @apiParam {int} id address_id
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
      */
     public function address(Request $request, $id)
     {
@@ -188,11 +198,17 @@ class UserController
     }
 
     /**
-     * 地址列表
-     * @param Request $request
-     * @param $page
-     * @param $limit
-     * @return mixed
+     * @api {get} /address/list 地址列表
+     * @apiName GetAddressList
+     * @apiGroup User.Address
+     * 
+     * @apiQuery {int} page
+     * @apiQuery {int} limit
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function address_list(Request $request)
     {
@@ -202,10 +218,19 @@ class UserController
     }
 
     /**
-     * 设置默认地址
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {post} /address/default/set 设置默认地址
+     * @apiName PostAddressDefaultSet
+     * @apiGroup User.Address
+     * 
+     * @apiQuery {int} id address_id
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * 
+     * }
      */
     public function address_default_set(Request $request)
     {
@@ -221,9 +246,16 @@ class UserController
     }
 
     /**
-     * 获取默认地址
-     * @param Request $request
-     * @return mixed
+     * @api {get} /address/default 获取默认地址
+     * @apiName GetAddressDefault
+     * @apiGroup User.Address
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function address_default(Request $request)
     {
@@ -236,9 +268,18 @@ class UserController
     }
 
     /**
-     * 修改 添加地址
-     * @param Request $request
-     * @return mixed
+     * @api {post} /address/edit 修改添加地址
+     * @apiName PostAddressEdit
+     * @apiGroup User.Address
+     * 
+     * @apiBody none None
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function address_edit(Request $request)
     {
@@ -307,10 +348,16 @@ class UserController
     }
 
     /**
-     * 删除地址
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {post} /address/del 删除地址
+     * @apiName PostAddressDel
+     * @apiGroup User.Address
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function address_del(Request $request)
     {
@@ -326,10 +373,16 @@ class UserController
 
 
     /**
-     * 获取收藏产品
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {get} /collect/user 获取收藏产品
+     * @apiName GetCollectUser
+     * @apiGroup User.Collect
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function collect_user(Request $request)
     {
@@ -343,11 +396,16 @@ class UserController
     }
 
     /**
-     * 添加收藏
-     * @param Request $request
-     * @param $id
-     * @param $category
-     * @return mixed
+     * @api {post} /collect/add 添加收藏
+     * @apiName PostCollectAdd
+     * @apiGroup User.Collect
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function collect_add(Request $request)
     {
@@ -359,10 +417,16 @@ class UserController
     }
 
     /**
-     * 取消收藏
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {post} /collect/del 取消收藏
+     * @apiName PostCollectDel
+     * @apiGroup User.Collect
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function collect_del(Request $request)
     {
@@ -374,9 +438,16 @@ class UserController
     }
 
     /**
-     * 批量收藏
-     * @param Request $request
-     * @return mixed
+     * @api {post} /collect/all 批量收藏
+     * @apiName PostCollectAll
+     * @apiGroup User.Collect
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * }
+     * @apiErrorExample Failed
+     * {
+     * }
      */
     public function collect_all(Request $request)
     {
@@ -397,14 +468,14 @@ class UserController
      * @param Request $request
      * @return mixed
      */
-//    public function like_add(Request $request)
-//    {
-//        list($id, $category) = UtilService::postMore([['id',0], ['category','product']], $request, true);
-//        if(!$id || !is_numeric($id))  return app('json')->fail('参数错误');
-//        $res = StoreProductRelation::productRelation($id,$request->uid(),'like',$category);
-//        if(!$res) return  app('json')->fail(StoreProductRelation::getErrorInfo());
-//        else return app('json')->successful();
-//    }
+    //    public function like_add(Request $request)
+    //    {
+    //        list($id, $category) = UtilService::postMore([['id',0], ['category','product']], $request, true);
+    //        if(!$id || !is_numeric($id))  return app('json')->fail('参数错误');
+    //        $res = StoreProductRelation::productRelation($id,$request->uid(),'like',$category);
+    //        if(!$res) return  app('json')->fail(StoreProductRelation::getErrorInfo());
+    //        else return app('json')->successful();
+    //    }
 
     /**
      * 取消点赞
@@ -412,21 +483,24 @@ class UserController
      * @param Request $request
      * @return mixed
      */
-//    public function like_del(Request $request)
-//    {
-//        list($id, $category) = UtilService::postMore([['id',0], ['category','product']], $request, true);
-//        if(!$id || !is_numeric($id)) return app('json')->fail('参数错误');
-//        $res = StoreProductRelation::unProductRelation($id, $request->uid(),'like',$category);
-//        if(!$res) return app('json')->fail(StoreProductRelation::getErrorInfo());
-//        else return app('json')->successful();
-//    }
+    //    public function like_del(Request $request)
+    //    {
+    //        list($id, $category) = UtilService::postMore([['id',0], ['category','product']], $request, true);
+    //        if(!$id || !is_numeric($id)) return app('json')->fail('参数错误');
+    //        $res = StoreProductRelation::unProductRelation($id, $request->uid(),'like',$category);
+    //        if(!$res) return app('json')->fail(StoreProductRelation::getErrorInfo());
+    //        else return app('json')->successful();
+    //    }
 
     /**
-     * 签到 配置
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /sign/config 签到配置
+     * @apiName GetSignConfig
+     * @apiGroup User.Sign
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function sign_config()
     {
@@ -435,11 +509,14 @@ class UserController
     }
 
     /**
-     * 签到 列表
-     * @param Request $request
-     * @param $page
-     * @param $limit
-     * @return mixed
+     * @api {get} /sign/list 签到列表
+     * @apiName GetSignList
+     * @apiGroup User.Sign
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function sign_list(Request $request)
     {
@@ -454,9 +531,10 @@ class UserController
     }
 
     /**
-     * 签到
-     * @param Request $request
-     * @return mixed
+     * @api {post} /sign/integral 签到
+     * @apiName PostSignIntegral
+     * @apiGroup User.Sign
+     * 
      */
     public function sign_integral(Request $request)
     {
@@ -468,9 +546,10 @@ class UserController
     }
 
     /**
-     * 签到用户信息
-     * @param Request $request
-     * @return mixed
+     * @api {post} /sign/user 签到用户信息
+     * @apiName PostSignUser
+     * @apiGroup User.Sign
+     * 
      */
     public function sign_user(Request $request)
     {
@@ -508,10 +587,10 @@ class UserController
     }
 
     /**
-     * 签到列表(年月)
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {get} /sign/month 签到列表(年月)
+     * @apiName GetSignMonth
+     * @apiGroup User.Sign
+     * 
      */
     public function sign_month(Request $request)
     {
@@ -525,8 +604,10 @@ class UserController
     }
 
     /**
-     * 获取活动状态
-     * @return mixed
+     * @api {get} /user/activity 获取活动状态
+     * @apiName GetUserActivity
+     * @apiGroup User
+     * 
      */
     public function activity()
     {
@@ -537,9 +618,17 @@ class UserController
     }
 
     /**
-     * 用户修改信息
-     * @param Request $request
-     * @return mixed
+     * @api {post} /user/edit 用户修改信息
+     * @apiName PostUserEdit
+     * @apiGroup User
+     * 
+     * @apiBody {string} avatar 头像
+     * @apiBody {string} nickname 昵称
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function edit(Request $request)
     {
@@ -552,12 +641,11 @@ class UserController
     }
 
     /**
-     * 推广人排行
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /rank 推广人排行
+     * @apiName GetRank
+     * @apiGroup User
+     * 
+     * 
      */
     public function rank(Request $request)
     {
@@ -571,9 +659,17 @@ class UserController
     }
 
     /**
-     * 佣金排行
-     * @param Request $request
-     * @return mixed
+     * @api {get} /brokerage_rank 佣金排行
+     * @apiName GetBrokerage_rank
+     * @apiGroup User
+     * 
+     * @apiBody {string} avatar 头像
+     * @apiBody {string} nickname 昵称
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
      */
     public function brokerage_rank(Request $request)
     {
@@ -604,7 +700,5 @@ class UserController
             'rank' => $users,
             'position' => $position
         ]);
-
     }
-
-}
+}

+ 30 - 28
app/api/controller/user/UserExtractController.php

@@ -8,7 +8,6 @@ use app\Request;
 use tw\services\payment\MachantPay;
 use tw\services\controller\PaymentService;
 use crmeb\services\UtilService;
-use think\facade\Log;
 use tw\redis\UserRds;
 
 /**
@@ -21,9 +20,9 @@ class UserExtractController
     /**
      * @api {get} /extract/bank 提现银行
      * @apiName ExtractBank
-     * @apiGroup Brokerage
+     * @apiGroup User.Extract
      * 
-     * @apiDescription 现前请求,用户显示和客户端过滤
+     * @apiDescription 现前请求,用户显示和客户端过滤
      * 
      * @apiSuccess {float} broken_commission 冻结佣金
      * @apiSuccess {float} brokerage_price 总佣金
@@ -80,7 +79,7 @@ class UserExtractController
     /**
      * @api {post} /extract/bank_fee 查询银行提现手续费
      * @apiName PostExtractBankFee
-     * @apiGroup Brokerage
+     * @apiGroup User.Extract
      * 
      * @apiBody {int} extract_type 提现类型/通道
      * @apiBody {float} money 提现金额
@@ -113,7 +112,7 @@ class UserExtractController
         if ($extractInfo['money'] < sys_config('user_extract_min_price')) {
             return app('json')->fail('金额小于最低提现金额');
         }
-        
+
         $bankMax = 1000; // 银行渠道限额
         if ($extractInfo['money'] > $bankMax) {
             return app('json')->fail("金额不能超过 $bankMax 元");
@@ -135,29 +134,8 @@ class UserExtractController
             'valid' => $valid,      // 实际到帐
         ]);
     }
-
     /**
-     * @api {post} /extract/cash 提现申请
-     * @apiName ExtractCash
-     * @apiGroup Brokerage
-     * 
-     * @apiBody {string} alipay_code 支付宝号码
-     * @apiBody {string="alipay","bank","weixin"} extract_type 提现类型
-     * @apiBody {float} money 提现金额
-     * @apiBody {string} bankName 开户行
-     * @apiBody {string} cardnum 卡号
-     * @apiBody {string} name 微信实名/银行户名/支付宝帐号
-     * @apiBody {string} weixin 微信实名
-     * 
-     * @apiSuccessExample Succeed
-     * {
-     * 
-     * }
-     * @apiErrorExample Failed
-     * {
-     *  
-     * }
-     * 
+     * @deprecated
      */
     public function cash(Request $request)
     {
@@ -193,6 +171,30 @@ class UserExtractController
      * API 执行失败,则必须重新提交提现请求,因为人工操作也是失败。
      * 如果API 返回 SYSTEMERROR, 则按照原订单参数重新提交。
      */
+
+    /**
+     * @api {post} /extract/cash 提现申请
+     * @apiName ExtractCash
+     * @apiGroup User.Extract
+     * 
+     * @apiBody {string} alipay_code 支付宝号码
+     * @apiBody {string="alipay","bank","weixin"} extract_type 提现类型
+     * @apiBody {float} money 提现金额
+     * @apiBody {string} bankName 开户行
+     * @apiBody {string} cardnum 卡号
+     * @apiBody {string} name 微信实名/银行户名/支付宝帐号
+     * @apiBody {string} weixin 微信实名
+     * 
+     * @apiSuccessExample Succeed
+     * {
+     * 
+     * }
+     * @apiErrorExample Failed
+     * {
+     *  
+     * }
+     * 
+     */
     public function flash_cash(Request $request)
     {
         // 提交申请
@@ -214,7 +216,7 @@ class UserExtractController
         $row = $msg;
         $extractRow = UserExtract::getUserExtractInfo($user['uid'], $row['extract_type'], $row['add_time']);
         if (!$extractRow) {
-            Log::error('Unbelievable error getUserExtractInfo(' . $user['uid'] . ' ' . $row['add_time'] . ')');
+            errlog('Unbelievable error getUserExtractInfo(' . $user['uid'] . ' ' . $row['add_time'] . ')');
             return app('json')->fail('提交申请失败');
         }
         // 检查条件

+ 12 - 10
app/api/controller/user/UserLevelController.php

@@ -15,9 +15,10 @@ class UserLevelController
 {
 
     /**
-     * 检测用户是否可以成为会员
-     * @param Request $request
-     * @return mixed
+     * @api {get} /user/level/detection 检测用户是否可以成为会员
+     * @apiName GetUserLevelDetection
+     * @apiGroup User.Level
+     * 
      */
     public function detection(Request $request)
     {
@@ -25,9 +26,10 @@ class UserLevelController
     }
 
     /**
-     * 会员等级列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} /user/level/grade 会员等级列表
+     * @apiName GetUserLevelGrade
+     * @apiGroup User.Level
+     * 
      */
     public function grade(Request $request)
     {
@@ -35,10 +37,10 @@ class UserLevelController
     }
 
     /**
-     * 获取等级任务
-     * @param Request $request
-     * @param $id
-     * @return mixed
+     * @api {get} /user/level/task/:id 获取等级任务
+     * @apiName GetUserLevelTask
+     * @apiGroup User.Level
+     * 
      */
     public function task(Request $request, $id)
     {

+ 18 - 3
app/api/controller/user/UserNoticeController.php

@@ -14,7 +14,12 @@ use crmeb\services\UtilService;
  */
 class UserNoticeController {
 
-    // 获取用户所有消息(分页)
+    /**
+     * @api {get} /user/messages 获取用户所有消息(分页)
+     * @apiName GetUserMessages
+     * @apiGroup User.Message
+     * 
+     */
     public function messages(Request $request) {
         [$page, $limit] = UtilService::getMore([
             ['page', 1],
@@ -25,7 +30,12 @@ class UserNoticeController {
         return app('json')->successful(UserNotice::getNoticeList($uid, intval($page), intval($limit)));
     }
 
-    // 标记已读
+    /**
+     * @api {post} /user/messages 标记已读
+     * @apiName PostUserMessages
+     * @apiGroup User.Message
+     * 
+     */ 
     public function read(Request $request) {
         list($ids, $read) = UtilService::postMore([
             ['ids', []],
@@ -44,7 +54,12 @@ class UserNoticeController {
         return app('json')->successful([]);
     }
 
-    // 删除
+    /**
+     * @api {post} /user/messages/del 删除消息
+     * @apiName PostUserMessageDel
+     * @apiGroup User.Message
+     * 
+     */
     public function del(Request $request) {
         list($ids) = UtilService::postMore([
             ['ids', []]

+ 17 - 14
app/api/controller/user/UserRechargeController.php

@@ -5,8 +5,6 @@ namespace app\api\controller\user;
 use app\models\system\SystemGroupData;
 use app\models\user\UserRecharge;
 use app\Request;
-use crmeb\services\GroupDataService;
-use crmeb\services\SystemConfigService;
 use crmeb\services\UtilService;
 
 /**
@@ -18,10 +16,10 @@ class UserRechargeController
 {
 
     /**
-     * 小程序充值
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {post} /recharge/routine 小程序充值
+     * @apiName PostRechargeRoutine
+     * @apiGroup User.Recharge
+     * 
      */
     public function routine(Request $request)
     {
@@ -65,10 +63,10 @@ class UserRechargeController
     }
 
     /**
-     * 公众号充值
-     *
-     * @param Request $request
-     * @return mixed
+     * @api {post} /recharge/wechat 公众号充值
+     * @apiName PostRechargeWechat
+     * @apiGroup User.Recharge
+     * 
      */
     public function wechat(Request $request)
     {
@@ -118,7 +116,10 @@ class UserRechargeController
     }
 
     /**
-     * app 充值
+     * @api {post} /recharge/app app 充值
+     * @apiName PostRechargeApp
+     * @apiGroup User.Recharge
+     * 
      */
     public function app(Request $request)
     {
@@ -170,8 +171,10 @@ class UserRechargeController
     }
 
     /**
-     * 充值额度选择
-     * @return mixed
+     * @api {get} /recharge/index 充值额度选择
+     * @apiName GetRechargeIndex
+     * @apiGroup User.Recharge
+     * 
      */
     public function index()
     {
@@ -182,4 +185,4 @@ class UserRechargeController
         $data['recharge_attention'] = $recharge_attention;
         return app('json')->successful($data);
     }
-}
+}

+ 39 - 30
app/api/controller/wechat/AuthController.php

@@ -45,18 +45,25 @@ class AuthController
      * 以上兼容旧协议
      * 'status' => 0/1 0 表示正常登录成功, 1 表示需要进一步调用 wx.getUserProfile 进行授权
      */
+
+    /**
+     * @api {post} /wechat/mp_auth_simple 只利用 code 登录
+     * @apiName PostWechatMpSimple
+     * @apiGroup Public
+     * 
+     */
     public function mp_auth_simple(Request $request)
     {
         list($code) = UtilService::postMore([
             ['code', ''],
         ], $request, true);
-        // Log::debug(__FUNCTION__ . " param code: $code");
+        // debuglog(__FUNCTION__ . " param code: $code");
         try {
             $json2sess = MiniProgramService::getUserInfo($code);
             // $sess_key = $json2sess['session_key'] ?? '';
             $openId = $json2sess['openid'] ?? '';
             $unionid = $json2sess['unionid'] ?? '';
-            // Log::debug("openid=$openId, unionid=$unionid");
+            // debuglog("openid=$openId, unionid=$unionid");
             // find by unionid
             if ($unionid != '') {
                 $uid = WechatUser::where(['unionid' => $unionid])
@@ -88,7 +95,7 @@ class AuthController
             if (!$token) {
                 return app('json')->fail('获取用户访问token失败!');
             }
-            // Log::debug("token=" . $token->token);
+            // debuglog("token=" . $token->token);
             // 缓存 session_key
             $cache_key = md5(time() . $code);
             Cache::set('eb_api_code_' . $cache_key, $json2sess, SECONDS_OF_ONEDAY);
@@ -119,9 +126,11 @@ class AuthController
     }
 
     /**
-     * @deprecated
-     * 小程序在 mp_auth_login 返回特定值(表示用户不存在,或刷新用户信息)后,
-     * 调用 wx.getUserProfile 获取用户信息,来注册或刷新信息。
+     * @api {post} /wechat/mp_auth_with_userinfo 提交用户资料注册或刷新
+     * @apiName PostWechatMpAuthWithUserinfo
+     * @apiGroup Public
+     * 
+     * @apiDeprecated 小程序在 mp_auth_login 返回特定值(表示用户不存在,或刷新用户信息)后,调用 wx.getUserProfile 获取用户信息,来注册或刷新信息。
      */
     public function mp_auth_with_userinfo(Request $request)
     {
@@ -176,13 +185,10 @@ class AuthController
     }
 
     /**
-     * 小程序授权登录
-     * @param Request $request
-     * @return mixed
-     * @throws \Psr\SimpleCache\InvalidArgumentException
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {post} /mp_auth 小程序授权登录
+     * @apiName PostMpAuth
+     * @apiGroup Public
+     * 
      */
     public function mp_auth(Request $request)
     {
@@ -192,7 +198,7 @@ class AuthController
             ['cache_key', ''],
             ['login_type', '']
         ], $request, true);
-        // Log::debug("code=$code, post_cache_key=$post_cache_key, login_type=$login_type");
+        // debuglog("code=$code, post_cache_key=$post_cache_key, login_type=$login_type");
         $session_key = Cache::get('eb_api_code_' . $post_cache_key);
         if (!$code && !$session_key)
             return app('json')->fail('授权失败,参数有误');
@@ -207,7 +213,7 @@ class AuthController
                     errmsg	string	错误信息
                  */
                 $userInfoWx = MiniProgramService::getUserInfo($code);
-                // Log::debug('userinfo=' . json_encode($userInfoWx));
+                // debuglog('userinfo=' . json_encode($userInfoWx));
                 $session_key = $userInfoWx['session_key'];
                 $cache_key = md5(time() . $code);
                 Cache::set('eb_api_code_' . $cache_key, $session_key, 86400);
@@ -225,7 +231,7 @@ class AuthController
         try {
             //解密获取用户信息
             $userInfo = MiniProgramService::encryptor($session_key, $data['iv'], $data['encryptedData']);
-            // Log::debug('userinfo=' . json_encode($userInfo));
+            // debuglog('userinfo=' . json_encode($userInfo));
         } catch (\Exception $e) {
             if ($e->getCode() == '-41003') return app('json')->fail('获取会话密匙失败');
         }
@@ -259,9 +265,10 @@ class AuthController
     }
 
     /**
-     * 获取授权logo
-     * @param Request $request
-     * @return mixed
+     * @api {get} /wechat/get_logo 获取授权logo
+     * @apiName GetWechatLogo
+     * @apiGroup Public
+     * 
      */
     public function get_logo(Request $request)
     {
@@ -282,9 +289,10 @@ class AuthController
     }
 
     /**
-     * 保存form id
-     * @param Request $request
-     * @return mixed
+     * @api {post} /wechat/set_form_id 保存form id
+     * @apiName PostWechatSetFormId
+     * @apiGroup Public
+     * 
      */
     public function set_form_id(Request $request)
     {
@@ -294,9 +302,7 @@ class AuthController
     }
 
     /**
-     * @api {get|post} /routine/notify 小程序支付回调
-     * @apiName RoutineNotify
-     * @apiGroup Wechat
+     * 小程序支付回调
      * 
      */
     public function notify()
@@ -305,8 +311,10 @@ class AuthController
     }
 
     /**
-     * 获取小程序订阅消息id
-     * @return mixed
+     * @api {get} /wechat/teml_ids 获取小程序订阅消息id
+     * @apiName GetWechatTemlIds
+     * @apiGroup Public
+     * 
      */
     public function teml_ids()
     {
@@ -322,9 +330,10 @@ class AuthController
     }
 
     /**
-     * 获取小程序直播列表
-     * @param Request $request
-     * @return mixed
+     * @api {get} /wechat/live 获取小程序直播列表
+     * @apiName GetWechatLive
+     * @apiGroup Public
+     * 
      */
     public function live(Request $request)
     {

+ 20 - 21
app/api/controller/wechat/WechatController.php

@@ -19,9 +19,7 @@ use crmeb\utils\Canvas;
 class WechatController
 {
     /**
-     * @api {get|post} /wechat/serve 微信公众号服务接口
-     * @apiName WechatServe
-     * @apiGroup Wechat
+     * 微信公众号服务接口
      * 
      */
     public function serve()
@@ -31,9 +29,7 @@ class WechatController
     }
 
     /**
-     * @api {get|post} /wechat/notify 公众号支付异步回调
-     * @apiName WechatNotify
-     * @apiGroup Wechat
+     * 公众号支付异步回调
      * 
      */
     public function notify()
@@ -43,9 +39,10 @@ class WechatController
     }
 
     /**
-     * 公众号权限配置信息获取
-     * @param Request $request
-     * @return mixed
+     * @api {get} /wechat/config 公众号权限配置信息获取
+     * @apiName GetWechatConfig
+     * @apiGroup Public
+     * 
      */
     public function config(Request $request)
     {
@@ -53,12 +50,10 @@ class WechatController
     }
 
     /**
-     * 公众号授权登陆
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /wechat/auth 公众号授权登陆
+     * @apiName GetWechatAuth
+     * @apiGroup Public
+     * 
      */
     public function auth(Request $request)
     {
@@ -104,12 +99,10 @@ class WechatController
     }
 
     /**
-     * app 授权登陆
-     * @param Request $request
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @api {get} /wechat/auth_app app 授权登陆
+     * @apiName GetWechatAuthApp
+     * @apiGroup Public
+     * 
      */
     public function auth_app(Request $request)
     {
@@ -117,6 +110,12 @@ class WechatController
 
     }
 
+    /**
+     * @api {get} /wechat/follow 获取关注微信公众号海报
+     * @apiName GetWechatFollow
+     * @apiGroup Public 
+     * 
+     */
     public function follow()
     {
         $canvas = Canvas::instance();

+ 8 - 0
app/common.php

@@ -22,6 +22,14 @@ define('ORDER_WAITING_SHIP', 0);
 define('ORDER_WAITING_RECEIPT', 1);
 define('ORDER_RECEIPTED', 2);
 define('ORDER_WAITING_COMMENT', 3);
+
+// 佣金类型
+define('BILL_ALL', 0);          // 全部
+define('BILL_SPEND', 1);        // 消费
+define('BILL_RECHARGE', 2);     // 充值
+define('BILL_BROKERAGE', 3);    // 返佣
+define('BILL_EXTRACT', 4);      // 提现
+
 // 退款状态
 // 0 未退款 1 申请中 2 已退款
 define('REFUND_NO', 0);

+ 3 - 4
app/models/store/StoreOrder.php

@@ -13,7 +13,6 @@ use app\admin\model\system\ShippingTemplatesRegion;
 use crmeb\basic\BaseModel;
 use think\facade\Cache;
 use crmeb\traits\ModelTrait;
-use think\facade\Log;
 use app\models\system\SystemStore;
 use app\models\routine\RoutineTemplate;
 use app\models\user\{
@@ -1457,10 +1456,10 @@ class StoreOrder extends BaseModel
             unset($orderList, $res, $pages);
             return null;
         } catch (\PDOException $e) {
-            Log::error('未支付自动取消时发生数据库查询错误,错误原因为:' . $e->getMessage());
+            errlog('未支付自动取消时发生数据库查询错误,错误原因为:' . $e->getMessage());
             throw new \Exception($e->getMessage());
         } catch (\think\Exception $e) {
-            Log::error('未支付自动取消时发生系统错误,错误原因为:' . $e->getMessage());
+            errlog('未支付自动取消时发生系统错误,错误原因为:' . $e->getMessage());
             throw new \Exception($e->getMessage());
         }
 
@@ -1628,7 +1627,7 @@ class StoreOrder extends BaseModel
      * 订单每月统计数据
      * @param $page
      * @param $limit
-     * @return array
+     * @return object
      */
     public static function getOrderDataPriceCount($page, $limit, $start, $stop)
     {

+ 1 - 2
app/models/store/StorePink.php

@@ -14,7 +14,6 @@ use app\models\user\WechatUser;
 use crmeb\basic\BaseModel;
 use crmeb\services\WechatTemplateService;
 use crmeb\traits\ModelTrait;
-use think\facade\Log;
 use think\facade\Route;
 use think\facade\Cache;
 
@@ -511,7 +510,7 @@ class StorePink extends BaseModel
                 } else return false;
             }
         } else {
-            Log::error('拼团支付成功读取产品数据失败订单号:' . $order['order_id']);
+            errlog('拼团支付成功读取产品数据失败订单号:' . $order['order_id']);
         }
     }
 

+ 20 - 10
app/models/store/StoreService.php

@@ -1,4 +1,5 @@
 <?php
+
 /**
  *
  * @author: xaboy<365615158@qq.com>
@@ -11,6 +12,15 @@ namespace app\models\store;
 use crmeb\basic\BaseModel;
 use crmeb\traits\ModelTrait;
 
+define('SHOW', 1);
+define('HIDE', 0);
+
+define('ENABLED', 1);
+define('DISABLED', 0);
+
+define('YES', 1);
+define('NO', 0);
+
 /**
  * TODO 客服Model
  * Class StoreService
@@ -36,14 +46,13 @@ class StoreService extends BaseModel
      * 获取客服列表
      * @param $page
      * @param $limit
-     * @return array
+     * @return object
      */
-    public static function lst($page, $limit)
+    public static function lst(int $page, int $limit)
     {
-//        if(!$page || !$limit) return [];
         $model = new self;
-        $model = $model->where('status', 1);
-//        $model = $model->page($page, $limit);
+        $model = $model->where('status', SHOW);
+        $model = $model->page($page, $limit);
         return $model->select();
     }
 
@@ -58,7 +67,7 @@ class StoreService extends BaseModel
      */
     public static function getServiceInfo($uid, $field = '*')
     {
-        return self::where('uid', $uid)->where('status', 1)->field($field)->find();
+        return self::where('uid', $uid)->where('status', SHOW)->field($field)->find();
     }
 
     /**
@@ -68,7 +77,7 @@ class StoreService extends BaseModel
      */
     public static function orderServiceStatus($uid)
     {
-        return self::where('uid', $uid)->where('status', 1)->where('customer', 1)->count();
+        return self::where('uid', $uid)->where('status', SHOW)->where('customer', YES)->count();
     }
 
     /**
@@ -76,7 +85,8 @@ class StoreService extends BaseModel
      *
      * @return array
      */
-    public static function getStoreServiceOrderNotice(){
-        return self::where('status',1)->where('notify',1)->column('uid','uid');
+    public static function getStoreServiceOrderNotice()
+    {
+        return self::where('status', SHOW)->where('notify', ENABLED)->column('uid', 'uid');
     }
-}
+}

+ 8 - 4
app/models/store/StoreServiceLog.php

@@ -1,4 +1,5 @@
 <?php
+
 /**
  *
  * @author: xaboy<365615158@qq.com>
@@ -55,19 +56,22 @@ class StoreServiceLog extends BaseModel
      * @param $toUid
      * @param $page
      * @param $limit
-     * @return array
+     * @return object
      */
     public static function lst($uid, $toUid, $page, $limit)
     {
-        if (!$limit || !$page) return [];
         $model = new self;
         $model = $model->whereIn('uid', [$uid, $toUid]);
         $model = $model->whereIn('to_uid', [$uid, $toUid]);
         $model = $model->order('id DESC');
         $model = $model->page($page, $limit);
+        // TODO: 循环 SQL
         return $model->select()->each(function ($item) {
             $userInfo = StoreService::where('uid', $item['uid'])->field('nickname,avatar')->find();
-            if(!$userInfo) $userInfo = User::getUserInfo($item['uid'],'nickname,avatar');
+            if (!$userInfo) {
+                $userInfo = User::getUserInfo($item['uid'], 'nickname,avatar');
+            }
+            
             if ($userInfo) {
                 $item['nickname'] = $userInfo['nickname'];
                 $item['avatar'] = $userInfo['avatar'];
@@ -92,4 +96,4 @@ class StoreServiceLog extends BaseModel
             $item['msn_type'] = (int)$item['msn_type'];
         });
     }
-}
+}

+ 5 - 6
app/models/user/UserBill.php

@@ -7,7 +7,6 @@
 
 namespace app\models\user;
 
-use app\models\store\StoreOrder;
 use think\facade\Cache;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
@@ -161,19 +160,19 @@ class UserBill extends BaseModel
         $model = self::where('uid', $uid)->where('category', 'now_money')->order('add_time desc')->where('number', '<>', 0)
             ->field('FROM_UNIXTIME(add_time,"%Y-%m") as time,group_concat(DISTINCT id ORDER BY id DESC SEPARATOR ",") ids')->group('time');
         switch ((int)$type) {
-            case 0:
+            case BILL_ALL:
                 $model = $model->where('type', 'in', 'recharge,brokerage,pay_money,system_add,pay_product_refund,system_sub');
                 break;
-            case 1:
+            case BILL_SPEND:
                 $model = $model->where('type', 'pay_money');
                 break;
-            case 2:
+            case BILL_RECHARGE:
                 $model = $model->where('type', 'in', 'recharge,system_add');
                 break;
-            case 3:
+            case BILL_BROKERAGE:
                 $model = $model->where('type', 'brokerage');
                 break;
-            case 4:
+            case BILL_EXTRACT:
                 $model = $model->where('type', 'extract');
                 break;
         }

+ 3 - 4
app/models/user/UserExtract.php

@@ -10,7 +10,6 @@ namespace app\models\user;
 use crmeb\basic\BaseModel;
 use crmeb\services\workerman\ChannelService;
 use crmeb\traits\ModelTrait;
-use think\facade\Log;
 use think\facade\Config;
 
 /**
@@ -145,7 +144,7 @@ class UserExtract extends BaseModel
         try{
             $res1 = self::create($insertData);
             if(!$res1) {
-                Log::error('UserExtract.php line 101. insert failed.');
+                errlog('UserExtract.php line 101. insert failed.');
                 return self::setErrorInfo('提现申请失败,请联系客服处理');
             }
 
@@ -160,14 +159,14 @@ class UserExtract extends BaseModel
                 event('UserRequestWithdrawal', ['user'=> $userInfo, 'info' => $insertData]);
                 //发送模板消息
             } else {
-                Log::error('UserExtract.php sql failed. $res2=' . $res2 . ' $res3=' . $res3);
+                errlog('UserExtract.php sql failed. $res2=' . $res2 . ' $res3=' . $res3);
                 self::rollbackTrans();
                 return self::setErrorInfo('提现申请失败,请联系客服处理');
             }
             self::commitTrans();
             return $insertData;
         }catch (\Exception $e){
-            Log::error('UserExtract.php exception:' . $e->getMessage());
+            errlog('UserExtract.php exception:' . $e->getMessage());
             self::rollbackTrans();
             return self::setErrorInfo('提现申请失败,请联系客服处理');
         }

+ 2 - 3
app/models/user/UserNotice.php

@@ -10,7 +10,6 @@ use app\admin\model\user\UserNoticeSee;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 use think\facade\Db;
-use think\facade\Log;
 use think\facade\Config;
 use think\facade\Env;
 /**
@@ -123,7 +122,7 @@ class UserNotice extends BaseModel
         try {
             UserNoticeSee::setAll($rows);
         } catch(\Exception $e) {
-            Log::warning("seeNotice exception.sql=".UserNoticeSee::getLastSql());
+            warnlog("seeNotice exception.sql=".UserNoticeSee::getLastSql());
         }
     }
 
@@ -132,7 +131,7 @@ class UserNotice extends BaseModel
             try{
                 UserNoticeSee::where('uid', $uid)->where('nid', $nid)->delete();
             }catch (\Exception $e){
-                Log::warning("unseeNotice exception.sql=". UserNoticeSee::getLastSql());
+                warnlog("unseeNotice exception.sql=". UserNoticeSee::getLastSql());
             }
         }
     }

+ 2 - 3
crmeb/repositories/CustomerRepository.php

@@ -9,7 +9,6 @@ use app\models\store\StoreSeckill;
 use app\models\store\StoreService;
 use app\models\user\User;
 use app\models\user\WechatUser;
-use think\facade\Log;
 use crmeb\services\WechatService;
 
 /**
@@ -65,7 +64,7 @@ class CustomerRepository
                             try {
                                 WechatService::staffService()->message($message)->to($userInfo['openid'])->send();
                             } catch (\Exception $e) {
-                                Log::error($userInfo['nickname'] . '发送失败' . $e->getMessage());
+                                errlog($userInfo['nickname'] . '发送失败' . $e->getMessage());
                             }
                         }else{
                             // 推送文字消息
@@ -74,7 +73,7 @@ class CustomerRepository
                             try {
                                 WechatService::staffService()->message($head)->to($userInfo['openid'])->send();
                             } catch (\Exception $e) {
-                                Log::error($userInfo['nickname'] . '发送失败' . $e->getMessage());
+                                errlog($userInfo['nickname'] . '发送失败' . $e->getMessage());
                             }
                          }
                     }

+ 2 - 6
crmeb/repositories/NoticeRepositories.php

@@ -8,14 +8,10 @@
 namespace crmeb\repositories;
 
 use app\models\user\WechatUser;
-use crmeb\services\WechatService;
 use crmeb\services\WechatTemplateService;
-use crmeb\services\workerman\ChannelService;
 use app\models\routine\RoutineTemplate;
 use app\models\store\StoreOrderCartInfo;
-use app\models\user\User;
 use crmeb\services\YLYService;
-use think\facade\Log;
 use think\facade\Route;
 
 /** 消息通知静态类
@@ -59,7 +55,7 @@ class NoticeRepositories
                 }
 
             } catch (\Exception $e) {
-                Log::error('购买后发送提醒失败,错误原因:' . $e->getMessage());
+                errlog('购买后发送提醒失败,错误原因:' . $e->getMessage());
             }
         }
         //打印小票
@@ -78,7 +74,7 @@ class NoticeRepositories
                 }
                 YLYService::instance()->setContent(sys_config('site_name'), is_object($order) ? $order->toArray() : $order, $product)->orderPrinting();
             } catch (\Exception $e) {
-                Log::error('小票打印出现错误,错误原因:' . $e->getMessage());
+                errlog('小票打印出现错误,错误原因:' . $e->getMessage());
             }
         }
         //短信通知 下发用户支付成功 下发管理员支付通知

+ 1 - 2
crmeb/services/template/storage/Subscribe.php

@@ -4,7 +4,6 @@ namespace crmeb\services\template\storage;
 
 use crmeb\basic\BaseMessage;
 use crmeb\services\MiniProgramService;
-use think\facade\Log;
 use think\facade\Db;
 
 /**
@@ -44,7 +43,7 @@ class Subscribe extends BaseMessage
             $this->clear();
             return $res;
         } catch (\Throwable $e) {
-            $this->isLog() && Log::error('发送给openid为:' . $this->openId . '小程序订阅消息失败,模板id为:' . $tempid . ';错误原因为:' . $e->getMessage());
+            $this->isLog() && errlog('发送给openid为:' . $this->openId . '小程序订阅消息失败,模板id为:' . $tempid . ';错误原因为:' . $e->getMessage());
             return $this->setError($e->getMessage());
         }
     }

+ 1 - 3
crmeb/services/template/storage/Wechat.php

@@ -4,9 +4,7 @@ namespace crmeb\services\template\storage;
 
 use crmeb\basic\BaseMessage;
 use crmeb\services\WechatService;
-use crmeb\services\WechatTemplateService;
 use think\facade\Db;
-use think\facade\Log;
 
 class Wechat extends BaseMessage
 {
@@ -44,7 +42,7 @@ class Wechat extends BaseMessage
             $this->clear();
             return $res;
         } catch (\Exception $e) {
-            $this->isLog() && Log::error('发送给openid为:' . $this->openId . '微信模板消息失败,模板id为:' . $tempid . ';错误原因为:' . $e->getMessage());
+            $this->isLog() && errlog('发送给openid为:' . $this->openId . '微信模板消息失败,模板id为:' . $tempid . ';错误原因为:' . $e->getMessage());
             return $this->setError($e->getMessage());
         }
     }

+ 1 - 6
crmeb/services/workerman/chat/ChatHandle.php

@@ -11,13 +11,8 @@ use app\models\user\User;
 use app\models\user\WechatUser;
 use crmeb\exceptions\AuthException;
 use crmeb\repositories\UserRepository;
-use crmeb\services\SystemConfigService;
 use crmeb\services\WechatService;
-use crmeb\services\workerman\ChannelService;
 use crmeb\services\workerman\Response;
-use think\facade\Log;
-use think\facade\Route as Url;
-use think\facade\Session;
 use Workerman\Connection\TcpConnection;
 
 class ChatHandle
@@ -111,7 +106,7 @@ class ChatHandle
                 try {
                     WechatService::staffService()->message($message)->to($userInfo['openid'])->send();
                 } catch (\Exception $e) {
-                    Log::error($userInfo['nickname'] . '发送失败' . $e->getMessage());
+                    errlog($userInfo['nickname'] . '发送失败' . $e->getMessage());
                 }
             }
         }

+ 1 - 4
crmeb/subscribes/MessageSubscribe.php

@@ -6,15 +6,12 @@ use app\admin\model\wechat\WechatMessage;
 use app\models\store\StoreOrder;
 use app\models\store\StoreProduct;
 use app\models\store\StoreProductReply;
-use app\models\store\StoreService;
 use app\models\user\User;
 use app\models\user\UserExtract;
 use app\models\user\WechatUser;
 use crmeb\repositories\CustomerRepository;
 use crmeb\repositories\ShortLetterRepositories;
-use crmeb\services\SystemConfigService;
 use crmeb\services\workerman\ChannelService;
-use think\facade\Log;
 
 /**
  * 用户消息事件
@@ -93,7 +90,7 @@ class MessageSubscribe
                 if (method_exists($this, $actionName)) $this->$actionName($order_id);
             }
         } catch (\Exception $e) {
-            Log::error('短信下发事件发生系统错误,错误原因:' . $e->getMessage());
+            errlog('短信下发事件发生系统错误,错误原因:' . $e->getMessage());
         }
     }
 

+ 17 - 9
crmeb/subscribes/ProductSubscribe.php

@@ -17,7 +17,7 @@ class ProductSubscribe
     }
 
     /**
-     * 加入购物车成功之后
+     * 加入购物车成功之后 StoreProductSetCartAfter
      * @param $event
      */
     public function onStoreProductSetCartAfter($event)
@@ -28,7 +28,7 @@ class ProductSubscribe
     }
 
     /**
-     * 用户操作产品点击事件  用户点赞产品  用户收藏产品
+     * 用户操作产品点击事件 用户点赞产品 用户收藏产品 StoreProductUserOperationConfirmAfter
      * @param $event
      */
     public function onStoreProductUserOperationConfirmAfter($event)
@@ -41,7 +41,7 @@ class ProductSubscribe
     }
 
     /**
-     * 用户操作产品取消事件    用户取消点赞产品  用户取消收藏产品
+     * 用户操作产品取消事件 用户取消点赞产品 用户取消收藏产品 StoreProductUserOperationCancelAfter
      * @param $event
      */
     public function onStoreProductUserOperationCancelAfter($event)
@@ -54,7 +54,7 @@ class ProductSubscribe
     }
 
     /**
-     * 添加产品
+     * 添加产品 StoreProductCreated
      */
     public function onStoreProductCreated($event)
     {
@@ -62,7 +62,15 @@ class ProductSubscribe
     }
 
     /**
-     * 删除产品
+     * 编辑商品 StoreEditProduct
+     */
+    public function onStoreEditProduct($event)
+    {
+
+    }
+
+    /**
+     * 删除产品 StoreProductDeleted
      */
     public function onStoreProductDeleted($event)
     {
@@ -70,7 +78,7 @@ class ProductSubscribe
     }
 
     /**
-     * 上下架产品
+     * 上下架产品 StoreProductOnOffShelf
      */
     public function onStoreProductOnOffShelf($event)
     {
@@ -78,7 +86,7 @@ class ProductSubscribe
     }
 
     /**
-     * 增加分类
+     * 增加分类 StoreCategoryCreated
      */
     public function onStoreCategoryCreated($event)
     {
@@ -86,7 +94,7 @@ class ProductSubscribe
     }
 
     /**
-     * 删除分类
+     * 删除分类 StoreCategoryDeleted
      */
     public function onStoreCategoryDeleted($event)
     {
@@ -94,7 +102,7 @@ class ProductSubscribe
     }
 
     /**
-     * 编辑分类
+     * 编辑分类 StoreCategoryEdited
      */
     public function onStoreCategoryEdited($event)
     {

+ 1 - 2
crmeb/subscribes/SystemSubscribe.php

@@ -5,7 +5,6 @@ namespace crmeb\subscribes;
 use app\admin\model\system\SystemAdmin;
 use app\admin\model\system\SystemLog;
 use crmeb\utils\Redis;
-use think\facade\Log;
 
 /**
  * 后台系统事件
@@ -55,7 +54,7 @@ class SystemSubscribe
     public function onAdminAddStoreProduct($event)
     {
         list('product'=>$product, 'admin'=>$admin) = $event;
-        Log::error($admin->account . ' create product ' . $product['store_name'] . ' id:' . $product['id']);
+        errlog($admin->account . ' create product ' . $product['store_name'] . ' id:' . $product['id']);
         Redis::hSet('log:admin_add_products:' . $admin['id'], $product['id'], $product['store_name']);
     }
 }

+ 2 - 3
crmeb/subscribes/TimerSubscribe.php

@@ -14,7 +14,6 @@ use tw\async\activities\LuckyCalc;
 use tw\async\activities\LuckyExtACalc;
 use tw\async\activities\LuckyExtBCalc;
 use think\facade\Db;
-use think\facade\Log;
 use app\admin\model\system\SystemLog;
 
 /**
@@ -109,11 +108,11 @@ class TimerSubscribe
             // 刪除跑馬燈
             SystemCarousel::removeTrash();
 
-            Log::warning('onTimer_60() activities calculated.');
+            warnlog('onTimer_60() activities calculated.');
             // 每日 24
             if (intval($tm['tm_hour']) == 0) {
                 SystemLog::deleteLog();
-                Log::warning('onTimer_60() remove outdated admin logs');
+                warnlog('onTimer_60() remove outdated admin logs');
             }
         }
     }

+ 8 - 10
crmeb/subscribes/UserSubscribe.php

@@ -5,12 +5,10 @@ namespace crmeb\subscribes;
 use app\models\user\User;
 use app\models\user\WechatUser;
 use think\facade\Cookie;
-use app\admin\model\system\SystemAttachment;
 use app\admin\model\user\UserBill;
 use app\models\user\UserLevel;
 use app\models\user\UserNotice;
 use tw\async\tasks\AsyncClass;
-use think\facade\Log;
 use think\facade\Config;
 
 /**
@@ -34,7 +32,7 @@ class UserSubscribe
     {
         list($user, $money) = $event;
 
-        Log::warning('EVENT admin add money ' . $money . ' to ' . $user['uid']);
+        warnlog('EVENT admin add money ' . $money . ' to ' . $user['uid']);
     }
 
     /**
@@ -107,7 +105,7 @@ class UserSubscribe
 
         // 对现存用户处理,用于过渡
         AsyncClass::push('tw\async\tasks\UserTaskClass', [], 'generate_user_poster', [$userInfo->uid]);
-        Log::debug('EVENT user ' . $userInfo->uid . ' login.');
+        debuglog('EVENT user ' . $userInfo->uid . ' login.');
     }
 
     /**
@@ -133,7 +131,7 @@ class UserSubscribe
     {
         list($user) = $event;
         AsyncClass::push('tw\async\tasks\UserTaskClass', [], 'generate_user_poster', [$user['uid']]);
-        Log::debug('EVENT user' . $user['uid'] . ' has becomed promoter');
+        debuglog('EVENT user' . $user['uid'] . ' has becomed promoter');
     }
     
     /**
@@ -144,7 +142,7 @@ class UserSubscribe
         list($userUid) = $event;
         $userinfo = User::get($userUid);
 
-        Log::debug("EVENT user " . $userUid . ' update to level ' . $userinfo['level']);
+        debuglog("EVENT user " . $userUid . ' update to level ' . $userinfo['level']);
     }
 
     /**
@@ -156,9 +154,9 @@ class UserSubscribe
 
         $res = UserBill::income('新用户送钱活动', $user['uid'], 'now_money', 'activity_1_gift', $user['now_money'], $user['uid'], $user['now_money'], '新用户送' . $user['now_money'] . '元');
         if (!$res) {
-            Log::error('user ' . $user['uid'] . 'registered send money ' . $user['now_money'] . ' failed.');
+            errlog('user ' . $user['uid'] . 'registered send money ' . $user['now_money'] . ' failed.');
         }
-        Log::debug('EVENT new user registered:' . $user['uid']);
+        debuglog('EVENT new user registered:' . $user['uid']);
     }
 
     /**
@@ -168,7 +166,7 @@ class UserSubscribe
     {
         list('order' => $order) = $event;
 
-        Log::debug('EVENT user ' . $order['uid'] . ' first order:' . $order['id']);
+        debuglog('EVENT user ' . $order['uid'] . ' first order:' . $order['id']);
     }
 
     /**
@@ -181,7 +179,7 @@ class UserSubscribe
     {
         list('user' => $user, 'info' => $info) = $event;
 
-        Log::debug('EVENT user ' . $user['uid'] . ' withdraw ' . mapped_implode(',', $info));
+        debuglog('EVENT user ' . $user['uid'] . ' withdraw ' . mapped_implode(',', $info));
     }
 
     /**

+ 2 - 2
docs/apidoc.json

@@ -1,7 +1,7 @@
 {
-    "name": "twong client API",
+    "name": "TWONG APP API DOC",
     "version": "1.2.5",
-    "description": "cross-client usage",
+    "description": "本 API 文档描述了前端接口",
     "header": {
         "title": "Introduction",
         "filename": "api_header.md"

+ 3 - 2
route/api/route.php

@@ -138,6 +138,8 @@ Route::group(function () {
     Route::post('order/pay', 'order.StoreOrderController/pay')->name('orderPay'); //订单支付
     Route::post('order/product', 'order.StoreOrderController/product')->name('orderProduct'); //订单产品信息
     Route::post('order/comment', 'order.StoreOrderController/comment')->name('orderComment'); //订单评价
+    Route::get('order/nopay', 'order.StoreOrderController/get_noPay')->name('getNoPay'); //获取未支付订单 首页
+
     // 活动---砍价
     Route::get('bargain/detail/:id', 'activity.StoreBargainController/detail')->name('bargainDetail'); //砍价产品详情
     Route::post('bargain/start', 'activity.StoreBargainController/start')->name('bargainStart'); //砍价开启
@@ -177,8 +179,7 @@ Route::group(function () {
     Route::get('user/level/detection', 'user.UserLevelController/detection')->name('userLevelDetection'); //检测用户是否可以成为会员
     Route::get('user/level/grade', 'user.UserLevelController/grade')->name('userLevelGrade'); //会员等级列表
     Route::get('user/level/task/:id', 'user.UserLevelController/task')->name('userLevelTask'); //获取等级任务
-    // 首页获取未支付订单
-    Route::get('order/nopay', 'order.StoreOrderController/get_noPay')->name('getNoPay'); //获取未支付订单
+    
     // 模拟推送 (需要登录)
     //Route::get('user/notifications', 'user.UserNotificationController/snapshot')->name('userNotifications');
 

+ 3 - 4
tw/async/tasks/Task.php

@@ -4,7 +4,6 @@ namespace tw\async\tasks;
 
 use crmeb\utils\Beanstalk;
 use think\facade\Config;
-use think\facade\Log;
 
 /**
  * 这个 Task 表示异步任务的基类, 借助于 beanstalkd 等服务来异步执行或延后执行
@@ -92,7 +91,7 @@ abstract class Task {
         try {
             $bean::useTube($tube)->put($json);
         } catch (\Exception $e) {
-            Log::error('beanstalk put failed: ' . $json . ' error:' . $e->getMessage());
+            errlog('beanstalk put failed: ' . $json . ' error:' . $e->getMessage());
             return false;
         }
         return true;
@@ -106,12 +105,12 @@ abstract class Task {
     protected function checkTask($task)
     {
         if (!$task || !isset($task['cmd']) || $task['cmd'] != $this->getCmd()) {
-            Log::error('task format error: null or invalid cmd');
+            errlog('task format error: null or invalid cmd');
             return false;
         }
 
         if (!isset($task['params']) || !is_array($task['params'])) {
-            Log::error('task format error: without params or not an array.');
+            errlog('task format error: without params or not an array.');
             return false;
         }
         return true;

+ 8 - 9
tw/async/tasks/UserTaskClass.php

@@ -6,7 +6,6 @@ use app\models\routine\RoutineCode;
 use crmeb\services\upload\Upload;
 use app\models\routine\RoutineQrcode;
 use crmeb\services\UtilService;
-use think\facade\Log;
 use app\models\user\User;
 
 /**
@@ -59,13 +58,13 @@ class UserTaskClass {
             $routineSpreadBanner = sys_data('routine_spread_banner');
             if (!count($routineSpreadBanner)) {
                 $err = '暂无海报';
-                Log::error($err);
+                errlog($err);
                 return [false, $err];
             }
             $user = User::getUserInfo($uid);
             if (!$user) {
                 $err = '用户不存在';
-                Log::error($err);
+                errlog($err);
                 return [false, $err];
             }
             $is_promoter = $user['is_promoter'] ?? 0;
@@ -126,7 +125,7 @@ class UserTaskClass {
                     $uploadRes = $upload->to('routine/spread/code')->validate()->stream($res['res'], $remoteName);
                     if ($uploadRes === false) {
                         $err = $upload->getError();
-                        Log::error("upload error:" . $err);
+                        errlog("upload error:" . $err);
                         return [false, $err];
                     }
                     $upload->delete($name);
@@ -151,12 +150,12 @@ class UserTaskClass {
                 ];
                 if (!file_exists($filelink['Bold'])) {
                     $err = '缺少字体文件Bold';
-                    Log::error($err);
+                    errlog($err);
                     return [false, $err];
                 }
                 if (!file_exists($filelink['Normal'])) {
                     $err = '缺少字体文件Normal';
-                    Log::error($err);
+                    errlog($err);
                     return [false, $err];
                 }
                 foreach ($routineSpreadBanner as $key => &$item) {
@@ -200,7 +199,7 @@ class UserTaskClass {
                     );
                     $resRoutine = $resRoutine && $posterInfo = UtilService::setSharePoster($config, 'routine/spread/poster');
                     if (!is_array($posterInfo)) {
-                        Log::error($posterInfo);
+                        errlog($posterInfo);
                         return [false, $posterInfo];
                     }
                     // 20210919 为了能小程序下载,这个函数上传的图片全部使用 https
@@ -215,7 +214,7 @@ class UserTaskClass {
                     }
                 }
             } else if ($type == 2) {
-                Log::error(__FUNCTION__ . ' bad parameter type=2');
+                errlog(__FUNCTION__ . ' bad parameter type=2');
             }
             if ($resRoutine && $resWap) {
                 return [true, $routineSpreadBanner];
@@ -223,7 +222,7 @@ class UserTaskClass {
                 return [false, '生成图片失败'];
             }
         } catch (\Exception $e) {
-            Log::error('生成图片时,系统错误:' . $e->getMessage());
+            errlog('生成图片时,系统错误:' . $e->getMessage());
             return [false, '生成图片时,系统错误:' . $e->getMessage()];
         }
     }

+ 2 - 3
tw/async/tasks/WechatNotify.php

@@ -3,7 +3,6 @@
 namespace tw\async\tasks;
 
 use crmeb\services\QyWeixinService;
-use think\facade\Log;
 
 /**
  * 异步机器人通知.
@@ -53,13 +52,13 @@ class WechatNotify extends Task
             self::TYPE_ERROR        => '故障',
         ];
         if (!isset($params['type']) || !is_string($params['type'])) {
-            Log::error('invalid type: bad format.');
+            errlog('invalid type: bad format.');
             return false;
         }
         $type = $params['type'];
         $key = isset($params['key']) ? $params['key'] : '';
         if (!isset($supported_types[$type])) {
-            Log::error('unsupported type:' . $type);
+            errlog('unsupported type:' . $type);
             return false;
         }
         $desc = isset($params['desc']) ? $params['desc'] : '';