diff --git a/app/common/dao/user/UserDao.php b/app/common/dao/user/UserDao.php index 30b111b..89df3f3 100644 --- a/app/common/dao/user/UserDao.php +++ b/app/common/dao/user/UserDao.php @@ -77,6 +77,12 @@ class UserDao extends BaseDao return $query->where('User.user_type', $where['user_type']); })->when(isset($where['uid']) && $where['uid'] !== '', function (BaseQuery $query) use ($where) { return $query->where('User.uid', $where['uid']); + })->when(isset($where['agent_id']) && $where['agent_id'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('User.agent_district_id' ,'>', 0); + })->when(isset($where['is_share']) && $where['is_share'] !== '', function (BaseQuery $query) use ($where) { + return $query->hasWhere('assets', function ($query) use ($where) { + $query->where('share_point', '>', 0); + }); })->when(isset($where['status']) && $where['status'] !== '', function (BaseQuery $query) use ($where) { return $query->where('User.status', intval($where['status'])); })->when(isset($where['group_id']) && $where['group_id'], function (BaseQuery $query) use ($where) { diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 4d25201..b8dc390 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -161,6 +161,11 @@ class User extends BaseModel return $this->hasOne(UserGroup::class, 'group_id', 'group_id'); } + public function assets() + { + return $this->hasOne(UserAssets::class, 'uid', 'uid'); + } + public function spread() { return $this->hasOne(User::class, 'uid', 'spread_uid'); diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index 9f15a76..aaff4ef 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -733,6 +733,9 @@ class UserAssetsLogRepository extends BaseRepository $changeType = $this->getChangeType(); foreach ($data as $item) { $item['type'] = $changeType[$item['type']]; + if($item['count'] > 0){ + $item['count'] = "+".$item['count']; + } $list[] = $item; } return compact('count', 'list'); diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index a5f2db3..2ac5d6e 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -180,9 +180,12 @@ class UserRepository extends BaseRepository 'member' => function ($query) { $query->field('user_brokerage_id,brokerage_level,brokerage_name,brokerage_icon'); }, - 'group']); + 'group', + 'assets' => function($query){ + $query->field('share_point'); + }]); $make = app()->make(UserLabelRepository::class); - $count = $query->count($this->dao->getPk()); + $count = $query->count(); $list = $query->page($page, $limit)->select()->each(function ($item) use ($make) { return $item->label = count($item['label_id']) ? $make->labels($item['label_id']) : []; }); diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index 7c286f4..6840eb7 100644 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -15,6 +15,8 @@ namespace app\controller\admin\user; use app\common\repositories\store\ExcelRepository; +use app\common\repositories\user\UserAssetsLogRepository; +use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserSpreadLogRepository; use app\common\repositories\user\UserVisitRepository; use crmeb\basic\BaseController; @@ -89,6 +91,8 @@ class User extends BaseController 'group_id', 'phone', 'uid', + 'agent_id', + 'is_share', ]); [$page, $limit] = $this->getPage(); return app('json')->success($this->repository->getList($where, $page, $limit)); @@ -470,6 +474,25 @@ class User extends BaseController return app('json')->success($this->repository->userOrderDetail($id)); } + public function info($id){ + if (!$this->repository->exists($id)) + return app('json')->fail('数据不存在'); + $user = $this->repository->getWhere(['uid' => $id]); + $assets = app(UserAssetsRepository::class)->assets($id); + $user['assets'] = $assets; + $user['spread'] = $this->repository->getWhere(['uid' => $user['spread_uid']]); + return app('json')->success($user); + } + + public function assetsLog($id, $type){ + /** + * @var UserAssetsLogRepository $logRepository + */ + $logRepository = \app()->make(UserAssetsLogRepository::class); + [$page, $limit] = $this->getPage(); + return \app('json')->success($logRepository->list($id, ['asset_type' => $type], $page, $limit)); + } + public function order($id, StoreOrderRepository $repository) { if (!$this->repository->exists($id)) diff --git a/app/controller/admin/user/UserGroup.php b/app/controller/admin/user/UserGroup.php index d2bf054..0cb7cc8 100644 --- a/app/controller/admin/user/UserGroup.php +++ b/app/controller/admin/user/UserGroup.php @@ -59,8 +59,11 @@ class UserGroup extends BaseController public function lst() { [$page, $limit] = $this->getPage(); + $all = $this->request->param("all"); $where = array(); - $where[] = ['group_id', '>', 1]; + if(empty($all)){ + $where[] = ['group_id', '>', 1]; + } Log::info(json_encode($where)); return app('json')->success($this->repository->getList($where, $page, $limit)); } diff --git a/route/admin/user.php b/route/admin/user.php index 2fe54d3..6fa92fe 100644 --- a/route/admin/user.php +++ b/route/admin/user.php @@ -85,6 +85,12 @@ Route::group(function () { Route::get('detail/:id', '/detail')->name('systemUserDetail')->option([ '_alias' => '用户详情', ]); + Route::get('info/:id', '/info')->name('systemUserInfo')->option([ + '_alias' => '用户详情', + ]); + Route::get('assets_log/:id/:type', '/assetsLog')->name('systemUserAssetsLog')->option([ + '_alias' => '用户资产记录', + ]); Route::get('order/:id', '/order')->name('systemUserOrder')->option([ '_alias' => '用户消费记录', ]); diff --git a/view/admin/.env.production b/view/admin/.env.production index 18fb70a..f9f4d1d 100644 --- a/view/admin/.env.production +++ b/view/admin/.env.production @@ -2,6 +2,6 @@ ENV = 'production' # base api -VUE_APP_BASE_API = +VUE_APP_BASE_API ='https://b2.njrenzhou.com' # socket 连接地址 -VUE_APP_WS_URL = +VUE_APP_WS_URL ='ws://mer1.crmeb.net' diff --git a/view/admin/src/api/user.js b/view/admin/src/api/user.js index aa3f473..b161526 100644 --- a/view/admin/src/api/user.js +++ b/view/admin/src/api/user.js @@ -182,6 +182,13 @@ export function userNewsApi(data) { export function userDetailApi(uid) { return request.get(`user/detail/${uid}`) } + +/** + * @description 用户 -- 详情头部 + */ +export function userInfoApi(uid) { + return request.get(`user/info/${uid}`) +} /** * @description 用户 -- 详情消费记录 */ @@ -200,6 +207,12 @@ export function userCouponApi(uid, data) { export function userBillApi(uid, data) { return request.get(`user/bill/${uid}`, data) } +/** + * @description 用户 -- 余额明细 + */ +export function userAssetsLogApi(uid, type, data) { + return request.get(`user/assets_log/${uid}/${type}`, data) +} /** * @description 用户 -- 城市列表 */ @@ -310,7 +323,7 @@ export function recordListImportApi(data) { } /** * 获取版权信息 - * @returns + * @returns */ export function getVersion() { return request.get('../api/version') @@ -374,4 +387,4 @@ export function getVersion() { */ export function giveMemberApi(id) { return request.get(`user/svip/${id}/form`) -} \ No newline at end of file +} diff --git a/view/admin/src/views/user/list/index.vue b/view/admin/src/views/user/list/index.vue index 5c416ff..8179e1d 100644 --- a/view/admin/src/views/user/list/index.vue +++ b/view/admin/src/views/user/list/index.vue @@ -2,14 +2,14 @@
- - - - - - - - + + + + + + + +
@@ -27,87 +27,35 @@ @@ -126,51 +74,51 @@
-
- 创建用户 - 发送图文消息 - 批量设置分组 - 批量设置标签 - 发送优惠券 + + + + + + -
+
- - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -205,18 +153,13 @@
- - - + + + + + - - - - + @@ -226,33 +169,40 @@ {{ row.spread ? row.spread.nickname + ' / ' + row.spread.uid : '-' }} - + + + + + - - @@ -270,7 +220,7 @@ - + @@ -411,7 +361,9 @@ export default { city: '', page: 1, limit: 20, - group_id: '' + group_id: '', + agent_id: '', + is_share: '', }, address: [], grid: { @@ -484,7 +436,7 @@ export default { } else if (index > -1) { this.checkedPage.splice(index, 1) } - + this.syncCheckedId() }, syncCheckedId() { @@ -513,7 +465,7 @@ export default { } }) } - + }, // 分开选择 changeOne(v, user) { @@ -552,7 +504,7 @@ export default { let label_id = this.userFrom.label_id == '' ? '' : this.getLabelValue(), user_type = this.findKey(this.userFrom.user_type,{'':'','微信用户':'wechat','小程序用户':'routine','H5用户':'h5'}), sex = this.findKey(this.userFrom.sex,{'男':'1','女':'2','保密':'0','':''}), - pay_count = this.findKey(this.userFrom.sex,{'0次':'-1','1次以上':'0','2次以上':'1','3次以上':'2','4次以上':'3','5次以上':'4','': ''}), + pay_count = this.findKey(this.userFrom.sex,{'0次':'-1','1次以上':'0','2次以上':'1','3次以上':'2','4次以上':'3','5次以上':'4','': ''}), is_promoter = this.findKey(this.userFrom.is_promoter,{'推广员':'1','普通用户':'0','':''}), user_time_type = this.userFrom.user_time_type == 'visit' ? '最后访问' : this.userFrom.user_time_type == 'add_time' ? '首次访问' : '' this.couponForm = { @@ -605,6 +557,7 @@ export default { // 分组列表 groupLists() { groupLstApi({ + all:1, page: 1, limit: 9999 }).then(async res => { @@ -637,7 +590,7 @@ export default { if (this.checkedIds.length === 0 && this.allCheck == false) return this.$message.warning('请先选择用户') this.visible = true this.wechatIds = this.getWechatUsers(this.tableData.data, this.checkedIds) - + }, handleClose() { this.visible = false @@ -650,7 +603,7 @@ export default { if(arr1[i]['wechat_user_id']){ newArr.push(arr1[i]['wechat_user_id']); } - } + } }else{ for (let i = 0; i < arr1.length; i++) { for (let j = 0; j < arr2.length; j++) { @@ -700,7 +653,7 @@ export default { this.$modalForm(changeMemberApi(row.uid)).then(() => this.getList('')) }, // 赠送付费会员 - giveMember(row) { + giveMember(row) { this.$modalForm(giveMemberApi(row.uid)).then(() => this.getList('')) }, // 修改推荐人 @@ -718,7 +671,7 @@ export default { this.$modalForm(changeNowMoneyApi(row.uid)).then(() => this.getList('')) }, // 修改积分余额 - changeIntegral(row){ + changeIntegral(row){ this.$modalForm(changeNowIntegralApi(row.uid)).then(() => this.getList('')) }, // 列表 diff --git a/view/admin/src/views/user/list/userDetails.vue b/view/admin/src/views/user/list/userDetails.vue index ce3c4bf..32b0715 100644 --- a/view/admin/src/views/user/list/userDetails.vue +++ b/view/admin/src/views/user/list/userDetails.vue @@ -3,15 +3,28 @@
-

- 余额: {{ psInfo.now_money }} - 总计订单: {{ psInfo.pay_count }} - 总消费金额: {{ psInfo.pay_price }} - 本月订单: {{ psInfo.total_pay_count }} - 本月消费金额: {{ psInfo.total_pay_price }} - 会员到期时间: {{ psInfo.svip_endtime }} - 注销时间: {{ cancelTime }} + uid: {{ psInfo.uid }} + 手机号: {{ psInfo.phone }} + 昵称: {{ psInfo.nickname }} + 注册时间: {{ psInfo.create_time }} + 登录时间: {{ psInfo.last_time }} + 推广人: {{ psInfo.spread.nickname }} +
+
+ 当前消费积分: {{ psInfo.assets.consume }} + 冻结消费积分: {{ psInfo.assets.consume_frozen }} + 当前分红点: {{ psInfo.assets.share_point }} + 当前福利积分: {{ psInfo.assets.welfare }} + 冻结福利积分: {{ psInfo.assets.welfare_frozen }} +
+
+ 当前惠通宝: {{ psInfo.assets.huitong }} + 冻结惠通宝: {{ psInfo.assets.huitong_frozen }} +
+
+ 当前贡献值: {{ psInfo.assets.contribution }} + 冻结贡献值: {{ psInfo.assets.contribution_frozen }}
@@ -36,18 +49,7 @@ :label="item.title" width="item.minWidth" /> - - - - - - +
// +---------------------------------------------------------------------- -import { userOrderApi, userDetailApi, userCouponApi, userBillApi, modifyUserRefLog } from '@/api/user' +import { userOrderApi, userDetailApi, userCouponApi, userBillApi, modifyUserRefLog, userInfoApi, userAssetsLogApi } from '@/api/user' export default { name: 'UserDetails', props: { @@ -96,9 +98,11 @@ export default { Visible: false, list: [ { val: '0', label: '消费记录' }, - { val: '3', label: '持有优惠券' }, - { val: '4', label: '余额变动' }, - { val: '2', label: '推荐人修改记录' } + { val: '1', label: '消费积分' }, + { val: '3', label: '福利积分' }, + { val: '2', label: '分红点' }, + { val: '5', label: '贡献值' }, + { val: '4', label: '惠通宝' } ], tableData: { data: [], @@ -173,98 +177,29 @@ export default { this.loading = false }) break - case '2': - modifyUserRefLog(this.uid, this.tableFrom).then(res => { - this.tableData.data = res.data.list - this.tableData.total = res.data.count - this.columns = [ - { - title: '上级推荐人ID', - key: 'spread_uid', - minWidth: 120 - }, - { - title: '上级推荐人昵称', - key: 'spread.nickname', - minWidth: 120 - }, - { - title: '绑定时间', - key: 'create_time', - minWidth: 120 - } - ] - this.loading = false - }).catch(() => { - this.loading = false - }) - break - case '3': - userCouponApi(this.uid, this.tableFrom).then(res => { - this.tableData.data = res.data.list - this.tableData.total = res.data.count - this.columns = [ - { - title: '优惠券名称', - key: 'coupon_title', - minWidth: 120 - }, - { - title: '面值', - key: 'coupon_price', - minWidth: 120 - }, - // { - // title: '有效期', - // key: 'add_time', - // minWidth: 120 - // }, - { - title: '最低消费额', - key: 'use_min_price', - minWidth: 120 - }, - { - title: '兑换时间', - key: 'use_time', - minWidth: 120 - } - ] - this.loading = false - }).catch(() => { - this.loading = false - }) - break + default: - userBillApi(this.uid, this.tableFrom).then(res => { + userAssetsLogApi(this.uid, key, this.tableFrom).then(res => { this.tableData.data = res.data.list this.tableData.total = res.data.count this.columns = [ { - title: '变动金额', - key: 'number', + title: '类型', + key: 'type', minWidth: 90 }, { - title: '变动后', - key: 'balance', + title: '分值', + key: 'count', minWidth: 90 }, - { - title: '类型', - key: 'title', - minWidth: 100 - }, + { title: '创建时间', key: 'create_time', minWidth: 150 }, - { - title: '备注', - key: 'mark', - minWidth: 200 - } + ] this.loading = false }).catch(() => { @@ -281,7 +216,7 @@ export default { this.getInfo(this.type) }, getHeader() { - userDetailApi(this.uid).then(res => { + userInfoApi(this.uid).then(res => { this.psInfo = res.data }) } diff --git a/view/mer/.env.production b/view/mer/.env.production index f5380e6..897ee46 100644 --- a/view/mer/.env.production +++ b/view/mer/.env.production @@ -2,7 +2,7 @@ ENV = 'production' # base api -VUE_APP_BASE_API = +VUE_APP_BASE_API ='https://b2.njrenzhou.com' # socket 连接地址 -VUE_APP_WS_URL = +VUE_APP_WS_URL ='ws://mer1.crmeb.net'