update 优化订单支付定时任务批量修改金额相关sql
This commit is contained in:
@@ -111,15 +111,13 @@ public class LeaseProductController {
|
||||
}
|
||||
|
||||
|
||||
//TODO 2025-11-21 查询店铺的矿机列表,不存在商品了
|
||||
|
||||
@ApiOperation("获取店铺商品列表用于新增绑定店铺钱包")
|
||||
@ApiOperation("获取店铺商品列表用于新增绑定店铺钱包-v1")
|
||||
@PostMapping("/getProductListForShopWalletConfig")
|
||||
public Result<List<ProductForWalletConfigDto>> getProductListForShopWalletConfig() {
|
||||
return leaseProductService.getProductListForShopWalletConfig();
|
||||
}
|
||||
|
||||
//TODO 2025-11-21 修改这些矿机的价格,并且绑定新钱包
|
||||
|
||||
@ApiOperation("新增绑定店铺钱包并设置店铺下面每个矿机该钱包币种的售价 + 钱包绑定")
|
||||
@PostMapping("/updateProductListForShopWalletConfig")
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.m2pool.lease.controller;
|
||||
|
||||
import com.m2pool.lease.annotation.LoginRequired;
|
||||
import com.m2pool.lease.dto.*;
|
||||
import com.m2pool.lease.dto.v2.MachineForWalletConfigDto;
|
||||
import com.m2pool.lease.dto.v2.MachineInfoDto;
|
||||
import com.m2pool.lease.dto.v2.SellerMachineInfoDto;
|
||||
import com.m2pool.lease.dto.v2.ShopInfoDto;
|
||||
@@ -104,7 +105,11 @@ public class LeaseProductMachineV2Controller {
|
||||
return leaseMachineService.getSupportAlgo(coin);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取店铺商品列表用于新增绑定店铺钱包-v2")
|
||||
@PostMapping("/getProductListForShopWalletConfig")
|
||||
public Result<List<MachineForWalletConfigDto>> getProductListForShopWalletConfig() {
|
||||
return leaseMachineService.getProductListForShopWalletConfig();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ProductMachineForWalletConfigVo {
|
||||
public static class PriceVo{
|
||||
@ApiModelProperty(value = "矿机ID")
|
||||
private Long productMachineId;
|
||||
@ApiModelProperty(value = "单价,可以多个以逗号隔开")
|
||||
@ApiModelProperty(value = "单价")
|
||||
private String price;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.m2pool.lease.dto.v2;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品对应实际商品返回对象
|
||||
* </p>
|
||||
*
|
||||
* @author yyb
|
||||
* @since 2025-07-23
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(description = "钱包配置修改矿机支付方式返回对象",value = "MachineForWalletConfigDto" )
|
||||
public class MachineForWalletConfigDto {
|
||||
|
||||
@ApiModelProperty(value = "矿机ID")
|
||||
private Long productMachineId;
|
||||
|
||||
@ApiModelProperty(value = "挖矿机器 对应的矿工账号")
|
||||
private String user;
|
||||
|
||||
@ApiModelProperty(value = "挖矿机器型号0 ASIC 1 GPU")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "挖矿机器编号")
|
||||
private String miner;
|
||||
|
||||
@ApiModelProperty(value = "上下架状态,0 上架,1 下架")
|
||||
private Integer state;
|
||||
|
||||
@ApiModelProperty(value = "售出状态 0未售出 1已售出 2售出中")
|
||||
private Integer saleState;
|
||||
|
||||
|
||||
|
||||
//@ApiModelProperty(value = "挖矿币种")
|
||||
//private String coin;
|
||||
//
|
||||
//@ApiModelProperty(value = "算力单位")
|
||||
//private String unit;
|
||||
//
|
||||
//@ApiModelProperty(value = "理论算力(卖方手动填写)")
|
||||
//private BigDecimal theoryPower;
|
||||
//
|
||||
//@ApiModelProperty(value = "单机理论收入(每日) 单位币种")
|
||||
//private BigDecimal theoryIncome;
|
||||
//
|
||||
//@ApiModelProperty(value = "单机理论收入(每日) 单位USDT")
|
||||
//private BigDecimal theoryUsdtIncome;
|
||||
//
|
||||
//@ApiModelProperty(value = "功耗 单位kw/h",example = "10")
|
||||
//private BigDecimal powerDissipation;
|
||||
//
|
||||
//@ApiModelProperty(value = "单价")
|
||||
//private BigDecimal price;
|
||||
//
|
||||
//@ApiModelProperty(value = "支付链")
|
||||
//private BigDecimal chain;
|
||||
//
|
||||
//@ApiModelProperty(value = "支付币种")
|
||||
//private BigDecimal symbol;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.m2pool.lease.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.m2pool.lease.dto.MachinePayTypeDto;
|
||||
import com.m2pool.lease.dto.ProductMachineForWalletConfigDto;
|
||||
import com.m2pool.lease.dto.v2.*;
|
||||
import com.m2pool.lease.entity.LeaseMachine;
|
||||
import com.m2pool.lease.vo.v2.SellerMachineVo;
|
||||
@@ -162,4 +163,10 @@ public interface LeaseMachineMapper extends BaseMapper<LeaseMachine> {
|
||||
*/
|
||||
int checkHasSaleMachineByShopId(@Param("shopId") Long shopId);
|
||||
|
||||
/**
|
||||
* 获取店铺下可出售的矿机列表
|
||||
* @param shopId
|
||||
* @return
|
||||
*/
|
||||
List<MachineForWalletConfigDto> getProductListForShopWalletConfig(@Param("shopId") Long shopId);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.m2pool.lease.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.m2pool.lease.dto.PageResult;
|
||||
import com.m2pool.lease.dto.ProductMachineForWalletConfigDto;
|
||||
import com.m2pool.lease.dto.Result;
|
||||
import com.m2pool.lease.dto.v2.MachineForWalletConfigDto;
|
||||
import com.m2pool.lease.dto.v2.MachineInfoDto;
|
||||
import com.m2pool.lease.dto.v2.SellerMachineInfoDto;
|
||||
import com.m2pool.lease.dto.v2.ShopInfoDto;
|
||||
@@ -92,4 +94,11 @@ public interface LeaseMachineService extends IService<LeaseMachine> {
|
||||
* @return
|
||||
*/
|
||||
Result<List<String>> getSupportAlgo( String coin);
|
||||
|
||||
|
||||
/**
|
||||
* 获取店铺商品列表用于新增绑定店铺钱包
|
||||
* @return
|
||||
*/
|
||||
Result<List<MachineForWalletConfigDto>> getProductListForShopWalletConfig();
|
||||
}
|
||||
|
||||
@@ -467,4 +467,15 @@ public class LeaseMachineServiceImpl extends ServiceImpl<LeaseMachineMapper, Lea
|
||||
List<String> supportAlgo = leaseMachineMapper.getSupportAlgo(coin);
|
||||
return Result.success(supportAlgo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<MachineForWalletConfigDto>> getProductListForShopWalletConfig() {
|
||||
LeaseShop leaseShop = leaseShopMapper.selectOne(new LambdaQueryWrapper<LeaseShop>()
|
||||
.select(LeaseShop::getId)
|
||||
.eq(LeaseShop::getUserEmail, SecurityUtils.getUsername())
|
||||
.eq(LeaseShop::getDel, false));
|
||||
List<MachineForWalletConfigDto> machineForWalletConfigDtoList = leaseMachineMapper.getProductListForShopWalletConfig(leaseShop.getId());
|
||||
|
||||
return Result.success(machineForWalletConfigDtoList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ public class LeaseProductServiceImpl extends ServiceImpl<LeaseProductMapper, Lea
|
||||
|
||||
@Override
|
||||
public Result<List<PayTypeDto>> getSupportPayType() {
|
||||
Long shopId = getShopIdByProductId();
|
||||
Long shopId = getShopIdByUsername();
|
||||
List<PayTypeDto> supportPayType = leaseProductMapper.getSupportPayType(shopId);
|
||||
return Result.success(supportPayType);
|
||||
}
|
||||
@@ -430,7 +430,7 @@ public class LeaseProductServiceImpl extends ServiceImpl<LeaseProductMapper, Lea
|
||||
|
||||
@Override
|
||||
public Result<List<ProductForWalletConfigDto>> getProductListForShopWalletConfig() {
|
||||
Long shopId = getShopIdByProductId();
|
||||
Long shopId = getShopIdByUsername();
|
||||
//1.获取商品列表
|
||||
List<ProductForWalletConfigDto> productForShopWalletConfigDtoList = leaseProductMapper.getProductListForShopWalletConfig(shopId);
|
||||
if (productForShopWalletConfigDtoList.isEmpty()){
|
||||
@@ -455,7 +455,7 @@ public class LeaseProductServiceImpl extends ServiceImpl<LeaseProductMapper, Lea
|
||||
return Result.success(productForShopWalletConfigDtoList);
|
||||
}
|
||||
|
||||
public Long getShopIdByProductId(){
|
||||
public Long getShopIdByUsername(){
|
||||
LeaseShop leaseShop = leaseShopMapper.selectOne(new LambdaQueryWrapper<LeaseShop>()
|
||||
.select(LeaseShop::getId)
|
||||
.eq(LeaseShop::getUserEmail, SecurityUtils.getUsername())
|
||||
|
||||
@@ -491,6 +491,7 @@ public class LeaseShopServiceImpl extends ServiceImpl<LeaseShopMapper, LeaseShop
|
||||
//4.查询店铺中是否存在要删除链的钱包 的订单,存在订单不能删除
|
||||
Long l = leaseOrderItemMapper.selectCount(new LambdaQueryWrapper<LeaseOrderItem>()
|
||||
.eq(LeaseOrderItem::getChain, config.getChain())
|
||||
.eq(LeaseOrderItem::getFromSymbol, config.getPayCoin())
|
||||
.ne(LeaseOrderItem::getStatus, 0)
|
||||
);
|
||||
if (l > 0){
|
||||
@@ -505,6 +506,7 @@ public class LeaseShopServiceImpl extends ServiceImpl<LeaseShopMapper, LeaseShop
|
||||
leaseMachinePriceMapper.update(LeaseMachinePrice.builder().del(true).build(),
|
||||
new LambdaQueryWrapper<LeaseMachinePrice>()
|
||||
.eq(LeaseMachinePrice::getChain, config.getChain())
|
||||
.eq(LeaseMachinePrice::getCoin, config.getPayCoin())
|
||||
.in(LeaseMachinePrice::getMachineId,ids)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -447,14 +447,34 @@
|
||||
|
||||
|
||||
<update id="updateBatchSaleNumbers">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
UPDATE lease_machine
|
||||
SET
|
||||
sale_out_numbers = sale_out_numbers - #{item.saleOutNumbers},
|
||||
can_sale_numbers = can_sale_numbers + #{item.canSaleNumbers}
|
||||
WHERE
|
||||
id = #{item.id}
|
||||
</foreach>
|
||||
UPDATE lease_machine
|
||||
SET
|
||||
sale_out_numbers = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN id = #{item.id}
|
||||
THEN sale_out_numbers - #{item.saleOutNumbers}
|
||||
</foreach>
|
||||
ELSE sale_out_numbers
|
||||
END,
|
||||
can_sale_numbers = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN id = #{item.id}
|
||||
THEN can_sale_numbers + #{item.canSaleNumbers}
|
||||
</foreach>
|
||||
ELSE can_sale_numbers
|
||||
END,
|
||||
sale_state = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN id = #{item.id}
|
||||
THEN false
|
||||
</foreach>
|
||||
ELSE sale_state
|
||||
END
|
||||
WHERE id IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
|
||||
<select id="checkHasSaleMachineByShopId" resultType="java.lang.Integer">
|
||||
@@ -467,5 +487,19 @@
|
||||
and `sale_state` = 1
|
||||
and `del` = 0
|
||||
</select>
|
||||
<select id="getProductListForShopWalletConfig"
|
||||
resultType="com.m2pool.lease.dto.v2.MachineForWalletConfigDto">
|
||||
SELECT
|
||||
lpm.id as productMachineId,
|
||||
lpm.`user`,
|
||||
lpm.type,
|
||||
lpm.miner,
|
||||
lpm.state,
|
||||
lpm.sale_state as saleState
|
||||
FROM
|
||||
lease_machine lpm
|
||||
WHERE
|
||||
del = false AND lpm.shop_id = #{shopId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -90,11 +90,31 @@
|
||||
</select>
|
||||
|
||||
<update id="updateBalance">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
UPDATE lease_shop_config
|
||||
SET balance = balance + #{item.realAmount}
|
||||
WHERE pay_address = #{item.fromAddress} AND pay_coin = #{item.fromSymbol} AND chain = #{item.fromChain} AND del = false
|
||||
</foreach>
|
||||
UPDATE lease_shop_config
|
||||
SET balance = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN pay_address = #{item.fromAddress} AND pay_coin = #{item.fromSymbol} AND chain = #{item.fromChain} AND del = false
|
||||
THEN balance + #{item.realAmount}
|
||||
</foreach>
|
||||
ELSE balance
|
||||
END
|
||||
WHERE pay_address IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromAddress}
|
||||
</foreach>
|
||||
)
|
||||
AND pay_coin IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromSymbol}
|
||||
</foreach>
|
||||
)
|
||||
AND chain IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromChain}
|
||||
</foreach>
|
||||
)
|
||||
AND del = false
|
||||
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -108,12 +108,37 @@
|
||||
|
||||
|
||||
<update id="updateBalanceAndBlockBalance">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
UPDATE lease_user_wallet_data
|
||||
SET balance = balance - #{item.realAmount},
|
||||
blocked_balance = blocked_balance - #{item.blockAmount}
|
||||
WHERE from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
|
||||
UPDATE lease_user_wallet_data
|
||||
SET balance = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
|
||||
THEN balance - #{item.realAmount}
|
||||
</foreach>
|
||||
ELSE balance
|
||||
END,
|
||||
blocked_balance = CASE
|
||||
<foreach collection="list" item="item">
|
||||
WHEN from_address = #{item.fromAddress} AND from_symbol = #{item.fromSymbol} AND from_chain = #{item.fromChain} AND del = false
|
||||
THEN blocked_balance - #{item.blockAmount}
|
||||
</foreach>
|
||||
ELSE blocked_balance
|
||||
END
|
||||
WHERE from_address IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromAddress}
|
||||
</foreach>
|
||||
)
|
||||
AND from_symbol IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromSymbol}
|
||||
</foreach>
|
||||
)
|
||||
AND from_chain IN (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fromChain}
|
||||
</foreach>
|
||||
)
|
||||
AND del = false
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user