diff --git a/app/common/dao/system/notice/SystemNoticeDao.php b/app/common/dao/system/notice/SystemNoticeDao.php index fc3811d..6cc75a2 100755 --- a/app/common/dao/system/notice/SystemNoticeDao.php +++ b/app/common/dao/system/notice/SystemNoticeDao.php @@ -31,6 +31,8 @@ class SystemNoticeDao extends BaseDao $query->whereLike('notice_title|notice_content', '%' . $where['keyword'] . '%'); })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { getModelTime($query, $where['date'], 'create_time'); + })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) { + $query->where('type', $where['type']); })->where('is_del', 0); } } diff --git a/app/common/dao/user/DepositRecordDao.php b/app/common/dao/user/DepositRecordDao.php index 2de6ca3..feb9e79 100644 --- a/app/common/dao/user/DepositRecordDao.php +++ b/app/common/dao/user/DepositRecordDao.php @@ -12,6 +12,7 @@ namespace app\common\dao\user; use app\common\dao\BaseDao; use app\common\model\user\DepositRecord; +use app\common\model\user\UserAssets; use app\common\model\user\UserRecharge; use app\common\repositories\store\order\StoreOrderRepository; @@ -27,4 +28,8 @@ class DepositRecordDao extends BaseDao $count = (int)DepositRecord::getDB()->where('uid', $uid)->where('create_time', '>=', date("Y-m-d"))->where('create_time', '<', date("Y-m-d", strtotime('+1 day')))->count(); return StoreOrderRepository::TYPE_SN_USER_DEPOSIT . date('YmdHis', time()) . ($uid . $count); } + + public function getSum($uid, $field){ + return DepositRecord::where('uid', $uid)->where('status', 1)->sum($field); + } } diff --git a/app/common/repositories/system/notice/SystemNoticeRepository.php b/app/common/repositories/system/notice/SystemNoticeRepository.php index b032ca2..3ce2faf 100755 --- a/app/common/repositories/system/notice/SystemNoticeRepository.php +++ b/app/common/repositories/system/notice/SystemNoticeRepository.php @@ -33,6 +33,7 @@ class SystemNoticeRepository extends BaseRepository $data['admin_id'] = $admin_id; $merchantRepository = app()->make(MerchantRepository::class); + $ids= array(); if ($data['type'] == 1) { $ids = (array)$data['mer_id']; $type_str = implode('/', $merchantRepository->names($ids)); @@ -44,12 +45,12 @@ class SystemNoticeRepository extends BaseRepository $type_str = implode('/', app()->make(MerchantCategoryRepository::class)->names((array)$data['category_id'])); } else if ($data['type'] == 4) { $ids = $merchantRepository->search([])->column('mer_id'); - $type_str = '全部'; + $type_str = '商户'; } else { - throw new ValidateException('商户类型有误'); + $type_str = '用户'; } - if (!count($ids)) throw new ValidateException('没有有效的商户信息'); +// if (!count($ids)) throw new ValidateException('没有有效的商户信息'); $data['type_str'] = $type_str; unset($data['is_trader'], $data['category_id'], $data['mer_id']); diff --git a/app/common/repositories/user/DepositRecordRepository.php b/app/common/repositories/user/DepositRecordRepository.php index 8ad6d32..ebae6cb 100644 --- a/app/common/repositories/user/DepositRecordRepository.php +++ b/app/common/repositories/user/DepositRecordRepository.php @@ -120,4 +120,8 @@ class DepositRecordRepository extends BaseRepository event('user.recharge',compact('recharge')); } + + public function getSum($uid, $field){ + return $this->dao->getSum($uid, $field); + } } diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index fddaf25..87cc4f4 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -317,8 +317,10 @@ class UserAssetsLogRepository extends BaseRepository $orderData = $orderRepository->orderStatisticsByUidArr($uidArr); foreach ($groupList as $group) { if ($orderData['count'] >= $group['order_count'] or $orderData['sum'] >= $group['order_sum']) { - $user['group_id'] = $group['group_id']; - $user->save(); + if($group['group_id'] > $user['group_id']){ + $user['group_id'] = $group['group_id']; + $user->save(); + } break; } } @@ -561,7 +563,6 @@ class UserAssetsLogRepository extends BaseRepository { $query = $this->dao->search($uid, $where); $count = $query->count(); - $sql = $query->getLastSql(); $data = $query->page($page, $limit)->order('id desc')->select(); $list = array(); $changeType = $this->getChangeType(); diff --git a/app/common/repositories/user/UserAssetsRepository.php b/app/common/repositories/user/UserAssetsRepository.php index 6ff98a0..93fb0cc 100644 --- a/app/common/repositories/user/UserAssetsRepository.php +++ b/app/common/repositories/user/UserAssetsRepository.php @@ -63,7 +63,7 @@ class UserAssetsRepository extends BaseRepository { $item = $this->dao->get($uid); if ($item) { - return $item->toArray(); + $ret = $item->toArray(); } else { $ret = array( 'uid' => $uid, @@ -74,8 +74,9 @@ class UserAssetsRepository extends BaseRepository 'create_time' => date('Y-m-d H:i:s'), ); $this->dao->create($ret); - return $ret; } + $ret['deposit_total'] = app(DepositRecordRepository::class)->getSum($uid,'price'); + return $ret; } diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index 4fc0a21..52f1386 100755 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -113,6 +113,7 @@ class User extends BaseController $type = $this->request->param('type'); $phone = $this->request->param('phone'); $date = $this->request->param('date'); + $uid = $this->request->param('uid', 0); $userWhere = array(); if($phone) $userWhere[] = array('phone','=',$phone); @@ -126,7 +127,7 @@ class User extends BaseController $where[] = array('create_time','between',[date('Y-m-d', strtotime($date[0])),date('Y-m-d', strtotime($date[1]) +86400)]); } if($user) $where[] = array('uid','=',$user['uid']); - return app('json')->success(app(UserAssetsLogRepository::class)->list(0, $where, $page, $limit)); + return app('json')->success(app(UserAssetsLogRepository::class)->list($uid, $where, $page, $limit)); } public function stockList(){ diff --git a/app/validate/admin/SystemNoticeValidate.php b/app/validate/admin/SystemNoticeValidate.php index 56a7518..bfb11d9 100755 --- a/app/validate/admin/SystemNoticeValidate.php +++ b/app/validate/admin/SystemNoticeValidate.php @@ -21,7 +21,7 @@ class SystemNoticeValidate extends Validate protected $failException = true; protected $rule = [ - 'type|商户类型' => 'require|in:1,2,3,4', + 'type|商户类型' => 'require|in:4,5', 'mer_id|商户' => 'requireIf:type,1|array', 'is_trader|自营类型' => 'requireIf:type,2|in:0,1', 'category_id|商户分类' => 'requireIf:type,3|array', diff --git a/public/system.html b/public/system.html index fc0e2df..7e075f0 100755 --- a/public/system.html +++ b/public/system.html @@ -1,3 +1,3 @@ -