Commit 1d97e6ad authored by tangtuo's avatar tangtuo

debug

parent ae45b327
......@@ -14,6 +14,7 @@ import com.fzm.common.entity.dto.CopyrightQueryResponse;
import com.fzm.common.entity.dto.EvidenceHashMessage;
import com.fzm.common.entity.vo.NftVo;
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.properties.CopyrightProperties;
......@@ -127,6 +128,7 @@ public class CopyrightTask {
continue;
}
copyrightApply.setRegisterState(registerState);
copyrightApply.setUpdateDate(new Date());
if (registerState.equals(CopyrightApplyState.SUCCEEDED.getCode())) {
// 审核成功
String nftHash = copyrightApply.getNftHash();
......@@ -149,7 +151,7 @@ public class CopyrightTask {
} else if (registerState.equals(CopyrightApplyState.FAILED.getCode())) {
// 审核失败,更新驳回原因,主动发起退款
copyrightApply.setRejectReason(copyrightResponse.getRemark());
Order order = orderService.getByPaySceneAndProductId(PayScene.COPYRIGHT.getCode(), copyrightApply.getId());
Order order = orderService.getByPaySceneAndProductId(PayScene.COPYRIGHT.getCode(), copyrightApply.getId(), OrderStatus.PAYED.getStatus());
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
......
......@@ -103,6 +103,8 @@ wx-pay:
api-v3-key: D864DA53FEF8ACD41519064967DC10D2
mch-serial-num: 72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path: apiclient_key.pem
pay-notify-url: https://test.inmvo.com/proxyApi/wx-pay/notify/jsapi
refund-notify-url: https://test.inmvo.com/proxyApi/wx-pay/notify/refund
sms:
app-key: Yiru
......
......@@ -104,6 +104,8 @@ wx-pay:
api-v3-key: D864DA53FEF8ACD41519064967DC10D2
mch-serial-num: 72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path: apiclient_key.pem
pay-notify-url: https://test.inmvo.com/proxyApi/wx-pay/notify/jsapi
refund-notify-url: https://test.inmvo.com/proxyApi/wx-pay/notify/refund
sms:
app-key: Yiru
......
......@@ -104,6 +104,8 @@ wx-pay:
api-v3-key: D864DA53FEF8ACD41519064967DC10D2
mch-serial-num: 72A62544B0A08A214FAEC780108692EDC6E7D5FA
private-key-path: apiclient_key.pem
pay-notify-url: https://test.inmvo.com/proxyApi/wx-pay/notify/jsapi
refund-notify-url: https://test.inmvo.com/proxyApi/wx-pay/notify/refund
sms:
app-key: Yiru
......
......@@ -68,7 +68,7 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
AbstractUser user;
String redisToken;
if (TokenConstant.TOKEN_APP_ID_PORTAL.equals(appId)) {
// 门户用户
// h5用户
user = userService.getById(userId);
redisToken = redisUtil.get(RedisConstant.PORTAL_USER_TOKEN_PREFIX + userId);
} else {
......
......@@ -2,7 +2,6 @@ package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Nft;
import com.fzm.common.entity.NftDto;
import com.fzm.common.entity.vo.CollectionNftVo;
import com.fzm.common.entity.vo.NftListVo;
import com.fzm.common.entity.vo.NftVo;
......@@ -186,8 +185,9 @@ public interface NftService extends IService<Nft> {
/**
* 获取当前用户正在发行中的nft列表
* @return
* @param status
*/
List<Nft> getPublishingList();
List<Nft> getPublishingList(Integer status);
......
......@@ -20,9 +20,10 @@ public interface OrderService extends IService<Order> {
*
* @param payScene
* @param productId
* @param orderStatus
* @return
*/
Order getByPaySceneAndProductId(Integer payScene, Integer productId);
Order getByPaySceneAndProductId(Integer payScene, Integer productId, Integer orderStatus);
/**
* 更新订单状态
......
......@@ -17,10 +17,7 @@ import com.fzm.common.entity.dto.CopyrightResponse;
import com.fzm.common.entity.vo.CopyrightApplyVo;
import com.fzm.common.entity.vo.CopyrightCertificateVo;
import com.fzm.common.entity.vo.CopyrightVo;
import com.fzm.common.enums.CopyrightApplyState;
import com.fzm.common.enums.PayScene;
import com.fzm.common.enums.RefundLaunchChannel;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.enums.*;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mapper.CopyrightApplyMapper;
import com.fzm.common.properties.CopyrightProperties;
......@@ -188,7 +185,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
copyright.setRegisterState(CopyrightApplyState.WITHDRAW.getCode());
updateById(copyright);
// 用户撤回后,需要主动退款
Order order = orderService.getByPaySceneAndProductId(PayScene.COPYRIGHT.getCode(), id);
Order order = orderService.getByPaySceneAndProductId(PayScene.COPYRIGHT.getCode(), id, OrderStatus.PAYED.getStatus());
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
......@@ -287,9 +284,9 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
copyrightFileService.saveBatch(files);
}
if (CollectionUtil.isNotEmpty(copyrightDTO.getAuthors())) {
// 删除作者信息
// 删除作者信息
copyrightAuthorService.delByCopyrightId(copyrightDTO.getId());
// 保存作者信息
// 保存修改后的作者信息
ArrayList<CopyrightAuthor> authors = new ArrayList<>();
for (CopyrightDTO.Author author : copyrightDTO.getAuthors()) {
CopyrightAuthor copyrightAuthor = new CopyrightAuthor(author);
......@@ -299,9 +296,9 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
copyrightAuthorService.saveBatch(authors);
}
if (CollectionUtil.isNotEmpty(copyrightDTO.getAuthorityIds())) {
// 删除权力信息
// 删除权力信息
copyrightAuthorityRelationService.delByCopyrightId(copyrightDTO.getId());
// 保存权力信息
// 保存修改后的权力信息
ArrayList<CopyrightAuthorityRelation> relations = new ArrayList<>();
for (Integer authorityId : copyrightDTO.getAuthorityIds()) {
CopyrightAuthorityRelation relation = new CopyrightAuthorityRelation(copyrightApply.getId(), authorityId);
......@@ -310,9 +307,9 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
copyrightAuthorityRelationService.saveBatch(relations);
}
if (CollectionUtil.isNotEmpty(copyrightDTO.getOwnerIds())) {
// 删除著作权人信息
// 删除著作权人信息
copyrightApplyOwnerRelationService.delByCopyrightId(copyrightDTO.getId());
// 保存著作权人信息
// 保存修改后的著作权人信息
ArrayList<CopyrightApplyOwnerRelation> owners = new ArrayList<>();
for (Integer ownerId : copyrightDTO.getOwnerIds()) {
owners.add(new CopyrightApplyOwnerRelation(copyrightApply.getId(), copyrightOwnerService.getById(ownerId)));
......@@ -353,7 +350,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
copyright.setRejectReason(rejectReason);
updateById(copyright);
// 管理员驳回后,需要自动发起退款
Order order = orderService.getByPaySceneAndProductId(PayScene.COPYRIGHT.getCode(), id);
Order order = orderService.getByPaySceneAndProductId(PayScene.COPYRIGHT.getCode(), id, OrderStatus.PAYED.getStatus());
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
......
......@@ -35,7 +35,6 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
......@@ -260,12 +259,12 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
}
@Override
public List<Nft> getPublishingList() {
public List<Nft> getPublishingList(Integer status) {
String token = request.getHeader("Authorization");
Integer userId = JwtUtil.getUserIdFromToken(token);
QueryWrapper<Nft> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId).
eq("publish_status", PublishStatus.PUBLISHING.getCode()).
eq("publish_status", status).
orderByDesc("publish_time");
return this.list(queryWrapper);
}
......
......@@ -2,6 +2,7 @@ package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Charge;
import com.fzm.common.entity.Order;
import com.fzm.common.entity.dto.OrderDto;
import com.fzm.common.entity.dto.OrderProcessMsg;
......@@ -9,10 +10,7 @@ import com.fzm.common.entity.vo.OrderVo;
import com.fzm.common.enums.*;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mapper.OrderMapper;
import com.fzm.common.service.CopyrightApplyService;
import com.fzm.common.service.NftService;
import com.fzm.common.service.OrderService;
import com.fzm.common.service.WxPayService;
import com.fzm.common.service.*;
import com.fzm.common.utils.JwtUtil;
import com.fzm.common.utils.SnowflakeUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -56,12 +54,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@Resource
private WxPayService wxPayService;
@Resource
private ChargeService chargeService;
@Override
public Order getByPaySceneAndProductId(Integer payScene, Integer productId) {
public Order getByPaySceneAndProductId(Integer payScene, Integer productId, Integer orderStatus) {
QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pay_scene", payScene)
.eq("product_id", productId)
.eq("order_status", OrderStatus.PAYED.getStatus());
.eq("order_status", orderStatus);
return this.getOne(queryWrapper);
}
......@@ -75,6 +76,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@Override
public Order createOrder(OrderDto orderDto) {
Charge charge = chargeService.getByType(orderDto.getPayScene());
if (!orderDto.getFee().equals(charge.getFee())) {
throw GlobalException.newException(ResultCode.FAILED, "订单创建失败, 金额有误");
}
Order successOrder = this.getByPaySceneAndProductId(orderDto.getPayScene(), orderDto.getProductId(), OrderStatus.PAYED.getStatus());
if (successOrder != null) {
throw GlobalException.newException(ResultCode.FAILED, "当前产品已支付成功,请勿重复创建订单");
}
Order payingOrder = this.getByPaySceneAndProductId(orderDto.getPayScene(), orderDto.getProductId(), OrderStatus.PAYING.getStatus());
if (payingOrder != null) {
throw GlobalException.newException(ResultCode.FAILED, "当前产品有一笔待支付订单,请勿重复创建");
}
Order order = new Order();
long id = snowflakeUtil.snowflakeId();
Integer productId = orderDto.getProductId();
......
......@@ -195,9 +195,10 @@ public class NftController {
return ResponseModel.success(nftService.getById(id));
}
@Authentication
@GetMapping("/publishing-list")
@ApiOperation(value = "获取当前用户正在发行中的nft列表")
public ResponseModel<List<Nft>> getPublishingList() {
return ResponseModel.success(nftService.getPublishingList());
@ApiOperation(value = "根据状态获取用户的nft列表")
public ResponseModel<List<Nft>> listByStatus(@RequestParam Integer status) {
return ResponseModel.success(nftService.getPublishingList(status));
}
}
......@@ -86,7 +86,7 @@ public class NftListener {
// nft发行失败,需要把nft的发行状态改成failed,然后主动发起退款
nft.setPublishStatus(PublishStatus.FAILED.getCode());
nftService.updateById(nft);
Order order = orderService.getByPaySceneAndProductId(PayScene.NFT.getCode(), nft.getId());
Order order = orderService.getByPaySceneAndProductId(PayScene.NFT.getCode(), nft.getId(), OrderStatus.PAYED.getStatus());
if (order != null) {
wxPayService.refund(order.getId(), RefundLaunchChannel.USER.getCode());
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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