|
|
@@ -0,0 +1,91 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 版权所有 2017~2021 LARAVEL研发中心
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 官方网站: http://www.laravel.cn
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author: laravel开发员 <laravel.qq.com>
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace App\Services\Api;
|
|
|
+
|
|
|
+use App\Models\AccountLogModel;
|
|
|
+use App\Models\MemberNodeModel;
|
|
|
+use App\Models\MemberSettingModel;
|
|
|
+use App\Services\BaseService;
|
|
|
+use App\Services\RedisService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 节点会员服务管理-服务类
|
|
|
+ * @author laravel开发员
|
|
|
+ * @since 2020/11/11
|
|
|
+ * @package App\Services\Common
|
|
|
+ */
|
|
|
+class MemberNodeService extends BaseService
|
|
|
+{
|
|
|
+ protected static $instance=null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ * @author laravel开发员
|
|
|
+ * @since 2020/11/11
|
|
|
+ * MemberSettingService constructor.
|
|
|
+ */
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->model = new MemberNodeModel();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 静态入口
|
|
|
+ * @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, $field = '', $userId=0)
|
|
|
+ {
|
|
|
+
|
|
|
+ $where = ['a.mark' => 1,'a.status'=>1];
|
|
|
+ $field = $field? $field : 'lev_a.id,lev_a.name,lev_a.price,lev_a.upgrade_level_id,lev_b.global_bonus_rate,lev_b.box_num as level_box_num,lev_a.limit_num,lev_a.box_num,lev_a.score_rate,lev_a.remark,lev_a.status';
|
|
|
+ $sortType = isset($params['sort_type']) ? $params['sort_type'] : 1;
|
|
|
+ $order = 'id asc';
|
|
|
+ if($sortType == 1){
|
|
|
+ $order = 'lev_a.id asc';
|
|
|
+ }
|
|
|
+ $list = $this->model->from('member_nodes as a')
|
|
|
+ ->leftJoin('member_level as b','b.id','=','a.upgrade_level_id')
|
|
|
+ ->where($where)
|
|
|
+ ->selectRaw($field)
|
|
|
+ ->orderByRaw($order)
|
|
|
+ ->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
+ $list = $list ? $list->toArray() : [];
|
|
|
+ if ($list) {
|
|
|
+ foreach ($list['data'] as &$item) {
|
|
|
+ // 是否已购买
|
|
|
+ $buyLogId = AccountLogModel::where(['user_id'=> $userId,'source_id'=>$item['id'],'type'=>4,'status'=>1,'mark'=>1])->value('id');
|
|
|
+ $item['buy_status'] = $buyLogId? 1 : 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'pageSize' => $pageSize,
|
|
|
+ 'total' => isset($list['total']) ? $list['total'] : 0,
|
|
|
+ 'list' => isset($list['data']) ? $list['data'] : []
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|