彭俊 6 年 前
コミット
1d8d03f53b

+ 43 - 19
app/Http/Controllers/Admin/SoccerStringNoteListController.php

@@ -13,6 +13,7 @@ use Illuminate\Http\Request as Req;
 use Illuminate\Support\Facades\DB;
 Use App\Lib\Settlement\SettlementOrder;
 Use App\Lib\Settlement\SettlementWinFail;
+use App\Models\MoneyBuyStr as MoneyBuyStrModel;
 use App\Models;
 use Request;
 
@@ -270,34 +271,36 @@ class SoccerStringNoteListController extends Controller
             return -1;
         }
 
-
     }
 
+
+    //把撤单状态的订单改为下单状态 (重下单,写流水,扣钱,改订单状态)
     public function resetStrOrder(Req $req)
     {
-        return ['status'=>-1,'msg'=>'功能废弃'];
         $id = $req->id;
         if (intval($id) < 1) {
-            return ['status'=>-1,'msg'=>'无效id'];
+            return ['status' => -1, 'msg' => '无效id'];
         }
-        $order = \App\Models\MoneyBuyStr::where('id', $id)->first();
-        if (empty($order)){
-            return ['status'=>-2,'msg'=>'订单不存在'];
+        $order = (new MoneyBuyStrModel())->with('matchdatas')->where('id', $id)->first();
+        $game_code = $order->matchdatas['0']->game_code;
+        $match_id = $order->matchdatas['0']->match_id;
+
+        if (empty($order)) {
+            return ['status' => -2, 'msg' => '订单不存在'];
         }
-        if ($order->status==1){
-            return ['status'=>-3,'msg'=>'状态错误'];
+        if ($order->status == 1) {
+            return ['status' => -3, 'msg' => '状态错误'];
         }
 
-        $order->status =1 ;
-        $order->settle_status =1 ;
-        $order->game_status = 0;
-        $ret = $order->save();
-
-        if ($ret){
-            return ['status'=>1,'msg'=>'更新成功'];
-        }else{
-            return ['status'=>-4,'msg'=>'更新失败'];
-        }
+        $order_id = $order->order_id;
+        $data = [
+            'token' => session('adminInfo.token'),    //外网
+            'order_id' => $order_id,
+            'game_code' => $game_code,
+            'match_id' => $match_id,
+        ];
+        $ret = request_post(config('sconstant.url') . '/ResStringOneOrder', $data);
+        return json_decode($ret, true);
 
     }
 
@@ -357,6 +360,17 @@ class SoccerStringNoteListController extends Controller
     //单订单手动提交结算
     private function do_settelement($order_id, $game_code, $match_id)
     {
+        $data = [
+            'token' => session('adminInfo.token'),    //外网
+            'order_id' => $order_id,
+            'bet_type' => 2,
+        ];
+        $ret = request_post(config('sconstant.url') . '/WinfailoneNomal', $data);
+        $retarr = json_decode($ret, true);
+        if (empty($ret) || empty($retarr) || !isset($retarr['status']) || $retarr['status'] != 1) {
+            return ['status' => 0, 'msg' => '计算输赢失败', 'data' => ''];
+        }
+
         $data = [
             'token' => session('adminInfo.token'),    //外网
             'order_ids' => $order_id,
@@ -400,13 +414,23 @@ class SoccerStringNoteListController extends Controller
     public function RevokeStrOrder(Req $req)
     {
         $order_id = $req->input('order_id');
-        if (empty($order_id)) {
+        $model = (new MoneyBuyStrModel())->with('matchdatas')->where('order_id', $order_id)->first();
+        $match_first = $model->matchdatas['0'];
+
+        if (empty($order_id) || empty($model) || empty($match_first)) {
             return responseToJson(-2001);
         }
+
+        $game_code = $match_first->game_code;
+        $match_id = $match_first->match_id;
+
         $data = [
             'token' => session('adminInfo.token'),
             'order_id' => $order_id,
+            'game_code' => $game_code,
+            'match_id' => $match_id,
         ];
+
         $ret = request_post(config('sconstant.url') . '/UnsetOneStringOrder', $data);
         return json_decode($ret, true);
 

+ 10 - 0
app/Http/Controllers/Api/SettlementController.php

@@ -21,6 +21,8 @@ use App\Models\MoneyBuyMatch as MoneyBuyMatchModel;
 use App\Lib\Biz\Sport\Common;
 
 
+use App\Lib\Settlement\SwInterface;
+
 class SettlementController extends Controller
 {
     use RulePlus;
@@ -47,6 +49,14 @@ class SettlementController extends Controller
     public function debug(Req $req)
     {
 
+        $ret = SwInterface::getInstance()->WinFailNomalOrder('S20191106102310815438283',1);
+        print_r($ret);
+
+
+
+
+        exit ;
+
         $match = DB::table('money_buy_match')->where(['order_id' => 'S20191102170628894846203'])->first();
         $result = DB::table('st_lq_result')->where(['match_id' => '161'])->get();
         //$result = DB::table('st_wq_result')->where(['id' => '20'])->get();

+ 0 - 1
app/Lib/Settlement/SwInterface.php

@@ -103,7 +103,6 @@ class SwInterface
         return $ret;
     }
 
-
     //取消一个订单
     public function CancelOneOrder($game_code, $match_id, $order_id)
     {

+ 5 - 0
app/Models/MoneyBuyStr.php

@@ -16,6 +16,11 @@ class MoneyBuyStr extends BaseModel
     protected $table = "money_buy_str";
     public $timestamps = false;
 
+    public function matchdatas()
+    {
+        return $this->hasMany(MoneyBuyMatchModel::class, 'order_id', 'order_id');
+    }
+
     function getinfo($list = 10, $page = 1, $where = [], $ids = [])
     {
 

+ 3 - 2
resources/views/sports/sports_stringnotelistSet.blade.php

@@ -77,6 +77,8 @@
         @{{#if(d.status==1){ }}
         <button onclick="invalid('/admin/SoccerStringNoteList/RevokeStrOrder','@{{d.order_id}}')" class="layui-btn layui-btn-sm settlement">作废</button><br/>
         <button onclick="settlement('/admin/SoccerStringNoteList/resettlement','@{{d.id}}')" class="layui-btn layui-btn-sm">结算</button>
+        @{{#}else{ }}
+        <button onclick="resetNoset('/admin/SoccerStringNoteList/resetStrOrder','@{{d.id}}')" class="layui-btn layui-btn-sm">重下单</button>
         @{{#} }}
 
 
@@ -311,10 +313,9 @@
             });
         }
 
-
         //把已作废的串式单改为未结算状态
         function  resetNoset(url,id){
-            layer.confirm('是否重新设置订单状态为未结算状态?', {
+            layer.confirm('是否重新设置订单状态为下单状态?', {
                 btn: ['确认', '取消'] //按钮
             }, function() {
                 $.getJSON(url,{id:id}, function(data) {