From 8dd28e50884d7109c2374d0518e9fc46edde9040 Mon Sep 17 00:00:00 2001 From: fengxinyhyl Date: Wed, 27 Mar 2024 23:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/FinancialRecordRepository.php | 42 +++++++++++++++++++ .../repositories/user/UserRepository.php | 4 ++ .../admin/system/merchant/Merchant.php | 4 ++ app/controller/admin/user/User.php | 29 +++++++++++++ app/controller/merchant/system/Merchant.php | 15 +++++++ public/mer.html | 2 +- public/system.html | 2 +- route/admin/user.php | 4 ++ 8 files changed, 100 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 3b693f8..55890f7 100644 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -17,8 +17,10 @@ namespace app\common\repositories\system\merchant; use app\common\dao\system\merchant\FinancialRecordDao; use app\common\repositories\BaseRepository; use app\common\repositories\store\order\StoreOrderRepository; +use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserBillRepository; use app\common\repositories\user\UserRechargeRepository; +use app\common\repositories\user\UserRepository; use think\facade\Cache; use think\facade\Db; @@ -197,6 +199,44 @@ class FinancialRecordRepository extends BaseRepository return compact('stat'); } + public function getMerchantStatistics($where){ + //商户收入 + $count = $this->dao->search($where)->where('financial_type','in',['order','mer_presell'])->sum('number'); + + //商户余额 + $mer_money = app()->make(MerchantRepository::class)->search(['mer_id' => $where['is_mer']])->value('mer_money'); + //最低提现额度 + $extract_minimum_line = systemConfig('extract_minimum_line'); + //商户可提现金额 + $_line = bcsub($mer_money,$extract_minimum_line,2); + //退款支出金额 + $refund_order = $this->dao->search($where)->where('financial_type','refund_order')->sum('number'); + + //商户冻结金额 + $merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($where['is_mer']); + + + $user = \app(UserRepository::class)->getUserByMerId($where['is_mer']); + if($user){ + $assets = app(UserAssetsRepository::class)->assets($user['uid']); + $welfare = $assets['welfare']; + $welfare_frozen = $assets['welfare_frozen']; + }else{ + $welfare = 0; + $welfare_frozen = 0; + } + + return array( + 'total' => $count, + 'mer_money' => $mer_money, + 'frozen_money' => $merLockMoney, + 'refund_money' => $refund_order, + 'available_money' => $_line, + 'welfare' => $welfare, + 'welfare_frozen' => $welfare_frozen, + ); + } + /** * TODO 商户头部统计 * @param $where @@ -229,6 +269,8 @@ class FinancialRecordRepository extends BaseRepository //商户可提现金额 // $bill_order = app()->make(StoreOrderRepository::class)->search(['paid' => 1,'date' => $where['date'],'pay_type' => 0])->sum('pay_price'); $merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($where['is_mer']); + + $stat = [ [ 'className' => 'el-icon-s-goods', diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index d7d641d..7c75deb 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -213,6 +213,10 @@ class UserRepository extends BaseRepository return $this->dao->getUserByPhone($phone); } + public function getUserByMerId($id){ + return $this->dao->getWhere(array('mer_id' => $id)); + } + public function getPulbicLst(array $where, $page, $limit) { $query = $this->dao->search($where); diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index 85e1b93..f50d122 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -15,7 +15,9 @@ namespace app\controller\admin\system\merchant; use app\common\repositories\store\product\ProductCopyRepository; +use app\common\repositories\system\merchant\FinancialRecordRepository; use app\common\repositories\system\merchant\MerchantTypeRepository; +use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserBillRepository; use app\common\repositories\user\UserRepository; use crmeb\basic\BaseController; @@ -107,6 +109,8 @@ class Merchant extends BaseController public function info(){ $id = $this->request->param('id'); $info = $this->repository->get($id); + + $info['assets'] = \app(FinancialRecordRepository::class)->getMerchantStatistics(array('is_mer' => $id)); return app('json')->success($info); } diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index d11b87e..dad0cd0 100644 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -15,6 +15,7 @@ namespace app\controller\admin\user; use app\common\repositories\store\ExcelRepository; +use app\common\repositories\system\HuitongRepository; use app\common\repositories\user\UserAssetsLogRepository; use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserSpreadLogRepository; @@ -273,6 +274,34 @@ class User extends BaseController return app('json')->success(app(UserAssetsLogRepository::class)->list(0, $where, $page, $limit)); } + public function huitongList(){ + $page = $this->request->param('page', 1); + $limit = $this->request->param('limit', 10); + $phone = $this->request->param('phone'); + + $where = array(); + $where[] = array('asset_type','=',UserAssetsLogRepository::ASSET_TYPE_HUITONG); + $where[] = array('type','=',UserAssetsLogRepository::CHANGE_TYPE_HUITONG_SEND); + + if($phone){ + $userWhere = array(); + $userWhere[] = array('phone','=',$phone); + $user = $this->repository->getWhere($userWhere); + $where[] = array('uid','=',$user ? $user['uid'] : 0); + } + + $data = app(UserAssetsLogRepository::class)->list(0, $where, $page, $limit); + foreach ($data['list'] as $k => $v){ + $user = $this->repository->get($v['uid']); + $data['list'][$k]['to_phone'] = $v['ext']['to_phone'] ?? ''; + $data['list'][$k]['count'] = abs($v['count']); + } + + $data['huitong'] = app(HuitongRepository::class)->getCurrent(); + + return app('json')->success($data); + } + /** * @param UserLabelRepository $labelRepository * @return mixed diff --git a/app/controller/merchant/system/Merchant.php b/app/controller/merchant/system/Merchant.php index 7a30d73..fc494d6 100644 --- a/app/controller/merchant/system/Merchant.php +++ b/app/controller/merchant/system/Merchant.php @@ -17,8 +17,12 @@ namespace app\controller\merchant\system; use app\common\repositories\store\MerchantTakeRepository; use app\common\repositories\store\product\ProductRepository; use app\common\repositories\system\config\ConfigValueRepository; +use app\common\repositories\system\merchant\FinancialRecordRepository; use app\common\repositories\system\serve\ServeOrderRepository; +use app\common\repositories\user\UserAssetsLogRepository; +use app\common\repositories\user\UserAssetsRepository; use app\common\repositories\user\UserBillRepository; +use app\common\repositories\user\UserRepository; use app\validate\merchant\MerchantTakeValidate; use crmeb\basic\BaseController; use app\common\repositories\system\merchant\MerchantRepository; @@ -148,6 +152,17 @@ class Merchant extends BaseController $data = array_merge($data,$delivery); $data['sys_bases_status'] = systemConfig('sys_bases_status') === '0' ? 0 : 1; + $data['assets'] = \app(FinancialRecordRepository::class)->getMerchantStatistics(array('is_mer' => $this->request->merId())); +// $user = \app(UserRepository::class)->getUserByMerId($this->request->merId()); +// if($user){ +// $assets = \app(UserAssetsRepository::class)->assets($user['uid']); +// $data['assets']['welfare'] = $assets['welfare']; +// $data['assets']['welfare_frozen'] = $assets['welfare_frozen']; +// }else{ +// $data['assets']['welfare'] = 0; +// $data['assets']['welfare_frozen'] = 0; +// } + return app('json')->success($data); } diff --git a/public/mer.html b/public/mer.html index 9d5d15b..18fdc51 100644 --- a/public/mer.html +++ b/public/mer.html @@ -1 +1 @@ -加载中...
\ No newline at end of file +加载中...
\ No newline at end of file diff --git a/public/system.html b/public/system.html index 179c285..b1b4b3d 100644 --- a/public/system.html +++ b/public/system.html @@ -1,3 +1,3 @@ -加载中...
\ No newline at end of file diff --git a/route/admin/user.php b/route/admin/user.php index d8195bb..4d3b606 100644 --- a/route/admin/user.php +++ b/route/admin/user.php @@ -56,6 +56,10 @@ Route::group(function () { Route::get('assets_list', '/assetsList')->name('systemUserAssetsList')->option([ '_alias' => '用户资产列表', ]); + //用户资产明细 + Route::get('huitong_list', '/huitongList')->name('systemUserHuitongList')->option([ + '_alias' => '用户惠通列表', + ]); Route::get('update/form/:id', '/updateForm')->name('systemUserUpdateForm')->option([ '_alias' => '用户编辑表单', '_auth' => false,