| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Models\Order;
- class FootballSettlement extends Command
- {
- /**
- * 命令名称和签名
- *
- * @var string
- */
- protected $signature = 'football:settlement';
-
- /**
- * 命令描述
- *
- * @var string
- */
- protected $description = '足球结算方法';
- /**
- * 执行命令
- *
- * @return int
- */
- public function handle()
- {
- $this->sportOrderSettlement();
- $function = 'MatchWinner';
- $params = [
- 'amount' => 10,
- 'score' => '1-1',
- 'detail' => [
- 'odds' => [
- [
- "id" => 1,
- "name" => "Match Winner",
- "values" => [
- [
- "value" => "Draw",
- "odd" => "3.30"
- ]
- ]
- ]
- ]
- ],
- ];
- $result = $this->doFunction($function, $params);
- print_r($result);die;
- return $result;
- }
- public function sportOrderSettlement(){
- $where = [
- 'status' => 1,
- 'pay_status' => 1,
- 'return_status' => 0,
- 'settlement_status' => 0,
- ];
- $list = Order::alias('o')
- ->join('sport s', 'o.data_id', '=', 's.data_id')
- ->where('s.state', 2)
- ->where($where)
- ->select('o.*', 's.score','s.half_score')
- ->get()->toArray();
- foreach($list as $item) {
- $detail = json_decode($item['detail'], true);
- $odd_id = $detail['odds'][0]['id'];
- $function = SportOdds::where('id',$odd_id)->value('function_name');
- $params = [
- 'score' => $item['score'],
- 'half_score' => $item['half_score'],
- 'data_id' => $item['data_id'],
- 'home_team_id' => $item['home_team_id'],
- 'guest_team_id' => $item['guest_team_id'],
- ];
- $result = $function($item['amount'], $detail, $params);
- print_r($result);die;
- }
- }
- }
|