|
@@ -739,6 +739,32 @@ class UserController
|
|
|
return app('json')->successful($data);
|
|
|
}
|
|
|
|
|
|
+ public function transfer_account(Request $request)
|
|
|
+ {
|
|
|
+ $param = UtilService::postMore([
|
|
|
+ ['phone', ''],
|
|
|
+ ['price', '']
|
|
|
+ ]);
|
|
|
+ Db::startTrans();
|
|
|
+ $user = User::where('uid', $request->uid())->lock(true)->find();
|
|
|
+ $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', 'extract', $param['price'], 0, $user['brokerage_price']-$param['price'], '佣金转账用户'.$tr_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();
|
|
|
+ return app('json')->success('转账成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return app('json')->fail('转账失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public function transformation(Request $request)
|
|
|
{
|