This commit is contained in:
磷叶 2025-01-23 10:15:14 +08:00
parent 67a013a596
commit 499597d357
5 changed files with 31 additions and 20 deletions

View File

@ -123,10 +123,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
bo.setPlatform(deptService.selectDeptById(Constants.ROOT_DEPT));
bo.setAgent(userService.selectSmUserByUserId(device.getAgentId()));
bo.setVip(vipService.selectVipById(dto.getVipId()));
if (bo.getVip() != null && bo.getSuit() != null) {
bo.setPrice(RechargeUtils.calcRechargePrePayPrice(bo.getVip(), bo.getSuit()));
}
bo.setPrice(RechargeUtils.calcRechargePrePayPrice(bo.getVip(), bo.getSuit()));
return bo;
}

View File

@ -46,6 +46,9 @@ public class VipServiceImpl implements VipService
@Override
public VipVO selectVipById(Long id)
{
if (id == null) {
return null;
}
return vipMapper.selectVipById(id);
}

View File

@ -2,11 +2,7 @@ package com.ruoyi.ss.vipLevel.domain;
import java.math.BigDecimal;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constants.DictTypeConstants;
@ -32,35 +28,39 @@ public class VipLevel extends BaseEntity
@Excel(name = "价格")
@ApiModelProperty("价格")
@DecimalMin(value = "0.01", message = "价格不允许小于0.01元")
private BigDecimal price;
@Excel(name = "时长(天)")
@ApiModelProperty("时长(天)")
@Min(value = 1, message = "时长不允许小于1天")
private Integer time;
@Excel(name = "描述")
@ApiModelProperty("描述")
@Size(max = 200, message = "描述不允许超过200个字符")
private String description;
@Excel(name = "限制类型", readConverterExp = "1=不限制,2=自然周,3=30天")
@ApiModelProperty("限制类型")
@NotBlank(message = "限制类型不允许为空", groups = {ValidGroup.Create.class})
@NotBlank(message = "限制类型不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
@DictValid(type = DictTypeConstants.VIP_LEVEL_LIMIT_TYPE, message = "非法的限制类型")
private String limitType;
@Excel(name = "限制次数")
@ApiModelProperty("限制次数")
@Min(value = 0, message = "限制次数不允许小于0")
private Integer limitCount;
@Excel(name = "状态", dictType = DictTypeConstants.VIP_LEVEL_STATUS)
@ApiModelProperty("状态")
@NotBlank(message = "状态不允许为空", groups = {ValidGroup.Create.class})
@NotBlank(message = "状态不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
@DictValid(type = DictTypeConstants.VIP_LEVEL_STATUS, message = "非法的状态")
private String status;
@Excel(name = "定价名称")
@ApiModelProperty("定价名称")
@NotBlank(message = "定价名称不允许为空", groups = {ValidGroup.Create.class})
@Excel(name = "名称")
@ApiModelProperty("名称")
@NotBlank(message = "会员名称不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
private String name;
@Excel(name = "原价")
@ -70,7 +70,7 @@ public class VipLevel extends BaseEntity
@Excel(name = "限制总次数")
@ApiModelProperty("限制总次数")
@Min(value = 0, message = "限制总次数不允许小于0")
@NotNull(message = "限制总次数不允许为空", groups = {ValidGroup.Create.class})
@NotNull(message = "限制总次数不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
private Integer limitTotal;
@Excel(name = "商户ID")
@ -80,13 +80,13 @@ public class VipLevel extends BaseEntity
@Excel(name = "折扣")
@ApiModelProperty("折扣")
@NotNull(message = "折扣不允许为空", groups = {ValidGroup.Create.class})
@NotNull(message = "折扣不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
@DecimalMin(value = "0.1", message = "折扣不允许小于0.1折")
@DecimalMax(value = "10", message = "折扣不允许大于10折")
private BigDecimal discount;
@Excel(name = "可用店铺ID")
@ApiModelProperty("可用店铺ID")
@NotNull(message = "可用店铺ID不允许为空", groups = {ValidGroup.Create.class})
@NotNull(message = "可用店铺不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
private Long storeId;
}

View File

@ -1,5 +1,8 @@
package com.ruoyi.ss.vipLevel.service.impl;
import com.ruoyi.ss.store.domain.StoreVo;
import com.ruoyi.ss.store.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.ServiceUtil;
@ -10,6 +13,9 @@ import com.ruoyi.ss.vipLevel.service.VipLevelValidator;
@Service
public class VipLevelValidatorImpl implements VipLevelValidator {
@Autowired
private StoreService storeService;
@Override
public void afterValid(VipLevelVO vo) {
ServiceUtil.assertion(vo == null, "VIP等级定价不存在");
@ -19,6 +25,11 @@ public class VipLevelValidatorImpl implements VipLevelValidator {
ServiceUtil.assertion(vo.getLimitCount() == null, "限制次数不能为空");
ServiceUtil.assertion(vo.getLimitCount() <= 0, "限制次数不能小于等于0");
}
// 判断店铺是否生效的店铺
StoreVo store = storeService.selectSmStoreById(vo.getStoreId());
ServiceUtil.assertion(store == null, "ID为%s的店铺不存在", vo.getStoreId());
ServiceUtil.assertion(store.getEnabled() == null || !store.getEnabled(), "店铺【%s】暂未生效请等待审核通过后重试", store.getName());
}
}

View File

@ -225,7 +225,7 @@ public class AppTransactionBillController extends BaseController
@ApiOperation("下单前获取订单预存金额")
@GetMapping("/recharge/prePayPrice")
public AjaxResult prePayPrice(@RequestParam @ApiParam("会员ID") Long vipId,
public AjaxResult prePayPrice(@RequestParam(required = false) @ApiParam("会员ID") Long vipId,
@RequestParam @ApiParam("套餐ID") Long suitId) {
return success(transactionBillService.calcRechargePrePayPrice(vipId, suitId));
}