GamePayShowLogic.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * GamePayShowLogic.php UTF-8
  4. * 支付显示逻辑处理
  5. *
  6. * @date : 2019/8/27 20:02
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : dengcongshuai <dcs@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\game;
  13. use huo\controller\game\GamePayShowCache;
  14. use huo\model\common\CommonModel;
  15. use huo\model\game\GamePayShowModel;
  16. use huolib\constant\OrderConst;
  17. class GamePayShowLogic extends CommonModel {
  18. public $base_field
  19. = [
  20. 'app_id' => 'app_id',
  21. 'start_time' => 'start_time',
  22. 'end_time' => 'end_time',
  23. 'start_ip' => 'start_ip',
  24. 'end_ip' => 'end_ip',
  25. 'price' => 'price',
  26. 'is_domestic' => 'is_domestic',
  27. 'is_overseas' => 'is_overseas',
  28. 'no_show_version' => 'no_show_version',
  29. 'system' => 'system',
  30. 'combat_num_mini' => 'combat_num_mini',
  31. 'combat_num_max' => 'combat_num_max',
  32. 'level_mini' => 'level_mini',
  33. 'level_max' => 'level_max',
  34. 'login_day_mini' => 'login_day_mini',
  35. 'login_day_max' => 'login_day_max',
  36. 'ip_black' => 'ip_black',
  37. 'area' => 'area',
  38. 'mem_id' => 'mem_id',
  39. ];
  40. public function getBaseField() {
  41. return $this->base_field;
  42. }
  43. /**
  44. * 切换规则列表
  45. *
  46. * @param int $app_id
  47. * @param string $page
  48. *
  49. * @return mixed
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\ModelNotFoundException
  52. * @throws \think\exception\DbException
  53. */
  54. public function getLists($app_id = 0, $page = '') {
  55. $_map = [];
  56. if (!empty($app_id)) {
  57. $_map['app_id'] = $app_id;
  58. }
  59. $_model = new GamePayShowModel();
  60. $_count = $_model->where($_map)->count();
  61. if ($_count <= 0) {
  62. $_rdata['count'] = 0;
  63. $_rdata['list'] = [];
  64. } else {
  65. $_field = $this->base_field;
  66. $_switch_lists = $_model
  67. ->with('game')
  68. ->field($_field)
  69. ->where($_map)
  70. ->page($page)
  71. ->select();
  72. if (is_object($_switch_lists)) {
  73. $_switch_lists = $_switch_lists->toArray();
  74. }
  75. $_lists = [];
  76. foreach ($_switch_lists as $_v) {
  77. $_data = [];
  78. foreach ($_field as $_value) {
  79. $_data[$_value] = $_v[$_value];
  80. }
  81. $_data['game_name'] = '';
  82. if (!empty($_v['game'])) {
  83. $_data['game_name'] = empty($_v['game']['game_name']) ? '' : $_v['game']['game_name'];
  84. }
  85. $_lists[] = $_data;
  86. }
  87. $_rdata = [
  88. 'count' => $_count,
  89. 'list' => $_lists
  90. ];
  91. }
  92. return $_rdata;
  93. }
  94. /***
  95. * 添加切换规则
  96. *
  97. * @param $param
  98. *
  99. * @return false|int
  100. */
  101. public function addPayShow($param) {
  102. $_rs = (new GamePayShowModel())->allowField(true)->save($param);
  103. return $_rs;
  104. }
  105. /**
  106. * 获取规则信息
  107. *
  108. * @param $app_id
  109. *
  110. * @return bool
  111. */
  112. public function getInfoByAppId($app_id) {
  113. if (empty($app_id)) {
  114. return false;
  115. }
  116. $_map['app_id'] = $app_id;
  117. $_field = $this->base_field;
  118. $_rdata = (new GamePayShowModel())->field($_field)->where($_map)->find();
  119. if (is_object($_rdata)) {
  120. $_rdata = $_rdata->toArray();
  121. }
  122. return $_rdata;
  123. }
  124. /**
  125. * 更新规则信息
  126. *
  127. * @param $param
  128. * @param $app_id
  129. *
  130. * @return GamePayShowModel
  131. */
  132. public function updatePaySwitch($param, $app_id) {
  133. $_map['app_id'] = $app_id;
  134. $_rs = (new GamePayShowModel())->update($param, $_map, true);
  135. return $_rs;
  136. }
  137. /***
  138. * 查找切换规则是否已存在
  139. *
  140. * @param $app_id
  141. *
  142. * @return bool
  143. */
  144. public function checkGame($app_id) {
  145. $_info = GamePayShowCache::ins()->getInfoByAppId($app_id);
  146. if (empty($_info)) {
  147. return false;
  148. }
  149. return true;
  150. }
  151. }