wesmiler преди 2 месеца
родител
ревизия
0312d93bf2

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

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

+ 11 - 10
app/Http/Controllers/Api/v1/IndexController.php

@@ -4,10 +4,6 @@ namespace App\Http\Controllers\Api\v1;
 
 use App\Http\Controllers\Api\webApp;
 use App\Services\Api\ArticleService;
-use App\Services\Api\GoodsService;
-use App\Services\Api\OrderService;
-use App\Services\Api\SocialCircleService;
-use App\Services\Api\StoreService;
 use App\Services\Common\AdService;
 use App\Services\Common\NoticeService;
 use App\Services\ConfigService;
@@ -61,6 +57,7 @@ class IndexController extends webApp
      */
     public function data()
     {
+        $type = request()->post('type',1);
         try {
             $data = [
                 // 轮播
@@ -76,16 +73,20 @@ class IndexController extends webApp
     }
 
     /**
-     * 主页店铺商品
+     * 行业数据
      * @return array
      */
-    public function storeGoods()
+    public function industry()
     {
-        $params = request()->post();
         try {
-            $params['user_id'] = $this->userId;
-            $datas = StoreService::make()->getGoodsList($params);
-            return showJson(StoreService::make()->getError(), true, $datas);
+            $data = [
+                // 轮播
+                'banners' => AdService::make()->getListByPosition(2),
+                'supervisors' => S::make()->getListByPosition(2),
+                'articles' => ArticleService::make()->getListByType(2),
+            ];
+
+            return showJson(1010, true, $data);
         } catch (\Exception $exception) {
             $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
             return showJson(1046, false, $error);

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

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

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

@@ -6,10 +6,10 @@ use App\Http\Controllers\Api\webApp;
 use App\Services\Api\JobsService;
 
 /**
- * 招聘信息
+ * 导师信息
  * @package App\Http\Controllers\Api
  */
-class JobsController extends webApp
+class SupervisorsController extends webApp
 {
 
     /**

+ 0 - 29
app/Models/AgentModel.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace App\Models;
-
-/**
- * 代理模型
- */
-class AgentModel extends BaseModel
-{
-    protected $table = 'agents';
-
-    /**
-     * 关联用户
-     */
-    public function user()
-    {
-        return $this->hasOne(MemberModel::class, 'id', 'user_id');
-    }
-
-    /**
-     * 获取团队人数
-     */
-    public function getTeamCountAttribute()
-    {
-        // 这里可以根据实际业务逻辑计算团队人数
-        // 例如:查询该代理推荐的下级用户数量
-        return 0;
-    }
-}

+ 0 - 13
app/Models/JobsCategoryModel.php

@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Models;
-
-/**
- * 招聘分类-模型
- */
-class JobsCategoryModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'jobs_categorys';
-}
-

+ 0 - 29
app/Models/JobsModel.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace App\Models;
-
-/**
- * 招聘信息-模型
- */
-class JobsModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'jobs';
-
-    /**
-     * 关联招聘分类
-     */
-    public function category()
-    {
-        return $this->belongsTo(JobsCategoryModel::class, 'category_id', 'id');
-    }
-
-    /**
-     * 商家店铺
-     */
-    public function store()
-    {
-        return $this->hasOne(StoreModel::class, 'id', 'store_id');
-    }
-}
-

+ 0 - 68
app/Models/PayMealsModel.php

@@ -1,68 +0,0 @@
-<?php
-
-namespace App\Models;
-
-/**
- * 缴费充值套餐模型
- */
-class PayMealsModel extends BaseModel
-{
-    protected $table = 'pay_meals';
-
-    protected $fillable = [
-        'product_id',
-        'money',
-        'discount',
-        'remark',
-        'gas_type',
-        'type',
-        'electric_type',
-        'phone_type',
-        'phone_service',
-        'sort',
-        'create_time',
-        'update_time',
-        'status',
-        'mark'
-    ];
-
-    /**
-     * 获取类型文本
-     */
-    public function getTypeTextAttribute()
-    {
-        $typeMap = [
-            1 => '话费充值',
-            2 => '电费充值',
-            3 => '燃气充值'
-        ];
-        return $typeMap[$this->type] ?? '未知';
-    }
-
-    /**
-     * 获取状态文本
-     */
-    public function getStatusTextAttribute()
-    {
-        return $this->status == 1 ? '有效' : '无效';
-    }
-
-    /**
-     * 获取折扣
-     */
-    public function getDiscountAttribute($value)
-    {
-        return floatval($value);
-    }
-
-    /**
-     * 获取实付金额
-     */
-    public function getPayMoneyAttribute()
-    {
-        if ($this->discount > 0) {
-            return round($this->money * $this->discount / 100, 2);
-        }
-        return $this->money;
-    }
-}

+ 0 - 101
app/Models/PayOrdersModel.php

@@ -1,101 +0,0 @@
-<?php
-
-namespace App\Models;
-
-/**
- * 充值缴费订单模型
- */
-class PayOrdersModel extends BaseModel
-{
-    protected $table = 'pay_orders';
-
-    protected $fillable = [
-        'order_no',
-        'user_id',
-        'total',
-        'type',
-        'discount',
-        'pay_total',
-        'charge_amount',
-        'pay_at',
-        'account',
-        'transaction_id',
-        'meal_id',
-        'product_id',
-        'out_trade_no',
-        'charge_kami',
-        'area',
-        'ytype',
-        'id_card_no',
-        'city',
-        'remark',
-        'result',
-        'failed_remark',
-        'create_time',
-        'update_time',
-        'refund_status',
-        'refund_money',
-        'refund_remark',
-        'status',
-        'mark'
-    ];
-
-    /**
-     * 关联用户
-     */
-    public function user()
-    {
-        return $this->belongsTo(MemberModel::class, 'user_id', 'id');
-    }
-
-    /**
-     * 关联套餐
-     */
-    public function meal()
-    {
-        return $this->belongsTo(PayMealsModel::class, 'meal_id', 'id');
-    }
-
-    /**
-     * 获取类型文本
-     */
-    public function getTypeTextAttribute()
-    {
-        $typeMap = [
-            1 => '话费',
-            2 => '电费',
-            3 => '燃气'
-        ];
-        return $typeMap[$this->type] ?? '未知';
-    }
-
-    /**
-     * 获取状态文本
-     */
-    public function getStatusTextAttribute()
-    {
-        $statusMap = [
-            1 => '待付款',
-            2 => '已付款',
-            3 => '充值中',
-            4 => '充值成功',
-            5 => '充值失败',
-            6 => '部分成功'
-        ];
-        return $statusMap[$this->status] ?? '未知';
-    }
-
-    /**
-     * 获取退款状态文本
-     */
-    public function getRefundStatusTextAttribute()
-    {
-        $refundStatusMap = [
-            0 => '无',
-            1 => '已成功',
-            2 => '待退款',
-            3 => '退款失败'
-        ];
-        return $refundStatusMap[$this->refund_status] ?? '未知';
-    }
-}

+ 0 - 38
app/Models/SocialCircleModel.php

@@ -1,38 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 生活圈管理-模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
-class SocialCircleModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'social_circles';
-
-    // 封面图
-    public function getLogoAttribute($value)
-    {
-        $value = $value ? get_image_url($value) : '';
-        return $value;
-    }
-
-    public function setLogoAttribute($value)
-    {
-
-        return $value ? get_image_path($value) : '';
-    }
-
-}

+ 0 - 60
app/Models/SocialCirclesModel.php

@@ -1,60 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 生活圈推荐应用-模型
- * @author laravel开发员
- * @since 2024/12/28
- * Class SocialCirclesModel
- * @package App\Models
- */
-class SocialCirclesModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'social_circles';
-
-    /**
-     * 获取应用信息
-     * @param int $id
-     * @param bool $convertUrl 是否转换logo为完整URL,默认true(列表显示),false时保持相对路径(编辑使用)
-     * @return array|string
-     * @author laravel开发员
-     * @since 2024/12/28
-     */
-    public function getInfo($id, $convertUrl = true)
-    {
-        $info = parent::getInfo($id);
-        if ($info) {
-            // 处理logo:列表显示时转换为完整URL,编辑时保持相对路径
-            if (isset($info['logo'])) {
-                if ($info['logo']) {
-                    // 根据参数决定是否转换为完整URL
-                    $info['logo'] = $convertUrl ? get_image_url($info['logo']) : $info['logo'];
-                } else {
-                    $info['logo'] = '';
-                }
-            }
-            // 创建时间
-            if (isset($info['create_time']) && $info['create_time']) {
-                $info['create_time'] = datetime($info['create_time']);
-            }
-            // 更新时间
-            if (isset($info['update_time']) && $info['update_time']) {
-                $info['update_time'] = datetime($info['update_time']);
-            }
-            // 平台类型文本
-            $info['link_type_text'] = isset($info['link_type']) && $info['link_type'] == 1 ? 'Web' : '小程序';
-        }
-        return $info;
-    }
-}

+ 0 - 24
app/Models/StoreCategoryModel.php

@@ -1,24 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 商家分类管理-模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
-class StoreCategoryModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'stores_categorys';
-}

+ 29 - 0
app/Models/SupervisorsConsultRecordsModel.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Models;
+
+/**
+ * 领航员/导师-模型
+ */
+class SupervisorsConsultRecordsModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'supervisors_consult_records';
+
+    /**
+     * 咨询用户
+     */
+    public function member()
+    {
+        return $this->hasOne(MemberModel::class, 'id', 'user_id');
+    }
+
+    /**
+     * 导师
+     */
+    public function supervisor()
+    {
+        return $this->hasOne(SupervisorsModel::class, 'id', 'supervisors_id');
+    }
+}
+

+ 29 - 0
app/Models/SupervisorsModel.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Models;
+
+/**
+ * 领航员/导师-模型
+ */
+class SupervisorsModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'supervisors';
+
+    /**
+     * 关联用户
+     */
+    public function member()
+    {
+        return $this->hasOne(MemberModel::class, 'id', 'user_id');
+    }
+
+    /**
+     * 咨询记录
+     */
+    public function consults()
+    {
+        return $this->hasMany(SupervisorsConsultRecordsModel::class, 'supervisors_id', 'id');
+    }
+}
+

+ 0 - 201
app/Services/Api/JobsService.php

@@ -1,201 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services\Api;
-
-use App\Models\JobsCategoryModel;
-use App\Models\JobsModel;
-use App\Services\BaseService;
-use App\Services\RedisService;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 招聘管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Api
- */
-class JobsService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function __construct()
-    {
-        $this->model = new JobsModel();
-    }
-
-    /**
-     * 静态入口
-     * @return static|null
-     */
-    public static function make()
-    {
-        if (!self::$instance) {
-            self::$instance = (new static());
-        }
-        return self::$instance;
-    }
-
-    /**
-     * @param $params
-     * @param int $pageSize
-     * @return array
-     */
-    public function getDataList($params, $pageSize = 15)
-    {
-        $where = ['a.mark' => 1];
-        $status = isset($params['status']) ? $params['status'] : 0;
-        $categoryId = isset($params['category_id']) ? $params['category_id'] : 0;
-        if ($status > 0) {
-            $where['a.status'] = $status;
-        }
-
-        if ($categoryId > 0) {
-            $where['a.category_id'] = $categoryId;
-        }
-        $list = $this->model->with(['store','category'])->from('jobs as a')
-            ->leftJoin('jobs_categorys as b', 'b.id', '=', 'a.category_id')
-            ->where($where)
-            ->where(function ($query) use ($params) {
-                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
-                if ($keyword) {
-                    $query->where('a.job_name', 'like', "%{$keyword}%")
-                    ->orWhere('a.job_title','like',"%{$keyword}%")
-                    ->orWhere('a.tags','like',"%{$keyword}%")
-                    ->orWhere('a.company','like',"%{$keyword}%");
-                }
-            })
-            ->select(['a.*'])
-            ->orderBy('a.create_time', 'desc')
-            ->paginate($pageSize > 0 ? $pageSize : 9999999);
-        $list = $list ? $list->toArray() : [];
-        if ($list) {
-            foreach ($list['data'] as &$item) {
-                $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
-            }
-        }
-
-        return [
-            'pageSize' => $pageSize,
-            'total' => isset($list['total']) ? $list['total'] : 0,
-            'list' => isset($list['data']) ? $list['data'] : []
-        ];
-    }
-
-    /**
-     * 分类
-     * @return array|mixed
-     */
-    public function getCategoryList()
-    {
-        $cacheKey = "caches:jobs:categoryList";
-        $datas = RedisService::get($cacheKey);
-        if($datas){
-            return $datas;
-        }
-
-        $datas = JobsCategoryModel::where(['pid'=>0,'status'=>1,'mark'=>1])
-            ->select(['id','name','pid','remark','sort'])
-            ->orderBy('sort','desc')
-            ->orderBy('id','desc')
-            ->get();
-        $datas = $datas? $datas->toArray() : [];
-        if($datas){
-            RedisService::set($cacheKey, $datas, rand(300,600));
-        }
-
-        return $datas;
-    }
-
-
-    /**
-     * 申请
-     * @param $userId
-     * @param $params
-     * @return mixed
-     */
-    public function apply($userId, $params)
-    {
-        $name = isset($params['name']) ? trim($params['name']) : '';
-        $realname = isset($params['real_name']) ? trim($params['real_name']) : '';
-        $phone = isset($params['phone']) ? trim($params['phone']) : '';
-        $address = isset($params['address']) ? trim($params['address']) : '';
-        $categoryId = isset($params['category_id']) ? intval($params['category_id']) : 0;
-        $logo = isset($params['logo']) && $params['logo']? get_image_path($params['logo']) : '';
-        $businessLicense = isset($params['business_license']) && $params['business_license']? get_image_path($params['business_license']) : '';
-        $otherPhoto = isset($params['other_photo']) && $params['other_photo']? get_image_path($params['other_photo']) : '';
-
-        $data = [
-            'user_id' => $userId,
-            'name' => $name,
-            'real_name' => $realname,
-            'phone' => $phone,
-            'address' => $address,
-            'category_id' => $categoryId,
-            'logo' => $logo,
-            'business_license' => $businessLicense,
-            'other_photo' => $otherPhoto,
-            'order_count' => 0,
-            'order_total' => 0,
-            'confirm_remark' => '',
-            'create_time' => time(),
-            'update_time' => time(),
-            'status' => 2,
-            'mark' => 1,
-        ];
-
-        DB::beginTransaction();
-        if($id = $this->model->where(['user_id'=>$userId])->value('id')){
-            $this->model->where(['id'=>$id])->update($data);
-        }else{
-            if (!$id = $this->model->insertGetId($data)) {
-                DB::rollBack();
-                $this->error = '申请入驻失败';
-                return false;
-            }
-        }
-
-        DB::commit();
-        RedisService::keyDel("caches:members:info_*");
-        RedisService::keyDel("caches:stores:info*");
-        $this->error = '申请入驻成功,请耐心等候审核~';
-        return ['id' => $id];
-    }
-
-    /**
-     * 详情
-     * @param $id
-     * @param $userId
-     * @return array|mixed
-     */
-    public function getInfo($id,$userId=0)
-    {
-        $cacheKey = "caches:jobs:info_{$id}_{$userId}";
-        $info = RedisService::get($cacheKey);
-        if($info){
-            return $info;
-        }
-        $where = ['id'=> $id,'mark'=>1];
-        $info = $this->model->with(['store','category'])->where($where)->first();
-        $info = $info? $info->toArray() : [];
-        if($info){
-            $info['category_name'] = isset($info['category']) && $info['category']?$info['category']['name'] : '';
-            RedisService::set($cacheKey, $info, rand(5, 10));
-        }
-
-        return $info;
-    }
-
-
-}

+ 0 - 139
app/Services/Api/SettleService.php

@@ -103,143 +103,4 @@ class SettleService extends BaseService
 
         return $result;
     }
-
-    /**
-     * 代理收益
-     * @param $userId
-     * @param $money
-     * @param $order
-     * @param $parentId
-     * @param int $type
-     * @return array|false|int
-     */
-    public function agentBonus($userId, $money, $order, $parentId, $type=0)
-    {
-        $orderNo = isset($order['order_no'])? $order['order_no'] : '';
-        if($money<=0 || $userId<=0 || $parentId<=0){
-            $this->error = '无收益可结算';
-            return false;
-        }
-
-        $parent = AgentModel::with(['user'])->where(['user_id'=> $parentId,'status'=>1,'mark'=>1])
-            ->select(['id','balance','user_id','income','status'])
-            ->first();
-        $agentId = isset($parent['id'])? $parent['id'] : 0;
-        $balance = isset($parent['balance'])? $parent['balance'] : 0;
-        $parentInfo = isset($parent['user'])? $parent['user'] : [];
-        $parentOneId = isset($parentInfo['parent_id'])? $parentInfo['parent_id'] :0;
-
-
-        // 推荐消费者的佣金
-        $logs = [];
-        $agentDirectBonusRate = ConfigService::make()->getConfigByCode('agent_direct_bonus_rate', 0);
-        $agentDirectBonusRate = $agentDirectBonusRate>0 && $agentDirectBonusRate<100? $agentDirectBonusRate : 0;
-        $bonus = moneyFormat($agentDirectBonusRate * $money/100, 2);
-        if(empty($parent) || $bonus<=0 || $agentId<=0){
-            $this->error = '上级代理无效';
-            return 0;
-        }
-
-        if(!AgentModel::where(['id'=> $agentId])->update(['balance'=>DB::raw("balance + {$bonus}"),'income'=>DB::raw("income + {$bonus}"),'order_count'=>DB::raw("order_count + 1"),'update_time'=>time()])){
-            $this->error = '推荐消费者收益结算错误,请联系客服处理';
-            return -1;
-        }
-
-        $logs[] = [
-            'user_id'=> $parentId,
-            'source_order_no'=> isset($order['order_no'])? $order['order_no'] : '',
-            'type'=> 9,
-            'money'=> $bonus,
-            'before_money'=> $balance,
-            'date'=>date('Y-m-d'),
-            'create_time'=>time(),
-            'remark'=> '推广收益',
-            'remark1'=> ['','话费充值','电费充值','燃气充值'][$type],
-            'status'=>1
-        ];
-
-
-        // 一级代理收益
-        $parentTwoId = 0;
-        $oneBonus = 0;
-        if($bonus>0 && $parentOneId){
-            $parentOne = AgentModel::with(['user'])->where(['user_id'=> $parentOneId,'status'=>1,'mark'=>1])
-                ->select(['id','balance','user_id','income','status'])
-                ->first();
-            $oneId = isset($parentOne['id'])? $parentOne['id'] : 0;
-            $oneBalance = isset($parentOne['balance'])? $parentOne['balance'] : 0;
-            $oneInfo = isset($parentOne['user'])? $parentOne['user'] : [];
-            $parentTwoId = isset($oneInfo['parent_id'])? $oneInfo['parent_id'] :0;
-
-            $agentBonusLevel1Rate = ConfigService::make()->getConfigByCode('agent_bonus_level1_rate', 0);
-            $agentBonusLevel1Rate = $agentBonusLevel1Rate>0 && $agentBonusLevel1Rate<100? $agentBonusLevel1Rate : 0;
-            $oneBonus = moneyFormat($agentBonusLevel1Rate * $bonus/100, 4);
-            if($oneBonus>=0.01){
-                if(!AgentModel::where(['id'=> $oneId])->update(['balance'=>DB::raw("balance + ".moneyFormat($oneBonus,2)),'income'=>DB::raw("income + ".moneyFormat($oneBonus,2)),'order_count'=>DB::raw("order_count + 1"),'update_time'=>time()])){
-                    $this->error = '推荐代理收益结算错误,请联系客服处理';
-                    return -1;
-                }
-
-                $logs[] = [
-                    'user_id'=> $parentOneId,
-                    'source_order_no'=> isset($order['order_no'])? $order['order_no'] : '',
-                    'type'=> 8,
-                    'money'=> moneyFormat($oneBonus,2),
-                    'before_money'=> $oneBalance,
-                    'date'=>date('Y-m-d'),
-                    'create_time'=>time()+1,
-                    'remark'=> '一级代理收益',
-                    'remark1'=> ['','话费充值','电费充值','燃气充值'][$type],
-                    'status'=>1
-                ];
-            }
-        }
-
-        // 二级代理收益
-        $twoBonus = 0;
-        if($bonus>0 && $parentTwoId){
-            $parentTwo = AgentModel::with(['user'])->where(['user_id'=> $parentTwoId,'status'=>1,'mark'=>1])
-                ->select(['id','balance','user_id','income','status'])
-                ->first();
-            $twoId = isset($parentTwo['id'])? $parentTwo['id'] : 0;
-            $twoBalance = isset($parentTwo['balance'])? $parentTwo['balance'] : 0;
-
-            $agentBonusLevel2Rate = ConfigService::make()->getConfigByCode('agent_bonus_level2_rate', 0);
-            $agentBonusLevel2Rate = $agentBonusLevel2Rate>0 && $agentBonusLevel2Rate<100? $agentBonusLevel2Rate : 0;
-            $twoBonus = moneyFormat($agentBonusLevel2Rate * $bonus/100, 4);
-            if($twoBonus>=0.01){
-                if(!AgentModel::where(['id'=> $twoId])->update(['balance'=>DB::raw("balance + ".moneyFormat($twoBonus,2)),'income'=>DB::raw("income + ".moneyFormat($twoBonus,2)),'order_count'=>DB::raw("order_count + 1"),'update_time'=>time()])){
-                    $this->error = '推荐代理收益结算错误,请联系客服处理';
-                    return -1;
-                }
-
-                $logs[] = [
-                    'user_id'=> $parentTwoId,
-                    'source_order_no'=> isset($order['order_no'])? $order['order_no'] : '',
-                    'type'=> 8,
-                    'money'=> moneyFormat($twoBonus,2),
-                    'before_money'=> $twoBalance,
-                    'date'=>date('Y-m-d'),
-                    'create_time'=>time()+2,
-                    'remark'=> '二级代理收益',
-                    'remark1'=> ['','话费充值','电费充值','燃气充值'][$type],
-                    'status'=>1
-                ];
-            }
-
-        }
-
-        if($logs && !$this->model->insert($logs)){
-            $this->error = '推荐代理收益结算错误,请联系客服处理';
-            return -1;
-        }
-
-        $result = ['user_id'=>$userId,'total'=> $money,'bonus'=>$bonus,'parent_id'=>$parentId,'oneId'=>$parentOneId,'oneBonus'=>$oneBonus,'twoId'=>$parentTwoId,'twoBonus'=>$twoBonus];
-        if(env('APP_DEBUG')){
-            RedisService::set("caches:settle:{$orderNo}:agent_{$userId}", $result, 7200);
-        }
-
-        return $result;
-    }
-
 }

+ 0 - 79
app/Services/Api/SocialCircleService.php

@@ -1,79 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services\Api;
-
-use App\Models\SocialCircleModel;
-use App\Services\BaseService;
-use App\Services\ConfigService;
-use App\Services\RedisService;
-
-/**
- * 生活圈-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Api
- */
-class SocialCircleService extends BaseService
-{
-    // 静态对象
-    protected static $instance = null;
-
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function __construct()
-    {
-        $this->model = new SocialCircleModel();
-    }
-
-    /**
-     * 静态入口
-     */
-    public static function make()
-    {
-        if (!self::$instance) {
-            self::$instance = new static();
-        }
-        return self::$instance;
-    }
-
-    /**
-     * 主页列表
-     * @param int $num
-     * @return array|mixed
-     */
-    public function getIndexList($num = 0)
-    {
-        $num = ConfigService::make()->getConfigByCode('show_social_num', 12);
-        $cacheKey = "caches:socials:list_{$num}";
-        $datas = RedisService::get($cacheKey);
-        if($datas){
-            return $datas;
-        }
-
-        $datas =  $this->model->where(['status'=>1,'mark'=>1])
-            ->select(['id','name','logo','link_type','app_id','sort','status'])
-            ->orderBy('sort','desc')
-            ->orderBy('id','asc')
-            ->limit($num)
-            ->get();
-        $datas = $datas? $datas->toArray() : [];
-        if($datas){
-            $datas = $datas?array_chunk($datas,8) : [];
-            RedisService::set($cacheKey, $datas, rand(300, 600));
-        }
-
-        return $datas;
-    }
-}

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

@@ -1,363 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services\Api;
-
-use App\Models\GoodsModel;
-use App\Models\MemberModel;
-use App\Models\StoreCategoryModel;
-use App\Models\StoreModel;
-use App\Services\BaseService;
-use App\Services\RedisService;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 商家管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Api
- */
-class StoreService extends BaseService
-{
-    protected static $instance = null;
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function __construct()
-    {
-        $this->model = new StoreModel();
-    }
-
-    /**
-     * 静态入口
-     * @return static|null
-     */
-    public static function make()
-    {
-        if (!self::$instance) {
-            self::$instance = (new static());
-        }
-        return self::$instance;
-    }
-
-    /**
-     * @param $params
-     * @param int $pageSize
-     * @return array
-     */
-    public function getDataList($params, $pageSize = 15)
-    {
-        $where = ['a.mark' => 1];
-        $status = isset($params['status']) ? $params['status'] : 0;
-        if ($status > 0) {
-            $where['a.status'] = $status;
-        }
-        $list = $this->model->with(['user'])->from('stores as a')
-            ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
-            ->where($where)
-            ->where(function ($query) use ($params) {
-                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
-                if ($keyword) {
-                    $query->where('a.name', 'like', "%{$keyword}%");
-                }
-            })
-            ->select(['a.*'])
-            ->orderBy('a.create_time', 'desc')
-            ->paginate($pageSize > 0 ? $pageSize : 9999999);
-        $list = $list ? $list->toArray() : [];
-        if ($list) {
-            foreach ($list['data'] as &$item) {
-                $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
-            }
-        }
-
-        return [
-            'pageSize' => $pageSize,
-            'total' => isset($list['total']) ? $list['total'] : 0,
-            'list' => isset($list['data']) ? $list['data'] : []
-        ];
-    }
-
-    /**
-     * 商品列表
-     * @param $params
-     * @param int $pageSize
-     * @return array
-     */
-    public function getGoodsList($params, $pageSize = 7)
-    {
-        $userId = isset($params['user_id'])? $params['user_id'] : 0;
-        $cacheKey = "caches:stores:index_goods_{$userId}_{$pageSize}:".md5(json_encode($params));
-        $datas = RedisService::get($cacheKey);
-        if($datas){
-            return $datas;
-        }
-
-        $storeId = $this->getStoreId($userId);
-        if($storeId<=0){
-            $this->error = $this->error? '没有店铺信息:'.$this->error: '没有店铺信息';
-            return false;
-        }
-
-        $storeInfo = $this->model->where(['id'=>$storeId,'status'=>1,'mark'=>1])
-            ->select(['id','user_id','name','logo'])
-            ->first();
-        if(empty($storeInfo)){
-            $this->error = '店铺信息不存在';
-            return ['id'=>$storeId];
-        }
-
-        $list = GoodsModel::where(['store_id'=>$storeId,'status'=>1,'mark'=>1])
-            ->where(function ($query) use ($params) {
-                $keyword = isset($params['keyword']) ? $params['keyword'] : '';
-                if ($keyword) {
-                    $query->where('goods_name', 'like', "%{$keyword}%")
-                        ->orWhere('tags', 'like', "%{$keyword}%");
-                }
-            })
-            ->where(function ($query) use ($params) {
-                $categoryId = isset($params['category_id']) ? $params['category_id'] : 0;
-                if ($categoryId>0) {
-                    $query->where('category_id', $categoryId);
-                }
-            })
-            ->select(['id','goods_name','thumb','price','sku_type','sales','sort','status'])
-            ->orderBy('sort', 'desc')
-            ->orderBy('id', 'desc')
-            ->limit($pageSize)
-            ->get();
-        $list = $list ? $list->toArray() : [];
-        $datas = ['id'=>$storeId];
-        if ($list) {
-            $datas = [
-                'id'=>$storeId,
-                'store'=>$storeInfo,
-                'goods'=>$list
-            ];
-            RedisService::set($cacheKey, $datas, rand(10,20));
-        }
-
-        return $datas;
-    }
-
-    /**
-     * 获取显示商家ID
-     * @param $userId
-     * @return array|int|mixed
-     */
-    public function getStoreId($userId)
-    {
-        $cacheKey = "caches:storeId:id_{$userId}";
-        $data = RedisService::get($cacheKey);
-        if($data){
-            return $data;
-        }
-
-        $params = request()->all();
-        $system = isset($params['system']) ? $params['system'] : [];
-        $system = $system && !is_array($system) ? json_decode($system, true) : $system;
-        $uuid = isset($system['uuid']) ? $system['uuid'] : '';
-        $uuKey = "caches:storeId:uuid_{$uuid}";
-        $ipKey = "caches:storeId:ip_".get_client_ip();
-        if($userId<=0){
-            if($storeId = RedisService::get($ipKey)){
-                $this->error = "未登录缓存的店铺";
-                return $storeId;
-            }else if($uuid && $storeId = RedisService::get($uuKey)){
-                $this->error = "未登录缓存的店铺";
-                return $storeId;
-            }
-        }
-
-        // 用户信息
-        $userInfo = MemberModel::with(['store'])
-            ->where(['id'=>$userId,'mark'=>1])
-            ->select(['id', 'realname', 'nickname','parents', 'status'])
-            ->first();
-        $store = isset($userInfo['store'])? $userInfo['store'] : [];
-        $parents = isset($userInfo['parents'])? $userInfo['parents'] : '';
-        $ids = $parents? explode(',', $parents) : [];
-        $ids = array_filter($ids);
-        $ids = array_reverse($ids);
-        $storeId = isset($store['id'])? $store['id'] : 0;
-        $storeStatus = isset($store['status'])? $store['status'] : 0;
-        $storeMark = isset($store['mark'])? $store['mark'] : 0;
-        if($userId && empty($userInfo)){
-            $this->error = '用户账户不存在';
-            return 0;
-        }
-
-        // 用户自己是商家
-        if($storeId>0 && $storeStatus==1 && $storeMark==1){
-            $this->error = '用户自己的店铺';
-            RedisService::set($cacheKey, $storeId, 7 * 86400);
-            return $storeId;
-        }
-
-        // 用户上级有商家
-        $parentStoreInfo = [];
-        if($ids){
-            $parentStoreInfo = $this->model->whereIn('user_id',$ids)
-                ->where(['status'=>1,'mark'=>1])
-                ->select(['id','user_id','name'])
-                ->orderByRaw("FIELD(user_id,".(implode(',',$ids)).") asc")
-                ->first();
-        }
-
-        $storeId = isset($parentStoreInfo['id'])?$parentStoreInfo['id'] : 0;
-        $parentUserId = isset($parentStoreInfo['user_id'])?$parentStoreInfo['user_id'] : 0;
-        if($parentStoreInfo && $storeId>0){
-            RedisService::set($cacheKey, $storeId, 7 * 86400);
-            RedisService::set($ipKey, $storeId, 7 * 86400);
-            RedisService::set($uuKey, $storeId, 7 * 86400);
-            $this->error = "上级[{$parentUserId}]的店铺";
-            return $storeId;
-        }
-
-        $this->error = "";
-        return 0;
-
-    }
-
-    /**
-     * 行业分类
-     * @return array|mixed
-     */
-    public function getCategoryList()
-    {
-        $cacheKey = "caches:stores:categoryList";
-        $datas = RedisService::get($cacheKey);
-        if($datas){
-            return $datas;
-        }
-
-        $datas = StoreCategoryModel::where(['pid'=>0,'status'=>1,'mark'=>1])
-            ->select(['id','name','pid','sort'])
-            ->orderBy('sort','desc')
-            ->orderBy('id','desc')
-            ->get();
-        $datas = $datas? $datas->toArray() : [];
-        if($datas){
-            RedisService::set($cacheKey, $datas, rand(300,600));
-        }
-
-        return $datas;
-    }
-
-
-    /**
-     * 申请
-     * @param $userId
-     * @param $params
-     * @return mixed
-     */
-    public function apply($userId, $params)
-    {
-        $name = isset($params['name']) ? trim($params['name']) : '';
-        $realname = isset($params['real_name']) ? trim($params['real_name']) : '';
-        $phone = isset($params['phone']) ? trim($params['phone']) : '';
-        $address = isset($params['address']) ? trim($params['address']) : '';
-        $intro = isset($params['intro']) ? trim($params['intro']) : '';
-        $categoryId = isset($params['category_id']) ? intval($params['category_id']) : 0;
-        $logo = isset($params['logo']) && $params['logo']? get_image_path($params['logo']) : '';
-        $businessLicense = isset($params['business_license']) && $params['business_license']? get_image_path($params['business_license']) : '';
-        $otherPhoto = isset($params['other_photo']) && $params['other_photo']? get_image_path($params['other_photo']) : '';
-
-        $data = [
-            'user_id' => $userId,
-            'name' => $name,
-            'real_name' => $realname,
-            'phone' => $phone,
-            'address' => $address,
-            'category_id' => $categoryId,
-            'logo' => $logo,
-            'business_license' => $businessLicense,
-            'other_photo' => $otherPhoto,
-            'intro' => $intro,
-            'order_count' => 0,
-            'order_total' => 0,
-            'confirm_remark' => '',
-            'create_time' => time(),
-            'update_time' => time(),
-            'status' => 2,
-            'mark' => 1,
-        ];
-
-        DB::beginTransaction();
-        if($id = $this->model->where(['user_id'=>$userId])->value('id')){
-            $this->model->where(['id'=>$id])->update($data);
-        }else{
-            if (!$id = $this->model->insertGetId($data)) {
-                DB::rollBack();
-                $this->error = '申请入驻失败';
-                return false;
-            }
-        }
-
-        DB::commit();
-        RedisService::keyDel("caches:members:info_*");
-        RedisService::keyDel("caches:stores:info*");
-        $this->error = '申请入驻成功,请耐心等候审核~';
-        return ['id' => $id];
-    }
-
-    /**
-     * 入驻信息
-     * @param $id
-     * @param $userId
-     * @return array|mixed
-     */
-    public function getApplyInfo($userId)
-    {
-        $cacheKey = "caches:stores:info_u{$userId}";
-        $info = RedisService::get($cacheKey);
-        if($info){
-            return $info;
-        }
-        $where = ['user_id'=> $userId,'mark'=>1];
-        $info = $this->model->with(['category'])->where($where)->first();
-        $info = $info? $info->toArray() : [];
-        if($info){
-            $info['category_name'] = isset($info['category']) && $info['category']?$info['category']['name'] : '';
-            RedisService::set($cacheKey, $info, rand(5, 10));
-        }
-
-        return $info;
-    }
-
-    /**
-     * 店铺详情
-     * @param $id
-     * @param $userId
-     * @return array|mixed
-     */
-    public function getInfo($id)
-    {
-        $cacheKey = "caches:stores:info_{$id}";
-        $info = RedisService::get($cacheKey);
-        if($info){
-            return $info;
-        }
-        $where = ['id'=> $id,'mark'=>1];
-        $info = $this->model->with(['category'])->where($where)->first();
-        $info = $info? $info->toArray() : [];
-        if($info){
-            $info['category_name'] = isset($info['category']) && $info['category']?$info['category']['name'] : '';
-            RedisService::set($cacheKey, $info, rand(5, 10));
-        }
-
-        return $info;
-    }
-
-
-}

+ 28 - 62
app/Services/Api/AgentService.php

@@ -11,17 +11,18 @@
 
 namespace App\Services\Api;
 
-use App\Models\AgentModel;
+use App\Models\SupervisorsModel;
 use App\Services\BaseService;
 use App\Services\RedisService;
+use Illuminate\Support\Facades\DB;
 
 /**
- * 代理管理-服务类
+ * 导师管理-服务类
  * @author laravel开发员
  * @since 2020/11/11
  * @package App\Services\Api
  */
-class AgentService extends BaseService
+class SupervisorsService extends BaseService
 {
     /**
      * 构造函数
@@ -30,7 +31,7 @@ class AgentService extends BaseService
      */
     public function __construct()
     {
-        $this->model = new AgentModel();
+        $this->model = new SupervisorsModel();
     }
 
     /**
@@ -52,23 +53,30 @@ class AgentService extends BaseService
      */
     public function getDataList($params, $pageSize = 15)
     {
-        $where = ['a.mark' => 1];
+        $where = ['supervisors.mark' => 1];
         $status = isset($params['status']) ? $params['status'] : 0;
+        $isRecommend = isset($params['is_recommend']) ? $params['is_recommend'] : 0;
         if ($status > 0) {
-            $where['a.status'] = $status;
+            $where['supervisors.status'] = $status;
         }
-        $list = $this->model->with(['user'])->from('agent as a')
-            ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
+
+        if ($isRecommend > 0) {
+            $where['supervisors.is_recommend'] = $isRecommend;
+        }
+        $list = $this->model->with(['member'])
+            ->from('supervisors')
             ->where($where)
             ->where(function ($query) use ($params) {
                 $keyword = isset($params['keyword']) ? $params['keyword'] : '';
                 if ($keyword) {
-                    $query->where('a.real_name', 'like', "%{$keyword}%")
-                        ->orWhere('a.phone', 'like', "%{$keyword}%");
+                    $query->where('supervisors.name', 'like', "%{$keyword}%")
+                    ->orWhere('supervisors.mobile','like',"%{$keyword}%");
                 }
             })
-            ->select(['a.*'])
-            ->orderBy('a.create_time', 'desc')
+            ->select(['supervisors.*'])
+            ->withCount(['consults'])
+            ->orderBy('supervisors.sort', 'desc')
+            ->orderBy('supervisors.id', 'desc')
             ->paginate($pageSize > 0 ? $pageSize : 9999999);
         $list = $list ? $list->toArray() : [];
         if ($list) {
@@ -85,70 +93,28 @@ class AgentService extends BaseService
     }
 
     /**
-     * 申请
-     * @param $userId
-     * @param $params
-     * @return mixed
-     */
-    public function apply($userId, $params)
-    {
-        $realname = isset($params['real_name']) ? trim($params['real_name']) : '';
-        $phone = isset($params['phone']) ? trim($params['phone']) : '';
-        $idcard = isset($params['idcard']) && $params['idcard']? trim($params['idcard']) : '';
-
-        $data = [
-            'user_id' => $userId,
-            'real_name' => $realname,
-            'phone' => $phone,
-            'idcard' => $idcard,
-            'income' => 0,
-            'balance' => 0,
-            'withdraw_total' => 0,
-            'order_count' => 0,
-            'confirm_remark' => '',
-            'create_time' => time(),
-            'update_time' => time(),
-            'status' => 2,
-            'mark' => 1,
-        ];
-
-
-        if($id = $this->model->where(['user_id'=>$userId])->value('id')){
-            $this->model->where(['id'=>$id])->update($data);
-        }else{
-            if (!$id = $this->model->insertGetId($data)) {
-                $this->error = '代理申请失败';
-                return false;
-            }
-        }
-
-        RedisService::keyDel("caches:members:info_*");
-        RedisService::keyDel("caches:agents:info*");
-        $this->error = '代理申请成功,请耐心等候审核~';
-        return ['id' => $id];
-    }
-
-    /**
-     * 代理信息
+     * 详情
      * @param $id
      * @param $userId
      * @return array|mixed
      */
-    public function getInfo($uid)
+    public function getInfo($id,$userId=0)
     {
-        $cacheKey = "caches:agents:info_{$uid}";
+        $cacheKey = "caches:jobs:info_{$id}_{$userId}";
         $info = RedisService::get($cacheKey);
         if($info){
             return $info;
         }
-        $where = ['user_id'=> $uid,'mark'=>1];
-        $info = $this->model->with(['user'])->where($where)->first();
+        $where = ['id'=> $id,'mark'=>1];
+        $info = $this->model->with(['store','category'])->where($where)->first();
         $info = $info? $info->toArray() : [];
         if($info){
-
+            $info['category_name'] = isset($info['category']) && $info['category']?$info['category']['name'] : '';
             RedisService::set($cacheKey, $info, rand(5, 10));
         }
 
         return $info;
     }
+
+
 }