| | |
| | | import java.io.BufferedReader;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.security.SignatureException;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | if (!StringUtil.isNullOrEmpty(orderNo)) {
|
| | | BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderNo);
|
| | | if (order != null) {// 支付成功消息推送
|
| | | BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid());
|
| | | BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid(),
|
| | | new BigDecimal(map.get("total_fee")).multiply(new BigDecimal("0.01")));
|
| | | Message message = new Message(MQTopicName.TOPIC_ORDER.name(),
|
| | | OrderTopicTagEnum.banLiShopOrderPaid.name(), new Gson().toJson(msg).getBytes());
|
| | | producer.send(message);
|
New file |
| | |
| | | /OrderAdminController.java |
| | |
| | | package com.yeshi.fanli.dto.mq.order.body;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | public class BanLiShopOrderMQMsg extends BaseMQMsgBody {
|
| | | private Long orderId;// 订单ID
|
| | | private Long uid;// 用户ID
|
| | | private BigDecimal money;// 付款金额
|
| | |
|
| | | public BigDecimal getMoney() {
|
| | | return money;
|
| | | }
|
| | |
|
| | | public void setMoney(BigDecimal money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public BanLiShopOrderMQMsg(Long orderId, Long uid) {
|
| | | super();
|
| | |
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BanLiShopOrderMQMsg(Long orderId, Long uid, BigDecimal money) {
|
| | | this.money = money;
|
| | | this.orderId = orderId;
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public BanLiShopOrderMQMsg() {
|
| | | super();
|
| | | }
|
| | |
| | | package com.yeshi.fanli.dto.mq.user;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserRegisterMQMsg;
|
| | | import com.yeshi.fanli.util.annotation.UserActive;
|
| | |
|
| | | public enum UserTopicTagEnum {
|
| | | userAccountBinding(UserActive.class), // 用户账号绑定
|
| | | userAccountBinding(UserAccountBindingMQMsg.class), // 用户账号绑定
|
| | | userActve(UserActive.class), // 用户活跃
|
| | | useSystemCoupon(UserActive.class), // 系统券使用
|
| | | inviteSuccess(UserActive.class), // 邀请成功
|
| | | integralTaskFinish(UserActive.class);// 完成金币任务
|
| | | inviteSuccess(UserInviteMQMsg.class), // 邀请成功
|
| | | integralTaskFinish(IntegralTaskMQMsg.class), // 完成金币任务
|
| | | userRegister(UserRegisterMQMsg.class);// 用户注册
|
| | | |
| | | |
| | |
|
| | | private final Class<?> clazz;
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 金币任务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class IntegralTaskMQMsg extends BaseMQMsgBody {
|
| | |
|
| | | public IntegralTaskMQMsg(Long uid, long longegralCount, Date createTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.longegralCount = longegralCount;
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public IntegralTaskMQMsg() {
|
| | | super();
|
| | | }
|
| | |
|
| | | private Long uid;// 用户ID
|
| | | private long longegralCount;// 金币数量
|
| | | private Date createTime;// 创建时间
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public long getIntegralCount() {
|
| | | return longegralCount;
|
| | | }
|
| | |
|
| | | public void setIntegralCount(long longegralCount) {
|
| | | this.longegralCount = longegralCount;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 账号绑定
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserAccountBindingMQMsg extends BaseMQMsgBody {
|
| | | public static int TYPE_PHONE = 3;
|
| | | public static int TYPE_WX = 2;
|
| | | public static int TYPE_TAOBAO = 1;
|
| | | public static int TYPE_ALIPAY = 4;
|
| | |
|
| | | private Long uid;// 用户ID
|
| | | private Integer type;// 绑定类型
|
| | | private String value;// 绑定的值
|
| | | private Date bindingTime;// 绑定时间
|
| | |
|
| | | public UserAccountBindingMQMsg(Long uid, Integer type, String value, Date bindingTime) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.type = type;
|
| | | this.value = value;
|
| | | this.bindingTime = bindingTime;
|
| | | }
|
| | |
|
| | | public UserAccountBindingMQMsg() {
|
| | | super();
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Integer getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(Integer type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getValue() {
|
| | | return value;
|
| | | }
|
| | |
|
| | | public void setValue(String value) {
|
| | | this.value = value;
|
| | | }
|
| | |
|
| | | public Date getBindingTime() {
|
| | | return bindingTime;
|
| | | }
|
| | |
|
| | | public void setBindingTime(Date bindingTime) {
|
| | | this.bindingTime = bindingTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 邀请信息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserInviteMQMsg extends BaseMQMsgBody {
|
| | | public static int STATE_NOT_SUCCESS = 0;
|
| | | public static int STATE_SUCCESS = 1;
|
| | |
|
| | | private Long bossId;// 上级ID
|
| | | private Long workerId;// 下级ID
|
| | | private Date inviteTime;// 邀请时间
|
| | | private Date successTime;// 成功时间
|
| | | private int state;// 邀请状态
|
| | |
|
| | | public UserInviteMQMsg(Long bossId, Long workerId, Date inviteTime, Date successTime, int state) {
|
| | | super();
|
| | | this.bossId = bossId;
|
| | | this.workerId = workerId;
|
| | | this.inviteTime = inviteTime;
|
| | | this.successTime = successTime;
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | public UserInviteMQMsg() {
|
| | | super();
|
| | | }
|
| | |
|
| | | public Long getBossId() {
|
| | | return bossId;
|
| | | }
|
| | |
|
| | | public void setBossId(Long bossId) {
|
| | | this.bossId = bossId;
|
| | | }
|
| | |
|
| | | public Long getWorkerId() {
|
| | | return workerId;
|
| | | }
|
| | |
|
| | | public void setWorkerId(Long workerId) {
|
| | | this.workerId = workerId;
|
| | | }
|
| | |
|
| | | public Date getInviteTime() {
|
| | | return inviteTime;
|
| | | }
|
| | |
|
| | | public void setInviteTime(Date inviteTime) {
|
| | | this.inviteTime = inviteTime;
|
| | | }
|
| | |
|
| | | public Date getSuccessTime() {
|
| | | return successTime;
|
| | | }
|
| | |
|
| | | public void setSuccessTime(Date successTime) {
|
| | | this.successTime = successTime;
|
| | | }
|
| | |
|
| | | public int getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(int state) {
|
| | | this.state = state;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.mq.user.body;
|
| | |
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | |
|
| | | /**
|
| | | * 用户注册信息
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class UserRegisterMQMsg extends BaseMQMsgBody {
|
| | | private Long uid;// 注册的用户ID
|
| | | private String wxUnionId;// 注册的微信unionId
|
| | | private String phone;// 注册的电话号码
|
| | |
|
| | | public UserRegisterMQMsg(Long uid, String wxUnionId, String phone) {
|
| | | super();
|
| | | this.uid = uid;
|
| | | this.wxUnionId = wxUnionId;
|
| | | this.phone = phone;
|
| | | }
|
| | |
|
| | | public UserRegisterMQMsg() {
|
| | | super();
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public String getWxUnionId() {
|
| | | return wxUnionId;
|
| | | }
|
| | |
|
| | | public void setWxUnionId(String wxUnionId) {
|
| | | this.wxUnionId = wxUnionId;
|
| | | }
|
| | |
|
| | | public String getPhone() {
|
| | | return phone;
|
| | | }
|
| | |
|
| | | public void setPhone(String phone) {
|
| | | this.phone = phone;
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.entity.bus.user;
|
| | |
|
| | | import javax.persistence.Entity;
|
| | | import javax.persistence.GeneratedValue;
|
| | | import javax.persistence.GenerationType;
|
| | | import javax.persistence.Id;
|
| | | import javax.persistence.JoinColumn;
|
| | | import javax.persistence.ManyToOne;
|
| | | import javax.persistence.OneToOne;
|
| | | import javax.persistence.Table;
|
| | | import javax.persistence.Transient;
|
| | |
|
| | |
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | |
| | | @Transactional
|
| | | @Override
|
| | | public LoginResult login(HttpServletRequest request, AcceptData acceptData, Boolean first, String appId,
|
| | |
| | | addUser(userInfo);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addUser(UserInfo user) {
|
| | |
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 添加账号绑定历史
|
| | | if (!StringUtil.isNullOrEmpty(user.getPhone()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(user.getWxUnionId()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId());
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | // 通过Code换取信息
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(1, "微信帐号授权失败");
|
| | | }
|
| | |
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | | } else {
|
| | |
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | }
|
| | |
|
| | | |
| | | @Transactional
|
| | | @Override
|
| | | public UserInfo loginWeiXinNew(HttpServletRequest request, AcceptData acceptData, int loginType, String wxCode, String appId) throws UserAccountException {
|
| | | public UserInfo loginWeiXinNew(HttpServletRequest request, AcceptData acceptData, int loginType, String wxCode,
|
| | | String appId) throws UserAccountException {
|
| | | // 日志信息
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | |
| | |
|
| | | // 通过Code换取信息
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(1, "微信帐号授权失败");
|
| | | }
|
| | |
| | | if (identifyCode != null && identifyCode.getEffective() != null && identifyCode.getEffective()) {
|
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | | }
|
| | |
|
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | if (userInfo == null) {
|
| | |
| | | });
|
| | | return userInfo;
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 更新账户登录信息
|
| | |
| | | throw new UserAccountException(1, "用户不存在");
|
| | | }
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(2, "微信帐号授权失败");
|
| | | }
|
| | |
| | | if (asInputStream == null) {
|
| | | LogHelper.test("微信头像下载失败: " +weiXinUser.getUnionid()+ " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, wxUnionId);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request) throws UserAccountException {
|
| | | public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request)
|
| | | throws UserAccountException {
|
| | | UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | if (phoneUser != null)
|
| | | throw new UserAccountException(1, "号码已经被占用");
|
| | |
| | | if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) {
|
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | | } else {
|
| | |
| | |
|
| | | return userInfo;
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | @Override
|
| | | public void forbiddenUserAll(Long uid, String reason) {
|
| | |
| | |
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInfoModifyRecordMapper;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class UserInfoModifyRecordServiceImpl implements UserInfoModifyRecordService {
|
| | |
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Async()
|
| | | @Transactional
|
| | | @Override
|
| | | public void addModifyRecord(Long uid, ModifyTypeEnum type, String value) {
|
| | | try {
|
| | |
| | | record.setValue(value);
|
| | | record.setCreateTime(new Date());
|
| | | userInfoModifyRecordMapper.insertSelective(record);
|
| | |
|
| | | if (oldRecord == null) {// 新建
|
| | | // 发送账号修改消息
|
| | | UserAccountBindingMQMsg mqMsg = null;
|
| | | if (type == ModifyTypeEnum.bindPhone) {
|
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_PHONE, value, new Date());
|
| | | } else if (type == ModifyTypeEnum.bindTaoBao) {
|
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_TAOBAO, value,
|
| | | new Date());
|
| | | } else if (type == ModifyTypeEnum.bindWeiXin) {
|
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_WX, value, new Date());
|
| | | } else if (type == ModifyTypeEnum.bindAlipay) {
|
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_ALIPAY, value,
|
| | | new Date());
|
| | | }
|
| | | Message message = new Message(MQTopicName.TOPIC_USER.name(),
|
| | | UserTopicTagEnum.userAccountBinding.name(), new Gson().toJson(mqMsg).getBytes());
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | |
| | | addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId());
|
| | | }
|
| | |
|
| | | if (user.getNickName() != null && !user.getNickName().startsWith("返利券")&&!user.getNickName().startsWith(Constant.systemCommonConfig.getDefaultNickName())) {
|
| | | if (user.getNickName() != null && !user.getNickName().startsWith("返利券")
|
| | | && !user.getNickName().startsWith(Constant.systemCommonConfig.getDefaultNickName())) {
|
| | | addModifyRecord(uid, ModifyTypeEnum.nickName, user.getNickName() + "");
|
| | | }
|
| | |
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherRewardIntegralDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.integral.IntegralDetail;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | | public class IntegralTaskRecordServiceImpl implements IntegralTaskRecordService {
|
| | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Override
|
| | | public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) {
|
| | | return integralTaskRecordMapper.getTotalGoldCoin(uid, cid, dateType);
|
| | |
| | | taskRecord.setCid(cid);
|
| | | taskRecord.setTaskId(taskId);
|
| | | taskRecord.setGoldCoin(goldCoin);
|
| | | taskRecord.setState(0);
|
| | | taskRecord.setState(IntegralTaskRecord.STATE_WAITING_RECIEVE);
|
| | | taskRecord.setCreateTime(new Date());
|
| | | taskRecord.setUpdateTime(new Date());
|
| | | integralTaskRecordMapper.insertSelective(taskRecord);
|
| | |
| | | return integralTaskRecordMapper.countGetCountByTaskIdAndDay(taskId, uid, minTime, maxTime);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException {
|
| | | if (record == null)
|
| | |
| | | if (record.getUpdateTime() == null)
|
| | | record.setUpdateTime(new Date());
|
| | | integralTaskRecordMapper.insertSelective(record);
|
| | | long count = integralTaskRecordMapper.getTotalGoldCoinByUid(record.getUid());
|
| | | if (count >= 200) {// 大于200发送消息
|
| | | IntegralTaskMQMsg msg = new IntegralTaskMQMsg(record.getUid(), count, new Date());
|
| | | Message message = new Message(MQTopicName.TOPIC_USER.name(), UserTopicTagEnum.integralTaskFinish.name(),
|
| | | new Gson().toJson(msg).getBytes());
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | return record;
|
| | | }
|
| | |
|
| | |
| | | return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long getTotalGoldCoinByUid(Long uid) {
|
| | | return integralTaskRecordMapper.getTotalGoldCoinByUid(uid);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Async()
|
| | | @Override
|
| | |
| | | userOtherMsgNotificationService.firstOrderRewardMsg(uid, null, msgOther);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 推广红包折算金币
|
| | | * |
| | | * @param uid
|
| | | * @param addGoldCoin
|
| | | * @param tlj
|
| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.ThreeSaleMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | public UserInfo getBoss(final long uid) {
|
| | | return threeSaleMapper.selectBoss(uid);
|
| | |
| | | ts.setSucceedTime(System.currentTimeMillis());
|
| | | ts.setWorker(worker);
|
| | | threeSaleMapper.insertSelective(ts);
|
| | | ThreeSaleCMQManager.getInstance().addThreeSaleMsg(ts);
|
| | | userInviteMsgNotificationService.inviteSuccess(inviter.getId(), ts);
|
| | | inviteSuccess(inviter.getId(), worker.getId(), ts);
|
| | | } else {
|
| | | if (!list.get(0).getState() && list.get(0).getExpire() == ThreeSale.EXPIRE_NORMAL
|
| | | && list.get(0).getBoss().getId() == inviter.getId().longValue()) {// 未生效的上级和现在上级一样就生效
|
| | |
| | | update.setState(true);
|
| | | update.setSucceedTime(System.currentTimeMillis());
|
| | | threeSaleMapper.updateByPrimaryKeySelective(update);
|
| | | ThreeSaleCMQManager.getInstance().addThreeSaleMsg(list.get(0));// 添加通知
|
| | | userInviteMsgNotificationService.inviteSuccess(inviter.getId(), list.get(0));
|
| | | inviteSuccess(list.get(0).getBoss().getId(), list.get(0).getWorker().getId(), list.get(0));
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | oldSale.setState(update.getState());
|
| | | oldSale.setSucceedTime(update.getSucceedTime());
|
| | |
|
| | | UserInfo inviter = list.get(0).getBoss();
|
| | | // 不以邀请人数计算等级
|
| | | // if (inviter != null)
|
| | | // reComputeUserRank(inviter.getId());
|
| | | // 添加到队列
|
| | | ThreeSaleCMQManager.getInstance().addThreeSaleMsg(oldSale);
|
| | | // 通知
|
| | | userInviteMsgNotificationService.inviteSuccess(inviter.getId(), oldSale);
|
| | | inviteSuccess(oldSale.getBoss().getId(), oldSale.getWorker().getId(), oldSale);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | threeSaleMapper.deleteExpireRecord(inviter.getId(), invitee.getId());
|
| | | }
|
| | |
|
| | | // 添加到队列
|
| | | ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale);
|
| | |
|
| | | // 邀请消息
|
| | | userInviteMsgNotificationService.inviteSuccess(inviter.getId(), threeSale);
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 邀请金币
|
| | | integralGetService.addInviteLevelOne(inviter.getId(), invitee.getId());
|
| | | }
|
| | | });
|
| | |
|
| | | inviteSuccess(inviter.getId(), invitee.getId(), threeSale);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | threeSale.setBoss(boss);
|
| | | threeSale.setWorker(invitee);
|
| | |
|
| | | // 添加到队列
|
| | | ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale);
|
| | | inviteSuccess(boss.getId(), invitee.getId(), threeSale);
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请成功
|
| | | */
|
| | | @Transactional
|
| | | private void inviteSuccess(Long bossId, Long workerId, ThreeSale threeSale) {
|
| | | // 邀请消息
|
| | | userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 邀请金币
|
| | | integralGetService.addInviteLevelOne(boss.getId(), invitee.getId());
|
| | | integralGetService.addInviteLevelOne(bossId, workerId);
|
| | | }
|
| | | });
|
| | | UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(), UserInviteMQMsg.STATE_SUCCESS);
|
| | | Message message = new Message(MQTopicName.TOPIC_USER.name(), UserTopicTagEnum.inviteSuccess.name(),
|
| | | new Gson().toJson(msg).getBytes());
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.PDDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | | doOrderTiChengFanLi();// 处理订单提成返利
|
| | | doWeiQuanOrder();// 处理维权订单
|
| | | doPushIOS();// 处理发送IOS消息
|
| | | doThreeSaleUserCouponJob();// 处理邀请队列
|
| | | doUserMoneyDebtJob();// 债务偿还
|
| | | initScheduler();// 启动商品更新定时任务
|
| | | doUpdateGoodsJob(); // 更新商品队列
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请关系变化后券的更新
|
| | | */
|
| | | public void doThreeSaleUserCouponJob() {
|
| | |
|
| | | // 采用2个线程做更新
|
| | | for (int i = 0; i < 2; i++)
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | |
|
| | | while (true) {
|
| | | try {
|
| | | Map<String, ThreeSale> map = ThreeSaleCMQManager.getInstance()
|
| | | .consumeQueueMsg(ThreeSaleCMQManager.QUEUE_USER_COUPON, 16);
|
| | | if (map != null) {
|
| | |
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | try {
|
| | | ThreeSale threeSale = map.get(key);
|
| | | if (threeSale != null)
|
| | | threeSale = threeSaleSerivce.selectByPrimaryKey(threeSale.getId());
|
| | | if (threeSale != null) {
|
| | | if (threeSale.getState() != null && threeSale.getState() == true) {
|
| | | // 邀请成功 - 券激活生效
|
| | | LogHelper.test("doThreeSaleUserCouponJob-" + threeSale.getId());
|
| | |
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | // 下级昵称
|
| | |
|
| | | String workerNickName = userInfoService
|
| | | .selectByPKey(threeSale.getWorker().getId()).getNickName();
|
| | |
|
| | | userSystemCouponService.activatedWelfareFreeCoupon(bossId,
|
| | | workerNickName);
|
| | | }
|
| | | }
|
| | | ThreeSaleCMQManager.getInstance()
|
| | | .deleteQueueMsg(ThreeSaleCMQManager.QUEUE_USER_COUPON, key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("更新商品出错:" + e.getMessage());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
New file |
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.redpack;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Action;
|
| | | import com.aliyun.openservices.ons.api.ConsumeContext;
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.MessageListener;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.user.body.UserRegisterMQMsg;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | /**
|
| | | * 红包消费
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class RedPackMessageListener implements MessageListener {
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Override
|
| | | public Action consume(Message message, ConsumeContext context) {
|
| | | LogHelper.mqInfo("consumer-RedPackMessageListener", message.getTopic(), message.getTag(),
|
| | | new String(message.getBody()));
|
| | | String tag = message.getTag();
|
| | | if (tag == null)
|
| | | tag = "";
|
| | | BaseMQMsgBody baseBody = new Gson().fromJson(new String(message.getBody()), BaseMQMsgBody.class);
|
| | | if (baseBody.isTest() != Constant.IS_TEST)
|
| | | return Action.ReconsumeLater;
|
| | |
|
| | | if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {// 返利到账
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) {// 订单统计
|
| | |
|
| | | }
|
| | | } else if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
|
| | | if (tag.equalsIgnoreCase(UserTopicTagEnum.userAccountBinding.name())) {// 账号绑定
|
| | | UserAccountBindingMQMsg userAccountBindingMQMsg = new Gson().fromJson(new String(message.getBody()),
|
| | | UserAccountBindingMQMsg.class);
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {// 邀请成功
|
| | | UserInviteMQMsg userInviteMQMsg = new Gson().fromJson(new String(message.getBody()),
|
| | | UserInviteMQMsg.class);
|
| | |
|
| | | } else if (tag.equalsIgnoreCase(UserTopicTagEnum.integralTaskFinish.name())) {// 金币任务完成
|
| | | IntegralTaskMQMsg integralTaskMQMsg = new Gson().fromJson(new String(message.getBody()),
|
| | | IntegralTaskMQMsg.class);
|
| | | }
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | | }
|
| | |
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression" value="banLiShopOrderDelay||banLiShopOrderPaid||banLiShopOrderRefund" /><!--expression |
| | | <property name="expression"
|
| | | value="banLiShopOrderDelay||banLiShopOrderPaid||banLiShopOrderRefund" /><!--expression |
| | | 即 Tag,可以设置成具体的 Tag,如 taga||tagb||tagc,也可设置成 *。 * 仅代表订阅所有 Tag,不支持通配 -->
|
| | | </bean>
|
| | | </key>
|
| | |
| | | </property>
|
| | | </bean>
|
| | |
|
| | | <!-- 红包消息订阅 -->
|
| | | <bean id="redPackMessageListener"
|
| | | class="com.yeshi.fanli.util.rocketmq.consumer.redpack.RedPackMessageListener"></bean>
|
| | | <!-- Group ID 订阅同一个 Topic,可以创建多个 ConsumerBean -->
|
| | | <bean id="redPackConsumer" class="com.aliyun.openservices.ons.api.bean.ConsumerBean"
|
| | | init-method="start" destroy-method="shutdown">
|
| | | <property name="properties"> <!--消费者配置信息 -->
|
| | | <props>
|
| | | <prop key="AccessKey">LTAI4FwmTxVCuzTaoZtDiV8z</prop>
|
| | | <prop key="SecretKey">ixWg90QbYFKP6ae5xpAo2P1qwIyll5</prop>
|
| | | <prop key="GROUP_ID">GID_RED_PACK</prop>
|
| | | <prop key="NAMESRV_ADDR">http://MQ_INST_1205444665315884_BbaMbxF4.mq-internet-access.mq-internet.aliyuncs.com:80
|
| | | </prop>
|
| | | <prop key="ConsumeThreadNums">50</prop>
|
| | | </props>
|
| | | </property>
|
| | | <property name="subscriptionTable">
|
| | | <map>
|
| | | <!-- 产生订单,订单到账 -->
|
| | | <entry value-ref="redPackMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_ORDER" />
|
| | | <property name="expression" value="orderStatistic||orderFanLiActual" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | |
|
| | | <!-- 用户注册,账号绑定,邀请好友 ,完成金币任务 -->
|
| | | <entry value-ref="redPackMessageListener">
|
| | | <key>
|
| | | <bean class="com.aliyun.openservices.ons.api.bean.Subscription">
|
| | | <property name="topic" value="TOPIC_USER" />
|
| | | <property name="expression"
|
| | | value="inviteSuccess||userAccountBinding||integralTaskFinish" />
|
| | | </bean>
|
| | | </key>
|
| | | </entry>
|
| | | </map>
|
| | | </property>
|
| | | </bean>
|
| | |
|
| | |
|
| | | </beans> |