自动返利活动补充

master
duhui 2022-11-07 09:59:51 +08:00
parent 6533b95e8a
commit 0be924a3e3
14 changed files with 374 additions and 111 deletions

View File

@ -2,13 +2,13 @@ package com.jmfy.controller;
import com.jmfy.dao.ActivityDao;
import com.jmfy.dao.ServerInfoDao;
import com.jmfy.model.ARBActivity;
import com.jmfy.model.ARBMission;
import com.jmfy.model.gm.ARBActivity;
import com.jmfy.model.gm.ARBMission;
import com.jmfy.model.ServerInfo;
import com.jmfy.model.vo.ARBActivityTypeEnum;
import com.jmfy.model.vo.ARBActivityTypeVo;
import com.jmfy.utils.FileCacheUtils;
import com.jmfy.utils.StringUtil;
import com.jmfy.redisProperties.RedisUserKey;
import com.jmfy.utils.*;
import config.SItemConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,7 +19,10 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Author hj
@ -94,6 +97,7 @@ public class ActivityController {
public @ResponseBody int
updateARBActivity(@RequestBody ARBActivity activity) throws Exception {
activityDao.uporsetActivity(activity);
activityUpdateVersion();
return 1;
}
@ -108,6 +112,7 @@ public class ActivityController {
removeARBActivity(HttpServletRequest request) throws Exception {
String activityId = request.getParameter("activityId");
activityDao.deleteActivity(activityId);
activityUpdateVersion();
return 1;
}
@ -126,54 +131,6 @@ public class ActivityController {
return "ARBMissions";
}
/**
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/addARBMission", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody int
addARBMission(HttpServletRequest request) throws Exception {
ARBMission mission = new ARBMission();
String title = request.getParameter("title");
String rechargeValue = request.getParameter("rechargeValue");
String propId = request.getParameter("propId");
String propNum = request.getParameter("propNum");
String activityId = request.getParameter("activityId");
// id
mission.setTitle(title);
mission.setRechargeValue(Integer.parseInt(rechargeValue));
// reward
String[] ids = propId.split(",");
String[] nums = propNum.split(",");
int[][] reward = new int[ids.length][2];
for (int i = 0; i < ids.length; i++) {
reward[i][0] = Integer.parseInt(ids[i]);
reward[i][1] = Integer.parseInt(nums[i]);
}
mission.setReward(reward);
// activity
ARBActivity oneActivity = activityDao.findOneActivity(activityId);
mission.setActivity(oneActivity);
activityDao.addMission(mission);
return 1;
}
/**
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/removeARBMission", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody int
removeARBMission(HttpServletRequest request) throws Exception {
String missionId = request.getParameter("missionId");
activityDao.deleteMission(missionId);
return 1;
}
/**
*
@ -192,7 +149,106 @@ public class ActivityController {
map.addAttribute("itemList",itemList);
String activityId = request.getParameter("activityId");
map.addAttribute("activityId", activityId);
int type = activityDao.findOneActivity(activityId).getType();
map.addAttribute("type", type);
return "addARBMission";
}
/**
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/addARBMission", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody int
addARBMission(HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
ARBMission mission = new ARBMission();
String sort = parameterMap.get("sort");
String title = parameterMap.get("title");
String propId = parameterMap.get("propId");
String propNum = parameterMap.get("propNum");
String activityId = parameterMap.get("activityId");
ARBActivity oneActivity = activityDao.findOneActivity(activityId);
// 专属参数处理
parameterToType(oneActivity.getType(),parameterMap,mission);
// 通用数据赋值
mission.setSort(Integer.parseInt(sort));
mission.setTitle(title);
mission.setActivity(oneActivity);
// reward
if (propId.equals("") || "".equals(propNum)){
mission.setReward(new int[0][]);
}else {
String[] ids = propId.split(",");
String[] nums = propNum.split(",");
int[][] reward = new int[ids.length][2];
for (int i = 0; i < ids.length; i++) {
reward[i][0] = Integer.parseInt(ids[i]);
reward[i][1] = Integer.parseInt(nums[i]);
}
mission.setReward(reward);
}
activityDao.addMission(mission);
return 1;
}
/**
*
* @param type
* @return
*/
private void parameterToType(int type, HashMap<String, String> parameterMap, ARBMission mission) throws Exception{
if (type == 2){
//返利专属的充值区间和返利额度
int beforeNum = Integer.parseInt(parameterMap.get("beforeNum"));
int afterNum = Integer.parseInt(parameterMap.get("afterNum"));
int backRatio = Integer.parseInt(parameterMap.get("backRatio"));
mission.setBeforeNum(beforeNum);
mission.setAfterNum(afterNum);
mission.setBackRatio(backRatio);
}else {
int rechargeNum = Integer.parseInt(parameterMap.get("rechargeValue"));
mission.setRechargeNum(rechargeNum);
}
}
@RequestMapping(value = "/jumpMissionValue", method = {RequestMethod.POST, RequestMethod.GET})
public String jumpMissionValue(HttpServletRequest request) {
int type = Integer.parseInt(request.getParameter("type"));
String result;
if (type == 2) {
//返利专属
result = "missionToMonsterCurrencyBack";
} else {
result = "missionToOneDayRecharge";
}
return result;
}
/**
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/removeARBMission", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody int
removeARBMission(HttpServletRequest request) throws Exception {
String missionId = request.getParameter("missionId");
activityDao.deleteMission(missionId);
return 1;
}
/**
* redis
*/
private static void activityUpdateVersion(){
RedisUtil.getInstence().set(RedisUserKey.GM_ACTIVITY_UPDATE, String.valueOf(DateUtil.nowInt()));
}
}

View File

@ -1,8 +1,7 @@
package com.jmfy.dao;
import com.jmfy.model.ARBActivity;
import com.jmfy.model.ARBActivity;
import com.jmfy.model.ARBMission;
import com.jmfy.model.gm.ARBActivity;
import com.jmfy.model.gm.ARBMission;
import java.util.List;

View File

@ -1,10 +1,11 @@
package com.jmfy.dao.impl;
import com.jmfy.dao.ActivityDao;
import com.jmfy.model.ARBActivity;
import com.jmfy.model.ARBMission;
import com.jmfy.model.gm.ARBActivity;
import com.jmfy.model.gm.ARBMission;
import com.jmfy.model.Constant;
import com.jmfy.utils.Connect;
import com.jmfy.utils.DateUtil;
import com.jmfy.utils.StringUtil;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.MongoTemplate;
@ -63,6 +64,7 @@ public class ActivityDaoImpl implements ActivityDao {
// 添加
ARBActivity oneActivity = findOneActivity(activity.getId());
if (oneActivity == null){
activity.setCreateTime(DateUtil.nowString());
mongoTemplate.insert(activity);
return;
}
@ -90,6 +92,12 @@ public class ActivityDaoImpl implements ActivityDao {
@Override
public void deleteActivity(String activityId) throws Exception {
MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName);
// 删除档位
List<ARBMission> missionList = findActivityMissionList(activityId);
for (ARBMission mission : missionList) {
deleteMission(mission.getId());
}
// 删除活动
Query query = new Query(Criteria.where("id").is(activityId));
mongoTemplate.remove(query, ARBActivity.class);
}

View File

@ -1,5 +1,6 @@
package com.jmfy.model;
package com.jmfy.model.gm;
import com.jmfy.model.ServerInfo;
import com.jmfy.model.vo.ARBActivityTypeEnum;
import com.jmfy.model.vo.ARBActivityTypeVo;
import com.jmfy.redisProperties.RedisUserKey;
@ -45,27 +46,15 @@ public class ARBActivity {
*
*/
private String endTime;
/**
*
*/
private String createTime;
/**
*
*/
private Set<String> serverIds = new HashSet<>();
public ARBActivity() {
}
public ARBActivity(String id, String name, String description, int type, String startTime, String endTime, String severStr) {
if (!StringUtil.isEmpty(id)){
this.id = id;
}
this.name = name;
this.description = description;
this.type = type;
this.startTime = startTime;
this.endTime = endTime;
String[] split = severStr.split(",");
this.serverIds = Arrays.stream(split).collect(Collectors.toSet());
}
public String getId() {
return id;
}
@ -115,6 +104,14 @@ public class ARBActivity {
return typeVo.getName();
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public void setType(int type) {
this.type = type;
}

View File

@ -1,8 +1,7 @@
package com.jmfy.model;
package com.jmfy.model.gm;
import com.jmfy.utils.JsonUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
@ -16,25 +15,39 @@ import org.springframework.data.mongodb.core.mapping.Document;
public class ARBMission {
@Id
private String id;
/**
*
*/
private int sort;
/**
*
*/
private String title;
/**
*
*
* @return
*/
private int rechargeValue;
private int rechargeNum;
/**
*
*/
private int[][] reward;
/**
*
*/
@DBRef
private ARBActivity activity;
/**
*
* @return
*/
private int beforeNum;
private int afterNum;
private int backRatio;
public String getId() {
return id;
}
@ -43,6 +56,14 @@ public class ARBMission {
this.id = id;
}
public int getSort() {
return sort;
}
public void setSort(int sort) {
this.sort = sort;
}
public String getTitle() {
return title;
}
@ -51,14 +72,6 @@ public class ARBMission {
this.title = title;
}
public int getRechargeValue() {
return rechargeValue;
}
public void setRechargeValue(int rechargeValue) {
this.rechargeValue = rechargeValue;
}
public int[][] getReward() {
return reward;
}
@ -78,4 +91,36 @@ public class ARBMission {
public void setActivity(ARBActivity activity) {
this.activity = activity;
}
public int getBeforeNum() {
return beforeNum;
}
public void setBeforeNum(int beforeNum) {
this.beforeNum = beforeNum;
}
public int getAfterNum() {
return afterNum;
}
public void setAfterNum(int afterNum) {
this.afterNum = afterNum;
}
public int getBackRatio() {
return backRatio;
}
public void setBackRatio(int backRatio) {
this.backRatio = backRatio;
}
public int getRechargeNum() {
return rechargeNum;
}
public void setRechargeNum(int rechargeNum) {
this.rechargeNum = rechargeNum;
}
}

View File

@ -37,14 +37,12 @@ public class RedisUserKey {
public static final String CROSS_SERVER_GROUP = "CROSS_SERVER_GROUP";//gm跨服分组每周一重新分组生效
public static final String SERVER_INFO = "SERVER_INFO";//服务器信息
/**
* 线 updata/min
*/
public static final String ONLINE_NUM = "ONLINE_NUM";
/**
*
*/
public static final String GAME_PAY_URL = "GAME_PAY_URL:";
public static final String ONLINE_NUM = "ONLINE_NUM";//在线人数 updata/min
public static final String GAME_PAY_URL = "GAME_PAY_URL:";//游戏支付端口
public static final String GM_ACTIVITY_UPDATE = "GM_ACTIVITY_UPDATE";// GM活动更新
public static String getKey(String type, String key, int serverId) {
if (serverId==0) {

View File

@ -252,8 +252,8 @@ public class DateUtil {
return System.currentTimeMillis();
}
public static long nowInt(){
return System.currentTimeMillis()/1000;
public static int nowInt(){
return (int)(System.currentTimeMillis()/1000);
}
public static String nowString(){

View File

@ -34,7 +34,7 @@ public class JsonUtil {
}
public HashMap<String, String> getParameterMap(HttpServletRequest request) {
HashMap<String, String> map = new HashMap();
HashMap map = new HashMap<String, String>();
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String paramName = (String) paramNames.nextElement();

View File

@ -0,0 +1,88 @@
/* ÀÁÈËͼ¿â ËѼ¯ÕûÀí www.lanrentuku.com */
/*-------------------------
Inline help tip
--------------------------*/
.help-tip{
position: absolute;
top: 4px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip:hover p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p{
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 200px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
z-index: 999;
}
.help-tip p:before{
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.help-tip p:after{
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}
@-webkit-keyframes fadeIn {
0% {
opacity:0;
transform: scale(0.6);
}
100% {
opacity:100%;
transform: scale(1);
}
}
@keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}

View File

@ -45,18 +45,16 @@
<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
<thead>
<tr class="text-c">
<th width="100">档位id</th>
<th width="100">档位排序</th>
<th width="100">档位标题</th>
<th width="50">充值金额条件值</th>
<th width="300">奖励</th>
<th width="60">操作</th>
</tr>
</thead>
<tbody>
<tr th:each="obj:${missions}" th:id="${obj.getId()}">
<td th:text="${obj.getId()}" style="text-align: center;"></td>
<td th:text="${obj.getSort()}" style="text-align: center;"></td>
<td th:text="${obj.getTitle()}" style="text-align: center;"></td>
<td th:text="${obj.getRechargeValue()}" style="text-align: center;"></td>
<td th:text="${obj.getRewardDescription()}" style="text-align: center;"></td>
<td style="text-align: center;">
<button type="button" th:id="${obj.getId()}" th:name="${obj.getTitle()}" class="btn btn-danger radius" onclick="return deleteMission(this)">

View File

@ -22,6 +22,7 @@
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css"/>
<!-- 引入layui.css -->
<link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css">
<link rel="stylesheet" type="text/css" href="../static/tips/help.css">
<!--[if IE 6]>
<script type="text/javascript" src="../static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
<script>DD_belatedPNG.fix('*');</script>
@ -49,6 +50,17 @@
<span>自动返利活动档位配置</span>
</div>
<div class="tabCon">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>排序:
</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="number" th:id="sortId" placeholder="" value="" class="input-text"/>
<div class="help-tip">
<p>排序越小档位越先验证排序id可以重复</p>
</div>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>档位标题:
@ -59,13 +71,13 @@
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>充值金额
<span class="c-red">*</span>档位条件
</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="number" th:id="rechargeValue" placeholder="" value="" class="input-text"/>
<iframe width="100%" height="100%" th:src="'jumpMissionValue?type='+${type}" id="values" scrolling="auto" frameborder="0"></iframe>
</div>
</div>
<div class="row cl">
<div class="row cl" >
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>道具信息:
</label>
@ -83,6 +95,9 @@
<tr>
<td colspan="3">
<span>在这里添加道具</span>
<div class="help-tip">
<p>自动返利活动无需添加道具</p>
</div>
</td>
<td colspan="1">
<div class="layui-btn-group">
@ -138,8 +153,12 @@
});
});
var type = [[${type}]];
var index = 1;
$('.add').on('click', function(){
if (type == 2){
return;
}
var element = $([
'<tr>',
'<td>'+ index +'</td>',
@ -210,15 +229,36 @@
function upsertMission() {
// ID
let activityId = document.getElementById("activityId").value;
// 排序
let sortId = document.getElementById("sortId").value;
// 标题
let title = document.getElementById("title").value;
// 充值条件
let rechargeValue = document.getElementById("rechargeValue").value;
if (title == "" || rechargeValue <= 0){
alert("参数不能为空!")
if (title == ""){
layer.msg('标题不能为空!', {icon: 6, time: 1000});
return false;
}
let iframe = document.getElementById('values');
let rechargeValue;
let beforeNum,afterNum,backRatio;
if (type == 2){
beforeNum = iframe.contentWindow.document.getElementById('beforeNum').value;
afterNum = iframe.contentWindow.document.getElementById('afterNum').value;
backRatio = iframe.contentWindow.document.getElementById('backRatio').value;
let bool = afterNum >= 0 && beforeNum > 0 && backRatio > 0 && afterNum >= beforeNum;
if (!bool) {
layer.msg('数值区间和返利数值配置错误!', {icon: 6, time: 1000});
return false;
}
} else {
// 充值条件
rechargeValue = iframe.contentWindow.document.getElementById('rechargeValue').value;
if (rechargeValue < 0){
layer.msg('充值金额错误!', {icon: 6, time: 1000});
return false;
}
}
// 奖励道具id
var ids = xmSelect.batch(null, 'getValue', 'value');
// 奖励数量
@ -235,17 +275,24 @@
$.ajax({
type: "POST",
data: {
"sort": sortId,
"title": title,
"rechargeValue": rechargeValue,
"propId": ids.toString(),
"propNum": nums.toString(),
"activityId": activityId,
"beforeNum": beforeNum,
"afterNum": afterNum,
"backRatio": backRatio
},
url: "/addARBMission",
success: function (data) {
if (data == 1) {
layer.msg('成功!', {icon: 6, time: 1000});
}
},
error:function () {
layer.msg('参数异常,请重试!', {icon: 6, time: 1000});
}
}
)

View File

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="h-ui/css/H-ui.min.css" />
<title>返利活动档位配置</title>
</head>
<body>
<div>
充值下限 <input type="number" id="beforeNum" placeholder="" value="" class="input-text"/>
> 充值上限 <input type="number" id="afterNum" placeholder="" value="" class="input-text"/>
> 返利百分比 <input type="number" id="backRatio" placeholder="" value="" class="input-text"/>
</div>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="h-ui/css/H-ui.min.css" />
<title>通用档位配置</title>
</head>
<body class="f-14 c-666">
<div>
充值额度 > <input type="number" id="rechargeValue" placeholder="" value="" class="input-text"/>
</div>
</body>
</html>

View File

@ -243,9 +243,8 @@
document.getElementById("startTime").value = activity.startTime.replace(" ","T");//赋初始值
document.getElementById("endTime").value = activity.endTime.replace(" ","T");//赋初始值
}
// 类型
typeInfos.update({ disabled: false });
typeInfos.update({ disabled: true });
}
});