兑换码

master
zhangshanxue 2019-09-12 17:32:44 +08:00
parent 7fcecdc205
commit 29360c92bc
11 changed files with 140 additions and 74 deletions

View File

@ -2,6 +2,7 @@ package com.jmfy.controller;
import com.jmfy.dao.CdkInfoDao;
import com.jmfy.dao.UserInfoDao;
import com.jmfy.dao.impl.GSUserDaoImpl;
import com.jmfy.model.*;
import com.jmfy.model.vo.CDKInfoVo;
import com.jmfy.model.vo.UseCDKInfoVo;
@ -22,18 +23,18 @@ import javax.servlet.http.HttpSession;
import java.io.*;
import java.util.*;
/**
* Created by huangds on 2017/10/24.
*/
@Controller
public class CdkInfoController {
@Resource
private CdkInfoDao cdkInfoDao;
@Resource
private UserInfoDao userInfoDao;
private GSUserDaoImpl gsUserDao;
@Resource
private SeqUtils seqUtils;
/**
*
*/
@RequestMapping(value = "/addCdkNumber", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody int addCdkNumber(HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
@ -51,7 +52,7 @@ public class CdkInfoController {
}
for (int i = 0; i < scdkInfo.getGoodsSum(); i++) {
long nowTime = System.currentTimeMillis();
String sdk = "YSJCDK" + goodsId + nowTime + UUID.randomUUID().toString();
String sdk = "JLCDK" + goodsId + nowTime + UUID.randomUUID().toString();
String id = MD5Util.encrypByMd5(sdk);
CdkInfo cdkInfo = new CdkInfo();
cdkInfo.setId(id);
@ -63,6 +64,7 @@ public class CdkInfoController {
cdkInfoDao.updateCdkGoodsInfo(scdkInfo,goodsId);
return 0;
}
@RequestMapping(value = "/findCdkInfo", method = {RequestMethod.POST, RequestMethod.GET})
public String findCdkInfo (HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
@ -70,11 +72,11 @@ public class CdkInfoController {
String cdkNum = parameterMap.get("cdkNum");
CdkInfo cdkInfo = cdkInfoDao.findCdkInfoBuyId(cdkNum);
if (cdkInfo == null){
return "404";
return "useCDKinfo";
}
SCdkInfo scdkInfo = cdkInfoDao.getScdkInfo(cdkInfo.getGoodsId());
if (scdkInfo == null){
return "404";
return "useCDKinfo";
}
List<CdkUseInfo> cdkUseInfoList = cdkInfoDao.findCdkUseInfoById(serverId,cdkNum);
List<UseCDKInfoVo> useCDKInfoVoList = new ArrayList<>();
@ -82,10 +84,9 @@ public class CdkInfoController {
UseCDKInfoVo useCDKInfoVo = new UseCDKInfoVo();
useCDKInfoVo.setIsData(1);
useCDKInfoVo.setUserId(cdkUseInfo.getUid());
CUser cUser = userInfoDao.findCuserInfo(cdkUseInfo.getServerId(), cdkUseInfo.getUid());
useCDKInfoVo.setUserName(cUser.getUserName());
CUserInfo cUserInfo = userInfoDao.findUserInfoByUserId(cdkUseInfo.getUid());
useCDKInfoVo.setOpenId(cUserInfo.getOpenId());
GSUser gsUser = gsUserDao.findUserInfo(cdkUseInfo.getServerId(), cdkUseInfo.getUid());
useCDKInfoVo.setUserName(gsUser.getPlayerManager().getNickName());
useCDKInfoVo.setOpenId(gsUser.getPlayerManager().getOpenId());
useCDKInfoVo.setGoodsName(scdkInfo.getGoodsName());
useCDKInfoVo.setUseTime(JsonUtil.timeStamp2Date(String.valueOf(cdkUseInfo.getCreateTime())));
useCDKInfoVoList.add(useCDKInfoVo);
@ -93,6 +94,10 @@ public class CdkInfoController {
map.put("useCDKinfo",useCDKInfoVoList);
return "useCDKinfo";
}
/**
*
*/
@RequestMapping(value = "/toCDKBuild", method = {RequestMethod.POST, RequestMethod.GET})
public String toCDKBuild (HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
List<SCdkInfo> sCdkInfoList = cdkInfoDao.getScdkInfoList();
@ -108,22 +113,15 @@ public class CdkInfoController {
cdkInfoVo.setGoodsNum(sCdkInfo.getGoodsSum());
long useNum = cdkInfoDao.getUseCdkNumByGoodsId(sCdkInfo.getId());
cdkInfoVo.setUseNum(useNum);
cdkInfoVo.setType(getUsetype(sCdkInfo));
cdkInfoVo.setType(String.valueOf(sCdkInfo.getUsetype()));
cdkInfoVo.setPid(sCdkInfo.getPid());
cdkInfoVo.setRoleUseNum(sCdkInfo.getRoleUseNum());
sCdkInfoListVo.add(cdkInfoVo);
}
map.put("sCdkInfoList",sCdkInfoListVo);
return "CDKBuild";
}
private String getUsetype(SCdkInfo sCdkInfo) {
String type = "C";
if (sCdkInfo.getUsetype() ==0){
type = "A";
}else if (sCdkInfo.getUsetype() ==1){
type = "B";
}
return type ;
}
@RequestMapping(value = "/downloadFile", method = {RequestMethod.POST, RequestMethod.GET})
public ResponseEntity<byte[]> downloadFile (HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
@ -146,9 +144,15 @@ public class CdkInfoController {
File file = new File(path);
return TXTUtils.buildResponseEntity(file);
}
/**
*
*/
@RequestMapping(value = "/addCdkGoodsInfo", method = {RequestMethod.POST, RequestMethod.GET})
public String addCdkGoodsInfo(HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
String pid = parameterMap.get("pid");
String roleUseNum = parameterMap.get("roleUseNum");
String goodsName = parameterMap.get("goodsName");
String addType = parameterMap.get("addType");
String goodsNum = parameterMap.get("goodsNum");
@ -169,6 +173,8 @@ public class CdkInfoController {
sCdkInfo.setStartTime(Long.parseLong(startTime));
sCdkInfo.setEndTime(Long.parseLong(endTime));
sCdkInfo.setIsAdd(0);
sCdkInfo.setPid(Integer.parseInt(pid));
sCdkInfo.setRoleUseNum(Integer.parseInt(roleUseNum));
cdkInfoDao.addCDKGoodsInfo(sCdkInfo);
return "redirect:/toCDKBuild";
}

View File

@ -72,13 +72,13 @@ public class GameTitleController {
@RequestMapping(value = "/backC", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody int backC(HttpSession session, ModelMap map , HttpServletRequest request) {
try {
// JSONObject jsonObject;
// HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
// String jsonString = JSON.toJSONString(parameterMap);
// jsonObject = JSON.parseObject(jsonString);
// BaseHandler handler = ManagerManager.getInstance().getBaseHandler("gm");
// int result = handler.execute(jsonObject);
return 1;
JSONObject jsonObject;
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
String jsonString = JSON.toJSONString(parameterMap);
jsonObject = JSON.parseObject(jsonString);
BaseHandler handler = ManagerManager.getInstance().getBaseHandler("gm");
int result = handler.execute(jsonObject);
return result;
} catch (Exception e) {
return 0;
}

View File

@ -40,8 +40,7 @@ public class QuestionController {
private static final DateFormat ymdhmsFormat_new = new SimpleDateFormat("yyyyMMddHHmm");
@RequestMapping(value = "/updataQuest", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody
int sendNotice(HttpSession session, HttpServletRequest request) throws Exception {
public @ResponseBody int sendNotice(HttpSession session, HttpServletRequest request) throws Exception {
List<ServerInfo> allServerInfo = serverInfoDao.getAllServerInfo();
List<String> serverList = new ArrayList<>();
@ -112,18 +111,14 @@ public class QuestionController {
return null;
}
for (int i = 0; i < questions.length; i++) {
if (questiontype[i].equals("2")) {
continue;
} else {
int j = i + 1;
String index = "questiontype_" + j + "_select";
CQuestionOptionBean cQuestionOptionBean = new CQuestionOptionBean();
cQuestionOptionBean.setType(Integer.valueOf(questiontype[i]));
cQuestionOptionBean.setAnswerType(Integer.valueOf(answertype[i]));
cQuestionOptionBean.setContent(questions[i]);
cQuestionOptionBean.setOptions(paramMap.get(index));
cQuestion.getcQuestionOptionBeans().add(cQuestionOptionBean);
}
int j = i + 1;
String index = "questiontype_" + j + "_select";
CQuestionOptionBean cQuestionOptionBean = new CQuestionOptionBean();
cQuestionOptionBean.setType(Integer.valueOf(questiontype[i]));
cQuestionOptionBean.setAnswerType(Integer.valueOf(answertype[i]));
cQuestionOptionBean.setContent(questions[i]);
cQuestionOptionBean.setOptions(paramMap.get(index));
cQuestion.getcQuestionOptionBeans().add(cQuestionOptionBean);
}
return cQuestion;
}

View File

@ -9,13 +9,18 @@ public class SCdkInfo {
@Id
private int id; //所属的商品id
/**
* 0:
* 1:
* 2: 使
* 0:
* 1:
*/
@Field(value = "usetype")
private int usetype;
@Field(value = "pid")
private int pid;
@Field(value = "role_use_num")
private int roleUseNum;
@Field(value = "start_time")
private long startTime;
@ -44,6 +49,7 @@ public class SCdkInfo {
public void setId(int id) {
this.id = id;
}
public int getUsetype() {
return usetype;
}
@ -107,5 +113,21 @@ public class SCdkInfo {
public void setIsAdd(int isAdd) {
this.isAdd = isAdd;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public int getRoleUseNum() {
return roleUseNum;
}
public void setRoleUseNum(int roleUseNum) {
this.roleUseNum = roleUseNum;
}
}

View File

@ -18,6 +18,10 @@ public class CDKInfoVo {
public String type ; // 类型
public long roleUseNum ; // 被使用数量
public int pid ; // pid
public void setId(int id) {
this.id = id;
}
@ -49,4 +53,12 @@ public class CDKInfoVo {
public void setType(String type) {
this.type = type;
}
public void setPid(int pid) {
this.pid = pid;
}
public void setRoleUseNum(long roleUseNum) {
this.roleUseNum = roleUseNum;
}
}

View File

@ -51,18 +51,18 @@ public class JsonUtil {
StringBuilder reward = new StringBuilder();
String[] itemIds = request.getParameterValues("itemIds[]");
String[] itemNums = request.getParameterValues("itemNums[]");
String[] itemTypes = request.getParameterValues("itemTypes[]");
if (itemIds.length ==0 || itemNums.length ==0 || itemTypes.length ==0){
if (itemIds.length ==0 || itemNums.length ==0 ){
return reward.toString();
}
for (int i = 0; i < itemIds.length; i++){
if (itemIds[i].isEmpty() || itemNums[i].isEmpty() || itemTypes[i].isEmpty()){
if (itemIds[i].isEmpty() || itemNums[i].isEmpty()){
return reward.toString();
}
if (reward.length() == 0){
reward = new StringBuilder(itemIds[i] + "#" + itemNums[i] + "#" + itemTypes[i]);
reward = new StringBuilder(itemIds[i] + "#" + itemNums[i] );
}else{
reward.append("|").append(itemIds[i]).append("#").append(itemNums[i]).append("#").append(itemTypes[i]);
reward.append("|").append(itemIds[i]).append("#").append(itemNums[i]).append("#");
}
}
return reward.toString();

View File

@ -11,7 +11,7 @@ spring.data.gameMongodb.uri = mongodb://60.1.1.14:27017
# redis config
spring.redis.database=13
spring.redis.database=0
spring.redis.host = 60.1.1.21
spring.redis.port = 6379
spring.redis.password =

View File

@ -36,7 +36,7 @@
</nav>
<div class="page-container">
<form class="form form-horizontal" id="form-article-add" action="/publishMSG" method="post" target="updataQuest"
<form class="form form-horizontal" id="form-article-add" action="/publishMSG" method="post" target="updataMSGQuest"
onsubmit="return sendCheck()">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
@ -68,7 +68,7 @@
</div>
</div>
</form>
<iframe name='updataQuest' id="updataQuest" style='display: none'></iframe>
<iframe name='updataMSGQuest' id="updataMSGQuest" style='display: none'></iframe>
</div>
@ -95,7 +95,7 @@ $(function(){
});
});
$('#updataQuest').load(function () {
$('#updataMSGQuest').load(function () {
// 根据后台返回值处理结果
var text=$(this).contents().find("body").text();
if (text != 0) {

View File

@ -36,7 +36,7 @@
</nav>
<div class="page-container">
<form class="form form-horizontal" id="form-article-add" action="/publishNotice" method="post" target="updataQuest"
<form class="form form-horizontal" id="form-article-add" action="/publishNotice" method="post" target="updataSYSQuest"
onsubmit="return sendCheck()">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
@ -68,7 +68,7 @@
</div>
</div>
</form>
<iframe name='updataQuest' id="updataQuest" style='display: none'></iframe>
<iframe name='updataSYSQuest' id="updataSYSQuest" style='display: none'></iframe>
</div>
@ -95,7 +95,7 @@ $(function(){
});
});
$('#updataQuest').load(function () {
$('#updataSYSQuest').load(function () {
// 根据后台返回值处理结果
var text=$(this).contents().find("body").text();
if (text != 0) {

View File

@ -39,6 +39,7 @@
<div class="tabBar cl">
<span>序列号礼包生成</span>
</div>
<div class="tabCon">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
@ -52,24 +53,52 @@
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
生成类型</label>
渠道id</label>
<div class="formControls col-xs-8 col-sm-9">
<select name="addType" class="input-text" id="contentType"><!--下拉列表-->
<option value="0" selected = "selected">A(同一批禮包序號,同角色不可重複兌換。每組序號限兌換一次)</option>
<option value="1" >B(同一批禮包序號,同角色可重複兌換。每組序號限兌換一次)</option>
<option value="2" >C(萬用序號,只出一組序號,可重複使用,每一帳號(一個賬號可能有多個角色)僅限兌換一次)</option>
</select>
<input type="text" name="pid" placeholder="pid" value="" class="input-text"/>
<span class="PID"></span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
礼包数量:</label>
使用属性:</label>
<div class="formControls col-xs-8 col-sm-9">
<select name="addType" class="input-text" id="contentType"><!--下拉列表-->
<option value="0" selected = "selected">不可重复</option>
<option value="1" >可重複使用</option>
</select>
</div>
</div>
<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="text" name="roleUseNum" placeholder="" value="" class="input-text"/>
<span class="ROLEUSENUM"></span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
CDK数量</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="goodsNum" placeholder="" value="" class="input-text"/>
<span class="GOODSNUM"></span>
</div>
</div>
<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="text" name="goodsInfo" placeholder=""class="input-text"/>
<span class="GOODSINFO"></span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
@ -86,15 +115,7 @@
<input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'datemin\')}' })" id="datemax" class="input-text Wdate" style="width:180px;" name="endTime">
</div>
</div>
<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="text" name="goodsInfo" placeholder=""class="input-text"/>
<span class="GOODSINFO"></span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
@ -104,7 +125,6 @@
<div>
物品id:<input type="text" name="itemIds[]" id="itemId_1" style="width: 150px" />
物品数量:<input type="text" name="itemNums[]" id="itemNum_1" style="width: 150px" />
物品类型:<input type="text" name="itemTypes[]" id="itemType_1" style="width: 150px"/>
<a href="#" class="removeclass"></a>
<a href="#" id="AddMoreFileBox" class="btn btn-info">+</a>
<span class="REWARD"></span>
@ -193,6 +213,8 @@ function toaddCDKInfo() {
var startTime = $("input[name='startTime']").val();
var endTime = $("input[name='endTime']").val();
var goodsInfo = $("input[name='goodsInfo']").val();
var pid = $("input[name='pid']").val();
if (goodsName === '' || goodsName == null) {
erroCode.html('<span style="color: red; ">商品名称不能为空!</span>');
return false;
@ -215,6 +237,11 @@ function toaddCDKInfo() {
erroCode = $('.GOODSINFO');
erroCode.html('<span style="color: red; ">商品信息不能为空!</span>');
return false;
}
if (pid === '' || pid == null) {
erroCode = $('.PID');
erroCode.html('<span style="color: red; ">渠道id不能为空!</span>');
return false;
}
return true;
}

View File

@ -34,12 +34,14 @@
<!--<th width="25"><input type="checkbox" name="" value=""/></th>-->
<th width="200">礼包名称</th>
<th width="200">礼包id</th>
<th width="200">pid</th>
<th width="200">礼包数量</th>
<th width="200">开始时间</th>
<th width="200">结束时间</th>
<th width="200">礼包内容</th>
<th width="200">礼包类型</th>
<th width="200">被使用数量</th>
<th width="200">角色使用数量</th>
<th width="200">操作</th>
</tr>
</thead>
@ -48,12 +50,14 @@
<!--<td><input type="checkbox" value="" name=""/></td>-->
<td th:text="${obj.goodsName}" style="text-align: center;"></td>
<td th:text="${obj.id}" style="text-align: center;"></td>
<td th:text="${obj.pid}" style="text-align: center;"></td>
<td th:text="${obj.goodsNum}" style="text-align: center;"></td>
<td th:text="${obj.startTime}" style="text-align: center;"></td>
<td th:text="${obj.endTime}" style="text-align: center;"></td>
<td th:text="${obj.goodsInfo}" style="text-align: center;"></td>
<td th:text="${obj.type}" style="text-align: center;"></td>
<td th:text="${obj.useNum}" style="text-align: center;"></td>
<td th:text="${obj.roleUseNum}" style="text-align: center;"></td>
<td style="text-align: center; width: 300px">
<button type="button" th:id="${obj.id}" class="btn btn-primary" onclick="return cdkAdd(this)"><i class="Hui-iconfont"></i> 序列號生成</button>
<button type="button" th:id="${obj.id}" class="btn btn-success" onclick="return download(this)"><i class="Hui-iconfont"></i> 序列號导出</button>