|
@@ -668,10 +668,11 @@ class UserController
|
|
|
$tr_user = User::where('phone', $param['phone'])->find();
|
|
|
|
|
|
if (!$tr_user) return app('json')->fail('转账用户不存在');
|
|
|
+ if ($user['phone'] == $param['phone']) return app('json')->fail('不能转给自己');
|
|
|
if ($user['brokerage_price'] < $param['price']) return app('json')->fail('佣金余额不足');
|
|
|
try {
|
|
|
UserBill::expend('佣金', $request->uid(), 'now_money', 'brokerage', $param['price'], 0, $user['brokerage_price']-$param['price'], '佣金转账用户'.$tr_user['phone']);
|
|
|
- UserBill::expend('佣金', $tr_user['uid'], 'now_money', 'brokerage', $param['price'], 0 , $tr_user['brokerage_price']+$param['price'], '接收用户'.$user['phone'].'转账佣金');
|
|
|
+ UserBill::income('佣金', $tr_user['uid'], 'now_money', 'brokerage', $param['price'], 0 , $tr_user['brokerage_price']+$param['price'], '接收用户'.$user['phone'].'转账佣金');
|
|
|
User::where('uid', $request->uid())->dec('brokerage_price', $param['price'])->update();
|
|
|
User::where('phone', $param['phone'])->inc('brokerage_price', $param['price'])->update();
|
|
|
Db::commit();
|
|
@@ -682,4 +683,27 @@ class UserController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function transformation(Request $request)
|
|
|
+ {
|
|
|
+ $param = UtilService::postMore([
|
|
|
+ ['price', '']
|
|
|
+ ]);
|
|
|
+ Db::startTrans();
|
|
|
+ $user = User::where('uid', $request->uid())->lock(true)->find();
|
|
|
+
|
|
|
+ if ($user['brokerage_price'] < $param['price']) return app('json')->fail('佣金余额不足');
|
|
|
+ try {
|
|
|
+ UserBill::expend('佣金', $request->uid(), 'now_money', 'brokerage', $param['price'], '', $user['brokerage_price']-$param['price'], '佣金转换');
|
|
|
+ UserBill::income('佣金转换余额', $request->uid(), 'now_money', 'transformation', $param['price'], '' , $user['now_money']+$param['price'], '佣金转换余额');
|
|
|
+ User::where('uid', $request->uid())->dec('brokerage_price', $param['price'])->update();
|
|
|
+ User::where('uid', $request->uid())->inc('now_money', $param['price'])->update();
|
|
|
+ Db::commit();
|
|
|
+ return app('json')->success('转换成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return app('json')->fail('转换失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|