UserExtractServices.php 23 KB

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