generated from root/miduo_server
返利道具修改
parent
b6f4d9e703
commit
b687f6363f
|
@ -4,13 +4,14 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.jmfy.dto.CPayOrder;
|
import com.jmfy.dto.CPayOrder;
|
||||||
import com.jmfy.dto.CUserDao;
|
import com.jmfy.dto.CUserDao;
|
||||||
|
import com.jmfy.paramBean.CMail;
|
||||||
import com.jmfy.paramBean.MailCache;
|
import com.jmfy.paramBean.MailCache;
|
||||||
import com.jmfy.paramBean.PaySdkEnum;
|
import com.jmfy.paramBean.PaySdkEnum;
|
||||||
import com.jmfy.redisProperties.RedisUserKey;
|
import com.jmfy.redisProperties.RedisUserKey;
|
||||||
import com.jmfy.util.JsonUtil;
|
import com.jmfy.util.JsonUtil;
|
||||||
import com.jmfy.util.RedisUtil;
|
import com.jmfy.util.RedisUtil;
|
||||||
import com.jmfy.util.ToolUtils;
|
import com.jmfy.util.ToolUtils;
|
||||||
import com.mongodb.util.JSON;
|
import com.jmfy.util.UUIDEnum;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -19,17 +20,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class ItemSendController {
|
public class ItemSendController {
|
||||||
|
@ -116,23 +115,22 @@ public class ItemSendController {
|
||||||
public void sendMail(HashMap<String, String> params) {
|
public void sendMail(HashMap<String, String> params) {
|
||||||
String title = params.get("title");
|
String title = params.get("title");
|
||||||
String content = params.get("content");
|
String content = params.get("content");
|
||||||
String serverId = params.get("sid");
|
|
||||||
String uid = params.get("roleid");
|
String uid = params.get("roleid");
|
||||||
|
int time = (int) (System.currentTimeMillis() / 1000);
|
||||||
Gson gson = new Gson();
|
|
||||||
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
|
||||||
String props = params.get("props");
|
String props = params.get("props");
|
||||||
Map<String, String> item = gson.fromJson(props, type);
|
Gson gson = new Gson();
|
||||||
|
Map<String, String> item = gson.fromJson(props, Map.class);
|
||||||
String reward = ToolUtils.getMailReward(item);
|
String reward = ToolUtils.getMailReward(item);
|
||||||
|
sendMailToRedis(Integer.parseInt(uid), title, content, reward, time, 2592000);
|
||||||
|
}
|
||||||
|
|
||||||
MailCache cache = new MailCache();
|
public static void sendMailToRedis(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime){
|
||||||
cache.setTitle(title);
|
CMail mail = new CMail(uid,title,content,reward,sendTime, mailEffectiveTime,"rebate", 4);
|
||||||
cache.setContent(content);
|
String key = RedisUserKey.MAIL_REWARD_MARK + ":" + uid;
|
||||||
cache.setReward(reward);
|
String timeKey = String.valueOf(System.currentTimeMillis() + UUIDEnum.MAIL.getValue());
|
||||||
cache.setTime((int)System.currentTimeMillis()/1000);
|
// 有新邮件就增加30天的有效时间
|
||||||
cache.setValidTime((int)(ToolUtils.ONE_DAY * 30 / 1000));
|
RedisUtil.getInstence().putMapEntry(RedisUserKey.MAIL_REWARD_MARK, String.valueOf(uid), timeKey, mail, mailEffectiveTime);
|
||||||
LOGGER.info("返利邮件,标题:{},内容:{}, 奖励:{}, 服务器ID: {}, UID: {}", title, content, reward, serverId, uid);
|
LOGGER.info("redis返利邮件标记:key:{}, time:{}, mail:{}",key,timeKey,mail);
|
||||||
RedisUtil.getInstence().putMapEntry(serverId, RedisUserKey.READY_TO_USER_MAIL, String.valueOf(uid), cache, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkSignature(Map<String, String> map) {
|
public boolean checkSignature(Map<String, String> map) {
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
package com.jmfy.paramBean;
|
||||||
|
|
||||||
|
import com.jmfy.util.ToolUtils;
|
||||||
|
import com.jmfy.util.UUIDEnum;
|
||||||
|
|
||||||
|
public class CMail {
|
||||||
|
|
||||||
|
private String id ;
|
||||||
|
|
||||||
|
private int roleUid; //所属玩家的UID
|
||||||
|
|
||||||
|
private int state;//0:未读 1:已读取 2: 未领取 3 已领取
|
||||||
|
|
||||||
|
private String head; //标题
|
||||||
|
|
||||||
|
private String content;//邮件内容
|
||||||
|
|
||||||
|
private String mailItem;//获取所有的附件
|
||||||
|
|
||||||
|
private int sendTime; //发送时间
|
||||||
|
|
||||||
|
private int effectiveTime;//有效时间(s) 0 永久有效
|
||||||
|
|
||||||
|
private String sendName;//发送者名字
|
||||||
|
|
||||||
|
private long noUseDeleteTime;//已读或已领取邮件删除时间
|
||||||
|
|
||||||
|
private int mailType; //邮件类型 1:系统邮件 2:idip 业务邮件
|
||||||
|
|
||||||
|
private int isTop;//0不置顶 1置顶
|
||||||
|
|
||||||
|
private int markType;//0无类型 1:站内信
|
||||||
|
|
||||||
|
|
||||||
|
public CMail(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 详细注释去游戏服mail类查询
|
||||||
|
public CMail(int uid, String head, String content, String mailItem, int sendTime, int effectiveTime, String sendName, int mailType){
|
||||||
|
this.id = ToolUtils.produceIdByModuleNew(UUIDEnum.MAIL, uid);
|
||||||
|
this.roleUid = uid;
|
||||||
|
this.state = 0;
|
||||||
|
this.head = head;
|
||||||
|
this.content = content;
|
||||||
|
this.mailItem = mailItem;
|
||||||
|
this.sendTime = sendTime;
|
||||||
|
this.effectiveTime = effectiveTime ;
|
||||||
|
this.sendName = sendName ;
|
||||||
|
this.mailType = mailType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRoleUid() {
|
||||||
|
return roleUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHead() {
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMailItem() {
|
||||||
|
return mailItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSendTime() {
|
||||||
|
return sendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEffectiveTime() {
|
||||||
|
return effectiveTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSendName() {
|
||||||
|
return sendName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMailType() {
|
||||||
|
return mailType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMailItem(String mailItem) {
|
||||||
|
this.mailItem = mailItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getNoUseDeleteTime() {
|
||||||
|
return noUseDeleteTime;
|
||||||
|
}
|
||||||
|
public void setNoUseDeleteTime(long noUseDeleteTime) {
|
||||||
|
this.noUseDeleteTime = noUseDeleteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsTop() {
|
||||||
|
return isTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsTop(int isTop) {
|
||||||
|
this.isTop = isTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarkType() {
|
||||||
|
return markType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkType(int markType) {
|
||||||
|
this.markType = markType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Mail{" +
|
||||||
|
"id='" + id + '\'' +
|
||||||
|
", roleUid=" + roleUid +
|
||||||
|
", state=" + state +
|
||||||
|
", head='" + head + '\'' +
|
||||||
|
", content='" + content + '\'' +
|
||||||
|
", mailItem='" + mailItem + '\'' +
|
||||||
|
", sendTime=" + sendTime +
|
||||||
|
", effectiveTime=" + effectiveTime +
|
||||||
|
", sendName='" + sendName + '\'' +
|
||||||
|
", noUseDeleteTime=" + noUseDeleteTime +
|
||||||
|
", mailType=" + mailType +
|
||||||
|
", isTop=" + isTop +
|
||||||
|
", markType=" + markType +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,4 +9,7 @@ public class RedisUserKey {
|
||||||
public final static String C_PAYORDER_MAP = "C_PAYORDER_MAP";
|
public final static String C_PAYORDER_MAP = "C_PAYORDER_MAP";
|
||||||
public static final String READY_TO_USER_MAIL = "READY_TO_USER_MAIL";
|
public static final String READY_TO_USER_MAIL = "READY_TO_USER_MAIL";
|
||||||
public static final String REBATES_ORDER = "rebates_order";
|
public static final String REBATES_ORDER = "rebates_order";
|
||||||
|
public static final String UUID_KEY = "UUID_KEY";//唯一key
|
||||||
|
public static final String MAIL_REWARD_MARK = "MAIL_REWARD_MARK";// 邮件奖励
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,20 @@ public class RedisUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long increment(String key) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
|
return oldRedisObjectTemplate.opsForValue().increment(key, 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(2);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
LOGGER.error("sleep->msg=null",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void delHash(String type, int key, String mapId) {
|
public void delHash(String type, int key, String mapId) {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.jmfy.util;
|
package com.jmfy.util;
|
||||||
|
|
||||||
|
import com.jmfy.paramBean.PaySdkEnum;
|
||||||
|
import com.jmfy.redisProperties.RedisUserKey;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -28,6 +31,15 @@ public class ToolUtils {
|
||||||
return reward.toString();
|
return reward.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized static String produceIdByModuleNew(UUIDEnum uuidEnum, int userId){
|
||||||
|
StringBuilder stringBuffer = new StringBuilder();
|
||||||
|
stringBuffer.append(userId);
|
||||||
|
stringBuffer.append(uuidEnum.getValue());
|
||||||
|
stringBuffer.append(System.currentTimeMillis());
|
||||||
|
stringBuffer.append(RedisUtil.getInstence().increment(RedisUserKey.UUID_KEY));
|
||||||
|
return stringBuffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取时间戳
|
* 获取时间戳
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.jmfy.util;
|
||||||
|
|
||||||
|
public enum UUIDEnum {
|
||||||
|
MAIL(101),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
UUIDEnum(int value ){
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue