feat:核销活动

This commit is contained in:
dzc committed 2025-10-31 16:35:39 +08:00
1 parent 069e329d9f
commit 0669710359
23 files changed
+254 -26

No files matched your search

@@ -28,7 +28,7 @@ public enum HardTypeEnum {
private final String description;
// 是否能预定
public static final List<HardTypeEnum> isReserveList = List.of(SUPERMARKET, CANTEEN);
public static final List<HardTypeEnum> isReserveList = List.of(SUPERMARKET, CANTEEN, FARMER);
// 不需要创建购物车
public static final List<HardTypeEnum> isNoneCar = List.of(MERCHANT_QR_CODE);
@@ -29,7 +29,7 @@ public enum HardOrderTypeEnum {
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
}
public static final List<HardOrderTypeEnum> refundList = List.of(BELOW, RESERVE, FOREIGN_TICKET, ZY, LB);
public static final List<HardOrderTypeEnum> refundList = List.of(BELOW, RESERVE, FOREIGN_TICKET, ZY, LB, FARMER);
public static final List<HardOrderTypeEnum> payList = List.of(BELOW, RESERVE);
@@ -19,7 +19,7 @@ public class HardAppCreateFarmerOrderDto {
@NotNull(message = "购物车id不能为空")
private Long carParentId;
@NotNull(message = "钱包类型id")
// @NotNull(message = "钱包类型id")
private Long walletTypeId;
@NotNull(message = "自提点id不能为空")
@@ -135,6 +135,16 @@ public class HardOrderController {
return R.ok(hardwareOrderService.pagejoin(page, dto));
}
@Operation(summary = "app查询共富商城列表", description = "app查询共富商城列表")
@GetMapping("/app/farmer-page-join")
public R appFarmerPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
dto.setIsFindCarList(true);
dto.setMchTypeCodes(List.of(MerchantTypeEnum.FARMER.getType()));
return R.ok(hardwareOrderService.pagejoin(page, dto));
}
@Operation(summary = "app商户查询订单列表", description = "app商户查询订单列表")
@GetMapping("/app/mch-page-join")
public R appMchPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
@@ -511,17 +511,22 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
}
// 共富商城
if (ObjectUtil.equals(sysType, HardTypeEnum.FARMER)) {
List<MallProductDetailAppVo> supList = remoteMallProductService.getDetailByIds(productIds).getData();
List<MallProductDetailAppVo> spuList = remoteMallProductService.getSkusWithSpuBySkuIds(productIds).getData();
for (HardCreateCarDto v : list) {
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
str.append(spu.getTitle()).append("x");
if (ObjectUtil.equals(spu.getProductNature(), HardProductNatureEnum.DEFAULT.getType())) {
str.append(v.getProductCount());
} else if (ObjectUtil.equals(spu.getProductNature(), HardProductNatureEnum.WEIGHT.getType())) {
str.append(v.getProductWeight()).append("/kg");
spu:
for (MallProductDetailAppVo spu : spuList) {
if (ObjectUtil.isEmpty(spu) || ObjectUtil.isEmpty(spu.getSkuList())) {
continue spu;
}
str.append(";");
});
MallProductSkuAppVo sku = spu.getSkuList().stream().filter(_item -> ObjectUtil.equals(_item.getId(), v.getProductId())).findFirst().orElse(null);
if (ObjectUtil.isEmpty(sku)) {
continue spu;
}
if (ObjectUtil.isEmpty(spu.getSkuList())) {
throw new RuntimeException("共富商城商品无SKU信息商品名字:" + spu.getTitle() + "商品ID:" + spu.getId() + "请联系管理员");
}
str.append(spu.getTitle()).append("/").append(sku.getSkuName()).append("x").append(v.getProductCount()).append(";");
}
}
}
return str.toString();
@@ -92,6 +92,7 @@ import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchPickUpVo;
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
import jakarta.validation.Valid;
@@ -645,7 +646,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
// 钱包
WalletManageEntity wallet = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), dto.getWalletTypeId()).getData();
WalletManageEntity wallet = null;
if (ObjectUtil.isEmpty(dto.getWalletTypeId())) {
wallet = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.PAY).getData();
} else {
wallet = remoteWalletService.getWalletByWalletTypeId(dto.getUserId(), dto.getWalletTypeId()).getData();
}
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
// 查询父订单
HardParentCarEntity parentCar = hardCarService.getParentCarById(dto.getCarParentId());
@@ -769,7 +775,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
public Long appCreateActOrder(HardCreateActOrderDto dto) {
if (ObjectUtil.isEmpty(dto.getCancelUserId())) throw new RuntimeException("核销用户不能为空");
// 查询活动详情
ActCancelItemEntity actDetail = remoteActCancelService.getDetail(dto.getActId()).getData();
ActCancelItemVo actDetail = remoteActCancelService.getDetail(dto.getActId()).getData();
if (ObjectUtil.isEmpty(actDetail)) throw new RuntimeException("活动不存在");
if (ObjectUtil.isNotEmpty(actDetail.getExpireTime())) {
if (actDetail.getExpireTime().isBefore(LocalDateTime.now())) {
@@ -804,7 +810,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
WalletManageEntity wallet = remoteWalletService.getWallet(userDetail.getSysUser().getUserId(), WalletTypeEnum.PAY).getData();
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
Integer balance = wallet.getBalance();
int totalPrice = 1 * 100;
int totalPrice = actDetail.getActiveCancelPrice();
String subject = "活动商品x?";
if (balance < totalPrice) throw new RuntimeException("钱包余额不足");
@@ -1136,6 +1142,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.SUPERMARKET) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) {
codeType = WalletCodeBizEnum.SUPERMARKET_RESERVE;
}
// 共富商城预定核销
if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.FARMER) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.FARMER)) {
codeType = WalletCodeBizEnum.FARMER_RESERVE;
}
if (ObjectUtil.isEmpty(codeType)) return;
R<Boolean> res = remoteCodeUseService.generateCode(order.getId(), order.getUserId(), codeType, 1);
if (res.getCode() != 0 || !res.getData()) {
@@ -1455,7 +1465,8 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private Boolean isHaveCode(HardOrderEntity order) {
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
if (ObjectUtil.isEmpty(orderTypeEnum)) return false;
if (!ObjectUtil.equals(HardOrderTypeEnum.RESERVE, orderTypeEnum)) {
List<HardOrderTypeEnum> typeList = List.of(HardOrderTypeEnum.RESERVE, HardOrderTypeEnum.FARMER);
if (!typeList.contains(orderTypeEnum)) {
return false;
}
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(order.getSysType());
@@ -14,6 +14,7 @@ public enum WalletCodeBizEnum {
CANTEEN_RESERVE("3", "食堂线上预订"),
SUPERMARKET_RESERVE("4", "超市线上预订"),
USER_WALLET("5", "用户钱包二维码"),
FARMER_RESERVE("6", "用户钱包二维码"),
;
private final String code;
@@ -3,7 +3,10 @@ package com.bsd.pjcloud.wallet.api.dto.act;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelEntity;
import lombok.Data;
import java.util.List;
@Data
public class ActCancelDto extends ActCancelEntity {
}
@@ -4,10 +4,15 @@ import com.bsd.pjcloud.wallet.api.entity.act.ActCancelItemEntity;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class ActCancelItemDto extends ActCancelItemEntity {
private List<Long> actIdList;
private List<Long> mchIdList;
private LocalDateTime[] cancelTimeList;
}
@@ -5,6 +5,7 @@ import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelItemEntity;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -17,7 +18,7 @@ public interface RemoteActCancelService {
@NoToken
@GetMapping("/act/cancel-item/get-detail")
R<ActCancelItemEntity> getDetail(@RequestParam Long id);
R<ActCancelItemVo> getDetail(@RequestParam Long id);
@NoToken
@PostMapping("/act/cancel-item/cancel")
@@ -0,0 +1,25 @@
package com.bsd.pjcloud.wallet.api.vo.act;
import lombok.Data;
@Data
public class ActCancelItemCountVo {
private Long actId;
/**
* 预约总数
*/
private Long totalCount;
/**
* 核销总数
*/
private Long cancelCount;
/**
* 未核销总数
*/
private Long cancelAwaitCount;
}
@@ -21,4 +21,9 @@ public class ActCancelItemVo extends ActCancelItemEntity {
*/
private String mchName;
/**
* 活动核销价格
*/
private Integer activeCancelPrice;
}
@@ -18,4 +18,9 @@ public class ActCancelVo extends ActCancelEntity implements BaseMchInterface {
private String merchantType;
/**
* 统计相关
*/
private ActCancelItemCountVo countVo;
}
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelDto;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelEntity;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelVo;
import com.bsd.pjcloud.wallet.service.ActCancelService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -30,10 +31,20 @@ public class ActCancelController {
private final ActCancelService actCancelService;
/* ************************************* start app start ************************************* */
@Operation(summary = "根据公告id查询活动", description = "根据公告id查询活动")
@GetMapping("/app/detail-by-notice-id")
public R getDetailByNoticeId(@RequestParam Long id) {
return R.ok(actCancelService.getDetailByNoticeId(id));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_actCancel_view')")
public R getActCancelPage(@ParameterObject Page page, @ParameterObject ActCancelDto dto) {
public R<Page<ActCancelVo>> getActCancelPage(@ParameterObject Page page, @ParameterObject ActCancelDto dto) {
return R.ok(actCancelService.scopePageJoin(page, dto, DataScope.of()));
}
@@ -35,13 +35,11 @@ public class ActCancelItemController {
private final ActCancelItemService actCancelItemService;
/* ************************************* start 远程调用 start ************************************* */
@Inner()
@Operation(summary = "查询优惠券详情", description = "查询优惠券详情")
@GetMapping("/get-detail")
public R<ActCancelItemEntity> getDetail(@RequestParam Long id) {
return R.ok(actCancelItemService.getById(id));
public R<ActCancelItemVo> getDetail(@RequestParam Long id) {
return R.ok(actCancelItemService.getDetail(id));
}
@Inner()
@@ -1,11 +1,18 @@
package com.bsd.pjcloud.wallet.mapper.act;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelDto;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelItemEntity;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemCountVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ActCancelItemMapper extends PjcloudBaseMapper<ActCancelItemEntity> {
List<ActCancelItemCountVo> count(@Param("dto") ActCancelItemDto dto);
}
@@ -14,6 +14,6 @@ import java.util.List;
@Mapper
public interface ActCancelMapper extends PjcloudBaseMapper<ActCancelEntity> {
List<ActCancelVo> scopePageJoin(Page page, @Param("dto") ActCancelDto dto, DataScope dataScope);
Page<ActCancelVo> scopePageJoin(Page page, @Param("dto") ActCancelDto dto, DataScope dataScope);
}
@@ -31,4 +31,9 @@ public interface ActCancelItemService extends IService<ActCancelItemEntity> {
* 核销
*/
Boolean cancel(ActCancelItemDto dto);
/**
* 查询详情
*/
ActCancelItemVo getDetail(Long id);
}
@@ -15,13 +15,18 @@ public interface ActCancelService extends IService<ActCancelEntity> {
/**
* 分页查询
*/
List<ActCancelVo> scopePageJoin(Page page, ActCancelDto dto, DataScope dataScope);
Page<ActCancelVo> scopePageJoin(Page page, ActCancelDto dto, DataScope dataScope);
/**
* 新增
*/
Long create(ActCancelDto dto);
/**
* 根据公告id查询核销活动
*/
ActCancelEntity getDetailByNoticeId(Long noticeId);
/**
* 根据ids删除
*/
@@ -100,6 +100,10 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
orderType = HardOrderTypeEnum.RESERVE;
payType = HardPayTypeEnum.RESERVE_QR_CODE;
}
if (biz == WalletCodeBizEnum.FARMER_RESERVE) {
orderType = HardOrderTypeEnum.FARMER;
payType = HardPayTypeEnum.WALLET_DEFAULT;
}
for (int i = 0; i < count; i++) {
WalletCodeUseEntity item = WalletCodeUseEntity.builder().bizId(id).userId(userId).bizType(biz.getCode()).build();
int insert = baseMapper.insert(item);
@@ -10,6 +10,7 @@ import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.vo.UserVO;
import com.bsd.pjcloud.common.core.constant.CommonRoleConstant;
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
@@ -17,11 +18,13 @@ import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.constant.act.ActCancelStatusEnum;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelEntity;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelItemEntity;
import com.bsd.pjcloud.wallet.api.entity.mch.MchManageEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemVo;
import com.bsd.pjcloud.wallet.mapper.act.ActCancelItemMapper;
import com.bsd.pjcloud.wallet.mapper.act.ActCancelMapper;
import com.bsd.pjcloud.wallet.service.ActCancelItemService;
import com.bsd.pjcloud.wallet.service.MchManageService;
import com.bsd.pjcloud.wallet.service.WalletManageService;
@@ -48,6 +51,8 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
private final MchManageService mchManageService;
private final WalletManageService walletManageService;
private final ActCancelMapper actCancelMapper;
private final RemoteUserService remoteUserService;
@Override
@@ -225,6 +230,23 @@ public class ActCancelItemServiceImpl extends ServiceImpl<ActCancelItemMapper, A
return true;
}
/**
* 查询详情
*/
@Override
public ActCancelItemVo getDetail(Long id) {
ActCancelItemVo result = new ActCancelItemVo();
ActCancelItemEntity detail = baseMapper.selectById(id);
if (ObjectUtil.isEmpty(detail)) return null;
result = BeanUtils.toBean(detail, ActCancelItemVo.class);
// 查询活动
ActCancelEntity actDetail = actCancelMapper.selectById(detail.getActId());
if (ObjectUtil.isNotEmpty(actDetail)) {
result.setActiveCancelPrice(actDetail.getActiveCancelPrice());
}
return result;
}
// 判断车牌号是否重复
private boolean existAct(Long userId) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<ActCancelItemEntity>()
@@ -1,5 +1,6 @@
package com.bsd.pjcloud.wallet.service.impl.act;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,8 +9,11 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.wallet.api.constant.act.ActStatusEnum;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelDto;
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelEntity;
import com.bsd.pjcloud.wallet.api.entity.act.ActCancelItemEntity;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemCountVo;
import com.bsd.pjcloud.wallet.api.vo.act.ActCancelVo;
import com.bsd.pjcloud.wallet.mapper.act.ActCancelItemMapper;
import com.bsd.pjcloud.wallet.mapper.act.ActCancelMapper;
@@ -20,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 核销活动
@@ -35,8 +40,27 @@ public class ActCancelServiceImpl extends ServiceImpl<ActCancelMapper, ActCancel
* 分页查询
*/
@Override
public List<ActCancelVo> scopePageJoin(Page page, ActCancelDto dto, DataScope dataScope) {
return baseMapper.scopePageJoin(page, dto, dataScope);
public Page<ActCancelVo> scopePageJoin(Page page, ActCancelDto dto, DataScope dataScope) {
Page<ActCancelVo> pageList = baseMapper.scopePageJoin(page, dto, dataScope);
disposeList(pageList.getRecords(), dto);
return pageList;
}
public void disposeList(List<ActCancelVo> list, ActCancelDto dto) {
if (ObjectUtil.isEmpty(list)) return;
List<Long> actIds = list.stream().map(ActCancelVo::getId).toList();
// 统计总数
ActCancelItemDto queryDto = new ActCancelItemDto();
queryDto.setActIdList(actIds);
List<ActCancelItemCountVo> countList = actCancelItemMapper.count(queryDto);
if (ObjectUtil.isNotEmpty(countList)) {
Map<Long, ActCancelItemCountVo> countMap = IterUtil.toMap(countList, ActCancelItemCountVo::getActId);
for (ActCancelVo v : list) {
if (ObjectUtil.isEmpty(countMap.get(v.getId()))) continue;
ActCancelItemCountVo targetCunt = countMap.get(v.getId());
v.setCountVo(targetCunt);
}
}
}
/**
@@ -44,6 +68,7 @@ public class ActCancelServiceImpl extends ServiceImpl<ActCancelMapper, ActCancel
*/
@Override
public Long create(ActCancelDto dto) {
if (existByNoticeId(dto)) throw new RuntimeException("绑定的公告已存在核销活动");
ActCancelEntity savObj = BeanUtils.toBean(dto, ActCancelEntity.class);
if (ObjectUtil.isEmpty(savObj.getActStatus())) {
savObj.setActStatus(ActStatusEnum.ACT_OPEN.getCode());
@@ -52,6 +77,16 @@ public class ActCancelServiceImpl extends ServiceImpl<ActCancelMapper, ActCancel
return savObj.getId();
}
/**
* 根据公告id查询核销活动
*/
@Override
public ActCancelEntity getDetailByNoticeId(Long noticeId) {
return baseMapper.selectOne(new LambdaQueryWrapper<ActCancelEntity>()
.eq(ActCancelEntity::getNoticeId, noticeId)
);
}
/**
* 根据ids删除
*/
@@ -70,4 +105,15 @@ public class ActCancelServiceImpl extends ServiceImpl<ActCancelMapper, ActCancel
}
}
}
public boolean existByNoticeId(Long id, Long noticeId) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<ActCancelEntity>()
.ne(ObjectUtil.isNotEmpty(id), ActCancelEntity::getId, id)
.eq(ObjectUtil.isNotEmpty(noticeId), ActCancelEntity::getNoticeId, noticeId)
);
if (ObjectUtil.isNotEmpty(id)) {
return count >= 1;
}
return count > 0;
}
}
@@ -3,4 +3,63 @@
<mapper namespace="com.bsd.pjcloud.wallet.mapper.act.ActCancelItemMapper">
<sql id="selectA">
select a.id,
a.act_id,
a.mch_id,
a.receiver_user_id,
a.receiver_user_name,
a.receiver_time,
a.act_status,
a.cancel_user_id,
a.cancel_time,
a.expire_time,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.actId != null">
and a.act_id = #{dto.actId}
</if>
<if test="dto.mchId != null">
and a.mch_id = #{dto.mchId}
</if>
<if test="dto.receiverUserId != null">
and a.receiver_user_id = #{dto.receiverUserId}
</if>
<if test="dto.actStatus != null">
and a.act_status = #{dto.actStatus}
</if>
<if test="dto.actIdList != null and dto.actIdList.size() != 0">
and a.act_id in
<foreach collection="dto.actIdList" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.mchIdList != null and dto.mchIdList.size() != 0">
and a.mch_id in
<foreach collection="dto.mchIdList" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
</sql>
<select id="count" resultType="com.bsd.pjcloud.wallet.api.vo.act.ActCancelItemCountVo">
select a.act_id,
sum(1) as totalCount,
sum(if(a.act_status = '2', 1, 0)) as cancelCount,
sum(if(a.act_status != '2', 1, 0)) as cancelAwaitCount
from act_cancel_item a
<where>
<include refid="whereA"/>
</where>
group by a.act_id
</select>
</mapper>