| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- <?php
- /**
- *------Create thems Model------
- *------SCWPHP Version 1.0.0------
- *------Dev Model Jions------
- *------Create Time 2017-06-13 18:45:24------
- */
- namespace App\Commons\Model;
- use \System\Model;
- class Money_buy_match extends Model {
- protected $table = 'money_buy_match';
- /**
- * 投注记录
- *
- * @access public
- * @param mixed $select 查询字段
- * @param mixed $where 查询条件
- * @param mixed $orWhere 关联关系 [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
- * @param mixed $begin 起始查询位置
- * @param mixed $pageSize 分页大小
- * @param mixed $orderBy 排序字段
- * $order_ids arr 订单id
- * @return array JsonString
- */
-
- public function moneyBuyMatch($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['order_id' => 'desc']) {
- // 查询字段
- $result = $this -> select($select)
- ->join('st_odds_code', function ($join) {
- $join->on('money_buy_match.odds_code', '=','st_odds_code.odds_code')->on('money_buy_match.game_code', '=','st_odds_code.game_code');
- });
- // 查询条件
- if (!empty($where)) {
- $result = $result -> where($where);
- }
- // 循环获取or查询
- if (!empty($orWhere)) {
- foreach ($orWhere as $value) {
- $result = $result -> where(function($query) use ($value) {
- foreach ($value as $k => $v) {
- if ($k == 0) {
- $query = $query -> where([$v[0] => $v[1]]);
- } else {
- $query = $query -> orWhere([$v[0] => $v[1]]);
- }
- }
- });
- }
- }
- // 查询起始
- if (strlen($begin)) {
- $result = $result -> offset($begin);
- }
- // 分页大小
- if (strlen($pageSize)) {
- $result = $result -> limit($pageSize);
- }
- // 循环排序规则
- foreach ($orderBy as $key => $value) {
- $result = $result -> orderBy($key, $value);
- }
- // 获取数据
- $result = $result -> get();
- return $result;
- }
- /**
- * 按注单id查询
- */
- public function moneyBuyMatch_v1($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['order_id' => 'desc'],$order_ids = []) {
- // 查询字段
- $result = $this -> select($select)
- // ->join('st_odds_code', 'st_odds_code.odds_code', '=', 'money_buy_match.odds_code')
- // ->join('st_odds_code', 'st_odds_code.game_code', '=', 'money_buy_match.game_code')
- ->join('st_odds_code', function ($join) {
- $join->on('money_buy_match.odds_code', '=','st_odds_code.odds_code')->on('money_buy_match.game_code', '=','st_odds_code.game_code');
- })
- // ->where($where)
- ->whereIn('order_id',$order_ids)
- // ->limit($pageSize)
- ->orderBy('order_id', 'desc')
- // ->offset($begin)
- ->get();
-
-
-
- // ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
- /*
- // 查询条件
- if (!empty($where)) {
- $result = $result -> where($where);
- }
- // 循环获取or查询
- if (!empty($orWhere)) {
- foreach ($orWhere as $value) {
- $result = $result -> where(function($query) use ($value) {
- foreach ($value as $k => $v) {
- if ($k == 0) {
- $query = $query -> where([$v[0] => $v[1]]);
- } else {
- $query = $query -> orWhere([$v[0] => $v[1]]);
- }
- }
- });
- }
- }
- // 查询起始
- if (strlen($begin)) {
- $result = $result -> offset($begin);
- }
- // 分页大小
- if (strlen($pageSize)) {
- $result = $result -> limit($pageSize);
- }
- // 循环排序规则
- foreach ($orderBy as $key => $value) {
- $result = $result -> orderBy($key, $value);
- }
- // 获取数据
- $result = $result -> get();
- */
- return $result;
- }
- /**
- * 投注记录
- *
- * @access public
- * @param mixed $select 查询字段
- * @param mixed $where 查询条件
- * @param mixed $orWhere 关联关系 [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
- * @param mixed $begin 起始查询位置
- * @param mixed $pageSize 分页大小
- * @param mixed $orderBy 排序字段
- * @return array JsonString
- */
- public function moneyBuyMatchAll($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['batch_id' => 'desc']) {
- // 查询字段
- $result = $this -> select($select);
- // 查询条件
- if (!empty($where)) {
- $result = $result -> where($where);
- }
- // 循环获取or查询
- if (!empty($orWhere)) {
- foreach ($orWhere as $value) {
- $result = $result -> where(function($query) use ($value) {
- foreach ($value as $k => $v) {
- if ($k == 0) {
- $query = $query -> where([$v[0] => $v[1]]);
- } else {
- $query = $query -> orWhere([$v[0] => $v[1]]);
- }
- }
- });
- }
- }
- // 查询起始
- if (strlen($begin)) {
- $result = $result -> offset($begin);
- }
- // 分页大小
- if (strlen($pageSize)) {
- $result = $result -> limit($pageSize);
- }
- // 循环排序规则
- foreach ($orderBy as $key => $value) {
- $result = $result -> orderBy($key, $value);
- }
- // 获取数据
- $result = $result -> get();
- return $result;
- }
- /**
- * 投注记录
- *
- * @access public
- * @param mixed $where 查询条件
- * @param mixed $orWhere 关联关系 [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
- * @return array JsonString
- */
- public function moneyBuyMatchTotal($where = '', $orWhere = '') {
- // 查询字段
- $result = $this;
- // 查询条件
- if (!empty($where)) {
- $result = $result -> where($where);
- }
- // 循环获取or查询
- if (!empty($orWhere)) {
- foreach ($orWhere as $value) {
- $result = $result -> where(function($query) use ($value) {
- foreach ($value as $k => $v) {
- if ($k == 0) {
- $query = $query -> where([$v[0] => $v[1]]);
- } else {
- $query = $query -> orWhere([$v[0] => $v[1]]);
- }
- }
- });
- }
- }
- // 获取数据
- $result = $result -> count();
- return $result;
- }
- public function getByDetail($Detailid){
- $ret = $this->where('money_buy_detail_id' ,$Detailid)->find();
- return $ret;
- }
- public function getByTypeMatch($type,$matchId){
- $rets = $this->where(['game_code'=>$type,'match_id'=>$matchId])->find();
- return $rets;
- }
- //查找某个订单下是否还有未处理完的订单情况
- public function FindByTypeOrderResult($type,$OrderId,$result=0){
- if (is_string($result)){
- $ret = $this->where(['game_code'=>$type,'order_id'=>$OrderId,'result'=>$result])->find();
- }else{
- $ret = $this->where(['game_code'=>$type,'order_id'=>$OrderId])->whereIn('result',$result)->find();
- }
- return $ret;
- }
- public function getByBatchId($batch_id){
- $ret = $this->where('batch_id',$batch_id)->find();
- return $ret;
- }
- }
|