GameextModel.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * GameextModel.php UTF-8
  4. *
  5. *
  6. * @date : 2017/11/21 21:21
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\game;
  13. use huo\model\common\CommonModel;
  14. use huolib\constant\CommonConst;
  15. class GameextModel extends CommonModel {
  16. protected $name = 'game_ext';
  17. /**
  18. * @return \think\model\relation\BelongsTo
  19. */
  20. public function game() {
  21. return $this->belongsTo('huo\model\game\GameModel', 'app_id', 'id')->field('id,name');
  22. }
  23. /**
  24. * @return \think\model\relation\BelongsTo
  25. */
  26. public function joingame() {
  27. return $this->belongsTo('huo\model\game\GameModel', 'app_id', 'id')->setEagerlyType(0);
  28. }
  29. /**
  30. * 获取游戏充值排行
  31. *
  32. * @param string $page
  33. *
  34. * @param string $order
  35. *
  36. * @return array|false
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. * @throws \think\exception\DbException
  40. */
  41. public function getChargeRank($page = '1,6', $order = '-sum_money') {
  42. $_field = 'sum_money total_money,app_id';
  43. $_map['joingame.is_delete']=CommonConst::CONST_NOT_DELETE;
  44. $_order = $this->orderFilter($order);
  45. $_data = $this->with('joingame')
  46. ->field($_field)
  47. ->where($_map)
  48. ->order($_order)
  49. ->page($page)
  50. ->select();
  51. if (is_object($_data)) {
  52. $_data = $_data->toArray();
  53. }
  54. return $_data;
  55. }
  56. /**
  57. * 更新游戏
  58. *
  59. * @param array $ge_data
  60. * @param string $app_id
  61. *
  62. * @return bool
  63. */
  64. public function updateData($ge_data, $app_id) {
  65. $_map['app_id'] = $app_id;
  66. $_data = $ge_data;
  67. $_rs = self::update($_data, $_map, true);
  68. if (false == $_rs) {
  69. return false;
  70. } else {
  71. return true;
  72. }
  73. }
  74. /**
  75. * 获取游戏扩信息
  76. *
  77. * @param int $app_id
  78. *
  79. * @return false|array
  80. */
  81. public function getDetail($app_id) {
  82. $_map['app_id'] = $app_id;
  83. $_data = $this->where($_map)->find();
  84. if (is_object($_data)) {
  85. $_data = $_data->toArray();
  86. }
  87. if (false == $_data) {
  88. return false;
  89. }
  90. return $_data;
  91. }
  92. }