UserExtractServices.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\services\user;
  13. use app\dao\user\UserExtractDao;
  14. use app\services\BaseServices;
  15. use app\services\order\StoreOrderCreateServices;
  16. use app\services\statistic\CapitalFlowServices;
  17. use app\services\system\admin\SystemAdminServices;
  18. use app\services\wechat\WechatUserServices;
  19. use crmeb\exceptions\AdminException;
  20. use crmeb\exceptions\ApiException;
  21. use crmeb\services\FormBuilder as Form;
  22. use crmeb\services\app\WechatService;
  23. use crmeb\services\pay\Pay;
  24. use crmeb\services\wechat\Payment;
  25. use crmeb\services\workerman\ChannelService;
  26. use EasyWeChat\Payment\Order;
  27. use think\exception\ValidateException;
  28. use think\facade\Route as Url;
  29. /**
  30. *
  31. * Class UserExtractServices
  32. * @package app\services\user
  33. */
  34. class UserExtractServices extends BaseServices
  35. {
  36. /**
  37. * UserExtractServices constructor.
  38. * @param UserExtractDao $dao
  39. */
  40. public function __construct(UserExtractDao $dao)
  41. {
  42. $this->dao = $dao;
  43. }
  44. /**
  45. * 获取一条提现记录
  46. * @param int $id
  47. * @param array $field
  48. * @return array|\think\Model|null
  49. */
  50. public function getExtract(int $id, array $field = [])
  51. {
  52. return $this->dao->get($id, $field);
  53. }
  54. /**
  55. * 获取某个用户提现总数
  56. * @param int $uid
  57. * @return float
  58. */
  59. public function getUserExtract(int $uid)
  60. {
  61. return $this->dao->getWhereSum(['uid' => $uid, 'status' => 1]);
  62. }
  63. /**
  64. * 获取某些用户的提现总数列表
  65. * @param array $uids
  66. */
  67. public function getUsersSumList(array $uids)
  68. {
  69. return $this->dao->getWhereSumList(['uid' => $uids, 'status' => 1]);
  70. }
  71. public function getCount(array $where = [])
  72. {
  73. return $this->dao->getCount($where);
  74. }
  75. /**
  76. * 获取提现列表
  77. * @param array $where
  78. * @param string $field
  79. * @return array
  80. * @throws \think\db\exception\DataNotFoundException
  81. * @throws \think\db\exception\DbException
  82. * @throws \think\db\exception\ModelNotFoundException
  83. */
  84. public function getUserExtractList(array $where, string $field = '*')
  85. {
  86. [$page, $limit] = $this->getPageValue();
  87. $list = $this->dao->getExtractList($where, $field, $page, $limit);
  88. foreach ($list as &$item) {
  89. $item['nickname'] = $item['user']['nickname'] ?? '';
  90. $item['receive_price'] = bcsub((string)$item['extract_price'], (string)$item['extract_fee'], 2);
  91. }
  92. $count = $this->dao->count($where);
  93. return compact('list', 'count');
  94. }
  95. /**
  96. * 获取提现总数
  97. * @param array $where
  98. */
  99. public function getExtractSum(array $where)
  100. {
  101. return $this->dao->getExtractMoneyByWhere($where, 'extract_price');
  102. }
  103. /**
  104. * 拒绝提现申请
  105. * @param $id
  106. * @param $fail_msg
  107. * @return bool
  108. * @throws \think\db\exception\DataNotFoundException
  109. * @throws \think\db\exception\ModelNotFoundException
  110. * @throws \think\exception\DbException
  111. */
  112. public function changeFail(int $id, $userExtract, $message)
  113. {
  114. $fail_time = time();
  115. $extract_number = $userExtract['extract_price'];
  116. $mark = '提现失败,退回佣金' . $extract_number . '元';
  117. $uid = $userExtract['uid'];
  118. $status = -1;
  119. /** @var UserServices $userServices */
  120. $userServices = app()->make(UserServices::class);
  121. $user = $userServices->getUserInfo($uid);
  122. $this->transaction(function () use ($user, $uid, $id, $extract_number, $message, $userServices, $status, $fail_time) {
  123. //增加佣金记录
  124. /** @var UserBrokerageServices $userBrokerageServices */
  125. $userBrokerageServices = app()->make(UserBrokerageServices::class);
  126. $now_brokerage = bcadd((string)$user['brokerage_price'], (string)$extract_number, 2);
  127. $userBrokerageServices->income('extract_fail', $uid, $extract_number, $now_brokerage, $id);
  128. if (!$userServices->update($uid, ['brokerage_price' => bcadd((string)$user['brokerage_price'], (string)$extract_number, 2)], 'uid'))
  129. throw new AdminException(400657);
  130. if (!$this->dao->update($id, ['fail_time' => $fail_time, 'fail_msg' => $message, 'status' => $status])) {
  131. throw new AdminException(100007);
  132. }
  133. });
  134. event('NoticeListener', [['uid' => $uid, 'userType' => strtolower($user['user_type']), 'extract_number' => $extract_number, 'nickname' => $user['nickname'], 'message' => $message], 'user_balance_change']);
  135. //自定义通知-用户提现失败
  136. $userExtract['nickname'] = $user['nickname'];
  137. $userExtract['message'] = $message;
  138. $userExtract['time'] = date('Y-m-d H:i:s');
  139. $userExtract['price'] = $extract_number;
  140. $userExtract['phone'] = app()->make(UserServices::class)->value($userExtract['uid'], 'phone');
  141. event('CustomNoticeListener', [$userExtract['uid'], $userExtract, 'extract_fail']);
  142. //自定义事件-用户提现失败
  143. event('CustomEventListener', ['admin_extract_fail', [
  144. 'uid' => $userExtract['uid'],
  145. 'price' => $userExtract['price'],
  146. 'pay_type' => $userExtract['extract_type'],
  147. 'nickname' => $userExtract['price'],
  148. 'phone' => $userExtract['phone'],
  149. 'fail_time' => date('Y-m-d H:i:s')
  150. ]]);
  151. return true;
  152. }
  153. /**
  154. * 通过提现申请
  155. * @param int $id
  156. * @param $userExtract
  157. * @return bool
  158. * @throws \think\db\exception\DataNotFoundException
  159. * @throws \think\db\exception\DbException
  160. * @throws \think\db\exception\ModelNotFoundException
  161. */
  162. public function changeSuccess(int $id, $userExtract)
  163. {
  164. $extractNumber = bcsub($userExtract['extract_price'], $userExtract['extract_fee'], 2);
  165. /** @var WechatUserServices $wechatServices */
  166. $wechatServices = app()->make(WechatUserServices::class);
  167. /** @var UserServices $userServices */
  168. $userServices = app()->make(UserServices::class);
  169. $userType = $userServices->value(['uid' => $userExtract['uid']], 'user_type');
  170. $nickname = $userServices->value(['uid' => $userExtract['uid']], 'nickname');
  171. $phone = $userServices->value(['uid' => $userExtract['uid']], 'phone');
  172. switch ($userExtract['extract_type']) {
  173. case 'bank':
  174. $order_id = $userExtract['bank_code'];
  175. break;
  176. case 'weixin':
  177. $order_id = $userExtract['wechat'];
  178. break;
  179. case 'alipay':
  180. $order_id = $userExtract['alipay_code'];
  181. break;
  182. default:
  183. $order_id = '';
  184. break;
  185. }
  186. $insertData = ['order_id' => $order_id, 'nickname' => $nickname, 'phone' => $phone];
  187. //自动提现到零钱
  188. if ($userExtract['extract_type'] == 'weixin' && sys_config('brokerage_type', 0)) {
  189. $openid = $wechatServices->uidToOpenid($userExtract['uid'], 'wechat');
  190. $type = Order::JSAPI;
  191. if (!$openid) {
  192. $openid = $wechatServices->uidToOpenid($userExtract['uid'], 'routine');
  193. $type = 'mini';
  194. }
  195. if (!$openid) {
  196. $openid = $wechatServices->uidToOpenid((int)$userExtract['uid'], 'app');
  197. $type = Order::APP;
  198. }
  199. if (!$openid) {
  200. throw new ValidateException('该用户暂不支持企业付款到零钱,请手动转账');
  201. }
  202. /** @var StoreOrderCreateServices $services */
  203. $services = app()->make(StoreOrderCreateServices::class);
  204. $insertData['order_id'] = $services->getNewOrderId();
  205. //v3商家转账到零钱
  206. if (sys_config('pay_wechat_type')) {
  207. $pay = new Pay('v3_wechat_pay');
  208. $res = $pay->merchantPay($openid, $insertData['order_id'], $extractNumber, [
  209. 'type' => $type,
  210. 'batch_name' => '提现佣金到零钱',
  211. 'batch_remark' => '您于' . date('Y-m-d H:i:s') . '提现.' . $extractNumber . '元'
  212. ]);
  213. } else {
  214. // 微信提现
  215. $res = WechatService::merchantPay($openid, $insertData['order_id'], $extractNumber, '提现佣金到零钱');
  216. }
  217. if (!$res) {
  218. throw new ApiException(400658);
  219. }
  220. // 更新 提现申请记录 wechat_order_id
  221. $this->dao->update($id, ['wechat_order_id' => $insertData['order_id']]);
  222. /** @var UserServices $userService */
  223. $userService = app()->make(UserServices::class);
  224. $user = $userService->getUserInfo($userExtract['uid']);
  225. $insertData['nickname'] = $user['nickname'];
  226. $insertData['phone'] = $user['phone'];
  227. }
  228. /** @var CapitalFlowServices $capitalFlowServices */
  229. $capitalFlowServices = app()->make(CapitalFlowServices::class);
  230. $capitalFlowServices->setFlow([
  231. 'order_id' => $insertData['order_id'],
  232. 'uid' => $userExtract['uid'],
  233. 'price' => bcmul('-1', $extractNumber, 2),
  234. 'pay_type' => $userExtract['extract_type'],
  235. 'nickname' => $insertData['nickname'],
  236. 'phone' => $insertData['phone']
  237. ], 'extract');
  238. if (!$this->dao->update($id, ['status' => 1])) {
  239. throw new AdminException(100007);
  240. }
  241. event('NoticeListener', [['uid' => $userExtract['uid'], 'userType' => strtolower($userType), 'extractNumber' => $extractNumber, 'nickname' => $nickname], 'user_extract']);
  242. //自定义通知-用户提现成功
  243. $userExtract['nickname'] = $nickname;
  244. $userExtract['phone'] = $phone;
  245. $userExtract['time'] = date('Y-m-d H:i:s');
  246. $userExtract['price'] = $extractNumber;
  247. event('CustomNoticeListener', [$userExtract['uid'], $userExtract, 'extract_success']);
  248. //自定义事件-用户提现成功
  249. event('CustomEventListener', ['admin_extract_success', [
  250. 'uid' => $userExtract['uid'],
  251. 'price' => $extractNumber,
  252. 'pay_type' => $userExtract['extract_type'],
  253. 'nickname' => $insertData['nickname'],
  254. 'phone' => $phone,
  255. 'success_time' => date('Y-m-d H:i:s')
  256. ]]);
  257. return true;
  258. }
  259. /**
  260. * 显示资源列表
  261. * @param array $where
  262. * @return array
  263. * @throws \think\db\exception\DataNotFoundException
  264. * @throws \think\db\exception\DbException
  265. * @throws \think\db\exception\ModelNotFoundException
  266. */
  267. public function index(array $where)
  268. {
  269. $list = $this->getUserExtractList($where);
  270. /** @var UserServices $userServices */
  271. $userServices = app()->make(UserServices::class);
  272. //待提现金额
  273. $where['status'] = 0;
  274. $extract_statistics['price'] = $this->getExtractSum($where);
  275. //已提现金额
  276. $where['status'] = 1;
  277. $extract_statistics['priced'] = $this->getExtractSum($where);
  278. /** @var UserBrokerageServices $userBrokerageServices */
  279. $userBrokerageServices = app()->make(UserBrokerageServices::class);
  280. $where['pm'] = 1;
  281. $brokerage_count = $userBrokerageServices->getUsersBokerageSum($where);
  282. $refund_brokerage = $userBrokerageServices->sum(['type' => 'refund'], 'number');
  283. $extract_statistics['brokerage_count'] = bcsub((string)$brokerage_count, (string)$refund_brokerage, 2);
  284. //未提现金额
  285. $extract_statistics['brokerage_not'] = $extract_statistics['brokerage_count'] > $extract_statistics['priced'] ? bcsub((string)$extract_statistics['brokerage_count'], (string)$extract_statistics['priced'], 2) : 0.00;
  286. return compact('extract_statistics', 'list');
  287. }
  288. /**
  289. * 显示编辑资源表单页.
  290. *
  291. * @param int $id
  292. * @return \think\Response
  293. */
  294. public function edit(int $id)
  295. {
  296. $UserExtract = $this->getExtract($id);
  297. if (!$UserExtract) {
  298. throw new AdminException(100026);
  299. }
  300. $f = array();
  301. $f[] = Form::input('real_name', '姓名', $UserExtract['real_name']);
  302. $f[] = Form::number('extract_price', '提现金额', (float)$UserExtract['extract_price'])->precision(2)->disabled(true);
  303. if ($UserExtract['extract_type'] == 'alipay') {
  304. $f[] = Form::input('alipay_code', '支付宝账号', $UserExtract['alipay_code']);
  305. } else if ($UserExtract['extract_type'] == 'weixin') {
  306. $f[] = Form::input('wechat', '微信号', $UserExtract['wechat']);
  307. } else if ($UserExtract['extract_type'] == 'balance') {
  308. } else {
  309. $f[] = Form::input('bank_code', '银行卡号', $UserExtract['bank_code']);
  310. $f[] = Form::input('bank_address', '开户行', $UserExtract['bank_address']);
  311. }
  312. $f[] = Form::input('mark', '备注', $UserExtract['mark'])->type('textarea');
  313. return create_form('编辑', $f, Url::buildUrl('/finance/extract/' . $id), 'PUT');
  314. }
  315. public function update(int $id, array $data)
  316. {
  317. if (!$this->dao->update($id, $data))
  318. throw new AdminException(100007);
  319. else
  320. return true;
  321. }
  322. /**
  323. * 拒绝
  324. * @param $id
  325. * @return mixed
  326. */
  327. public function refuse(int $id, string $message)
  328. {
  329. $extract = $this->getExtract($id);
  330. if (!$extract) {
  331. throw new AdminException(100026);
  332. }
  333. if ($extract->status == 1) {
  334. throw new AdminException(400659);
  335. }
  336. if ($extract->status == -1) {
  337. throw new AdminException(400660);
  338. }
  339. $res = $this->changeFail($id, $extract, $message);
  340. if ($res) {
  341. return true;
  342. } else {
  343. throw new AdminException(100005);
  344. }
  345. }
  346. /**
  347. * 通过
  348. * @param int $id
  349. * @return mixed
  350. * @throws \think\db\exception\DataNotFoundException
  351. * @throws \think\db\exception\ModelNotFoundException
  352. */
  353. public function adopt(int $id)
  354. {
  355. $extract = $this->getExtract($id);
  356. if (!$extract) {
  357. throw new AdminException(100026);
  358. }
  359. if ($extract->status == 1) {
  360. throw new AdminException(400659);
  361. }
  362. if ($extract->status == -1) {
  363. throw new AdminException(400660);
  364. }
  365. if ($this->changeSuccess($id, $extract)) {
  366. return true;
  367. } else {
  368. throw new AdminException(100005);
  369. }
  370. }
  371. /**待提现的数量
  372. * @return int
  373. */
  374. public function userExtractCount()
  375. {
  376. return $this->dao->count(['status' => 0]);
  377. }
  378. /**
  379. * 银行卡提现
  380. * @param int $uid
  381. * @return mixed
  382. */
  383. public function bank(int $uid)
  384. {
  385. /** @var UserServices $userService */
  386. $userService = app()->make(UserServices::class);
  387. $user = $userService->getUserInfo($uid, 'brokerage_price,uid');
  388. if (!$user) {
  389. throw new ApiException(100026);
  390. }
  391. /** @var UserBrokerageServices $services */
  392. $services = app()->make(UserBrokerageServices::class);
  393. $data['broken_commission'] = $services->getUserFrozenPrice($uid);
  394. if ($data['broken_commission'] < 0)
  395. $data['broken_commission'] = '0';
  396. $data['brokerage_price'] = $user['brokerage_price'];
  397. //可提现佣金
  398. $data['commissionCount'] = bcsub((string)$data['brokerage_price'], (string)$data['broken_commission'], 2);
  399. $extractBank = sys_config('user_extract_bank') ?? []; //提现银行
  400. $extractBank = str_replace("\r\n", "\n", $extractBank);//防止不兼容
  401. $data['extractBank'] = explode("\n", is_array($extractBank) ? ($extractBank[0] ?? $extractBank) : $extractBank);
  402. $data['minPrice'] = sys_config('user_extract_min_price');//提现最低金额
  403. $data['brokerageType'] = sys_config('brokerage_type', 0);//到账方式
  404. $data['withdrawal_fee'] = sys_config('withdrawal_fee', 0);//提现手续费
  405. return $data;
  406. }
  407. /**
  408. * 提现申请
  409. * @param int $uid
  410. * @param array $data
  411. */
  412. public function cash(int $uid, array $data)
  413. {
  414. /** @var UserServices $userService */
  415. $userService = app()->make(UserServices::class);
  416. $user = $userService->getUserInfo($uid);
  417. if (!$user) {
  418. throw new ApiException(100026);
  419. }
  420. if ($data['extract_type'] == 'weixin' && !sys_config('brokerage_type', 0) && !$data['weixin']) {
  421. throw new ApiException(400110);
  422. }
  423. if ($data['extract_type'] == 'weixin' && bccomp($data['money'], '1', 2) < 0) {
  424. throw new ApiException(410112);
  425. }
  426. /** @var WechatUserServices $wechatServices */
  427. $wechatServices = app()->make(WechatUserServices::class);
  428. $openid = $wechatServices->uidToOpenid($uid, 'wechat');
  429. if (!$openid) $openid = $wechatServices->uidToOpenid($uid, 'routine');
  430. if ($data['extract_type'] == 'weixin' && sys_config('brokerage_type', 0) && !$openid) {
  431. throw new ApiException(410024);
  432. }
  433. /** @var UserBrokerageServices $services */
  434. $services = app()->make(UserBrokerageServices::class);
  435. $data['broken_commission'] = $services->getUserFrozenPrice($uid);
  436. if ($data['broken_commission'] < 0)
  437. $data['broken_commission'] = 0;
  438. $data['brokerage_price'] = $user['brokerage_price'];
  439. //可提现佣金
  440. $commissionCount = bcsub((string)$data['brokerage_price'], (string)$data['broken_commission'], 2);
  441. if ($data['money'] > $commissionCount) {
  442. throw new ApiException(400661);
  443. }
  444. $extractPrice = $user['brokerage_price'];
  445. $userExtractMinPrice = sys_config('user_extract_min_price');
  446. if ($data['money'] < $userExtractMinPrice) {
  447. throw new ApiException(400662, ['money' => $userExtractMinPrice]);
  448. }
  449. if ($extractPrice < 0) {
  450. throw new ApiException(400663, ['money' => $data['money']]);
  451. }
  452. if ($data['money'] > $extractPrice) {
  453. throw new ApiException(400663, ['money' => $data['money']]);
  454. }
  455. if ($data['money'] <= 0) {
  456. throw new ApiException(400664);
  457. }
  458. $data['extract_price'] = bcmul($data['money'], '1', 2);
  459. $insertData = [
  460. 'uid' => $user['uid'],
  461. 'extract_type' => $data['extract_type'],
  462. 'extract_price' => $data['extract_price'],
  463. 'extract_fee' => bcmul((string)$data['extract_price'], bcdiv((string)sys_config('withdrawal_fee', '0'), '100', 4), 2),
  464. 'add_time' => time(),
  465. 'balance' => $user['brokerage_price'],
  466. 'status' => 0
  467. ];
  468. if (isset($data['name']) && strlen(trim($data['name']))) $insertData['real_name'] = $data['name'];
  469. else $insertData['real_name'] = $user['nickname'];
  470. if (isset($data['cardnum'])) $insertData['bank_code'] = $data['cardnum'];
  471. else $insertData['bank_code'] = '';
  472. if (isset($data['bankname'])) $insertData['bank_address'] = $data['bankname'];
  473. else $insertData['bank_address'] = '';
  474. if (isset($data['weixin'])) $insertData['wechat'] = $data['weixin'];
  475. else $insertData['wechat'] = $user['nickname'];
  476. $mark = '';
  477. $feeMark = sys_config('withdrawal_fee', 0) == 0 ? '' : ',手续费' . $insertData['extract_fee'] . '元';
  478. if ($data['extract_type'] == 'alipay') {
  479. $insertData['alipay_code'] = $data['alipay_code'];
  480. $insertData['qrcode_url'] = $data['qrcode_url'];
  481. $mark = '使用支付宝提现' . $insertData['extract_price'] . '元' . $feeMark;
  482. } else if ($data['extract_type'] == 'bank') {
  483. $mark = '使用银联卡' . $insertData['bank_code'] . '提现' . $insertData['extract_price'] . '元' . $feeMark;
  484. } else if ($data['extract_type'] == 'weixin') {
  485. $insertData['qrcode_url'] = $data['qrcode_url'];
  486. $mark = '使用微信提现' . $insertData['extract_price'] . '元' . $feeMark;
  487. if (sys_config('brokerage_type', 0) && $openid) {
  488. if ($data['extract_price'] < 1) {
  489. throw new ApiException(400665);
  490. }
  491. }
  492. }
  493. $res1 = $this->transaction(function () use ($insertData, $data, $uid, $userService, $user, $mark) {
  494. if (!$res1 = $this->dao->save($insertData)) {
  495. throw new ApiException(410121);
  496. }
  497. $balance = bcsub((string)$user['brokerage_price'], $data['extract_price'], 2) ?? 0;
  498. if (!$userService->update($uid, ['brokerage_price' => $balance], 'uid')) {
  499. throw new ApiException(410121);
  500. }
  501. //保存佣金记录
  502. /** @var UserBrokerageServices $userBrokerageServices */
  503. $userBrokerageServices = app()->make(UserBrokerageServices::class);
  504. $userBrokerageServices->income('extract', $uid, ['mark' => $mark, 'number' => $data['extract_price']], $balance, $res1['id']);
  505. return $res1;
  506. });
  507. try {
  508. ChannelService::instance()->send('WITHDRAW', ['id' => $res1->id]);
  509. } catch (\Exception $e) {
  510. }
  511. /** @var SystemAdminServices $systemAdmin */
  512. $systemAdmin = app()->make(SystemAdminServices::class);
  513. $systemAdmin->adminNewPush();
  514. //消息
  515. event('NoticeListener', [['nickname' => $user['nickname'], 'money' => $data['extract_price']], 'kefu_send_extract_application']);
  516. //自定义事件-用户提现
  517. event('CustomEventListener', ['user_extract', [
  518. 'uid' => $insertData['uid'],
  519. 'phone' => $user['phone'],
  520. 'extract_type' => $insertData['extract_type'],
  521. 'extract_price' => $insertData['extract_price'],
  522. 'extract_fee' => $insertData['extract_fee'],
  523. 'extract_time' => date('Y-m-d H:i:s'),
  524. ]]);
  525. return true;
  526. }
  527. /**
  528. * @param array $where
  529. * @param string $SumField
  530. * @param string $selectType
  531. * @param string $group
  532. * @return float|mixed
  533. */
  534. public function getOutMoneyByWhere(array $where, string $SumField, string $selectType, string $group = "")
  535. {
  536. switch ($selectType) {
  537. case "sum" :
  538. return $this->dao->getWhereSumField($where, $SumField);
  539. case "group" :
  540. return $this->dao->getGroupField($where, $SumField, $group);
  541. }
  542. }
  543. }