feat: 1.美团团购券相关接口

This commit is contained in:
张松
2024-11-26 15:26:07 +08:00
parent 94285f68d0
commit 2d65fc817c
25 changed files with 784 additions and 4 deletions

View File

@@ -85,6 +85,7 @@ public class TbCashierCart implements Serializable {
private String discountSaleNote;
private Boolean isPrint;
private String useCouponInfo;
private int isThirdCoupon;
public void copy(TbCashierCart source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
@@ -94,6 +95,10 @@ public class TbCashierCart implements Serializable {
* 根据是否会员充值价格
*/
public void resetTotalAmount() {
if (isThirdCoupon == 1) {
totalAmount = BigDecimal.ZERO;
return;
}
if ("false".equals(isPack)) {
packFee = BigDecimal.ZERO;
}
@@ -115,6 +120,10 @@ public class TbCashierCart implements Serializable {
* 根据是否会员充值价格
*/
public void resetTotalAmount(BigDecimal discountRadio) {
if (isThirdCoupon == 1) {
totalAmount = BigDecimal.ZERO;
return;
}
if (discountRadio == null) {
discountRadio = BigDecimal.ONE;
}
@@ -124,10 +133,15 @@ public class TbCashierCart implements Serializable {
if ("true".equals(isGift)) {
totalAmount = packFee;
} else {
discountSaleAmount = discountSaleAmount == null ? BigDecimal.ZERO : discountSaleAmount;
BigDecimal subtract;
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio);
subtract = memberPrice.subtract(discountSaleAmount);
totalAmount = totalNumber.multiply(subtract).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
} else {
totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio);
subtract = salePrice.subtract(discountSaleAmount);
totalAmount = totalNumber.multiply(subtract)
.add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
}
}
}
@@ -137,6 +151,9 @@ public class TbCashierCart implements Serializable {
*
*/
public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) {
if (isThirdCoupon == 1) {
return BigDecimal.ZERO;
}
if (discountRadio == null) {
discountRadio = new BigDecimal("1");
}

View File

@@ -51,5 +51,6 @@ public class TbOrderDetail implements Serializable {
private static final long serialVersionUID = 1L;
private Integer isMember;
private Integer isThirdCoupon;
}

View File

@@ -0,0 +1,271 @@
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.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName tb_third_party_coupon_record
*/
@TableName(value ="tb_third_party_coupon_record")
public class TbThirdPartyCouponRecord implements Serializable {
/**
*
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 核销状态 1 成功
*/
private Integer state;
/**
* 平台 meituan
*/
private String plat;
/**
* 券码
*/
private String code;
/**
* 创建时间
*/
private Date createTime;
/**
* 核销时间
*/
private Date checkTime;
/**
* 店铺id
*/
private Integer shopId;
/**
* 使用数量
*/
private Integer num;
/**
* 抵扣的购物车id
*/
private String cartIdList;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
*
*/
public Integer getId() {
return id;
}
/**
*
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 订单id
*/
public Integer getOrderId() {
return orderId;
}
/**
* 订单id
*/
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
/**
* 核销状态 1 成功
*/
public Integer getState() {
return state;
}
/**
* 核销状态 1 成功
*/
public void setState(Integer state) {
this.state = state;
}
/**
* 平台 meituan
*/
public String getPlat() {
return plat;
}
/**
* 平台 meituan
*/
public void setPlat(String plat) {
this.plat = plat;
}
/**
* 券码
*/
public String getCode() {
return code;
}
/**
* 券码
*/
public void setCode(String code) {
this.code = code;
}
/**
* 创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 核销时间
*/
public Date getCheckTime() {
return checkTime;
}
/**
* 核销时间
*/
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
/**
* 店铺id
*/
public Integer getShopId() {
return shopId;
}
/**
* 店铺id
*/
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
/**
* 使用数量
*/
public Integer getNum() {
return num;
}
/**
* 使用数量
*/
public void setNum(Integer num) {
this.num = num;
}
/**
* 抵扣的购物车id
*/
public String getCartIdList() {
return cartIdList;
}
/**
* 抵扣的购物车id
*/
public void setCartIdList(String cartIdList) {
this.cartIdList = cartIdList;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
TbThirdPartyCouponRecord other = (TbThirdPartyCouponRecord) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getPlat() == null ? other.getPlat() == null : this.getPlat().equals(other.getPlat()))
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getCheckTime() == null ? other.getCheckTime() == null : this.getCheckTime().equals(other.getCheckTime()))
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
&& (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum()))
&& (this.getCartIdList() == null ? other.getCartIdList() == null : this.getCartIdList().equals(other.getCartIdList()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getPlat() == null) ? 0 : getPlat().hashCode());
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getCheckTime() == null) ? 0 : getCheckTime().hashCode());
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode());
result = prime * result + ((getCartIdList() == null) ? 0 : getCartIdList().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", orderId=").append(orderId);
sb.append(", state=").append(state);
sb.append(", plat=").append(plat);
sb.append(", code=").append(code);
sb.append(", createTime=").append(createTime);
sb.append(", checkTime=").append(checkTime);
sb.append(", shopId=").append(shopId);
sb.append(", num=").append(num);
sb.append(", cartIdList=").append(cartIdList);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@@ -0,0 +1,25 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class ThirdCouponCheckDTO {
private String type = "meituan";
@NotNull
private Integer shopId;
@NotBlank
private String code;
@Min(1)
private Integer num;
@NotNull
private Integer orderId;
// 核销的对应商品
@NotEmpty
private List<Integer> cartId;
}

View File

@@ -0,0 +1,11 @@
package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class BaseQueryDTO {
@NotNull
private Integer shopId;
}

View File

@@ -0,0 +1,20 @@
package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@EqualsAndHashCode(callSuper = true)
@Data
public class CheckCouponDTO extends BaseQueryDTO {
@NotBlank
private String couponCode;
@NotNull
@Min(1)
private Integer num;
@NotBlank
private String title;
}

View File

@@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
@EqualsAndHashCode(callSuper = true)
@Data
public class GetActivateCouponDTO extends BaseQueryDTO{
@NotBlank
private String code;
}

View File

@@ -0,0 +1,13 @@
package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
@EqualsAndHashCode(callSuper = true)
@Data
public class RevokeCouponDTO extends BaseQueryDTO{
@NotBlank
private String couponCode;
}