fix: 霸王餐充值接口开发

This commit is contained in:
2024-10-28 09:17:52 +08:00
parent 1faa2cccc6
commit 05a7470c6f
3 changed files with 40 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.constant;
import lombok.EqualsAndHashCode;
import lombok.Getter;
public interface TableConstant {
@@ -28,6 +29,39 @@ public interface TableConstant {
this.value = value;
}
}
@Getter
public enum UseType {
TAKEOUT("takeout"),
DINE_IN_AFTER("dine-in-after"),
DINE_IN_BEFORE("dine-in-before");
private final String value;
UseType(String value) {
this.value = value;
}
public boolean equalsVals(String value) {
return this.value.equals(value);
}
}
}
class ShopInfo {
@Getter
public enum EatModel {
TAKEOUT("takeout"),
DINE_IN("dine-in");
private final String value;
EatModel(String value) {
this.value = value;
}
public boolean equalsVals(String value) {
return this.value.equals(value);
}
}
}

View File

@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
import lombok.Data;
import java.io.Serializable;
@@ -214,4 +215,8 @@ public class TbOrderInfo implements Serializable {
this.createdAt = System.currentTimeMillis();
this.isAccepted = 1;
}
public String getEatModel() {
return TableConstant.OrderInfo.UseType.TAKEOUT.equalsVals(this.getUseType()) ? TableConstant.ShopInfo.EatModel.TAKEOUT.getValue() : TableConstant.ShopInfo.EatModel.DINE_IN.getValue();
}
}

View File

@@ -405,7 +405,7 @@ public class PayService {
}
// 校验就餐模式是否满足
if (!freeDineConfig.getUseType().contains(orderInfo.getUseType())) {
if (!freeDineConfig.getUseType().contains(orderInfo.getEatModel())) {
throw new MsgException("当前店铺未开启此就餐模式霸王餐");
}
BigDecimal shouldPayAmount = orderInfo.getOriginAmount().multiply(BigDecimal.valueOf(freeDineConfig.getRechargeTimes()));