feat:额外收费
This commit is contained in:
1 parent
54a431891a
commit
33ff7edc2e
46 files changed
+955
-26
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 钱包的unique code
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WalletXfjDiscountsEnum {
|
||||
|
||||
JZ_DISCOUNT("1", "9折优惠"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String desc;
|
||||
|
||||
public static WalletXfjDiscountsEnum valueOfByCode(String code) {
|
||||
if (ObjectUtil.isEmpty(code)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(code, v.getCode())).findFirst().get();
|
||||
}
|
||||
|
||||
public static WalletXfjDiscountsEnum descOf(String description) {
|
||||
return Arrays.stream(WalletXfjDiscountsEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+69
-3
@@ -4,8 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -20,7 +19,7 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("wallet_setting")
|
||||
@TableName(value = "wallet_setting", autoResultMap = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "支付设置")
|
||||
public class WalletSettingEntity extends Model<WalletSettingEntity> {
|
||||
@@ -91,6 +90,36 @@ public class WalletSettingEntity extends Model<WalletSettingEntity> {
|
||||
*/
|
||||
private Long topupUserId;
|
||||
|
||||
/**
|
||||
* 在编消默认费机优惠规则
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<WalletXfjDiscounts> zbDefaultXfjDiscounts;
|
||||
|
||||
/**
|
||||
* 在编消特殊费机优惠规则
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<WalletXfjDiscounts> zbSpecialXfjDiscounts;
|
||||
|
||||
/**
|
||||
* 非在编消默认费机优惠规则
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<WalletXfjDiscounts> fzbDefaultXfjDiscounts;
|
||||
|
||||
/**
|
||||
* 非在编消特殊费机优惠规则
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<WalletXfjDiscounts> fzbSpecialXfjDiscounts;
|
||||
|
||||
/**
|
||||
* 特殊消费机列表
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> specialXfjIdList;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@@ -132,4 +161,41 @@ public class WalletSettingEntity extends Model<WalletSettingEntity> {
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 消费机优惠规则
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class WalletXfjDiscounts {
|
||||
|
||||
/**
|
||||
* 时间类型
|
||||
*/
|
||||
private String hourType;
|
||||
|
||||
/**
|
||||
* 基础金额(分),超过了这个基数`extraPer`就生效
|
||||
*/
|
||||
private int basePrice;
|
||||
|
||||
/**
|
||||
* 额外多收的百分比(1.5,10块就是15块)
|
||||
*/
|
||||
private double extraPer;
|
||||
|
||||
/**
|
||||
* 特色菜是否额外收费
|
||||
*/
|
||||
private String specialDishEnable;
|
||||
|
||||
/**
|
||||
* 是否开启
|
||||
*/
|
||||
private String enable;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.bsd.pjcloud.wallet.api.feign;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargePackageEntity;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@FeignClient(contextId = "remoteWalletRechargePackageService", value = ServiceNameConstants.WALLET_SERVICE)
|
||||
public interface RemoteWalletRechargePackageService {
|
||||
|
||||
@GetMapping("/wallet-recharge-package/remote/{id}")
|
||||
R<WalletRechargePackageEntity> remoteGetById(@PathVariable("id") Long id);
|
||||
|
||||
}
|
||||
+8
-2
@@ -4,17 +4,23 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletXfjDiscounts;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "remoteWalletSettingService", value = ServiceNameConstants.WALLET_SERVICE)
|
||||
public interface RemoteWalletSettingService {
|
||||
/**
|
||||
* 获取支付配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/wallet-setting/get-setting")
|
||||
R<WalletSettingVo> get();
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/wallet-setting/remote/get-discounts-list")
|
||||
R<List<WalletXfjDiscounts>> remoteGetDiscountsList(@RequestParam String hardId, @RequestParam Long userId, @RequestParam(required = false) Long userDeptId);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletXfjDiscountsEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 消费机优惠
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WalletXfjDiscounts {
|
||||
|
||||
/**
|
||||
* 消费机优惠活动名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用餐时间段类型
|
||||
*/
|
||||
private String hourType;
|
||||
|
||||
/**
|
||||
* 消费机优惠活动名称
|
||||
*
|
||||
* @see WalletXfjDiscountsEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 基础金额(分),超过了这个基数`extraPer`就生效
|
||||
*/
|
||||
private int basePrice;
|
||||
|
||||
/**
|
||||
* 消费机优惠活动名称
|
||||
*/
|
||||
private Double extraPer;
|
||||
|
||||
public int computedDiscountsExtraPrice(int totalPrice) {
|
||||
if (totalPrice <= basePrice) return 0;
|
||||
double rate = ObjectUtil.isEmpty(extraPer) ? 1.0 : extraPer;
|
||||
if (rate == 1.0) return 0;
|
||||
return (int) Math.round(totalPrice * (rate - 1));
|
||||
}
|
||||
}
|
||||
+1
@@ -6,6 +6,7 @@ com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargeService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRuleTransactionService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteMchService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargePackageService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletThirdZyService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletTransactionService
|
||||
|
||||
Reference in new issue
Block a user