|
@@ -14,6 +14,7 @@ class Slot extends MY_Controller
|
|
|
private $_role_title3 =['关卡','攻击<br/>(权重)','偷袭<br/>(权重)','体力<br/>(权重)','护盾<br/>(权重)','金币<br/>(权重)','金币袋<br/>(权重)','收集物<br/>(权重)','事件牌<br/>(权重)','万能福<br/>(权重)'];
|
|
|
|
|
|
private $treasurepro_title = ['关卡','转盘','小王子*3','狐狸*3','小王子*2','王冠*3','小王子*1','黑桃*3','红桃*3','方块*3','黑桃+红桃+方块','没有奖励','转盘1','转盘2','转盘3','转盘4','转盘5','转盘6','转盘7'];
|
|
|
+ private $editUserList = [];
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
@@ -249,116 +250,207 @@ class Slot extends MY_Controller
|
|
|
|
|
|
|
|
|
//老虎机权重配置
|
|
|
- public function realGroupWeights($gid,$type=1, $page = 0)
|
|
|
+ public function realGroupWeights($gid, $type = 1, $page = 0, $ceProb = "weight")
|
|
|
{
|
|
|
$length = 50;
|
|
|
- $start = (ceil($page/$length)) * $length;
|
|
|
$title = $this->_role_title3;
|
|
|
- $tb = otable::realSlotWeightGroupsCfg();
|
|
|
- $where = " where gid='{$gid}' and type='{$type}' ";
|
|
|
- $sql = "SELECT * from {$tb} {$where} LIMIT {$start},{$length}";
|
|
|
- $rs = oo::commonOprDb('slavedb')->getAll($sql,1);
|
|
|
- $arr = [];
|
|
|
- foreach ($rs as $k=>$v){
|
|
|
- $arr[$v['levelId']] = json_decode($v['slotpro'],true);
|
|
|
- }
|
|
|
- $sql = "SELECT COUNT(*) as num from {$tb} {$where} ";
|
|
|
- $rs = oo::commonOprDb('slavedb')->getOne($sql,1);
|
|
|
- $retData = [
|
|
|
- 'total'=>$rs['num'],
|
|
|
- 'data'=>$arr,
|
|
|
- ];
|
|
|
|
|
|
- if($retData['total'] == 0){
|
|
|
- $list = [];
|
|
|
- }else{
|
|
|
- $list = $retData['data'];
|
|
|
+ switch ($ceProb) {
|
|
|
+ case "weight":
|
|
|
+ list("total" => $total, "list" => $list) = self::groupWeightList($gid, $type, $page, $length);
|
|
|
+ break;
|
|
|
+ case "ceProb":
|
|
|
+ list("total" => $total, "list" => $list) = self::ceProConfList($gid, $type);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $total = 0;
|
|
|
+ $list = [];
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
$data['title'] = $title;
|
|
|
$data['list'] = $list;
|
|
|
- $data['total'] = $retData['total'];
|
|
|
+ $data['total'] = $total;
|
|
|
$data['page'] = $page/50;
|
|
|
$data['editUserList'] = $this->editUserList;
|
|
|
$pageConfig = $this->pageConfig;
|
|
|
$pageConfig['base_url'] = base_url('#slot/realGroupWeights/'.$gid."/".$type);
|
|
|
- $pageConfig['total_rows'] = $data['total'];
|
|
|
+ $pageConfig['total_rows'] = $total;
|
|
|
$pageConfig['per_page'] = $length;
|
|
|
$this->pagination->initialize($pageConfig);
|
|
|
$pageurl = $this->pagination->create_links();
|
|
|
$data['pageurl'] = $pageurl;
|
|
|
$data['gid'] = $gid;
|
|
|
$data['type'] = $type;
|
|
|
+ $data['ceProb'] = $ceProb;
|
|
|
$this->load->view('slot/realGroupWeights', $data);
|
|
|
}
|
|
|
|
|
|
+ private static function groupWeightList($gid, $type, $page,$length): array
|
|
|
+ {
|
|
|
+ $start = (ceil($page / $length)) * $length;
|
|
|
+
|
|
|
+ $tb = otable::realSlotWeightGroupsCfg();
|
|
|
+ $where = " Where gid='{$gid}' and type='{$type}' ";
|
|
|
+ $rs = oo::commonOprDb('slavedb')->getAll("SELECT * from {$tb} {$where} LIMIT {$start},{$length}");
|
|
|
+
|
|
|
+ $arr = [];
|
|
|
+ foreach ($rs as $k => $v) {
|
|
|
+ $arr[$v['levelId']] = json_decode($v['slotpro'], true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $sql = "SELECT COUNT(*) as num from {$tb} {$where} ";
|
|
|
+ $rs = oo::commonOprDb('slavedb')->getOne($sql, 1);
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'total' => $rs['num'],
|
|
|
+ 'list' => $arr,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 老虎机概率干预事件
|
|
|
+ private static function ceProConfList($gid, $type):array
|
|
|
+ {
|
|
|
+ $tb = otable::realSlotCeProConf();
|
|
|
+ $where = " Where gid='{$gid}' and type='{$type}' ";
|
|
|
+ $rs = oo::commonOprDb('slavedb')->getAll("SELECT * from {$tb} {$where}");
|
|
|
+
|
|
|
+ $arrMap = [];
|
|
|
+ foreach ($rs as $k => $v) {
|
|
|
+ $arrMap[$v['levelId']] = json_decode($v['slotpro'], true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $arr = [];
|
|
|
+ for ($i = 1; $i <= 3; $i++) {
|
|
|
+ $arr[$i] = $arrMap[$i] ?? [
|
|
|
+ ["id" => 1, "v" => 0],
|
|
|
+ ["id" => 2, "v" => 0],
|
|
|
+ ["id" => 3, "v" => 0],
|
|
|
+ ["id" => 4, "v" => 0],
|
|
|
+ ["id" => 5, "v" => 0],
|
|
|
+ ["id" => 6, "v" => 0],
|
|
|
+ ["id" => 7, "v" => 0],
|
|
|
+ ["id" => 8, "v" => 0],
|
|
|
+ ["id" => 99, "v" => 0]];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'total' => 3,
|
|
|
+ 'list' => $arr,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Notes: 设置老虎机权重配置
|
|
|
* User: wsc
|
|
|
* Time: 2021/2/27 13:23
|
|
|
* @return json
|
|
|
*/
|
|
|
- public function actionRealSlotWeightcfg($gid,$type){
|
|
|
+ public function actionRealSlotWeightcfg($gid, $type, $ceProb)
|
|
|
+ {
|
|
|
$postData = $this->input->post();
|
|
|
$data = json_decode($postData['data']);
|
|
|
+
|
|
|
$upload = [];
|
|
|
$level = [];
|
|
|
- foreach ($data as $row){
|
|
|
+ foreach ($data as $row) {
|
|
|
$level[] = $row->id;
|
|
|
$upload[] = [
|
|
|
- 'level'=>$row->id,
|
|
|
- 'slotpro' =>$row->data,
|
|
|
+ 'level' => $row->id,
|
|
|
+ 'slotpro' => $row->data,
|
|
|
];
|
|
|
}
|
|
|
$nLevel = array_unique($level);
|
|
|
if(count($nLevel) != count($level)){
|
|
|
return $this->response(1, 'levelId 重复');
|
|
|
}
|
|
|
-
|
|
|
- $retData = $this->saveRealSlotWeightCfg($gid,$type, $upload);
|
|
|
+ file_put_contents("/tmp/xzxcmserr.log", json_encode($upload) . PHP_EOL, FILE_APPEND);
|
|
|
+ switch ($ceProb) {
|
|
|
+ case "weight":
|
|
|
+ $retData = $this->saveRealSlotWeightCfg($upload, $gid, $type);
|
|
|
+ break;
|
|
|
+ case "ceProb":
|
|
|
+ $retData = $this->saveRealSlotCeProbCfg($upload, $gid, $type);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return $this->response(1, "cePron 类型错误:{$ceProb}");
|
|
|
+ }
|
|
|
oo::logs()->adminlog($this->router->fetch_method());
|
|
|
|
|
|
- if($retData == 0){
|
|
|
+ if ($retData == 0) {
|
|
|
return $this->response(1, '操作失败');
|
|
|
- }else{
|
|
|
-// $this->makeBeginGuideJson();
|
|
|
+ } else {
|
|
|
return $this->response(0, '操作成功');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Notes:保存老虎机权重配置
|
|
|
- * User: wsc
|
|
|
- * Time: 2021/2/27 13:24
|
|
|
- * @param $data
|
|
|
- * @return array|int
|
|
|
*/
|
|
|
- public function saveRealSlotWeightCfg($gid,$type, $data){
|
|
|
+ public function saveRealSlotWeightCfg($data, $gid, $type)
|
|
|
+ {
|
|
|
$tb = otable::realSlotWeightGroupsCfg();
|
|
|
$sql = "SELECT levelId from {$tb} where gid={$gid} and type ={$type}";
|
|
|
- $rs = oo::commonOprDb('slavedb')->getAll($sql,1);
|
|
|
+ $rs = oo::commonOprDb('slavedb')->getAll($sql);
|
|
|
+
|
|
|
$temp = [];
|
|
|
- foreach ($rs as $row){
|
|
|
- array_push($temp,(int)$row['levelId']);
|
|
|
+ foreach ($rs as $row) {
|
|
|
+ $temp[] = (int)$row['levelId'];
|
|
|
}
|
|
|
- $data = json_decode(json_encode($data,32));
|
|
|
- foreach ($data as $row){
|
|
|
-// $slotPro = [];
|
|
|
-// foreach ($row->slotpro as $k => $items){
|
|
|
-// echo json_encode([$k => $items]);die;
|
|
|
-// }
|
|
|
- $tempData = json_encode($row->slotpro,JSON_UNESCAPED_UNICODE);
|
|
|
-// echo $tempData;die;
|
|
|
- if(in_array($row->level,$temp)){
|
|
|
+
|
|
|
+ $data = json_decode(json_encode($data, 32));
|
|
|
+ foreach ($data as $row) {
|
|
|
+
|
|
|
+ $tempData = json_encode($row->slotpro, JSON_UNESCAPED_UNICODE);
|
|
|
+ if (in_array($row->level, $temp)) {
|
|
|
$sql = "UPDATE {$tb} SET slotpro='{$tempData}' WHERE levelId={$row->level} and gid={$gid} and type ={$type}";
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$sql = "INSERT INTO {$tb} (gid, levelId,type,slotpro) VALUES ({$gid}, {$row->level},{$type},'{$tempData}')";
|
|
|
}
|
|
|
-// echo $sql;die;
|
|
|
$rs = oo::commonOprDb('games')->query($sql);
|
|
|
- oo::commonOprRedis('games')->hset(okeys::RealSlotWeightConfig($gid,$row->level),$type, $tempData);
|
|
|
+ oo::commonOprRedis('games')->hset(okeys::RealSlotWeightConfig($gid, $row->level), $type, $tempData);
|
|
|
}
|
|
|
|
|
|
- return $rs ? $rs : 0;
|
|
|
+ return $rs ?: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Notes:保存老虎机修正概率配置
|
|
|
+ */
|
|
|
+ public function saveRealSlotCeProbCfg($data, $gid, $type)
|
|
|
+ {
|
|
|
+ $tb = otable::realSlotCeProConf();
|
|
|
+
|
|
|
+ $sql = "SELECT levelId from {$tb} where gid={$gid} and type ={$type}";
|
|
|
+ $rs = oo::commonOprDb('slavedb')->getAll($sql);
|
|
|
+
|
|
|
+ $temp = [];
|
|
|
+ foreach ($rs as $row) {
|
|
|
+ $temp[] = (int)$row['levelId'];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($data as $row) {
|
|
|
+ if (!in_array($row['level'], [1, 2, 3])) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ $upMap = [];
|
|
|
+ foreach ($row['slotpro'] as $item) {
|
|
|
+ $upMap[$item->id] = $item->v;
|
|
|
+ }
|
|
|
+ oo::commonOprRedis('games')->hMset(okeys::RealSloCeProbConfig($gid, $row['level']), $upMap);
|
|
|
+
|
|
|
+ $tempData = json_encode($row['slotpro'], JSON_NUMERIC_CHECK);
|
|
|
+
|
|
|
+ if (in_array($row['level'], $temp)) {
|
|
|
+ $sql = "UPDATE {$tb} SET slotpro='{$tempData}' WHERE levelId={$row['level']} and gid={$gid} and type ={$type}";
|
|
|
+ } else {
|
|
|
+ $sql = "INSERT INTO {$tb} (gid, levelId,type,slotpro) VALUES ({$gid}, {$row['level']},{$type},'{$tempData}')";
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = oo::commonOprDb('games')->query($sql);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $rs ?: 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -433,4 +525,26 @@ class Slot extends MY_Controller
|
|
|
return $this->response(1, '操作失败',$data);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ const CONFIG_SlOT_LS_CONF="CONFIG_SlOT_LS_CONF";
|
|
|
+
|
|
|
+ // 概率干预修正区间
|
|
|
+ public function ceProConf()
|
|
|
+ {
|
|
|
+ $data['conf'] = oo::commonOprModel('config')->getCommonConf(self::CONFIG_SlOT_LS_CONF);
|
|
|
+
|
|
|
+ $this->load->view('slot/ceProConf', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 概率干预修正区间 更新
|
|
|
+ public function ceProConfUpdate()
|
|
|
+ {
|
|
|
+ $posts = $this->input->post();
|
|
|
+
|
|
|
+ oo::commonOprModel('config')->saveCommonConf(self::CONFIG_SlOT_LS_CONF, $posts['conf'], "收集活动等级体力分组修正等级配置");
|
|
|
+
|
|
|
+ oo::commonOprRedis('games')->delete(self::CONFIG_SlOT_LS_CONF);
|
|
|
+
|
|
|
+ return $this->response(0, '操作成功');
|
|
|
+ }
|
|
|
}
|