feat(shop): 优化商品与优惠券逻辑;修复礼品相关映射;补充接口测试
This commit is contained in:
@@ -29,4 +29,9 @@ public interface PlayCustomGiftInfoMapper extends MPJBaseMapper<PlayCustomGiftIn
|
||||
int incrementGiftCount(@Param("customId") String customId, @Param("giftId") String giftId,
|
||||
@Param("tenantId") String tenantId, @Param("delta") long delta);
|
||||
|
||||
@Update("UPDATE play_custom_gift_info SET giff_number = 0, deleted = 0 "
|
||||
+ "WHERE tenant_id = #{tenantId} AND custom_id = #{customId} AND giff_id = #{giftId}")
|
||||
int resetGiftCount(@Param("tenantId") String tenantId, @Param("customId") String customId,
|
||||
@Param("giftId") String giftId);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,4 +29,9 @@ public interface PlayClerkGiftInfoMapper extends BaseMapper<PlayClerkGiftInfoEnt
|
||||
int incrementGiftCount(@Param("clerkId") String clerkId, @Param("giftId") String giftId,
|
||||
@Param("tenantId") String tenantId, @Param("delta") long delta);
|
||||
|
||||
@Update("UPDATE play_clerk_gift_info SET giff_number = 0, deleted = 0 "
|
||||
+ "WHERE tenant_id = #{tenantId} AND clerk_id = #{clerkId} AND giff_id = #{giftId}")
|
||||
int resetGiftCount(@Param("tenantId") String tenantId, @Param("clerkId") String clerkId,
|
||||
@Param("giftId") String giftId);
|
||||
|
||||
}
|
||||
|
||||
@@ -103,7 +103,11 @@ public class PlayCommodityInfoServiceImpl extends ServiceImpl<PlayCommodityInfoM
|
||||
@Override
|
||||
public List<PlayCommodityInfoEntity> selectByType() {
|
||||
LambdaQueryWrapper<PlayCommodityInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PlayCommodityInfoEntity::getItemType, "服务类型");
|
||||
String tenantId = SecurityUtils.getTenantId();
|
||||
if (StrUtil.isNotBlank(tenantId)) {
|
||||
lambdaQueryWrapper.eq(PlayCommodityInfoEntity::getTenantId, tenantId);
|
||||
}
|
||||
lambdaQueryWrapper.eq(PlayCommodityInfoEntity::getPId, "00");
|
||||
lambdaQueryWrapper.orderByDesc(PlayCommodityInfoEntity::getSort);
|
||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.starry.admin.modules.shop.service.impl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -158,12 +159,12 @@ public class PlayCouponDetailsServiceImpl extends ServiceImpl<PlayCouponDetailsM
|
||||
|
||||
@Override
|
||||
public void updateCouponUseStateByIds(List<String> ids, String useState) {
|
||||
LocalDateTime useTime = CouponUseState.USED.getCode().equals(useState) ? LocalDateTime.now() : null;
|
||||
for (String id : ids) {
|
||||
PlayCouponDetailsEntity entity = new PlayCouponDetailsEntity();
|
||||
entity.setId(id);
|
||||
entity.setUseState(useState);
|
||||
entity.setUseTime(LocalDateTime.now());
|
||||
baseMapper.updateById(entity);
|
||||
baseMapper.update(null, com.baomidou.mybatisplus.core.toolkit.Wrappers.<PlayCouponDetailsEntity>lambdaUpdate()
|
||||
.eq(PlayCouponDetailsEntity::getId, id)
|
||||
.set(PlayCouponDetailsEntity::getUseState, useState)
|
||||
.set(PlayCouponDetailsEntity::getUseTime, useTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ class PlayCommodityInfoApiTest extends WxCustomOrderApiTestSupport {
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200));
|
||||
|
||||
ensureTenantContext();
|
||||
PlayCommodityAndLevelInfoEntity pricing = commodityAndLevelInfoService.lambdaQuery()
|
||||
.eq(PlayCommodityAndLevelInfoEntity::getCommodityId, child.getId())
|
||||
.eq(PlayCommodityAndLevelInfoEntity::getLevelId, ApiTestDataSeeder.DEFAULT_CLERK_LEVEL_ID)
|
||||
@@ -266,6 +267,7 @@ class PlayCommodityInfoApiTest extends WxCustomOrderApiTestSupport {
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200));
|
||||
|
||||
ensureTenantContext();
|
||||
PlayCommodityInfoEntity updated = commodityInfoService.getById(child.getId());
|
||||
assertThat(updated.getAutomaticSettlementDuration())
|
||||
.isEqualTo(AutomaticSettlementPolicy.TEN_MINUTES.getSeconds());
|
||||
|
||||
Reference in New Issue
Block a user