Merge branch 'master' into pjfk
# Conflicts: # pjcloud-supermarket/pjcloud-supermarket-api/src/main/java/com/bsd/pjcloud/supermarket/vo/app/ShopSpuListAppVo.java # pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/controller/AppShopSpuController.java
This commit is contained in:
commit
7e6d2247dc
20 files changed
+247
-20
No files matched your search
+1
-1
@@ -501,7 +501,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// 判断商户合作状态
|
||||
if (ObjectUtil.equals(mch.getTypes(), MerchantTypeEnum.SUPERMARKET.getType()) && ObjectUtil.equals(mch.getSupType(), WalletMchSupType.MCH.getCode())) {
|
||||
if (ObjectUtil.equals(mch.getCooperationStatus(), YesNoEnum.NO.getCode())) {
|
||||
throw new RuntimeException("改商家未合作");
|
||||
throw new RuntimeException("该商家未合作");
|
||||
}
|
||||
}
|
||||
// 查询用户
|
||||
|
||||
+13
@@ -165,7 +165,20 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
refundDto.setRefundStatusCodes(List.of(HardSaleStatusEnum.COMPLETE.getStatus()));
|
||||
DataScope refundDataScope = DataScope.of();
|
||||
refundDataScope.setScopeDeptName("merchant_dept_id");
|
||||
|
||||
List<HardOrderCsVo> refundList = hardOrderMapper.listRefundCs(refundDto, refundDataScope);
|
||||
// 有退款没有流水的情况
|
||||
if (ObjectUtil.isAllNotEmpty(totalList, refundList)) {
|
||||
List<Long> totalIds = totalList.stream().map(HardOrderCsVo::getMerchantId).toList();
|
||||
for (HardOrderCsVo refund : refundList) {
|
||||
if (!totalIds.contains(refund.getMerchantId())) {
|
||||
HardOrderCsVo entity = BeanUtils.toBean(refund, HardOrderCsVo.class);
|
||||
entity.setTotalPayPrice(BigDecimal.ZERO);
|
||||
entity.setTotalPayCount(BigDecimal.ZERO);
|
||||
totalList.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (HardOrderCsVo v : totalList) {
|
||||
// 退款
|
||||
if (ObjectUtil.isNotEmpty(refundList)) {
|
||||
|
||||
+6
@@ -121,4 +121,10 @@ public class ShopSkuEntity extends Model<ShopSkuEntity> {
|
||||
|
||||
@Schema(description="版本号")
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
@Schema(description="销量")
|
||||
private Integer salesCount;
|
||||
}
|
||||
+4
-3
@@ -46,6 +46,7 @@ public class ShopSpuListAppVo {
|
||||
/**
|
||||
* 总库存
|
||||
*/
|
||||
@Schema(description="总库存")
|
||||
private Double totalStock;
|
||||
}
|
||||
@Schema(description="总销量")
|
||||
private Double salesCount;
|
||||
|
||||
}
|
||||
+12
-12
@@ -48,25 +48,25 @@ public class AppShopSpuController {
|
||||
IPage<ShopSpuEntity> spuPage = shopSpuService.page(page, wrapper);
|
||||
List<Long> spuIds = spuPage.getRecords().stream().map(ShopSpuEntity::getId).collect(java.util.stream.Collectors.toList());
|
||||
List<ShopSkuEntity> skuList = spuIds.isEmpty() ? List.of() : shopSkuService.list(
|
||||
Wrappers.<ShopSkuEntity>lambdaQuery().in(ShopSkuEntity::getSpuId, spuIds)
|
||||
Wrappers.<ShopSkuEntity>lambdaQuery().in(ShopSkuEntity::getSpuId, spuIds)
|
||||
);
|
||||
java.util.Map<Long, List<ShopSkuEntity>> skuMap = skuList.stream().collect(java.util.stream.Collectors.groupingBy(ShopSkuEntity::getSpuId));
|
||||
IPage<ShopSpuListAppVo> voPage = spuPage.convert(spu -> {
|
||||
ShopSpuListAppVo vo = com.bsd.pjcloud.common.core.util.BeanUtils.toBean(spu, ShopSpuListAppVo.class);
|
||||
List<ShopSkuEntity> skus = skuMap.getOrDefault(spu.getId(), List.of());
|
||||
vo.setMinPrice(skus.stream()
|
||||
.map(ShopSkuEntity::getRetailPrice)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.map(price -> new java.math.BigDecimal(price).divide(new java.math.BigDecimal(100)))
|
||||
.min(java.math.BigDecimal::compareTo)
|
||||
.orElse(java.math.BigDecimal.ZERO));
|
||||
vo.setTotalStock(
|
||||
skus.stream()
|
||||
.map(ShopSkuEntity::getStock)
|
||||
.map(ShopSkuEntity::getRetailPrice)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.mapToDouble(Double::doubleValue)
|
||||
.sum()
|
||||
);
|
||||
.map(price -> new java.math.BigDecimal(price).divide(new java.math.BigDecimal(100)))
|
||||
.min(java.math.BigDecimal::compareTo)
|
||||
.orElse(java.math.BigDecimal.ZERO));
|
||||
// vo.setTotalStock(
|
||||
// skus.stream()
|
||||
// .map(ShopSkuEntity::gets)
|
||||
// .filter(java.util.Objects::nonNull)
|
||||
// .mapToDouble(Double::doubleValue)
|
||||
// .sum()
|
||||
// );
|
||||
return vo;
|
||||
});
|
||||
return R.ok(voPage);
|
||||
|
||||
+5
@@ -8,4 +8,9 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface ShopSpuMapper extends PjcloudBaseMapper<ShopSpuEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 修改销量
|
||||
* @param num
|
||||
*/
|
||||
void updateSalesCount(Long spuId,Integer num);
|
||||
}
|
||||
+14
@@ -1,9 +1,12 @@
|
||||
package com.bsd.pjcloud.supermarket.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
|
||||
import com.bsd.pjcloud.supermarket.mapper.ShopSkuMapper;
|
||||
import com.bsd.pjcloud.supermarket.mapper.ShopSpuMapper;
|
||||
import com.bsd.pjcloud.supermarket.service.ShopSkuService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
/**
|
||||
* sku
|
||||
@@ -12,7 +15,10 @@ import org.springframework.stereotype.Service;
|
||||
* @date 2025-06-19 12:43:40
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ShopSkuServiceImpl extends ServiceImpl<ShopSkuMapper, ShopSkuEntity> implements ShopSkuService {
|
||||
|
||||
private final ShopSpuMapper shopSpuMapper;
|
||||
/**
|
||||
* 修改库存(乐观锁)
|
||||
* 正数:增加库存,负数:扣减库存
|
||||
@@ -24,7 +30,15 @@ public class ShopSkuServiceImpl extends ServiceImpl<ShopSkuMapper, ShopSkuEntity
|
||||
if (sku == null) return false;
|
||||
// 扣减时判断库存是否足够
|
||||
if (num < 0 && sku.getStock() < -num) return false;
|
||||
LambdaQueryWrapper<ShopSkuEntity> shopSkuEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
shopSkuEntityLambdaQueryWrapper.eq(ShopSkuEntity::getId, skuId);
|
||||
ShopSkuEntity shopSkuEntity = baseMapper.selectOne(shopSkuEntityLambdaQueryWrapper);
|
||||
if (null==shopSkuEntity){
|
||||
return false;
|
||||
}
|
||||
int updated = baseMapper.deductStock(skuId, num, sku.getVersion());
|
||||
//更新spu已售总数
|
||||
shopSpuMapper.updateSalesCount(shopSkuEntity.getSpuId(),num);
|
||||
if (updated > 0) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -22,11 +22,12 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="salesCount" column="sales_count"/>
|
||||
</resultMap>
|
||||
|
||||
<update id="deductStock">
|
||||
UPDATE shop_sku
|
||||
SET stock = stock + #{num}, version = version + 1
|
||||
SET stock = stock + #{num}, version = version + 1,sales_count=sales_count+#{num}
|
||||
WHERE id = #{skuId} AND stock + #{num} >= 0 AND version = #{version}
|
||||
</update>
|
||||
</mapper>
|
||||
+5
@@ -28,4 +28,9 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
<update id="updateSalesCount">
|
||||
UPDATE shop_spu
|
||||
SET sales_count=sales_count+#{num}
|
||||
WHERE id = #{spuId}
|
||||
</update>
|
||||
</mapper>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletQbTotalVo {
|
||||
|
||||
/**
|
||||
* 总余额
|
||||
*/
|
||||
private Long total = 0L;
|
||||
|
||||
/**
|
||||
* 饭卡钱包余额
|
||||
*/
|
||||
private Long eatTotal = 0L;
|
||||
|
||||
/**
|
||||
* 消费钱包余额
|
||||
*/
|
||||
private Long payTotal = 0L;
|
||||
|
||||
}
|
||||
+7
@@ -18,6 +18,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTopupActionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletQbTotalVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
@@ -201,6 +202,12 @@ public class WalletManageController {
|
||||
return R.ok(walletManageService.scopePageList(page, dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@PostMapping("/qb-total")
|
||||
public R<WalletQbTotalVo> qbTotal(@RequestBody WalletManageBalanceDto dto) {
|
||||
return R.ok(walletManageService.qbTotal(dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@Operation(summary = "钱包记录分页", description = "钱包记录分页")
|
||||
@PostMapping("/page-join-qb")
|
||||
public R<Page<WalletManageVo>> pageJoinQb(@ParameterObject Page page, @RequestBody WalletManageBalanceDto dto) {
|
||||
|
||||
+9
-1
@@ -17,6 +17,8 @@ import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeSaveTopupDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyCompareAceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletRechargeByApplyExcelVo;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyComposeService;
|
||||
@@ -61,10 +63,16 @@ public class WalletRechargeApplyController {
|
||||
|
||||
@GetMapping("/compare-page-join")
|
||||
@Operation(summary = "批量充值/扣款记录")
|
||||
public R comparePageJoin(@ParameterObject Page page, @ParameterObject WalletRechargeApplyDto dto) {
|
||||
public R<WalletRechargeApplyCompareAceVo> comparePageJoin(@ParameterObject Page page, @ParameterObject WalletRechargeApplyDto dto) {
|
||||
return R.ok(walletTransactionComposeService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/compare-invoice-page-join")
|
||||
@Operation(summary = "批量充值/扣款记录发票查询")
|
||||
public R<Page<WalletRechargeImportVo>> compareInvoicePageJoin(@ParameterObject Page page, @ParameterObject WalletRechargeApplyDto dto) {
|
||||
return R.ok(walletTransactionComposeService.compareInvoicePageJoin(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "提交申请", description = "提交申请")
|
||||
@SysLog("提交申请")
|
||||
@GetMapping("/apply")
|
||||
|
||||
+2
@@ -167,4 +167,6 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
Page<WalletManageVo> activeBalancePage(Page page, @Param("dto") WalletTopupActionDto dto, @Param("unactiveDayNumberStr") String unactiveDayNumberStr);
|
||||
|
||||
List<WalletManageVo> activeBalanceList(@Param("dto") WalletTopupActionDto dto, @Param("unactiveDayNumberStr") String unactiveDayNumberStr);
|
||||
|
||||
Long selectTotalBalance(@Param("dto") WalletManageBalanceDto dto);
|
||||
}
|
||||
+1
@@ -25,6 +25,7 @@ public interface WalletRechargeImportMapper extends PjcloudBaseMapper<WalletRech
|
||||
MPJLambdaWrapper<WalletRechargeImportEntity> wrapper = new MPJLambdaWrapper<WalletRechargeImportEntity>()
|
||||
.eqIfExists(WalletRechargeImportEntity::getId, dto.getId())
|
||||
.eqIfExists(WalletRechargeImportEntity::getApplyId, dto.getApplyId())
|
||||
.eqIfExists(WalletRechargeImportEntity::getInvoiceId, dto.getInvoiceId())
|
||||
.orderByDesc(WalletRechargeImportEntity::getCreateTime)
|
||||
.orderByDesc(WalletRechargeImportEntity::getUserId);
|
||||
return selectJoinPage(page, WalletRechargeImportVo.class, wrapper);
|
||||
|
||||
+3
@@ -9,6 +9,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTopupActionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletQbTotalVo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@@ -68,6 +69,8 @@ public interface WalletManageService extends IService<WalletManageEntity> {
|
||||
|
||||
Page<WalletManageVo> scopeQbPage(Page page, WalletManageBalanceDto dto, DataScope dataScope);
|
||||
|
||||
WalletQbTotalVo qbTotal(WalletManageBalanceDto dto, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 不活跃用户钱包
|
||||
*/
|
||||
|
||||
+6
@@ -4,8 +4,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeSaveTopupDto;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyCompareAceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
|
||||
public interface WalletRechargeApplyComposeService {
|
||||
|
||||
WalletRechargeApplyCompareAceVo pageJoin(Page page, WalletRechargeApplyDto dto);
|
||||
|
||||
/**
|
||||
* 批量充值/扣款记录发票查询
|
||||
*/
|
||||
Page<WalletRechargeImportVo> compareInvoicePageJoin(Page page, WalletRechargeApplyDto dto);
|
||||
}
|
||||
+27
-1
@@ -40,6 +40,7 @@ import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageBalanceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletQbTotalVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
@@ -51,7 +52,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -59,6 +59,8 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* 钱包管理
|
||||
@@ -306,6 +308,30 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
return walletPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletQbTotalVo qbTotal(WalletManageBalanceDto dto, DataScope dataScope) {
|
||||
WalletQbTotalVo result = new WalletQbTotalVo();
|
||||
// 查询钱包类表
|
||||
List<WalletTypeEntity> walletTypeList = walletTypeService.list();
|
||||
// 查询所有钱包类型的流水记录
|
||||
for (WalletTypeEntity i : walletTypeList) {
|
||||
WalletManageBalanceDto walletBalanceDto = BeanUtils.toBean(dto, WalletManageBalanceDto.class);
|
||||
walletBalanceDto.setWalletTypeId(i.getId());
|
||||
|
||||
Long total = baseMapper.selectTotalBalance(walletBalanceDto);
|
||||
if (ObjectUtil.isEmpty(total)) total = 0L;
|
||||
|
||||
if (ObjectUtil.equals(i.getUniqueCode(), WalletTypeEnum.EAT.getCode())) {
|
||||
result.setEatTotal(total);
|
||||
}
|
||||
if (ObjectUtil.equals(i.getUniqueCode(), WalletTypeEnum.PAY.getCode())) {
|
||||
result.setPayTotal(total);
|
||||
}
|
||||
}
|
||||
result.setTotal(result.getEatTotal() + result.getPayTotal());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不活跃用户钱包
|
||||
*/
|
||||
|
||||
+32
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.wallet.service.impl.recharge;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
@@ -164,6 +165,37 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<WalletRechargeImportVo> compareInvoicePageJoin(Page page, WalletRechargeApplyDto dto) {
|
||||
WalletRechargeImportDto importDto = new WalletRechargeImportDto();
|
||||
WalletRechargeApplyEntity applyEntity = null;
|
||||
|
||||
if (ObjectUtil.isNotEmpty(dto.getInvoiceId())) {
|
||||
importDto.setInvoiceId(dto.getInvoiceId());
|
||||
} else if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
importDto.setApplyId(dto.getId());
|
||||
applyEntity = rechargeApplyService.getById(dto.getId());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
Page<WalletRechargeImportVo> list = rechargeImportService.pageJoin(page, importDto);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
for (WalletRechargeImportVo v : list.getRecords()) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getInvoiceId())) {
|
||||
v.setBizType(WalletBizRechargeEnum.ADD.getCode());
|
||||
} else if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
if (ObjectUtil.isNotEmpty(applyEntity)) {
|
||||
v.setBizType(dto.getBizType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void getItem(WalletRechargeImportVo user,
|
||||
List<WalletRechargeApplySelectCompareVo> monthList,
|
||||
List<WalletRechargeApplySelectCompareVo> prenMonthList,
|
||||
|
||||
-1
@@ -103,7 +103,6 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
|
||||
.set(WalletRechargeInvoiceEntity::getProcessStatus, null)
|
||||
.set(WalletRechargeInvoiceEntity::getProcessTime, null)
|
||||
.set(WalletRechargeInvoiceEntity::getStampPicUrl, null)
|
||||
.set(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.FINANCE_CANCELLATION.getCode())
|
||||
.eq(WalletRechargeInvoiceEntity::getId, id)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,4 +192,79 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTotalBalance" resultType="java.lang.Long">
|
||||
SELECT
|
||||
SUM(a.balance)
|
||||
FROM wallet_transaction a
|
||||
LEFT JOIN wallet_manage m on a.wallet_id = m.id
|
||||
<where>
|
||||
a.del_flag = 0
|
||||
<if test="dto.walletRecordMonth != null">
|
||||
AND a.create_time = (
|
||||
SELECT MAX(sub.create_time)
|
||||
FROM wallet_transaction sub
|
||||
LEFT JOIN wallet_manage wallet on wallet.id = sub.wallet_id
|
||||
WHERE sub.user_id = a.user_id
|
||||
AND DATE_FORMAT(sub.create_time, '%Y-%m') <= #{dto.walletRecordMonth}
|
||||
<if test="dto.userId != null">
|
||||
AND sub.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.userIds != null and dto.userIds.size() != 0">
|
||||
and sub.user_id in
|
||||
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
|
||||
<choose>
|
||||
<when test="dto.isInclude != null and dto.isInclude == true">
|
||||
and wallet.dept_id IN
|
||||
</when>
|
||||
<when test="dto.isInclude != null and dto.isInclude == false">
|
||||
and wallet.dept_id NOT IN
|
||||
</when>
|
||||
<otherwise>
|
||||
and wallet.dept_id IN
|
||||
</otherwise>
|
||||
</choose>
|
||||
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.walletTypeId != null">
|
||||
AND wallet.wallet_type_id = #{dto.walletTypeId}
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="dto.userId != null">
|
||||
AND a.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.walletTypeId != null">
|
||||
AND m.wallet_type_id = #{dto.walletTypeId}
|
||||
</if>
|
||||
<if test="dto.userIds != null and dto.userIds.size() != 0">
|
||||
and a.user_id in
|
||||
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
|
||||
<choose>
|
||||
<when test="dto.isInclude != null and dto.isInclude == true">
|
||||
and m.dept_id IN
|
||||
</when>
|
||||
<when test="dto.isInclude != null and dto.isInclude == false">
|
||||
and m.dept_id NOT IN
|
||||
</when>
|
||||
<otherwise>
|
||||
and m.dept_id IN
|
||||
</otherwise>
|
||||
</choose>
|
||||
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user