clientws4.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/5/23
  6. * Time: 17:42
  7. */
  8. define('START_TIME', microtime(true));
  9. require __DIR__ . '/../vendor/autoload.php';
  10. \datainf\lib\boot::init();
  11. use App\Lib\ModelBase;
  12. use Illuminate\Database\Capsule\Manager as DB;
  13. ModelBase::init();
  14. //var_dump($obj);
  15. //var_dump(DB::table('datainf_log')->where('id',766)->first());
  16. //ModelBase::init()->getConnection()->disconnect();
  17. echo "---------------------\n\n";
  18. //$obj->getConnection()->disconnect();
  19. //var_dump(DB::table('datainf_log')->where('id',766)->first());
  20. /*
  21. $sql = "select * from datainf_log where id in (766,767) ";
  22. $pdo = ModelBase::init()->getConnection()->getPdo();
  23. foreach ($pdo->query($sql ) as $row) {
  24. print_r($row); //你可以用 echo($GLOBAL); 来看到这些值
  25. }
  26. */
  27. /*
  28. try{
  29. ModelBase::beginTransaction();
  30. $model = new \App\Http\Model\StZqResult();
  31. $ret = $model->where(['id'=>4314])->first();
  32. print_r($ret);
  33. ModelBase::commit();
  34. }catch (\Exception $e){
  35. echo $e->getMessage();
  36. ModelBase::rollBack();
  37. }
  38. $model = new App\Lib\TestModel();
  39. $model->name = 'name_'.mt_rand(1000,99999) ;
  40. $model->sex = '男';
  41. $model->age = mt_rand(10,50);
  42. $ret = $model->save();
  43. print_r([$ret,$model->toArray()]);
  44. */
  45. function getIds($type, $match_id, $game_code = '')
  46. {
  47. $return = [];
  48. if ($type == 1) {
  49. $ret = DB::table('money_buy_simplex')->where(['match_id' => $match_id])->get();
  50. if ($ret) {
  51. foreach ($ret as $val) {
  52. $return[] = $val->order_id;
  53. }
  54. }
  55. return $return;
  56. } else {
  57. $ret = DB::table('money_buy_str')->leftJoin('money_buy_match', 'money_buy_match.batch_id', '=', 'money_buy_str.batch_id')->where(['money_buy_match.match_id' => $match_id, 'money_buy_match.game_code' => $game_code])->get();
  58. if ($ret) {
  59. foreach ($ret as $val) {
  60. $return[] = $val->order_id;
  61. }
  62. }
  63. return $return;
  64. }
  65. }
  66. $ids = getIds(1, 483, 'zg');
  67. echo "ids_len:" . count($ids) . "\n";
  68. function request_post($url = '', $param = '')
  69. {
  70. if (empty($url) || empty($param)) {
  71. return false;
  72. }
  73. $postUrl = $url;
  74. $curlPost = $param;
  75. $ch = curl_init();//初始化curl
  76. curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
  77. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  78. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  79. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  80. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  81. $data = curl_exec($ch);//运行curl
  82. curl_close($ch);
  83. return $data;
  84. }
  85. $data = [
  86. 'token' => 'O9Z8zK15629128605d28285cb15dc',
  87. 'order_ids' => implode(",", $ids),
  88. 'bettype' => 1,
  89. 'settype' => 2,
  90. 'game_code' => 'zq',
  91. 'match_id' => 483,
  92. 'change_status' => 1
  93. ];
  94. $ret = request_post('http://192.168.2.220:9094/Settelement', $data);
  95. echo "返回:" . print_r($ret, true) . "\n\n";
  96. /*
  97. $str = '';
  98. $arr = json_decode($str,true);
  99. $arr2 = json_decode( $arr['0']['data'] ,true);
  100. foreach ($arr2 as $val){
  101. print_r($val);
  102. echo "\n\n";
  103. }
  104. */