update 删除部分未用到的引用

This commit is contained in:
yyb
2026-01-07 10:37:24 +08:00
parent 7627b8962d
commit db8384f04b
8 changed files with 101 additions and 20 deletions

View File

@@ -35,6 +35,7 @@ public class ProductMachineForWalletConfigVo {
@ApiModelProperty(value = "支付币种,可以多个以逗号隔开")
private String symbol;
@ApiModelProperty(value = "价格列表")
private List<PriceVo> productMachineForWalletConfigVoList;

View File

@@ -81,7 +81,7 @@ public interface LeaseMachineMapper extends BaseMapper<LeaseMachine> {
* @param machineIds
* @return
*/
List<CartMachineInfoDto> getMachinesByIds(@Param("machineIds") List<Long> machineIds);
List<CartMachineInfoDto> getMachinesByIds(@Param("machineIds") List<Long> machineIds, @Param("userId") String username);
/**

View File

@@ -19,10 +19,7 @@ import com.m2pool.lease.mapper.*;
import com.m2pool.lease.netty.handler.ChannelManager;
import com.m2pool.lease.netty.message.ClientMessage;
import com.m2pool.lease.redis.service.RedisService;
import com.m2pool.lease.service.LeaseOrderInfoService;
import com.m2pool.lease.service.LeaseOrderItemService;
import com.m2pool.lease.service.LeaseProductService;
import com.m2pool.lease.service.LeaseUserOwnedProductService;
import com.m2pool.lease.service.*;
import com.m2pool.lease.utils.DateUtils;
import com.m2pool.lease.utils.SecurityUtils;
import com.m2pool.lease.utils.UuidGeneratorUtil;
@@ -69,6 +66,9 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
@Resource
private LeaseShopMapper leaseShopMapper;
@Resource
private LeaseShopService leaseShopService;
@Resource
private LeasePaymentRecordMapper leasePaymentRecordMapper;
@@ -864,6 +864,7 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
LeaseShop leaseShop = shopMap.get(leaseMachine.getShopId());
leaseShop.setSaleNumber(leaseShop.getSaleNumber() + orderInfoVo.getNumbers());
LeaseOrderItem build = LeaseOrderItem.builder()
.userId(userEmail)
.orderId(leaseOrderInfo.getId())
@@ -895,6 +896,9 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
//获取itemId
machineOrderItemIdMap.put(machineId,build.getId());
}
//修改商铺出售机器
leaseShopService.updateBatchById(shopMap.values());
//开始生成支付订单并返回
checkBalanceAndSetBlockBalance(fromAddressMap,leaseOrderInfoList);
int i = 0;

View File

@@ -16,6 +16,7 @@ import com.m2pool.lease.entity.*;
import com.m2pool.lease.exception.ProductSoldOutException;
import com.m2pool.lease.mapper.*;
import com.m2pool.lease.redis.service.RedisService;
import com.m2pool.lease.service.LeaseMachinePriceService;
import com.m2pool.lease.service.LeaseProductMachinePriceService;
import com.m2pool.lease.service.LeaseProductService;
import com.m2pool.lease.service.LeaseShopConfigService;
@@ -68,6 +69,8 @@ public class LeaseProductServiceImpl extends ServiceImpl<LeaseProductMapper, Lea
@Resource
private LeaseProductMachinePriceMapper leaseProductMachinePriceMapper;
@Resource
private LeaseMachinePriceService leaseMachinePriceService;
@Override
public PageResult<ProductDto> getProductList(ProductPageVo productPageVo) {
@@ -478,22 +481,23 @@ public class LeaseProductServiceImpl extends ServiceImpl<LeaseProductMapper, Lea
}
String[] symbolList = productMachineForWalletConfigVo.getSymbol().split(",");
List<ProductMachineForWalletConfigVo.PriceVo> priceAndIdList = productMachineForWalletConfigVo.getProductMachineForWalletConfigVoList();
List<LeaseProductMachinePrice> leaseProductMachinePriceList = new ArrayList<>();
List<LeaseMachinePrice> leaseProductMachinePriceList = new ArrayList<>();
for (ProductMachineForWalletConfigVo.PriceVo priceVo : priceAndIdList) {
String[] priceList = priceVo.getPrice().split(",");
if (priceList.length != symbolList.length){
return Result.fail("绑定钱包失败,存在商品矿机未设置新钱包售价");
}
for (int i = 0; i < priceList.length; i++) {
leaseProductMachinePriceList.add(LeaseProductMachinePrice.builder()
.productMachineId(priceVo.getProductMachineId())
leaseProductMachinePriceList.add(LeaseMachinePrice.builder()
.machineId(priceVo.getProductMachineId())
.price(new BigDecimal(priceList[i]))
.coin(symbolList[i])
.chain(chain)
.build());
}
}
boolean b = leaseProductMachinePriceService.saveBatch(leaseProductMachinePriceList);
boolean b = leaseMachinePriceService.saveBatch(leaseProductMachinePriceList);
if (b || leaseProductMachinePriceList.isEmpty()){
//绑定钱包新钱包
List<LeaseShopConfig> shopConfigList = leaseShopConfigMapper.getCoinIconByChainAndCoin(chain, payCoinsList);

View File

@@ -445,7 +445,7 @@ public class LeaseShoppingCartServiceImpl extends ServiceImpl<LeaseShoppingCartM
.collect(Collectors.groupingBy(MachinePayTypeDto::getProductMachineId));
//查询店铺中机器详情
List<CartMachineInfoDto> leaseProductMachines = leaseMachineMapper.getMachinesByIds(machineIds);
List<CartMachineInfoDto> leaseProductMachines = leaseMachineMapper.getMachinesByIds(machineIds,userId);
//设置每个矿机的售价,并按店铺分组
Map<Long, List<CartMachineInfoDto>> shopIdAndMachineInfoMap = leaseProductMachines.stream()

View File

@@ -378,9 +378,10 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
@Transactional
public Result<String> closeAccount(CloseAccountVo closeAccountVo) {
String userEmail = SecurityUtils.getUsername();
//1.谷歌验证 和邮箱验证码验证
//1.
GoogleInfo googleInfo = leaseUserMapper.getGoogleInfoByEmail(userEmail);
// 开发环境
//1.1谷歌验证
//if(googleInfo == null || StringUtils.isBlank(googleInfo.getSecret())){
// //未绑定定谷歌验证器
// return Result.fail("您的账号未开启双重验证,请先开启验证!");
@@ -388,8 +389,12 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
//if(!GoogleAuthenticator.checkCode(googleInfo.getSecret(), closeAccountVo.getGCode(), System.currentTimeMillis())){
// return Result.fail("谷歌验证码错误");
//}
//1.2邮箱验证码验证
verifyCode(RedisAuthKey.getCloseAccountKey(userEmail),closeAccountVo.getECode());
//1.3订单,钱包余额校验
//2.删除用户信息
int update = leaseUserMapper.update(LeaseUser.builder().del(true).build(), new LambdaUpdateWrapper<LeaseUser>()
.eq(LeaseUser::getUserId, userEmail));

View File

@@ -138,7 +138,7 @@ public class OrderAndPayTask {
}
@Scheduled(cron = "0 0/2 * * * ? ")
@Scheduled(cron = "0 0/1 * * * ? ")
@Async("scheduledTaskExecutor")
@DSTransactional
public void paymentTaskV2(){
@@ -303,10 +303,9 @@ public class OrderAndPayTask {
//LocalDateTime endTime = orderTimeInfoDto.getCreateTime().plusDays(orderTimeInfoDto.getLeaseTime());
//TODO 开发环境测试用1分钟当一天 差值改为差1分钟
LocalDateTime endTime = orderTimeInfoDto.getCreateTime().plusMinutes(orderTimeInfoDto.getLeaseTime() * 2);
System.out.println("支付开始"+"开始时间"+now+ "结束时间"+endTime+ "差值:"+Duration.between(now, endTime).toMinutes());
// 获取订单完成的订单详情:比较 now 和 endTime 的年月日时分秒差值是否小于30分
if (Duration.between(now, endTime).toMinutes() <= 2) {
LocalDateTime endTime = orderTimeInfoDto.getCreateTime().plusMinutes(orderTimeInfoDto.getLeaseTime() );
// 获取订单完成的订单详情:比较 now 和 endTime 的年月日时分秒差值是否小于30分
if (Duration.between(now, endTime).toMinutes() <= 1) {
completeMachines.add(LeaseMachine.builder()
.id(orderTimeInfoDto.getProductMachineId())
.canSaleNumbers(orderTimeInfoDto.getNumbers())
@@ -427,12 +426,77 @@ public class OrderAndPayTask {
leaseOrderItemMapper.update(LeaseOrderItem.builder().status(0).build(), new LambdaUpdateWrapper<LeaseOrderItem>()
.in(LeaseOrderItem::getId, itemIds));
//修改商品库存矿机表 矿机状态为 0 未售出
leaseMachineMapper.updateBatchSaleNumbers(completeMachines);
System.out.println("打印"+JSONUtil.toJsonPrettyStr(completeMachines));
// 合并相同 id 的机器,避免 SQL CASE WHEN 只执行第一条的问题
List<LeaseMachine> mergedMachines = mergeMachines(completeMachines);
leaseMachineMapper.updateBatchSaleNumbers(mergedMachines);
//挖矿订单信息 改为状态0 租约已过期
leaseOrderMiningMapper.update(LeaseOrderMining.builder().status(false).build(), new LambdaUpdateWrapper<LeaseOrderMining>()
.in(LeaseOrderMining::getOrderItemId, itemIds));
}
/**
* 合并相同 id 的机器,避免 SQL CASE WHEN 只执行第一条的问题
* @param machines 机器列表
* @return 合并后的机器列表
*/
private List<LeaseMachine> mergeMachines(List<LeaseMachine> machines) {
if (machines == null || machines.isEmpty()) {
return new ArrayList<>();
}
return new ArrayList<>(machines.stream()
.collect(Collectors.groupingBy(
LeaseMachine::getId,
Collectors.collectingAndThen(
Collectors.toList(),
list -> {
LeaseMachine merged = list.get(0);
Integer totalSaleOutNumbers = list.stream()
.mapToInt(m -> m.getSaleOutNumbers() != null ? m.getSaleOutNumbers() : 0)
.sum();
Integer totalCanSaleNumbers = list.stream()
.mapToInt(m -> m.getCanSaleNumbers() != null ? m.getCanSaleNumbers() : 0)
.sum();
merged.setSaleOutNumbers(totalSaleOutNumbers);
merged.setCanSaleNumbers(totalCanSaleNumbers);
return merged;
}
)
))
.values());
}
/**
* 合并相同查询条件的支付记录消息,避免 SQL CASE WHEN 只执行第一条的问题
* @param records 支付记录消息列表
* @return 合并后的支付记录消息列表
*/
private List<LeasePayRecordMessage> mergePayRecordMessages(List<LeasePayRecordMessage> records) {
if (records == null || records.isEmpty()) {
return new ArrayList<>();
}
return new ArrayList<>(records.stream()
.collect(Collectors.groupingBy(
r -> r.getFromAddress() + "_" + r.getFromSymbol() + "_" + r.getFromChain(),
Collectors.collectingAndThen(
Collectors.toList(),
list -> {
LeasePayRecordMessage merged = list.get(0);
BigDecimal totalRealAmount = list.stream()
.map(r -> r.getRealAmount() != null ? r.getRealAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalBlockAmount = list.stream()
.map(r -> r.getBlockAmount() != null ? r.getBlockAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
merged.setRealAmount(totalRealAmount);
merged.setBlockAmount(totalBlockAmount);
return merged;
}
)
))
.values());
}
/**
* 支付 定时任务
*/
@@ -819,8 +883,11 @@ public class OrderAndPayTask {
});
System.out.println("部分完成"+JSONUtil.toJsonPrettyStr(reocrdList));
leasePayRecordMessageService.saveBatch(reocrdList);
int buyerUpdate = leaseUserWalletDataMapper.updateBalanceAndBlockBalance(reocrdList);
int sellerUpdate = leaseShopConfigMapper.updateBalance(reocrdList);
// 合并相同查询条件的记录,避免 SQL CASE WHEN 只执行第一条的问题
List<LeasePayRecordMessage> mergedRecordList = mergePayRecordMessages(reocrdList);
int buyerUpdate = leaseUserWalletDataMapper.updateBalanceAndBlockBalance(mergedRecordList);
int sellerUpdate = leaseShopConfigMapper.updateBalance(mergedRecordList);
if (buyerUpdate > 0 && sellerUpdate > 0){
for (LeasePayRecordMessage item : reocrdList) {

View File

@@ -304,7 +304,7 @@
gpc.coin,
gpc.`algorithm`
) sub
JOIN lease_shopping_cart_info ci ON sub.id = ci.product_machine_id
JOIN lease_shopping_cart_info ci ON sub.id = ci.product_machine_id AND ci.user_id = #{userId}
AND ci.version = 1
WHERE
sub.id IN