diff --git a/plugins/cultural-space/src/admin/ContributionController.php b/plugins/cultural-space/src/admin/ContributionController.php index 4e7b16e2..80f15135 100644 --- a/plugins/cultural-space/src/admin/ContributionController.php +++ b/plugins/cultural-space/src/admin/ContributionController.php @@ -2,21 +2,67 @@ namespace Yunshop\CulturalSpace\admin; use app\common\components\BaseController; - +use Yunshop\CulturalSpace\models\ContributionLog; +use Yunshop\CulturalSpace\models\CulturalSpace; class ContributionController extends BaseController{ - // 列表 + + /** + * Common: 变更明细 + * Author: wu-hui + * Time: 2023/11/03 9:40 + * @return array|\Illuminate\Http\JsonResponse|string + * @throws \Throwable + */ public function index(){ + if(request()->isMethod('post')){ + // 参数获取 + $search = request()->input('search'); + // 获取变更记录 + $field = [ + 'id', + 'uid', + 'change_type', + 'change_quantity', + 'change_front', + 'change_after', + 'remark', + 'created_at' + ]; + $result = ContributionLog::getList($search,$field); - - - - - + return $this->successJson('success',[ + 'current_page' => $result['current_page'], + 'data' => $result['data'], + 'last_page' => $result['last_page'], + ]); + } return view('Yunshop\CulturalSpace::contribution.index')->render(); } + /** + * Common: 用户持有统计 + * Author: wu-hui + * Time: 2023/11/03 10:03 + * @return \Illuminate\Http\JsonResponse + */ + public function hold(){ + // 参数获取 + $search = request()->input('search'); + // 获取记录 + $result = CulturalSpace::getList($search); + + return $this->successJson('success',[ + 'current_page' => $result['current_page'], + 'data' => $result['data'], + 'last_page' => $result['last_page'], + ]); + } + // 分红记录 + public function bonus(){} + + diff --git a/plugins/cultural-space/src/models/ContributionLog.php b/plugins/cultural-space/src/models/ContributionLog.php index 6e732bea..abea4d9d 100644 --- a/plugins/cultural-space/src/models/ContributionLog.php +++ b/plugins/cultural-space/src/models/ContributionLog.php @@ -3,6 +3,7 @@ namespace Yunshop\CulturalSpace\models; use app\common\models\BaseModel; +use app\common\models\Member; class ContributionLog extends BaseModel{ @@ -27,13 +28,46 @@ class ContributionLog extends BaseModel{ ]; + /** + * Common: 贡献值变更记录 + * Author: wu-hui + * Time: 2023/11/03 9:39 + * @param $search + * @param string[] $field + * @return array + */ + public function getList($search,$field = ['*']){ + // 条件生成 + $where = []; + if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']]; + if($search['change_type'] >= 0 && $search['change_type'] != '') $where[] = ['change_type','=',$search['change_type']]; + // 列表获取 + $list = self::uniacid() + ->select($field) + ->where($where) + ->with([ + 'member' => function($query){ + $query->select(['uid','nickname','realname','avatar']); + } + ]) + ->orderBy('created_at','DESC') + ->orderBy('id','DESC') + ->paginate(10); + + return $list ? $list->toArray() : []; + } - - - - + /** + * Common: 一对一关联 用户信息 + * Author: wu-hui + * Time: 2023/11/03 9:35 + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function member(){ + return $this->hasOne(Member::class,'uid','uid'); + } } diff --git a/plugins/cultural-space/src/models/CulturalSpace.php b/plugins/cultural-space/src/models/CulturalSpace.php index d1d7013e..6143698e 100644 --- a/plugins/cultural-space/src/models/CulturalSpace.php +++ b/plugins/cultural-space/src/models/CulturalSpace.php @@ -20,6 +20,40 @@ class CulturalSpace extends BaseModel{ ]; + /** + * Common: 贡献值持有信息列表 + * Author: wu-hui + * Time: 2023/11/03 9:51 + * @param $search + * @return array + */ + public function getList($search){ + // 条件生成 + $where = []; + if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']]; + // 查询model + $model = self::uniacid() + ->where($where) + ->with([ + 'member' => function($query){ + $query->select(['uid','nickname','realname','avatar']); + } + ]); + // 信息获取 + $totalContribution = $model->sum('contribution'); + $list = $model->select(['id','uid','contribution']) + ->orderBy('id','DESC') + ->paginate(10) + ->toArray(); + foreach($list['data'] as &$item){ + $item['total_proportion'] = (float)sprintf("%.2f",$totalContribution); + $item['ratio'] = (float)sprintf("%.2f",$item['contribution'] / $totalContribution * 100); + } + + return $list; + } + + /** * Common: 购买商品奖励贡献值 * Author: wu-hui @@ -152,4 +186,15 @@ class CulturalSpace extends BaseModel{ + + + /** + * Common: 一对一关联 用户信息 + * Author: wu-hui + * Time: 2023/11/03 9:35 + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function member(){ + return $this->hasOne(Member::class,'uid','uid'); + } } diff --git a/plugins/cultural-space/views/contribution/index.blade.php b/plugins/cultural-space/views/contribution/index.blade.php index 10b6da4a..c9dffe1f 100644 --- a/plugins/cultural-space/views/contribution/index.blade.php +++ b/plugins/cultural-space/views/contribution/index.blade.php @@ -34,21 +34,6 @@ overflow: hidden; text-overflow: ellipsis; } - .level_0{ - background-color: #5bc0de!important; - } - .level_1{ - background-color: #f0ad4e!important; - } - .level_2{ - background-color: #5cb85c!important; - } - .level_3{ - background-color: #337ab7!important; - } - .level_4{ - background-color: #d9534f!important; - } .panel-body .label{ display: inline-block; margin-bottom: 2px; @@ -81,22 +66,16 @@ {{--搜索--}} - + - + - - - - - - - + 查询 @@ -128,28 +107,15 @@ - - - - + {{--搜索--}} - + - - - - - - - + 查询 @@ -171,11 +137,53 @@ - + + + + + + + + + + + + + + {{--搜索--}} + + + + + + 查询 + + + {{--表单--}} + + + + @@ -192,7 +200,7 @@ @@ -216,59 +224,58 @@ el: '#contributionIndexContent', delimiters: ['[[', ']]'], name: 'cultural_space_index_content', - data: { - tabs_active: 'show_detail', - level_list: JSON.parse('{!! json_encode($level_list) !!}'), - // 分页信息 - page: 1, - total_page: 1, - list: [], - search_list: { - member_id: '', - team_dividend_agency_level_id: '', - change_type: '', + data() { + return { + tabs_active: 'show_detail', + // 分页信息 + page: 1, + total_page: 1, + list: [], + search_info: { + uid: '', + change_type: '', + } } }, watch:{}, mounted () { - // this.getData(); + this.getData(); }, methods: { // 获取数据 根据当前选项卡获取对应的信息 getData(){ let _this = this; let loading = _this.showLoading(); - let link = "{!! yzWebUrl('plugin.cultural-space.admin.index.changeRecord') !!}"; - if(_this.tabs_active === 'show_group') link = "{!! yzWebUrl('plugin.cultural-space.admin.index.changeGroupRecord') !!}"; + // 获取请求地址 + let link = "{!! yzWebUrl('plugin.cultural-space.admin.contribution.index') !!}"; + if(_this.tabs_active === 'show_group') link = "{!! yzWebUrl('plugin.cultural-space.admin.contribution.hold') !!}"; + else if(_this.tabs_active === 'show_bonus') link = "{!! yzWebUrl('plugin.cultural-space.admin.contribution.bonus') !!}"; + // 请求获取数据 $.ajax({ url: link, type: "post", data: { page: _this.page, - search: _this.search_list, + search: _this.search_info, is_get: 1 }, success: function(result) { - loading.close(0); let data = result.data; if(parseInt(result.result) === 1){ // 处理数据 _this.list = data.data; _this.total_page = data.last_page; } + loading.close(); } }); }, // 切换选项卡 changeTabs(){ this.page = 1; - this.search_list = { - member_id: '', - team_dividend_agency_level_id: '', - change_type: '', - }; this.total_page = 1; this.list = []; + this.search_info = Object.assign({},this.$options.data().search_info); this.getData(); }, // 数据分页 @@ -290,14 +297,17 @@ background: 'rgba(0, 0, 0, 0.7)' }); }, - // 查看分组的变更明细 - seeDetail(member_id,level_id){ - let link = "{{yzWebUrl('plugin.cultural-space.admin.index.changeRecord')}}" + `&member_id=${member_id}&level_id=${level_id}`; - let popup = util.ajaxshow(link,'权重值变更明细',{ - width: $(window).width() * 0.8 > 1200 ? $(window).width() * 0.8 : 1200, - height: $(window).height() * 0.8 > 1200 ? $(window).height() * 0.8 : 1200, - }); - } + // 用户持有统计中查看某个用户的贡献值变更记录 + seeChangeRecord(uid){ + this.search_info.uid = uid; + this.page = 1; + this.tabs_active = 'show_detail'; + this.getData() + }, + + + + }, })