|
@@ -61,13 +61,13 @@ class UserExtract extends BaseModel
|
|
|
if (!in_array($data['extract_type'], self::$extractType))
|
|
if (!in_array($data['extract_type'], self::$extractType))
|
|
|
return self::setErrorInfo('提现方式不存在');
|
|
return self::setErrorInfo('提现方式不存在');
|
|
|
$userInfo = User::get($userInfo['uid']);
|
|
$userInfo = User::get($userInfo['uid']);
|
|
|
- $extractPrice = $userInfo['brokerage_price'];
|
|
|
|
|
|
|
+ $extractPrice = $userInfo['cash'];
|
|
|
if ($extractPrice < 0) return self::setErrorInfo('提现佣金不足' . $data['money']);
|
|
if ($extractPrice < 0) return self::setErrorInfo('提现佣金不足' . $data['money']);
|
|
|
if ($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足' . $data['money']);
|
|
if ($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足' . $data['money']);
|
|
|
if ($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
|
|
if ($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
|
|
|
- $balance = bcsub($userInfo['brokerage_price'], $data['money'], 2);
|
|
|
|
|
|
|
+ $balance = bcsub($userInfo['cash'], $data['money'], 2);
|
|
|
if ($balance < 0) $balance = 0;
|
|
if ($balance < 0) $balance = 0;
|
|
|
- $real_get_ratio = sys_config('extract_ratio', 100);//实际到账率
|
|
|
|
|
|
|
+ $real_get_ratio = sys_config('extract_ratio', 100, true);//实际到账率
|
|
|
$insertData = [
|
|
$insertData = [
|
|
|
'uid' => $userInfo['uid'],
|
|
'uid' => $userInfo['uid'],
|
|
|
'extract_type' => $data['extract_type'],
|
|
'extract_type' => $data['extract_type'],
|
|
@@ -101,8 +101,8 @@ class UserExtract extends BaseModel
|
|
|
try {
|
|
try {
|
|
|
$res1 = self::create($insertData);
|
|
$res1 = self::create($insertData);
|
|
|
if (!$res1) return self::setErrorInfo('提现失败');
|
|
if (!$res1) return self::setErrorInfo('提现失败');
|
|
|
- $res2 = User::edit(['brokerage_price' => $balance], $userInfo['uid'], 'uid');
|
|
|
|
|
- $res3 = UserBill::expend('余额提现', $userInfo['uid'], 'now_money', 'extract', $data['money'], $res1['id'], $balance, $mark);
|
|
|
|
|
|
|
+ $res2 = User::edit(['cash' => $balance], $userInfo['uid'], 'uid');
|
|
|
|
|
+ $res3 = UserBill::expend('现金提现', $userInfo['uid'], 'cash', 'extract', $data['money'], $res1['id'], $balance, $mark);
|
|
|
$res = $res2 && $res3;
|
|
$res = $res2 && $res3;
|
|
|
if ($res) {
|
|
if ($res) {
|
|
|
self::commitTrans();
|
|
self::commitTrans();
|
|
@@ -120,6 +120,50 @@ class UserExtract extends BaseModel
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户自主提现记录提现记录,后台执行审核
|
|
|
|
|
+ * @param array $userInfo 用户个人信息
|
|
|
|
|
+ * @param array $data 提现详细信息
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function userExchange($userInfo, $data)
|
|
|
|
|
+ {
|
|
|
|
|
+ $userInfo = User::get($userInfo['uid']);
|
|
|
|
|
+ $extractPrice = $userInfo['brokerage_price'];
|
|
|
|
|
+ if ($extractPrice < 0) return self::setErrorInfo('转换佣金不足' . $data['money']);
|
|
|
|
|
+ if ($data['money'] > $extractPrice) return self::setErrorInfo('转换佣金不足' . $data['money']);
|
|
|
|
|
+ if ($data['money'] <= 0) return self::setErrorInfo('转换佣金大于0');
|
|
|
|
|
+ $balance = bcsub($userInfo['brokerage_price'], $data['money'], 2);
|
|
|
|
|
+ if ($balance < 0) $balance = 0;
|
|
|
|
|
+ $real_get_ratio = sys_config('exchange_ratio', 100, true);//实际到账率
|
|
|
|
|
+ $get = bcmul(bcdiv($real_get_ratio, 100, 4), $data['money'], 2);
|
|
|
|
|
+ self::beginTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $res = true;
|
|
|
|
|
+
|
|
|
|
|
+ $res2 = User::edit(['brokerage_price' => $balance], $userInfo['uid'], 'uid');
|
|
|
|
|
+ $res2 = $res2 && UserBill::expend('佣金转现金', $userInfo['uid'], 'now_money', 'brokerage', $data['money'], 0, $balance, '佣金转换现金');
|
|
|
|
|
+
|
|
|
|
|
+ $res3 = User::edit(['cash' => $userInfo['cash'] + (float)$get], $userInfo['uid'], 'uid');
|
|
|
|
|
+ $res3 = $res3 && UserBill::income('现金提现', $userInfo['uid'], 'cash', 'brokerage_exchange', $get, 0, $userInfo['cash'] + (float)$get, '佣金转换现金,实际转换' . $get);
|
|
|
|
|
+
|
|
|
|
|
+ if ($data['money'] > $get) {
|
|
|
|
|
+ $num = $data['money'] - $get;
|
|
|
|
|
+ $res = $res && UserBill::income('提现转换', $userInfo['uid'], 'integral', 'extract_get', $num, 0, $userInfo['integral'] + $num, '佣金转换现金,其中部分佣金转换为响亮积分' . $num);
|
|
|
|
|
+ $res = $res && User::where('uid', $userInfo['uid'])->inc('integral', $num)->update();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $res = $res && $res2 && $res3;
|
|
|
|
|
+ if ($res) {
|
|
|
|
|
+ self::commitTrans();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else return self::setErrorInfo('转换失败!');
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ self::rollbackTrans();
|
|
|
|
|
+ return self::setErrorInfo($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获得用户最后一次提现信息
|
|
* 获得用户最后一次提现信息
|
|
|
* @param $openid
|
|
* @param $openid
|