Commit b26b0e92 authored by 33's avatar 33

代码规范,新增消息系统,ntf详情添加申请人信息

parent 913a5e9e
FROM java:8
# 时区调整
COPY localtime /etc/
RUN echo 'Asia/Shanghai' >/etc/timezone
ADD joying-portal-1.0.0.jar app.jar
EXPOSE 8001
# -Dspring.profiles.active=sit 等号后面表示使用application-sit.yml,修改该项使用其他配置文件
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=sit", "-jar", "/app.jar"]
File added
......@@ -17,6 +17,7 @@ import com.fzm.common.enums.CopyrightApplyState;
import com.fzm.common.enums.OrderStatus;
import com.fzm.common.enums.PayScene;
import com.fzm.common.enums.RefundLaunchChannel;
import com.fzm.common.mq.NotifyPublisher;
import com.fzm.common.properties.CopyrightProperties;
import com.fzm.common.service.CopyrightApplyService;
import com.fzm.common.service.NftService;
......@@ -78,6 +79,9 @@ public class CopyrightTask {
@Resource
private OrderService orderService;
@Resource
private NotifyPublisher notifyPublisher;
/**
* 定时任务更新版权申请状态
*/
......@@ -86,13 +90,17 @@ public class CopyrightTask {
// 加锁,防止集群部署时,定时任务在多个节点上执行
RLock lock = redisson.getLock("update:copyright:state");
if (!lock.tryLock(30, TimeUnit.SECONDS)) {
log.warn("更新版权状态的定时任务已在其他节点运行");
if (log.isDebugEnabled()) {
log.debug("更新版权状态的定时任务已在其他节点运行");
}
return;
}
try {
List<String> list = copyrightApplyService.getSerialCodes();
if (CollectionUtil.isEmpty(list)) {
log.info("当前无待更新状态的申请记录");
if (log.isDebugEnabled()) {
log.debug("当前无待更新状态的申请记录");
}
return;
}
for (String serial_code : list) {
......@@ -120,7 +128,7 @@ public class CopyrightTask {
continue;
}
CopyrightApply copyrightApply = copyrightApplyService.getBySerialNum(serial_code);
//审核状态(0:未提交,1:待审核,2:同意,3:驳回,4:已提交,5:待终审,6:审核通过)
// 审核状态(0:未提交,1:待审核,2:同意,3:驳回,4:已提交,5:待终审,6:审核通过)
Integer audit_status = copyrightResponse.getAudit_status();
Integer registerState = getRegisterState(audit_status);
if (registerState == null || registerState.equals(copyrightApply.getRegisterState())) {
......@@ -134,6 +142,8 @@ public class CopyrightTask {
String nftHash = copyrightApply.getNftHash();
copyrightApply.setEvidenceDate(new Date());
copyrightApply.setRegisterCode(copyrightResponse.getCertificate().getRegister_code());
copyrightApply.setRegisterOwner(copyrightResponse.getCertificate().getOwner_name());
copyrightApply.setRegisterTime(copyrightResponse.getCertificate().getFinish_time());
copyrightApply.setRegisterState(CopyrightApplyState.SUCCEEDED.getCode());
Nft nft = nftService.getByNftHash(nftHash);
String tokenInfo = paraChainClient.evmGetTokenInfo(abi, contractAddr, nft.getTokenId(), nft.getPublishAddress());
......@@ -148,6 +158,9 @@ public class CopyrightTask {
// 发送交易hash到死信队列,5秒后查询真实哈希,然后更新存证hash
EvidenceHashMessage msg = new EvidenceHashMessage(serial_code, hash);
rabbitTemplate.convertAndSend(RabbitMQConfig.COPYRIGHT_DIRECT, "evidence.hash.query", msg);
// 发送系统消息
notifyPublisher.copyrightApplySuccessNotify(copyrightApply.getUserId());
} else if (registerState.equals(CopyrightApplyState.FAILED.getCode())) {
// 审核失败,更新驳回原因,主动发起退款
copyrightApply.setRejectReason(copyrightResponse.getRemark());
......@@ -155,6 +168,9 @@ public class CopyrightTask {
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
// 发送系统消息
notifyPublisher.copyrightApplyFailNotify(copyrightApply.getUserId(), copyrightResponse.getRemark());
}
copyrightApplyService.updateById(copyrightApply);
} catch (Exception e) {
......
......@@ -29,6 +29,9 @@ public class CopyrightApply {
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "申请人名称")
private String applyName;
@ApiModelProperty(value = "nft哈希")
private String nftHash;
......@@ -114,6 +117,10 @@ public class CopyrightApply {
@ApiModelProperty("登记证书编号,在版权登记审核通过后生成")
private String registerCode;
@ApiModelProperty("登记证书人名称,在版权登记审核通过后生成")
private String registerOwner;
@ApiModelProperty("登记证书时间,在版权登记审核通过后生成")
private String registerTime;
private Date createDate;
......
package com.fzm.common.entity;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author wt
* @date 2022/3/7
*/
@Data
public class Notify {
private Integer id;
/**
* uid
*/
private Integer uid;
/**
* 标题
*/
private String title;
/**
* 概要
*/
private String summary;
/**
* 内容
*/
private String content;
/**
* 1系统消息,2公告消息
*/
private Integer type;
/**
* 状态1有效2无效
*/
private Integer state;
private LocalDateTime createTime;
private LocalDateTime updateTime;
/**
* 0未删除,1已删除
*/
private Integer delete;
}
package com.fzm.common.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wt
* @date 2022/3/7
*/
@Data
@ApiModel("消息状态响应")
public class NotifyState {
@ApiModelProperty("uid")
private Integer uid;
@ApiModelProperty("未读消息数量")
private Integer number;
@ApiModelProperty("未读消息数量id数组")
private String nids;
}
......@@ -24,6 +24,9 @@ public class CopyrightVo {
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "申请人名称")
private String applyName;
@ApiModelProperty(value = "登记委托书")
private String registerEntrust;
......@@ -95,6 +98,10 @@ public class CopyrightVo {
@ApiModelProperty("登记证书编号,在版权登记审核通过后生成")
private String registerCode;
@ApiModelProperty("登记证书人名称,在版权登记审核通过后生成")
private String registerOwner;
@ApiModelProperty("登记证书时间,在版权登记审核通过后生成")
private String registerTime;
@ApiModelProperty(value = "作品类别")
private OpusCategory opusCategory;
......
package com.fzm.common.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author wt
* @date 2022/3/7
*/
@Data
@ApiModel("消息响应")
public class NotifyVO {
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("uid")
private Integer uid;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("概要")
private String summary;
@ApiModelProperty("内容")
private String content;
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
}
package com.fzm.common.mapper;
import com.fzm.common.entity.Notify;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author wt
* @date 2022/3/7
*/
@Mapper
public interface NotifyMapper {
/**
* 保存消息
*/
void insert(Notify notify);
/**
* 更新消息
*/
void update(Notify notify);
/**
* 通过id查询消息
*/
Notify selectById(int id);
/**
* 根据类型查询消息/通知
*/
List<Notify> select(@Param("uid") int uid, @Param("type") int type, @Param("state") int state);
}
package com.fzm.common.mapper;
import com.fzm.common.entity.NotifyState;
import org.apache.ibatis.annotations.Mapper;
/**
* @author wt
* @date 2021/8/23
*/
@Mapper
public interface NotifyStateMapper {
/**
* 保存用户消息
*/
void insert(NotifyState notifyState);
/**
* 更新用户消息
*/
void update(NotifyState notifyState);
/**
* 查询用户消息
*
* @param uid uid
*/
NotifyState selectByUid(Integer uid);
}
package com.fzm.common.mq;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author wt
* @date 2022/3/7
*/
@Configuration
public class NotifyConfig {
public static final String NOTIFY_QUEUE = "notify.queue";
@Bean
public Queue notifyQueue() {
return new Queue(NOTIFY_QUEUE);
}
}
package com.fzm.common.mq;
import com.alibaba.fastjson.JSON;
import com.fzm.common.entity.Notify;
import com.fzm.common.entity.NotifyState;
import com.fzm.common.mapper.NotifyMapper;
import com.fzm.common.mapper.NotifyStateMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author wt
* @date 2022/3/7
*/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class NotifyConsumer {
private final NotifyMapper notifyMapper;
private final NotifyStateMapper notifyStateMapper;
@RabbitListener(queues = {NotifyConfig.NOTIFY_QUEUE})
public void notifyMessageUser(String content) {
if (StringUtils.isBlank(content)) {
return;
}
Notify notify = JSON.parseObject(content, Notify.class);
notifyMapper.insert(notify);
Integer uid = notify.getUid();
NotifyState notifyState = notifyStateMapper.selectByUid(uid);
boolean doNotExist = notifyState == null;
notifyState = doNotExist ? new NotifyState() : notifyState;
notifyState.setUid(uid);
// 获取用户原始消息通知id数组
String nids = notifyState.getNids();
nids = StringUtils.isBlank(nids) ? "[]" : nids;
List<Integer> nidArray = JSON.parseArray(nids, Integer.class);
// 最多500未读消息
if (nidArray.size() >= 500) {
nidArray.remove(0);
}
nidArray.add(notify.getId());
nidArray.sort(Integer::compareTo);
notifyState.setNumber(nidArray.size());
notifyState.setNids(JSON.toJSONString(nidArray));
if (doNotExist) {
try {
notifyStateMapper.insert(notifyState);
return;
} catch (Exception ignored) {
}
}
notifyStateMapper.update(notifyState);
}
}
package com.fzm.common.mq;
import com.alibaba.fastjson.JSON;
import com.fzm.common.entity.Notify;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wt
* @date 2022/3/7
*/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class NotifyPublisher {
private final AmqpTemplate amqpTemplate;
public void sendNotify(Notify notify) {
notify.setType(1);
notify.setState(1);
notify.setDelete(0);
amqpTemplate.convertAndSend(NotifyConfig.NOTIFY_QUEUE, JSON.toJSONString(notify));
}
public void personAuthSuccessNotify(Integer uid) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("实名认证");
notify.setSummary("认证成功");
notify.setContent("恭喜您,您已完成实名认证");
sendNotify(notify);
}
public void personAuthFailNotify(Integer uid, String result) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("实名认证");
notify.setSummary("认证失败");
notify.setContent("恭喜您,您的实名认证未通过。原因:" + result);
sendNotify(notify);
}
public void copyrightApplyRejectNotify(Integer uid, String reason) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("版权申请");
notify.setSummary("一幕影链核验失败");
notify.setContent("很抱歉,您的版权申请未通过一幕影链的核验。原因:" + reason);
sendNotify(notify);
}
public void copyrightApplyPassNotify(Integer uid) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("版权申请");
notify.setSummary("一幕影链核验成功");
notify.setContent("您好,您的版权申请已通过一幕影链的核验,已提交湖北版权保护中心。请耐心等待审核结果。");
sendNotify(notify);
}
public void copyrightApplySuccessNotify(Integer uid) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("版权申请");
notify.setSummary("版权局审核成功");
notify.setContent("您好,您的版权申请已通过湖北版权保护中心的审核,可以在我的-版权申请中查看版权。");
sendNotify(notify);
}
public void copyrightApplyFailNotify(Integer uid, String reason) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("版权申请");
notify.setSummary("版权局审核失败");
notify.setContent("很抱歉,您的版权申请未通过湖北版权保护中心的审核。原因:" + reason);
sendNotify(notify);
}
public void nftSuccessNotify(Integer uid, String nftName) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("数字藏品铸造");
notify.setSummary("铸造成功");
notify.setContent("恭喜您,您的数字藏品《" + nftName + "》已经铸造成功,可以在我的-我的数字藏品查看。");
sendNotify(notify);
}
public void nftFailNotify(Integer uid, String nftName, String reason) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("数字藏品铸造");
notify.setSummary("铸造失败");
notify.setContent("很抱歉,您的数字藏品《" + nftName + "》铸造失败。原因:" + reason);
sendNotify(notify);
}
public void nftOutNotify(Integer uid, String nftName) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("数字藏品转让");
notify.setSummary("转出成功");
notify.setContent("恭喜您,您的数字藏品《" + nftName + "》已成功转出。");
sendNotify(notify);
}
public void nftInNotify(Integer uid, String nftName) {
Notify notify = new Notify();
notify.setUid(uid);
notify.setTitle("数字藏品转让");
notify.setSummary("转入");
notify.setContent("您好,您的账户成功转入一个数字藏品《" + nftName + "》,可以在我的-我的数字藏品查看。");
sendNotify(notify);
}
}
package com.fzm.common.service;
import com.fzm.common.entity.NotifyState;
import com.fzm.common.entity.vo.NotifyVO;
import com.github.pagehelper.PageInfo;
/**
* @author wt
* @date 2022/3/7
*/
public interface NotifyService {
NotifyVO selectById(int id);
PageInfo<NotifyVO> pages(Integer uid, int page, int size);
NotifyState selectByUid(Integer uid);
void updateState(NotifyState notifyState);
}
......@@ -20,6 +20,7 @@ import com.fzm.common.entity.vo.CopyrightVo;
import com.fzm.common.enums.*;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mapper.CopyrightApplyMapper;
import com.fzm.common.mq.NotifyPublisher;
import com.fzm.common.properties.CopyrightProperties;
import com.fzm.common.service.*;
import com.fzm.common.utils.CopyrightSignUtil;
......@@ -105,6 +106,9 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
@Resource
private WxPayService wxPayService;
@Resource
private NotifyPublisher notifyPublisher;
@Override
public Integer submit(CopyrightDTO copyrightDTO) {
......@@ -124,6 +128,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
// 首次提交,登记状态为待支付
copyrightApply.setRegisterState(CopyrightApplyState.TO_BE_PAY.getCode());
copyrightApply.setUserId(user.getId());
copyrightApply.setApplyName(user.getAuthPerson().getName());
copyrightApply.setApplyTime(new Date());
try {
save(copyrightApply);
......@@ -354,6 +359,10 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
// 发送系统消息
notifyPublisher.copyrightApplyRejectNotify(copyright.getUserId(), rejectReason);
return true;
}
......@@ -399,7 +408,12 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
copyright.setRegisterState(CopyrightApplyState.SUBMITTED.getCode());
copyright.setRejectReason("");
copyright.setPassTime(new Date());
return updateById(copyright);
boolean updateResult = updateById(copyright);
// 发送系统消息
notifyPublisher.copyrightApplyPassNotify(copyright.getUserId());
return updateResult;
} finally {
lock.unlock();
}
......
......@@ -24,6 +24,7 @@ import com.fzm.common.enums.PublishStatus;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mapper.NftMapper;
import com.fzm.common.mq.NotifyPublisher;
import com.fzm.common.params.NftTransferParam;
import com.fzm.common.properties.SmsProperties;
import com.fzm.common.service.*;
......@@ -99,6 +100,9 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
@Resource
private ObsUtil obsUtil;
@Resource
private NotifyPublisher notifyPublisher;
//private static String abi = "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"URI\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"accounts\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"balanceOfBatch\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"burnTokenBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getTokenInfo\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"getUserTokens\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"mintTokenBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeBatchTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenInfo\",\"type\":\"string\"}],\"name\":\"setTokenInfo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"uri\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]";
private static String abi = "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\"}],\"name\":\"TransferBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"TransferSingle\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"URI\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"accounts\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"}],\"name\":\"balanceOfBatch\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"burnTokenBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getTokenInfo\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mintToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"mintTokenBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"ids\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeBatchTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"tokenInfo\",\"type\":\"string\"}],\"name\":\"setTokenInfo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"uri\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]";
......@@ -206,6 +210,13 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
setFromAddress(user.getWallet()).
setToAddress(param.getReceiveWallet());
nftTransferRecordService.save(record);
// 发送系统消息
notifyPublisher.nftOutNotify(user.getId(), nft.getName());
if (receiveUser != null) {
notifyPublisher.nftInNotify(receiveUser.getId(), nft.getName());
}
return true;
}
......
package com.fzm.common.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.fzm.common.entity.Notify;
import com.fzm.common.entity.NotifyState;
import com.fzm.common.entity.vo.NotifyVO;
import com.fzm.common.mapper.NotifyMapper;
import com.fzm.common.mapper.NotifyStateMapper;
import com.fzm.common.service.NotifyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author wt
* @date 2022/3/7
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class NotifyServiceImpl implements NotifyService {
private final NotifyMapper notifyMapper;
private final NotifyStateMapper notifyStateMapper;
@Override
public NotifyVO selectById(int id) {
Notify notify = notifyMapper.selectById(id);
return BeanUtil.copyProperties(notify, NotifyVO.class);
}
@Override
public PageInfo<NotifyVO> pages(Integer uid, int page, int size) {
PageHelper.startPage(page, size);
List<Notify> notifyList = notifyMapper.select(uid, 0, 0);
List<NotifyVO> notifyVOList = new ArrayList<>(notifyList.size());
notifyList.forEach(n -> notifyVOList.add(BeanUtil.copyProperties(n, NotifyVO.class)));
return new PageInfo<>(notifyVOList);
}
@Override
public NotifyState selectByUid(Integer uid) {
return notifyStateMapper.selectByUid(uid);
}
@Override
public void updateState(NotifyState notifyState) {
notifyStateMapper.update(notifyState);
}
}
......@@ -33,7 +33,7 @@ public class SmsServiceImpl implements SmsService {
public void sendRefundSms(Long orderId) {
Order order = orderService.getById(orderId);
User user = userService.getById(order.getUserId());
String fee = BigDecimal.valueOf(order.getFee()).divide(new BigDecimal(100)).toString();
String fee = BigDecimal.valueOf(order.getFee()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN).toString();
smsUtil.sendRefundSms(user.getTelephone(), fee);
}
}
......@@ -21,6 +21,7 @@ import com.fzm.common.enums.IdCardVerificationResponse;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mapper.UserMapper;
import com.fzm.common.mq.NotifyPublisher;
import com.fzm.common.params.LoginParam;
import com.fzm.common.properties.DebugProperties;
import com.fzm.common.properties.SmsProperties;
......@@ -41,11 +42,11 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Base64;
import java.util.List;
/**
......@@ -87,6 +88,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Resource
private DebugProperties debugProperties;
@Resource
private NotifyPublisher notifyPublisher;
@Override
public User loadUserByUsername(String username) {
......@@ -241,8 +245,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
response.setIdCard("000000000000000000");
response.setName("个人认证");
} else {
BASE64Encoder base64Encoder = new BASE64Encoder();
String encode = "data:image/jpg;base64," + base64Encoder.encode(cardPictureFront.getBytes());
String encode = "data:image/jpg;base64," + Base64.getEncoder().encodeToString(cardPictureFront.getBytes());
response = TencentApi.idCardOCRVerification(encode);
log.info("实名认证结果:{}", JSONUtil.toJsonStr(response));
}
......@@ -269,6 +272,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
update(userUpdateWrapper);
if (AuthStatus.SUCCESS.getStatus().equals(status)) {
redisUtil.delete("user::statistic");
// 验证成功发送消息
notifyPublisher.personAuthSuccessNotify(userId);
} else {
notifyPublisher.personAuthFailNotify(userId, response.getResult());
}
return response;
}
......
......@@ -119,7 +119,7 @@ public class WxPayServiceImpl implements WxPayService {
CloseableHttpResponse response = httpClient.execute(httpPost);
String bodyAsString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONUtil.parseObj(bodyAsString);
if (jsonObject == null || StringUtils.isBlank(jsonObject.getStr("prepay_id"))) {
if (StringUtils.isBlank(jsonObject.getStr("prepay_id"))) {
throw GlobalException.newException(ResultCode.PAY_FAILED, "微信支付下单失败");
}
String prepay_id = jsonObject.getStr("prepay_id");
......
......@@ -10,7 +10,6 @@ import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.HashMap;
......@@ -20,7 +19,6 @@ import java.util.Map;
* @author tangtuo
* @date 2021/6/23 9:40
*/
@Slf4j
public class JwtUtil {
private static final String CLAIM_KEY_USERNAME = "sub";
......@@ -194,10 +192,7 @@ public class JwtUtil {
Date created = claims.get(CLAIM_KEY_CREATED, Date.class);
Date refreshDate = new Date();
//刷新时间在创建时间的指定时间内
if (refreshDate.after(created) && refreshDate.before(DateUtil.offsetSecond(created, time))) {
return true;
}
return false;
return refreshDate.after(created) && refreshDate.before(DateUtil.offsetSecond(created, time));
}
public static void main(String[] args) {
......
......@@ -5,7 +5,6 @@ import com.google.zxing.*;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
import java.awt.*;
......@@ -15,6 +14,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Base64;
import java.util.Hashtable;
public class QRCodeUtil {
......@@ -100,9 +100,8 @@ public class QRCodeUtil {
e.printStackTrace();
}
byte[] bytes = baos.toByteArray();//转换成字节
BASE64Encoder encoder = new BASE64Encoder();
String png_base64 = encoder.encodeBuffer(bytes).trim();//转换成base64串
png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n
String png_base64 = Base64.getEncoder().encodeToString(bytes);//转换成base64串
return "data:image/jpg;base64," + png_base64;
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fzm.common.mapper.NotifyMapper">
<insert id="insert" parameterType="com.fzm.common.entity.Notify"
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into tb_notify(uid, title, summary, content, type, state, create_time, update_time, is_delete)
VALUES (#{uid}, #{title}, #{summary}, #{content}, #{type}, #{state}, now(), now(), #{delete})
</insert>
<update id="update" parameterType="com.fzm.common.entity.Notify">
update tb_notify
<set>
<if test="title != null and title != ''">
title = #{title},
</if>
<if test="summary != null and summary != ''">
summary = #{summary},
</if>
<if test="content != null and content != ''">
content = #{content},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="state != null">
state = #{state},
</if>
<if test="delete != null">
is_delete = #{delete},
</if>
update_time = now()
</set>
where id = #{id}
</update>
<select id="selectById" resultType="com.fzm.common.entity.Notify">
select id,
uid,
title,
summary,
content,
type,
state,
create_time,
update_time,
is_delete `delete`
from tb_notify
where id = #{id}
</select>
<select id="select" resultType="com.fzm.common.entity.Notify">
select id,
uid,
title,
summary,
type,
state,
create_time,
update_time,
is_delete `delete`
from tb_notify
where is_delete = 0
<if test="uid != 0">
and uid = #{uid}
</if>
<if test="type != 0">
and type = #{type}
</if>
<if test="state != 0">
and state = #{state}
</if>
order by update_time desc
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fzm.common.mapper.NotifyStateMapper">
<insert id="insert" parameterType="com.fzm.common.entity.NotifyState">
insert into tb_notify_state(uid, number, nids)
VALUES (#{uid}, #{number}, #{nids})
</insert>
<update id="update" parameterType="com.fzm.common.entity.NotifyState">
update tb_notify_state
set number = #{number},
nids = #{nids}
where uid = #{uid}
</update>
<select id="selectByUid" resultType="com.fzm.common.entity.NotifyState">
select uid, number, nids
from tb_notify_state
where uid = #{uid}
</select>
</mapper>
\ No newline at end of file
from openjdk:8-jdk-alpine
run mkdir /home/joying
run mkdir /home/joying/portal
workdir /home/joying/portal
copy joying-portal-1.0.0.jar /home/joying/portal/app.jar
ENV LANG en_US.utf8
#定义时区参数
ENV TZ=Asia/Shanghai
#设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
#配置容器启动后执行的命令,并指定使用项目外部的配置文件
ENTRYPOINT ["java","-Xms512m","-Xmx4096m","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=dev","-jar","/home/joying/portal/app.jar"]
package com.fzm.portal.controller;
import com.alibaba.fastjson.JSON;
import com.fzm.common.annotation.Authentication;
import com.fzm.common.entity.NotifyState;
import com.fzm.common.entity.vo.NotifyVO;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.NotifyService;
import com.fzm.common.utils.JwtUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
* @author wt
* @date 2022/3/7
*/
@Api(value = "通知", tags = "通知", description = " ")
@RestController
@Authentication
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping(value = "/notify", produces = MediaType.APPLICATION_JSON_VALUE)
public class NotifyController {
private final NotifyService notifyService;
@GetMapping("/pages")
@ApiOperation(value = "分页查询")
public ResponseModel<PageInfo<NotifyVO>> pages(@ApiParam(value = "页码", required = true) @RequestParam Integer pageNum,
@ApiParam(value = "每页记录数", required = true) @RequestParam Integer pageSize,
@RequestHeader String Authorization) {
Integer userId = JwtUtil.getUserIdFromToken(Authorization);
PageInfo<NotifyVO> pageInfo = notifyService.pages(userId, pageNum, pageSize);
return ResponseModel.success(pageInfo);
}
@ApiOperation("未读消息数量")
@GetMapping("/count")
public ResponseModel<NotifyState> messageCount(@RequestHeader String Authorization) {
Integer userId = JwtUtil.getUserIdFromToken(Authorization);
NotifyState notifyState = notifyService.selectByUid(userId);
return ResponseModel.success(notifyState);
}
@ApiOperation("查询详细")
@GetMapping("/detail")
public ResponseModel<NotifyVO> getById(@RequestParam Integer id, @RequestHeader String Authorization) {
if (id == null || id <= 0) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED);
}
NotifyVO vo = notifyService.selectById(id);
if (vo != null) {
Integer userId = JwtUtil.getUserIdFromToken(Authorization);
NotifyState notifyState = notifyService.selectByUid(userId);
if (notifyState != null) {
val nids = notifyState.getNids();
val nidArray = JSON.parseArray(nids, Integer.class);
if (nidArray.contains(id)) {
nidArray.remove(id);
notifyState.setNumber(nidArray.size());
notifyState.setNids(JSON.toJSONString(nidArray));
notifyService.updateState(notifyState);
}
}
}
return ResponseModel.success(vo);
}
@ApiOperation("全部已读")
@GetMapping("/all-read")
public ResponseModel<Boolean> allRead(@RequestHeader String Authorization) {
Integer userId = JwtUtil.getUserIdFromToken(Authorization);
NotifyState notifyState = notifyService.selectByUid(userId);
if (notifyState != null) {
notifyState.setNumber(0);
notifyState.setNids("[]");
notifyService.updateState(notifyState);
}
return ResponseModel.success();
}
}
......@@ -10,6 +10,7 @@ import com.fzm.common.entity.User;
import com.fzm.common.entity.dto.NftPublishMsg;
import com.fzm.common.enums.*;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mq.NotifyPublisher;
import com.fzm.common.service.NftService;
import com.fzm.common.service.OrderService;
import com.fzm.common.service.UserService;
......@@ -48,6 +49,9 @@ public class NftListener {
@Resource
private WxPayService wxPayService;
@Resource
private NotifyPublisher notifyPublisher;
/**
* 监听nft发行结果
*
......@@ -57,8 +61,9 @@ public class NftListener {
public void listenNftPublish(NftPublishMsg msg) throws Exception {
log.info("收到确认nft发行结果的消息: {}", msg);
Nft nft = nftService.getById(msg.getId());
User user = userService.getUserByWallet(nft.getPublishAddress());
try {
User user = userService.getUserByWallet(nft.getPublishAddress());
String hash = msg.getHash();
// 确认交易结果
TxResult txResult = paraChainClient.cycleConfirmTxWithHash(hash, true, 1000);
......@@ -79,6 +84,8 @@ public class NftListener {
userService.updateById(u);
redisUtil.delete("user::statistic");
}
notifyPublisher.nftSuccessNotify(user.getId(), nft.getName());
} catch (Exception e) {
log.error(e.getMessage(), e);
// nft发行失败,需要把nft的发行状态改成failed,然后主动发起退款
......@@ -88,6 +95,8 @@ public class NftListener {
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
notifyPublisher.nftFailNotify(user.getId(), nft.getName(), e.getMessage());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment