|
@@ -6,20 +6,15 @@ import cn.hutool.core.map.MapUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.qnfhq.common.constant.Constant;
|
|
|
|
|
import com.qnfhq.common.page.PageData;
|
|
import com.qnfhq.common.page.PageData;
|
|
|
import com.qnfhq.common.redis.RedisUtils;
|
|
import com.qnfhq.common.redis.RedisUtils;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.qnfhq.common.service.impl.BaseServiceImpl;
|
|
import com.qnfhq.common.service.impl.BaseServiceImpl;
|
|
|
-import com.qnfhq.common.service.impl.CrudServiceImpl;
|
|
|
|
|
import com.qnfhq.common.utils.DateUtils;
|
|
import com.qnfhq.common.utils.DateUtils;
|
|
|
import com.qnfhq.common.utils.MessageUtils;
|
|
import com.qnfhq.common.utils.MessageUtils;
|
|
|
import com.qnfhq.common.utils.Result;
|
|
import com.qnfhq.common.utils.Result;
|
|
|
import com.qnfhq.constant.CacheConstants;
|
|
import com.qnfhq.constant.CacheConstants;
|
|
|
import com.qnfhq.modules.c2c.dao.C2cOrderDao;
|
|
import com.qnfhq.modules.c2c.dao.C2cOrderDao;
|
|
|
import com.qnfhq.modules.c2c.dto.C2cOrderCreateDTO;
|
|
import com.qnfhq.modules.c2c.dto.C2cOrderCreateDTO;
|
|
|
-import com.qnfhq.modules.c2c.dto.C2cOrderDTO;
|
|
|
|
|
-import com.qnfhq.modules.c2c.dto.C2cOrderLogDTO;
|
|
|
|
|
import com.qnfhq.modules.c2c.entity.*;
|
|
import com.qnfhq.modules.c2c.entity.*;
|
|
|
import com.qnfhq.modules.c2c.enums.*;
|
|
import com.qnfhq.modules.c2c.enums.*;
|
|
|
import com.qnfhq.modules.c2c.service.*;
|
|
import com.qnfhq.modules.c2c.service.*;
|
|
@@ -34,14 +29,11 @@ import com.qnfhq.modules.user.service.AppWalletRecordService;
|
|
|
import com.qnfhq.utils.OrderUtils;
|
|
import com.qnfhq.utils.OrderUtils;
|
|
|
import com.qnfhq.utils.RandomNumberGenerator;
|
|
import com.qnfhq.utils.RandomNumberGenerator;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -130,16 +122,6 @@ public class C2cOrderServiceImpl extends BaseServiceImpl<C2cOrderDao, C2cOrderEn
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public QueryWrapper<C2cOrderEntity> getWrapper(Map<String, Object> params){
|
|
|
|
|
-// String id = (String)params.get("id");
|
|
|
|
|
-//
|
|
|
|
|
-// QueryWrapper<C2cOrderEntity> wrapper = new QueryWrapper<>();
|
|
|
|
|
-// wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
|
|
|
|
-//
|
|
|
|
|
-// return wrapper;
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String getC2cOrderKeyByUid(String uid) {
|
|
public String getC2cOrderKeyByUid(String uid) {
|
|
|
return new StringBuilder("c2c_order_uid:").append(uid).toString();
|
|
return new StringBuilder("c2c_order_uid:").append(uid).toString();
|
|
@@ -147,10 +129,9 @@ public class C2cOrderServiceImpl extends BaseServiceImpl<C2cOrderDao, C2cOrderEn
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public C2cOrderEntity getTradingByAdId(long adId) {
|
|
public C2cOrderEntity getTradingByAdId(long adId) {
|
|
|
- return getOne(new LambdaQueryWrapper<C2cOrderEntity>()
|
|
|
|
|
|
|
+ return baseDao.selectOne(new LambdaQueryWrapper<C2cOrderEntity>()
|
|
|
.eq(C2cOrderEntity::getC2cAdId, adId)
|
|
.eq(C2cOrderEntity::getC2cAdId, adId)
|
|
|
.eq(C2cOrderEntity::getFlow, 0)
|
|
.eq(C2cOrderEntity::getFlow, 0)
|
|
|
- .last(" limit 1")
|
|
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -160,7 +141,7 @@ public class C2cOrderServiceImpl extends BaseServiceImpl<C2cOrderDao, C2cOrderEn
|
|
|
public C2cOrderEntity selectOrder(Long id) {
|
|
public C2cOrderEntity selectOrder(Long id) {
|
|
|
C2cOrderEntity order = selectOrderFromRedis(id);
|
|
C2cOrderEntity order = selectOrderFromRedis(id);
|
|
|
if(order == null) {
|
|
if(order == null) {
|
|
|
- order = getById(id);
|
|
|
|
|
|
|
+ order = selectById(id);
|
|
|
if(order == null) {
|
|
if(order == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -266,7 +247,7 @@ public class C2cOrderServiceImpl extends BaseServiceImpl<C2cOrderDao, C2cOrderEn
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Result createC2cOrder(C2cOrderCreateDTO c2cOrderDTO, C2cAdEntity c2cAd,BigDecimal legalCoinAmount, BigDecimal symbolNum,
|
|
|
|
|
|
|
+ public Result createC2cOrder(C2cOrderCreateDTO c2cOrderDTO, C2cAdEntity c2cAd, BigDecimal legalCoinAmount, BigDecimal symbolNum,
|
|
|
Long loginUserId, String realName) throws Exception {
|
|
Long loginUserId, String realName) throws Exception {
|
|
|
/** 1买入 2 卖出 */
|
|
/** 1买入 2 卖出 */
|
|
|
Integer direction = c2cOrderDTO.getDirection();
|
|
Integer direction = c2cOrderDTO.getDirection();
|
|
@@ -383,7 +364,7 @@ public class C2cOrderServiceImpl extends BaseServiceImpl<C2cOrderDao, C2cOrderEn
|
|
|
@Override
|
|
@Override
|
|
|
public int cancelC2cOrderRedis(int oldStatus,C2cOrderEntity order) {
|
|
public int cancelC2cOrderRedis(int oldStatus,C2cOrderEntity order) {
|
|
|
//redis广告可用数量恢复
|
|
//redis广告可用数量恢复
|
|
|
- C2cAdEntity c2cAd = c2cAdService.getById(order.getC2cAdId());
|
|
|
|
|
|
|
+ C2cAdEntity c2cAd = c2cAdService.selectById(order.getC2cAdId());
|
|
|
c2cAdService.deleteAdCache(c2cAd.getId(),c2cAd.getPayway().replaceAll("^,|,$", ""),c2cAd.getLegalCoin(),c2cAd.getSymbol(),c2cAd.getDirection());
|
|
c2cAdService.deleteAdCache(c2cAd.getId(),c2cAd.getPayway().replaceAll("^,|,$", ""),c2cAd.getLegalCoin(),c2cAd.getSymbol(),c2cAd.getDirection());
|
|
|
c2cAdService.setAdCache(c2cAd);
|
|
c2cAdService.setAdCache(c2cAd);
|
|
|
deleteOrderCache(order);
|
|
deleteOrderCache(order);
|
|
@@ -465,7 +446,7 @@ public class C2cOrderServiceImpl extends BaseServiceImpl<C2cOrderDao, C2cOrderEn
|
|
|
info.getFrozen(),info.getFrozen().subtract(order.getSymbolNum()),"c2c订单取消解冻资产");
|
|
info.getFrozen(),info.getFrozen().subtract(order.getSymbolNum()),"c2c订单取消解冻资产");
|
|
|
}
|
|
}
|
|
|
//广告可用数量恢复
|
|
//广告可用数量恢复
|
|
|
- C2cAdEntity c2cAd = c2cAdService.getById(order.getC2cAdId());
|
|
|
|
|
|
|
+ C2cAdEntity c2cAd = c2cAdService.selectById(order.getC2cAdId());
|
|
|
BigDecimal maxAmount = null;
|
|
BigDecimal maxAmount = null;
|
|
|
if(order.getTranAmount().compareTo(c2cAd.getMaxAmount())==1) {
|
|
if(order.getTranAmount().compareTo(c2cAd.getMaxAmount())==1) {
|
|
|
maxAmount = order.getTranAmount();
|
|
maxAmount = order.getTranAmount();
|