GameImproveRtpGlobal.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\model\GameImproveRtpGlobalModel;
  5. use think\facade\Request;
  6. class GameImproveRtpGlobal extends BaseController
  7. {
  8. public function getImproveRtpGlobalList()
  9. {
  10. $userInfo = $this->getUserInfo();
  11. $info = GameImproveRtpGlobalModel::find($userInfo['merchant_id'])->toArray();
  12. $info['evaluation_period_text'] = [
  13. '1' => '每日',
  14. '2' => '每周',
  15. '3' => '每月',
  16. '4' => '终生',
  17. '5' => '自定义时间'
  18. ][$info['evaluation_period']] ?? "";
  19. if(!empty($info['custom_time_start']) && !empty($info['custom_time_end'])) {
  20. $info['custom_time_start'] = date('Y-m-d H:i:s', $info['custom_time_start']);
  21. $info['custom_time_end'] = date('Y-m-d H:i:s', $info['custom_time_end']);
  22. }
  23. return json_success(['total' => 1, 'list' => [$info]]);
  24. }
  25. public function updateImproveRtpGlobalStatus()
  26. {
  27. $status = Request::param('status', '', 'trim');
  28. if(!in_array($status, ['0', '1'])){
  29. return json_error([], '参数错误');
  30. }
  31. $userInfo = $this->getUserInfo();
  32. $info = GameImproveRtpGlobalModel::find($userInfo['merchant_id']);
  33. $info->status = $status;
  34. $info->save();
  35. return json_success([],'操作成功');
  36. }
  37. public function updateImproveRtpGlobalInfo()
  38. {
  39. $userInfo = $this->getUserInfo();
  40. try{
  41. $data = Request::param([
  42. 'net_income' => 100, // 设定玩家在游戏内盈利值达到后关闭功能
  43. 'turnover_multiple' => 5, //达到设定流水倍数关闭提升状态
  44. 'evaluation_period' => 4, // 系统控制的触发周期选择
  45. 'effective_count' => 1, //周期内可被系统控制的次数
  46. 'trigger_interval_rounds' => 300, // 每次系统控制间隔局数
  47. ], 'post', 'trim');
  48. foreach ($data as $k => $v) {
  49. if(empty($v)) {
  50. return json_error([], '参数错误');
  51. }
  52. }
  53. $custom_time_start = Request::post('custom_time_start', '', 'trim');
  54. $custom_time_end = Request::post('custom_time_end', '', 'trim');
  55. if($data['evaluation_period'] == 5) {
  56. if(empty($custom_time_start) || empty($custom_time_end)) {
  57. return json_error([], '参数错误');
  58. }
  59. }
  60. $info = GameImproveRtpGlobalModel::find($userInfo['merchant_id']);
  61. // 更新
  62. $info->effective_count = $data['effective_count'];
  63. $info->evaluation_period = $data['evaluation_period'];
  64. $info->net_income = $data['net_income'];
  65. $info->trigger_interval_rounds = $data['trigger_interval_rounds'];
  66. $info->turnover_multiple = $data['turnover_multiple'];
  67. $info->custom_time_start = !empty($custom_time_start) ? strtotime($custom_time_start) : 0;
  68. $info->custom_time_end = !empty($custom_time_end) ? strtotime($custom_time_end) : 0;
  69. if($info->evaluation_period != 5) {
  70. $info->round_status = 1;
  71. $info->open_status_time = time();
  72. }else {
  73. if(time() >= $info->custom_time_start) {
  74. $info->round_status = 1;
  75. }
  76. if(time() >= $info->custom_time_end) {
  77. $info->round_status = 2;
  78. }
  79. $info->open_status_time = $info->custom_time_start;
  80. }
  81. $info->save();
  82. return json_success([],'操作成功');
  83. }catch (\Exception $e){
  84. return json_error([], "更新全局养客功能错误:". $e->getMessage());
  85. }
  86. }
  87. }