123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?php
- // +----------------------------------------------------------------------
- // | Niucloud-admin 企业快速开发的saas管理平台
- // +----------------------------------------------------------------------
- // | 官方网址:https://www.niucloud.com
- // +----------------------------------------------------------------------
- // | niucloud团队 版权所有 开源版本可自由商用
- // +----------------------------------------------------------------------
- // | Author: Niucloud Team
- // +----------------------------------------------------------------------
- namespace app\adminapi\controller\member;
- use app\dict\member\MemberAccountTypeDict;
- use app\service\admin\member\MemberAccountService;
- use app\service\admin\member\MemberService;
- use core\base\BaseAdminController;
- use think\Response;
- class Account extends BaseAdminController
- {
- /**
- * 积分流水
- * @return Response
- */
- public function point()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'from_type', '' ],
- [ 'create_time', [] ],
- [ 'keywords', '' ],
- ]);
- $data[ 'account_type' ] = 'point';
- return success(( new MemberAccountService() )->getPage($data));
- }
- /**
- * 会员积分统计(用于会员积分统计窗口)
- */
- public function sumPoint()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- ]);
- $member_account_service = new MemberAccountService();
- $member_service = new MemberService();
- if (empty($data[ 'member_id' ])) {
- $commission_data = [
- 'point_get' => $member_service->getSum('point_get'),//累计
- 'point_use' => abs($member_account_service->getExpensesSumAccount(MemberAccountTypeDict::POINT)),
- ];
- return success($commission_data);
- } else {
- $info = $member_account_service->getMemberAccountInfo($data[ 'member_id' ]);
- $commission_data = [
- 'point_get' => $info[ 'point_get' ],
- 'point_use' => abs($member_account_service->getExpensesSumAccount(MemberAccountTypeDict::POINT, $data[ 'member_id' ])),
- ];
- return success($commission_data);
- }
- }
- /**
- * 余额流水
- * @return Response
- */
- public function balance()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'from_type', '' ],
- [ 'create_time', [] ],
- [ 'keywords', '' ],
- ]);
- $data[ 'account_type' ] = 'balance';
- return success(( new MemberAccountService() )->getPage($data));
- }
- /**
- * 可提现余额流水
- * @return Response
- */
- public function money()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'from_type', '' ],
- [ 'create_time', [] ],
- [ 'keywords', '' ],
- ]);
- $data[ 'account_type' ] = 'money';
- return success(( new MemberAccountService() )->getPage($data));
- }
- /**
- * 查询成长值
- * @return Response
- */
- public function growth() {
- $data = $this->request->params([
- ['member_id', ''],
- ['from_type', ''],
- ['create_time', []],
- ['keywords', ''],
- ]);
- $data['account_type'] = 'growth';
- return success(( new MemberAccountService() )->getPage($data));
- }
- /**
- * 积分账户调整
- */
- public function adjustPoint()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'account_data', 0 ],
- [ 'memo', '' ],
- ]);
- $res = ( new MemberAccountService() )->adjustPoint($data);
- return success('SUCCESS', [ 'id' => $res ]);
- }
- /**
- * 余额账户调整
- */
- public function adjustBalance()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'account_data', 0 ],
- [ 'memo', '' ],
- ]);
- $res = ( new MemberAccountService() )->adjustBalance($data);
- return success('SUCCESS', [ 'id' => $res ]);
- }
- /**
- * 零钱调整
- * @return Response
- */
- public function adjustMoney()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'account_data', 0 ],
- [ 'memo', '' ],
- ]);
- $res = ( new MemberAccountService() )->adjustMoney($data);
- return success('SUCCESS', [ 'id' => $res ]);
- }
- /**
- * 会员佣金
- * @return Response
- */
- public function commission()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- [ 'from_type', '' ],
- [ 'create_time', [] ],
- [ 'keywords', '' ],
- ]);
- $data[ 'account_type' ] = 'commission';
- return success(( new MemberAccountService() )->getPage($data));
- }
- /**
- * 会员佣金统计(用于会员账户统计窗口)
- */
- public function sumCommission()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- ]);
- $member_account_service = new MemberAccountService();
- $member_service = new MemberService();
- if (empty($data[ 'member_id' ])) {
- $commission_data = [
- 'total_commission' => $member_service->getSum('commission_get'),//累计
- 'commission' => $member_service->getSum('commission'),//未提现
- 'withdrawn_commission' => $member_account_service->getWithdrawnCommission(),//已提现
- 'commission_cash_outing' => $member_service->getSum('commission_cash_outing'),//提现中
- ];
- return success($commission_data);
- } else {
- $info = $member_account_service->getMemberAccountInfo($data[ 'member_id' ]);
- $commission_data = [
- 'commission' => $info[ 'commission' ],
- 'commission_cash_outing' => $info[ 'commission_cash_outing' ],
- 'withdrawn_commission' => $member_account_service->getWithdrawnCommission($data[ 'member_id' ]),//已提现
- 'total_commission' => $info[ 'commission_get' ],
- ];
- return success($commission_data);
- }
- }
- /**
- * 会员余额统计(用于会员账户统计窗口)
- */
- public function sumBalance()
- {
- $data = $this->request->params([
- [ 'member_id', '' ],
- ]);
- $member_account_service = new MemberAccountService();
- if (empty($data[ 'member_id' ])) {
- $balance_data = [
- MemberAccountTypeDict::BALANCE => number_format($member_account_service->getSumAccount(MemberAccountTypeDict::BALANCE), 2, '.', ''),
- MemberAccountTypeDict::MONEY => number_format($member_account_service->getSumAccount(MemberAccountTypeDict::MONEY), 2, '.', ''),
- ];
- return success($balance_data);
- } else {
- return success($member_account_service->getMemberAccountInfo($data[ 'member_id' ]));
- }
- }
- /**
- * 账户变化类型
- * @param string $account_type
- * @return Response
- */
- public function changeType(string $account_type)
- {
- $res = ( new MemberAccountService() )->getFromType($account_type);
- return success($res);
- }
- /**
- * 账户类型
- */
- public function accountType()
- {
- return success(MemberAccountTypeDict::getType());
- }
- }
|