|
|
@@ -13,6 +13,7 @@ declare (strict_types=1);
|
|
|
namespace app\services\user;
|
|
|
|
|
|
use app\jobs\system\CapitalFlowJob;
|
|
|
+use app\model\user\UserExtract;
|
|
|
use app\services\BaseServices;
|
|
|
use app\dao\user\UserExtractDao;
|
|
|
use app\services\order\StoreOrderCreateServices;
|
|
|
@@ -223,26 +224,26 @@ class UserExtractServices extends BaseServices
|
|
|
if (!$this->dao->update($id, ['status' => 2])) {
|
|
|
throw new AdminException('修改失败');
|
|
|
}
|
|
|
- $userServices = app()->make(UserServices::class);
|
|
|
- $userInfo = $userServices->get($userExtract['uid']);
|
|
|
- if (!$userInfo['professional_id']) {
|
|
|
- throw new ValidateException('用户未认证签约');
|
|
|
- }
|
|
|
- $bankInfo = WithdrawService::init()::contractInfo($userInfo['enterprise_professional_facilitator_id']);
|
|
|
- if (!$bankInfo['sign_img']) throw new ValidateException('用户未签约');
|
|
|
- $res = WithdrawService::init()::fastIssuing(
|
|
|
- $userInfo['professional_id'],
|
|
|
- $userExtract['id'],
|
|
|
- $bankInfo['name'],
|
|
|
- $bankInfo['cer_code'],
|
|
|
- $bankInfo['mobile'],
|
|
|
- $bankInfo['bank_code'],
|
|
|
- $extractNumber,
|
|
|
- '佣金提现'
|
|
|
- );
|
|
|
- if ($res) {
|
|
|
- $this->dao->update($id, ['trade_number' => $res['trade_number']]);
|
|
|
- }
|
|
|
+// $userServices = app()->make(UserServices::class);
|
|
|
+// $userInfo = $userServices->get($userExtract['uid']);
|
|
|
+// if (!$userInfo['professional_id']) {
|
|
|
+// throw new ValidateException('用户未认证签约');
|
|
|
+// }
|
|
|
+// $bankInfo = WithdrawService::init()::contractInfo($userInfo['enterprise_professional_facilitator_id']);
|
|
|
+// if (!$bankInfo['sign_img']) throw new ValidateException('用户未签约');
|
|
|
+// $res = WithdrawService::init()::fastIssuing(
|
|
|
+// $userInfo['professional_id'],
|
|
|
+// $userExtract['id'],
|
|
|
+// $bankInfo['name'],
|
|
|
+// $bankInfo['cer_code'],
|
|
|
+// $bankInfo['mobile'],
|
|
|
+// $bankInfo['bank_code'],
|
|
|
+// $extractNumber,
|
|
|
+// '佣金提现'
|
|
|
+// );
|
|
|
+// if ($res) {
|
|
|
+// $this->dao->update($id, ['trade_number' => $res['trade_number']]);
|
|
|
+// }
|
|
|
}
|
|
|
});
|
|
|
return true;
|
|
|
@@ -420,15 +421,20 @@ class UserExtractServices extends BaseServices
|
|
|
if (!$user) {
|
|
|
throw new ValidateException('数据不存在');
|
|
|
}
|
|
|
- if (!$user['enterprise_professional_facilitator_id']) {
|
|
|
- throw new ValidateException('签约未完成');
|
|
|
- }
|
|
|
- $bank_info = WithdrawService::init()::contractInfo($user['enterprise_professional_facilitator_id']);
|
|
|
- if (!$bank_info['sign_img']) {
|
|
|
- throw new ValidateException('签约未完成');
|
|
|
+ if (UserExtract::where('uid', $user['uid'])
|
|
|
+ ->whereTime('add_time', 'month')
|
|
|
+ ->where('status', 0)->find()) {
|
|
|
+ throw new ValidateException('请等待上次提现申请通过');
|
|
|
}
|
|
|
- $data['cardnum'] = $bank_info['bank_code'];
|
|
|
- $data['bankname'] = '灵活用工提现';
|
|
|
+// if (!$user['enterprise_professional_facilitator_id']) {
|
|
|
+// throw new ValidateException('签约未完成');
|
|
|
+// }
|
|
|
+// $bank_info = WithdrawService::init()::contractInfo($user['enterprise_professional_facilitator_id']);
|
|
|
+// if (!$bank_info['sign_img']) {
|
|
|
+// throw new ValidateException('签约未完成');
|
|
|
+// }
|
|
|
+// $data['cardnum'] = $bank_info['bank_code'];
|
|
|
+// $data['bankname'] = '灵活用工提现';
|
|
|
/** @var UserBrokerageServices $userBrokerageServices */
|
|
|
$userBrokerageServices = app()->make(UserBrokerageServices::class);
|
|
|
$data['broken_commission'] = $userBrokerageServices->getUserFrozenPrice($uid);
|
|
|
@@ -455,7 +461,29 @@ class UserExtractServices extends BaseServices
|
|
|
if ($data['money'] <= 0) {
|
|
|
throw new ValidateException('提现佣金大于0');
|
|
|
}
|
|
|
- $extract_fee = bcmul((string)$data['money'], bcdiv(sys_config('withdraw_fee'), '100', 4), 2);
|
|
|
+ $fee = sys_data('withdraw_fee');
|
|
|
+ $fees = [];
|
|
|
+ foreach ($fee as $v) {
|
|
|
+ $fees[$v['month_number']] = (string)$v['fee'];
|
|
|
+ }
|
|
|
+ krsort($fees, SORT_DESC);
|
|
|
+ $sum_money = UserExtract::where('uid', $user['uid'])
|
|
|
+ ->whereTime('add_time', 'month')
|
|
|
+ ->where('extract_type', '<>', 'balance')
|
|
|
+ ->where('status', 1)->sum('extract_price');
|
|
|
+ $money = $data['money'];
|
|
|
+ $extract_fee = 0;
|
|
|
+ $max = PHP_INT_MAX;
|
|
|
+ foreach ($fees as $k => $v) {
|
|
|
+ if ($sum_money > $max) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $max = $k;
|
|
|
+ if ($sum_money + $money > $k) {
|
|
|
+ $extract_fee = bcadd($extract_fee, bcmul((string)($sum_money + $money - ($sum_money > $k ? $sum_money : $k)), bcdiv($v, '100', 4), 2));
|
|
|
+ $money = $money - ($sum_money + $money - $k);
|
|
|
+ }
|
|
|
+ }
|
|
|
$insertData = [
|
|
|
'uid' => $user['uid'],
|
|
|
'extract_type' => $data['extract_type'],
|
|
|
@@ -463,6 +491,7 @@ class UserExtractServices extends BaseServices
|
|
|
'extract_fee' => $extract_fee,
|
|
|
'add_time' => time(),
|
|
|
'balance' => $user['brokerage_price'],
|
|
|
+ 'image' => $data['image'],
|
|
|
'status' => 0
|
|
|
];
|
|
|
if (isset($data['name']) && strlen(trim($data['name']))) $insertData['real_name'] = $data['name'];
|