|
@@ -74,11 +74,11 @@ class ManyController
|
|
|
['price']
|
|
|
]);
|
|
|
$many = Many::where('id', $data['id'])->find();
|
|
|
- $surplus = $this->surplus($data['id'], 1);
|
|
|
+ $surplus = $this->surplus($data['id'], $request->uid(),1);
|
|
|
$user = User::where('uid', $request->uid())->find();
|
|
|
if (!$many) return app('json')->fail('场次不存在');
|
|
|
if ($many['number'] >= $many['money']) return app('json')->fail('已完成无法投注');
|
|
|
- if ( $many['status'] == 0) return app('json')->fail('未开启');
|
|
|
+ if ($many['status'] == 0) return app('json')->fail('未开启');
|
|
|
if ($many['end_time'] < time()) return app('json')->fail('已结束');
|
|
|
if (($many['number']+$data['price']) > $many['money']) return app('json')->fail('还能最大投注'.($many['money']-$many['number']));
|
|
|
if ($surplus < $data['price']) return app('json')->fail('超过最大可投注额度');
|
|
@@ -95,7 +95,9 @@ class ManyController
|
|
|
$white = $user['white_integral'];
|
|
|
$user['white_integral'] = 0;
|
|
|
$user['purple_integral'] = ($data['price'] - $white);
|
|
|
- UserBill::expend('扣除白积分', $user['uid'], 'white_integral', 'bet', $white, 0,0,'使用白积分,投注场次'.$many['name'].'成功');
|
|
|
+ if ($white > 0){
|
|
|
+ UserBill::expend('扣除白积分', $user['uid'], 'white_integral', 'bet', $white, 0,0,'使用白积分,投注场次'.$many['name'].'成功');
|
|
|
+ }
|
|
|
UserBill::expend('扣除紫积分', $user['uid'], 'purple_integral', 'bet', $data['price']-$white, 0,$user['purple_integral'],'使用紫积分,投注场次'.$many['name'].'成功');
|
|
|
}else{
|
|
|
$user['white_integral'] -= $data['price'];
|
|
@@ -140,18 +142,18 @@ class ManyController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function surplus($id, $type = 0)
|
|
|
+ public function surplus($id, $uid,$type = 0)
|
|
|
{
|
|
|
if ($type > 0){
|
|
|
$many = Many::where('id', $id)->find();
|
|
|
if (!$many) return app('json')->fail('场次不存在');
|
|
|
- $many_order = ManyOrder::where('many_id', $id)->where('stage', $many['stage'])->sum('price');
|
|
|
+ $many_order = ManyOrder::where('many_id', $id)->where('uid', $uid)->where('stage', $many['stage'])->sum('price');
|
|
|
$price = ($many['upper_limit'] - $many_order); // 还可以投注额度
|
|
|
return $price;
|
|
|
}else{
|
|
|
$many = Many::where('id', $id)->find();
|
|
|
if (!$many) return app('json')->fail('场次不存在');
|
|
|
- $many_order = ManyOrder::where('many_id', $id)->where('stage', $many['stage'])->sum('price');
|
|
|
+ $many_order = ManyOrder::where('many_id', $id)->where('uid', $uid)->where('stage', $many['stage'])->sum('price');
|
|
|
$data['price'] = ($many['upper_limit'] - $many_order); // 还可以投注额度
|
|
|
|
|
|
return app('json')->fail($data);
|