generated from root/miduo_server
自定义礼包码
parent
7553259e95
commit
63696f08c1
|
|
@ -35,6 +35,7 @@ public class CdkInfoController {
|
|||
@Resource
|
||||
private ServerInfoDao serverInfoDao;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@RequestMapping(value = "/toAddCDKGoodsPage",method = RequestMethod.GET)
|
||||
public String toAddCDKGoodsPage(ModelMap map){
|
||||
Map<Integer, String> itemNameMap = FileCacheUtils.itemNameMap;
|
||||
|
|
@ -51,7 +52,7 @@ public class CdkInfoController {
|
|||
* 生成序列号
|
||||
*/
|
||||
@RequestMapping(value = "/addCdkNumber", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody int addCdkNumber(HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
|
||||
public @ResponseBody int addCdkNumber(HttpServletRequest request) throws Exception {
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
int goodsId = Integer.parseInt(parameterMap.get("goodsId"));
|
||||
SCdkInfo scdkInfo = cdkInfoDao.getScdkInfo(goodsId);
|
||||
|
|
@ -59,25 +60,34 @@ public class CdkInfoController {
|
|||
return 1;
|
||||
}
|
||||
long time = System.currentTimeMillis();
|
||||
if (scdkInfo.getIsAdd() ==1){
|
||||
if (scdkInfo.getIsAdd() == 1){
|
||||
return 3;
|
||||
}
|
||||
if (scdkInfo.getStartTime() > time || scdkInfo.getEndTime() < time) {
|
||||
return 2;
|
||||
}
|
||||
for (int i = 0; i < scdkInfo.getGoodsSum(); i++) {
|
||||
long nowTime = System.currentTimeMillis();
|
||||
String sdk = "JLCDK" + goodsId + nowTime + UUID.randomUUID().toString();
|
||||
String id = MD5Util.encrypByMd5(sdk);
|
||||
// 自定义礼包码生成
|
||||
if (!"".equals(scdkInfo.getCustomGood())){
|
||||
CdkInfo cdkInfo = new CdkInfo();
|
||||
cdkInfo.setId(id);
|
||||
cdkInfo.setId(scdkInfo.getCustomGood());
|
||||
cdkInfo.setGoodsId(goodsId);
|
||||
cdkInfo.setStatus(0);
|
||||
cdkInfo.setServerId(scdkInfo.getServerId());
|
||||
cdkInfoDao.addCdkInfo(cdkInfo);
|
||||
}
|
||||
//scdkInfo.setIsAdd(1);
|
||||
cdkInfoDao.updateCdkGoodsInfo(scdkInfo,goodsId);
|
||||
// 随机礼包码生成
|
||||
else {
|
||||
for (int i = 0; i < scdkInfo.getGoodsSum(); i++) {
|
||||
String sdk = "JLCDK" + goodsId + DateUtil.now() + UUID.randomUUID().toString();
|
||||
String id = MD5Util.encrypByMd5(sdk);
|
||||
CdkInfo cdkInfo = new CdkInfo();
|
||||
cdkInfo.setId(id);
|
||||
cdkInfo.setGoodsId(goodsId);
|
||||
cdkInfo.setStatus(0);
|
||||
cdkInfo.setServerId(scdkInfo.getServerId());
|
||||
cdkInfoDao.addCdkInfo(cdkInfo);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -85,8 +95,9 @@ public class CdkInfoController {
|
|||
public @ResponseBody int deleteCdkNumber(ModelMap map,int goodsId) throws Exception {
|
||||
return cdkInfoDao.deleteCdk(goodsId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findCdkInfo", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String findCdkInfo (HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
|
||||
public String findCdkInfo (ModelMap map , HttpServletRequest request) throws Exception {
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
int serverId = Integer.parseInt(parameterMap.get("serverId"));
|
||||
String cdkNum = parameterMap.get("cdkNum");
|
||||
|
|
@ -119,7 +130,7 @@ public class CdkInfoController {
|
|||
* 礼包信息
|
||||
*/
|
||||
@RequestMapping(value = "/toCDKBuild", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String toCDKBuild (HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
|
||||
public String toCDKBuild (ModelMap map) throws Exception {
|
||||
List<SCdkInfo> sCdkInfoList = cdkInfoDao.getScdkInfoList();
|
||||
List<CDKInfoVo> sCdkInfoListVo = new ArrayList<>();
|
||||
for (SCdkInfo sCdkInfo :sCdkInfoList){
|
||||
|
|
@ -129,9 +140,8 @@ public class CdkInfoController {
|
|||
cdkInfoVo.setGoodsInfo(sCdkInfo.getGoodsInfo());
|
||||
cdkInfoVo.setStartTime(JsonUtil.timeStamp2Date(String.valueOf(sCdkInfo.getStartTime())));
|
||||
cdkInfoVo.setEndTime(JsonUtil.timeStamp2Date(String.valueOf(sCdkInfo.getEndTime())));
|
||||
// long goodsNum = cdkInfoDao.getCdkNumByGoodsId(sCdkInfo.getId());
|
||||
cdkInfoVo.setGoodsNum(sCdkInfo.getGoodsSum());
|
||||
long useNum = cdkInfoDao.getUseCdkNumByGoodsId(sCdkInfo.getId());
|
||||
long useNum = cdkInfoDao.getUseCdkNumByGoodsId(sCdkInfo.getId());
|
||||
cdkInfoVo.setUseNum(useNum);
|
||||
cdkInfoVo.setType(String.valueOf(sCdkInfo.getUsetype()));
|
||||
cdkInfoVo.setPid(sCdkInfo.getPid());
|
||||
|
|
@ -146,18 +156,19 @@ public class CdkInfoController {
|
|||
|
||||
|
||||
@RequestMapping(value = "/downloadFile", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public ResponseEntity<byte[]> downloadFile (HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
public ResponseEntity<byte[]> downloadFile (HttpServletRequest request) throws Exception {
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
int goodsId = Integer.parseInt(parameterMap.get("goodsId"));
|
||||
String osName = System.getProperty("os.name");
|
||||
String path;
|
||||
if (osName.matches("^(?i)Windows.*$")) {// Window 系统
|
||||
if (osName.matches("^(?i)Windows.*$")) {
|
||||
// Window 系统
|
||||
path = "conf/txt/";
|
||||
} else {// Linux 系统
|
||||
path = "./config/txt/";
|
||||
}
|
||||
List<CdkInfo> cdkInfoList = cdkInfoDao.findCdkUseInfoByGoodsId(goodsId);
|
||||
path = path + "cdk_"+goodsId + System.currentTimeMillis()+"_.txt";
|
||||
path = path + "cdk_" + goodsId + "_" + DateUtil.now() +"_.txt";
|
||||
List<String> cdkNumList = new ArrayList<>();
|
||||
for (CdkInfo cdkInfo :cdkInfoList){
|
||||
cdkNumList.add(cdkInfo.getId());
|
||||
|
|
@ -171,7 +182,7 @@ public class CdkInfoController {
|
|||
* 生成礼包
|
||||
*/
|
||||
@RequestMapping(value = "/addCdkGoodsInfo", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String addCdkGoodsInfo(HttpSession session, ModelMap map , HttpServletRequest request) throws Exception {
|
||||
public String addCdkGoodsInfo(HttpServletRequest request) throws Exception {
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
String pid = parameterMap.get("pid");
|
||||
String roleUseNum = parameterMap.get("roleUseNum");
|
||||
|
|
@ -181,10 +192,19 @@ public class CdkInfoController {
|
|||
String startTime = JsonUtil.date3TimeStamp(parameterMap.get("startTime"));
|
||||
String endTime = JsonUtil.date3TimeStamp(parameterMap.get("endTime"));
|
||||
String goodsInfo = parameterMap.get("goodsInfo");
|
||||
String reward = JsonUtil.getInstence().getReward(request);
|
||||
String serverId = parameterMap.get("serverId");
|
||||
|
||||
String reward = JsonUtil.getInstence().getReward(request);
|
||||
if (reward.isEmpty()){
|
||||
throw new Exception("item erro !!!");
|
||||
throw new Exception("item error !!!");
|
||||
}
|
||||
|
||||
String customGood = parameterMap.get("customGood");
|
||||
if (!"".equals(customGood)){
|
||||
CdkInfo info = cdkInfoDao.findCdkInfoBuyId(customGood);
|
||||
if (info != null){
|
||||
throw new Exception("error customGood is exist !!!");
|
||||
}
|
||||
}
|
||||
SCdkInfo sCdkInfo = new SCdkInfo();
|
||||
sCdkInfo.setId(seqUtils.getSequence("cdk_goods_id"));
|
||||
|
|
@ -200,6 +220,7 @@ public class CdkInfoController {
|
|||
sCdkInfo.setRoleUseNum(Integer.parseInt(roleUseNum));
|
||||
sCdkInfo.setServerId(Integer.parseInt(serverId));
|
||||
sCdkInfo.setBuildTime(Calendar.getInstance().getTime().getTime());
|
||||
sCdkInfo.setCustomGood(customGood);
|
||||
cdkInfoDao.addCDKGoodsInfo(sCdkInfo);
|
||||
return "redirect:/toCDKBuild";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,11 @@ import java.util.Date;
|
|||
|
||||
@Document(collection = "cdk_add_info")
|
||||
public class SCdkInfo {
|
||||
/**
|
||||
* 所属的商品id
|
||||
*/
|
||||
@Id
|
||||
private int id; //所属的商品id
|
||||
private int id;
|
||||
/**
|
||||
* 0:兌換一次。
|
||||
* 1:兌換多次。
|
||||
|
|
@ -41,13 +44,19 @@ public class SCdkInfo {
|
|||
@Field(value = "goods_sum")
|
||||
private int goodsSum;
|
||||
|
||||
/**
|
||||
* 1: 已生成过 ,0: 未生成过
|
||||
*/
|
||||
@Field(value = "isAdd")
|
||||
private int isAdd; // 1: 已生成过 ,0: 未生成过
|
||||
private int isAdd;
|
||||
|
||||
@Field(value = "serverId")
|
||||
private int serverId;
|
||||
@Field(value = "buildTime")
|
||||
private long buildTime;
|
||||
@Field(value = "customGood")
|
||||
private String customGood;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -151,5 +160,13 @@ public class SCdkInfo {
|
|||
public void setBuildTime(long buildTime) {
|
||||
this.buildTime = buildTime;
|
||||
}
|
||||
|
||||
public String getCustomGood() {
|
||||
return customGood;
|
||||
}
|
||||
|
||||
public void setCustomGood(String customGood) {
|
||||
this.customGood = customGood;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<!--_meta 作为公共模版分离出去-->
|
||||
<!DOCTYPE HTML>
|
||||
<!--suppress EqualityComparisonWithCoercionJS -->
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
|
|
@ -42,6 +43,15 @@
|
|||
</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="text" name="customGood" placeholder="不填写默认随机生成" value="" class="input-text"/>
|
||||
<span class="CUSTOMGOOD"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
|
|
@ -117,6 +127,7 @@
|
|||
开始时间:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'datemin\')}' })" id="datemin" class="input-text Wdate" style="width:180px;" name="startTime">
|
||||
<span class="STARTTIME"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
|
|
@ -125,6 +136,7 @@
|
|||
结束时间:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<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">
|
||||
<span class="ENDTIME"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -235,6 +247,7 @@ $(document).ready(function() {
|
|||
})
|
||||
|
||||
});
|
||||
|
||||
function toaddCDKInfo() {
|
||||
var erroCode = $('.GOODSNAME');
|
||||
var goodsName = $("input[name='goodsName']").val();
|
||||
|
|
@ -242,9 +255,25 @@ function toaddCDKInfo() {
|
|||
var startTime = $("input[name='startTime']").val();
|
||||
var endTime = $("input[name='endTime']").val();
|
||||
var goodsInfo = $("input[name='goodsInfo']").val();
|
||||
var serverId = $("input[name='serverId']").val();
|
||||
var pid = $("input[name='pid']").val();
|
||||
var customGood = $("input[name='customGood']").val();
|
||||
var roleUseNum = $("input[name='roleUseNum']").val();
|
||||
|
||||
if (customGood != "" && customGood.length < 6) {
|
||||
erroCode = $('.CUSTOMGOOD');
|
||||
erroCode.html('<span style="color: red; ">自定义礼包码长度不能小于6!</span>');
|
||||
return false;
|
||||
}
|
||||
if (customGood != "" && goodsNum != 1) {
|
||||
erroCode = $('.CUSTOMGOOD');
|
||||
erroCode.html('<span style="color: red; ">创建自定义礼包码,礼包码数量之只能为1!</span>');
|
||||
return false;
|
||||
}
|
||||
if (customGood != "" && roleUseNum != 1) {
|
||||
erroCode = $('.CUSTOMGOOD');
|
||||
erroCode.html('<span style="color: red; ">创建自定义礼包码,单个玩家使用次数必须为1</span>');
|
||||
return false;
|
||||
}
|
||||
if (goodsName === '' || goodsName == null) {
|
||||
erroCode.html('<span style="color: red; ">商品名称不能为空!</span>');
|
||||
return false;
|
||||
|
|
@ -254,7 +283,7 @@ function toaddCDKInfo() {
|
|||
return false;
|
||||
}
|
||||
if (startTime === '' || startTime == null) {
|
||||
erroCode = $('.GOODSNUM');
|
||||
erroCode = $('.STARTTIME');
|
||||
erroCode.html('<span style="color: red; ">开始时间不能为空!</span>');
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue