|
|
@@ -14,7 +14,7 @@ use app\models\system\SystemStoreMember;
|
|
|
use app\models\user\UserBill;
|
|
|
use think\facade\Route as Url;
|
|
|
use crmeb\services\JsonService;
|
|
|
-use app\admin\model\user\UserExtract as UserExtractModel;
|
|
|
+use app\admin\model\system\StoreExtract as UserExtractModel;
|
|
|
use crmeb\services\{UtilService as Util, FormBuilder as Form, WechatService};
|
|
|
|
|
|
/**
|
|
|
@@ -57,9 +57,9 @@ class StoreExtract extends AuthController
|
|
|
|
|
|
public function edit($id)
|
|
|
{
|
|
|
- if (!$id) return $this->failed('数据不存在');
|
|
|
+ if (!$id) $this->failed('数据不存在');
|
|
|
$UserExtract = UserExtractModel::get($id);
|
|
|
- if (!$UserExtract) return JsonService::fail('数据不存在!');
|
|
|
+ if (!$UserExtract) $this->failed('数据不存在!');
|
|
|
$f = array();
|
|
|
$f[] = Form::input('real_name', '姓名', $UserExtract['real_name']);
|
|
|
$f[] = Form::number('extract_price', '提现金额', $UserExtract['extract_price'])->precision(2);
|
|
|
@@ -80,7 +80,7 @@ class StoreExtract extends AuthController
|
|
|
public function update($id)
|
|
|
{
|
|
|
$UserExtract = UserExtractModel::get($id);
|
|
|
- if (!$UserExtract) return JsonService::fail('数据不存在!');
|
|
|
+ if (!$UserExtract) JsonService::fail('数据不存在!');
|
|
|
if ($UserExtract['extract_type'] == 'alipay') {
|
|
|
$data = Util::postMore([
|
|
|
'real_name',
|
|
|
@@ -88,9 +88,9 @@ class StoreExtract extends AuthController
|
|
|
'extract_price',
|
|
|
'alipay_code',
|
|
|
]);
|
|
|
- if (!$data['real_name']) return JsonService::fail('请输入姓名');
|
|
|
- if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
|
|
- if (!$data['alipay_code']) return JsonService::fail('请输入支付宝账号');
|
|
|
+ if (!$data['real_name']) JsonService::fail('请输入姓名');
|
|
|
+ if ($data['extract_price'] <= -1) JsonService::fail('请输入提现金额');
|
|
|
+ if (!$data['alipay_code']) JsonService::fail('请输入支付宝账号');
|
|
|
} else if ($UserExtract['extract_type'] == 'weixin') {
|
|
|
$data = Util::postMore([
|
|
|
'real_name',
|
|
|
@@ -98,9 +98,8 @@ class StoreExtract extends AuthController
|
|
|
'extract_price',
|
|
|
'wechat',
|
|
|
]);
|
|
|
-// if(!$data['real_name']) return JsonService::fail('请输入姓名');
|
|
|
- if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
|
|
- if (!$data['wechat']) return JsonService::fail('请输入微信账号');
|
|
|
+ if ($data['extract_price'] <= -1) JsonService::fail('请输入提现金额');
|
|
|
+ if (!$data['wechat']) JsonService::fail('请输入微信账号');
|
|
|
} else {
|
|
|
$data = Util::postMore([
|
|
|
'real_name',
|
|
|
@@ -109,83 +108,67 @@ class StoreExtract extends AuthController
|
|
|
'bank_code',
|
|
|
'bank_address',
|
|
|
]);
|
|
|
- if (!$data['real_name']) return JsonService::fail('请输入姓名');
|
|
|
- if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
|
|
- if (!$data['bank_code']) return JsonService::fail('请输入银行卡号');
|
|
|
- if (!$data['bank_address']) return JsonService::fail('请输入开户行');
|
|
|
+ if (!$data['real_name']) JsonService::fail('请输入姓名');
|
|
|
+ if ($data['extract_price'] <= -1) JsonService::fail('请输入提现金额');
|
|
|
+ if (!$data['bank_code']) JsonService::fail('请输入银行卡号');
|
|
|
+ if (!$data['bank_address']) JsonService::fail('请输入开户行');
|
|
|
}
|
|
|
if (!UserExtractModel::edit($data, $id))
|
|
|
- return JsonService::fail(UserExtractModel::getErrorInfo('修改失败'));
|
|
|
+ JsonService::fail(UserExtractModel::getErrorInfo('修改失败'));
|
|
|
else
|
|
|
- return JsonService::successful('修改成功!');
|
|
|
+ JsonService::successful('修改成功!');
|
|
|
}
|
|
|
|
|
|
public function fail($id)
|
|
|
{
|
|
|
- if (!UserExtractModel::be(['id' => $id, 'status' => 0])) return JsonService::fail('操作记录不存在或状态错误!');
|
|
|
+ if (!UserExtractModel::be(['id' => $id, 'status' => 0])) JsonService::fail('操作记录不存在或状态错误!');
|
|
|
$fail_msg = request()->post();
|
|
|
$extract = UserExtractModel::get($id);
|
|
|
- if (!$extract) return JsonService::fail('操作记录不存在!');
|
|
|
- if ($extract->status == 1) return JsonService::fail('已经提现,错误操作');
|
|
|
- if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝,请勿重复操作!');
|
|
|
+ if (!$extract) JsonService::fail('操作记录不存在!');
|
|
|
+ if ($extract->status == 1) JsonService::fail('已经提现,错误操作');
|
|
|
+ if ($extract->status == -1) JsonService::fail('您的提现申请已被拒绝,请勿重复操作!');
|
|
|
$res = UserExtractModel::changeFail($id, $fail_msg['message']);
|
|
|
if ($res) {
|
|
|
- return JsonService::successful('操作成功!');
|
|
|
+ JsonService::successful('操作成功!');
|
|
|
} else {
|
|
|
- return JsonService::fail('操作失败!');
|
|
|
+ JsonService::fail('操作失败!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function succ($id)
|
|
|
{
|
|
|
if (!UserExtractModel::be(['id' => $id, 'status' => 0]))
|
|
|
- return JsonService::fail('操作记录不存在或状态错误!');
|
|
|
+ JsonService::fail('操作记录不存在或状态错误!');
|
|
|
UserExtractModel::beginTrans();
|
|
|
$extract = UserExtractModel::get($id);
|
|
|
- if (!$extract) return JsonService::fail('操作记录不存!');
|
|
|
- if ($extract->status == 1) return JsonService::fail('您已提现,请勿重复提现!');
|
|
|
- if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
|
|
|
+ if (!$extract) JsonService::fail('操作记录不存!');
|
|
|
+ if ($extract->status == 1) JsonService::fail('您已提现,请勿重复提现!');
|
|
|
+ if ($extract->status == -1) JsonService::fail('您的提现申请已被拒绝!');
|
|
|
$res = UserExtractModel::changeSuccess($id);
|
|
|
- if ($extract['commission_consumer'] > 0) {
|
|
|
- $res = $res && UserBill::income('提现转换(消费券)', $extract['uid'], 'consumer', 'extract_get_consumer', $extract['commission_consumer'], $extract['id'], \app\admin\model\user\User::where('uid', $extract['uid'])->value('consumer') + $extract['commission_consumer'], '提现申请通过,其中部分佣金转换为消费券' . $extract['commission_consumer']);
|
|
|
- $res = $res && \app\admin\model\user\User::where('uid', $extract['uid'])->inc('consumer', $extract['commission_consumer'])->update();
|
|
|
- }
|
|
|
- if ($extract['commission_yue'] > 0) {
|
|
|
- $res = $res && UserBill::income('提现转换(余额)', $extract['uid'], 'now_money', 'extract_get_now_money', $extract['commission_yue'], $extract['id'], \app\admin\model\user\User::where('uid', $extract['uid'])->value('now_money') + $extract['commission_yue'], '提现申请通过,其中部分佣金转换为余额' . $extract['commission_yue']);
|
|
|
- $res = $res && \app\admin\model\user\User::where('uid', $extract['uid'])->inc('now_money', $extract['commission_yue'])->update();
|
|
|
- }
|
|
|
- if ($extract['commission_gf'] > 0) {
|
|
|
- $res = $res && UserBill::income('提现转换(股份)', $extract['uid'], 'gf', 'extract_get_gf', $extract['commission_gf'], $extract['id'], \app\admin\model\user\User::where('uid', $extract['uid'])->value('gf') + $extract['commission_gf'], '提现申请通过,其中部分佣金转换为股份' . $extract['commission_gf']);
|
|
|
- $res = $res && \app\admin\model\user\User::where('uid', $extract['uid'])->inc('gf', $extract['commission_gf'])->update();
|
|
|
- }
|
|
|
|
|
|
- $real_get = $extract['extract_price'] - $extract['commission_gf'] - $extract['commission_consumer'] - $extract['commission_yue'] - $extract['commission'];
|
|
|
-
|
|
|
- if ($real_get >= 0.3 && $extract['extract_type'] == 'weixin') {
|
|
|
- $open_id = WechatUser::where('uid', $extract['uid'])->find();
|
|
|
- if ($open_id['openid']) {
|
|
|
- try {
|
|
|
- WechatService::paymentService()->batches(
|
|
|
- 'ex' . date('YmdHis') . $extract['id'],
|
|
|
- $open_id['openid'],
|
|
|
- $real_get * 100,
|
|
|
- sys_config('site_name') . '-' . '用户提现到账'
|
|
|
- );
|
|
|
- } catch (\Exception $e) {
|
|
|
- UserExtractModel::rollbackTrans();
|
|
|
- return JsonService::fail($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-// if ($extract['commission_gf'] > 0 && SystemStoreMember::be(['uid' => $extract['uid']])) {
|
|
|
-// $res = $res && SystemStoreMember::where('uid', $extract['uid'])->inc('consume_rights', $extract['commission_gf'])->update();
|
|
|
+// $real_get = $extract['extract_price'] - $extract['commission'];
|
|
|
+// if ($real_get >= 0.3 && $extract['extract_type'] == 'weixin') {
|
|
|
+// $open_id = WechatUser::where('uid', $extract['uid'])->find();
|
|
|
+// if ($open_id['openid']) {
|
|
|
+// try {
|
|
|
+// WechatService::paymentService()->batches(
|
|
|
+// 'ex' . date('YmdHis') . $extract['id'],
|
|
|
+// $open_id['openid'],
|
|
|
+// $real_get * 100,
|
|
|
+// sys_config('site_name') . '-' . '用户提现到账'
|
|
|
+// );
|
|
|
+// } catch (\Exception $e) {
|
|
|
+// UserExtractModel::rollbackTrans();
|
|
|
+// return JsonService::fail($e->getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
// }
|
|
|
if ($res) {
|
|
|
UserExtractModel::commitTrans();
|
|
|
- return JsonService::successful('操作成功!');
|
|
|
+ JsonService::successful('操作成功!');
|
|
|
} else {
|
|
|
UserExtractModel::rollbackTrans();
|
|
|
- return JsonService::fail('操作失败!');
|
|
|
+ JsonService::fail('操作失败!');
|
|
|
}
|
|
|
}
|
|
|
}
|