feat: 优惠券积分支付相关
This commit is contained in:
@@ -21,6 +21,39 @@ public interface TableConstant {
|
||||
}
|
||||
}
|
||||
|
||||
class CashierCart {
|
||||
public static final String ID = "-999";
|
||||
|
||||
@Getter
|
||||
public enum Status {
|
||||
REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"),
|
||||
UNPAID("unpaid"), PAYING("paying"), RETURN("return"), CANCEL("cancel");
|
||||
private final String value;
|
||||
Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(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 OrderInfo {
|
||||
@Getter
|
||||
public enum Status {
|
||||
@@ -31,6 +64,9 @@ public interface TableConstant {
|
||||
Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CreateOrderDTO;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.service.CartService;
|
||||
import com.chaozhanggui.system.cashierservice.service.OrderService;
|
||||
@@ -34,9 +35,9 @@ public class OrderController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/creatOrder")
|
||||
public Result createOrder(@RequestHeader String environment, @RequestBody JSONObject jsonObject){
|
||||
jsonObject.put("environment",environment);
|
||||
return Utils.runFunAndCheckKey(() -> cartService.createOrder(jsonObject), stringRedisTemplate, RedisCst.getLockKey("CREATE_ORDER_KEY"));
|
||||
public Result createOrder(@RequestHeader String environment, @RequestBody CreateOrderDTO createOrderDTO){
|
||||
createOrderDTO.setEnvironment(environment);
|
||||
return Utils.runFunAndCheckKey(() -> cartService.createOrder(createOrderDTO), stringRedisTemplate, RedisCst.getLockKey("CREATE_ORDER_KEY"));
|
||||
// return orderService.createOrder(shopTable.getTableId(),shopTable.getShopId(),shopTable.getUserId());
|
||||
}
|
||||
|
||||
|
||||
@@ -48,4 +48,7 @@ public interface TbProductMapper {
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||
int decrStockUnCheck(@Param("id") String id, @Param("num") Integer num);
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number+#{addNum} WHERE id=#{id}")
|
||||
int incrStock(@Param("id") Integer id, @Param("addNum") Integer addNum);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,9 @@ public class TbCashierCart implements Serializable {
|
||||
private String useType;
|
||||
private Integer placeNum;
|
||||
|
||||
// 使用的优惠券id
|
||||
private Integer userCouponId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String getSkuName() {
|
||||
|
||||
@@ -126,14 +126,14 @@ public class TbOrderInfo implements Serializable {
|
||||
private BigDecimal seatAmount;
|
||||
private BigDecimal pointsDiscountAmount;
|
||||
private Integer pointsNum;
|
||||
// 用户优惠券id
|
||||
private String activateInInfoList;
|
||||
private BigDecimal activateInDiscountAmount;
|
||||
|
||||
|
||||
//根据状态返回 需付款 已付款 未付款 已退
|
||||
@TableField(exist = false)
|
||||
private String description;
|
||||
private BigDecimal fullCouponDiscountAmount;
|
||||
private BigDecimal productCouponDiscountAmount;
|
||||
private String couponInfoList;
|
||||
|
||||
public void setDescription(String shopName) {
|
||||
this.shopName = shopName;
|
||||
@@ -220,4 +220,6 @@ public class TbOrderInfo implements Serializable {
|
||||
public String getEatModel() {
|
||||
return TableConstant.OrderInfo.UseType.TAKEOUT.equalsVals(this.getUseType()) ? TableConstant.ShopInfo.EatModel.TAKEOUT.getValue() : TableConstant.ShopInfo.EatModel.DINE_IN.getValue();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
public class TbShopUser implements Serializable {
|
||||
private String id;
|
||||
|
||||
@@ -66,299 +69,22 @@ public class TbShopUser implements Serializable {
|
||||
private Long updatedAt;
|
||||
|
||||
private String miniOpenId;
|
||||
@TableField(exist = false)
|
||||
private String shopName="";
|
||||
@TableField(exist = false)
|
||||
private String lat="";
|
||||
@TableField(exist = false)
|
||||
private String lng="";
|
||||
@TableField(exist = false)
|
||||
private String address="";
|
||||
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private String isUser;
|
||||
|
||||
private Timestamp joinTime;
|
||||
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id == null ? null : id.trim();
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public BigDecimal getCreditAmount() {
|
||||
return creditAmount;
|
||||
}
|
||||
|
||||
public void setCreditAmount(BigDecimal creditAmount) {
|
||||
this.creditAmount = creditAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getConsumeAmount() {
|
||||
return consumeAmount;
|
||||
}
|
||||
|
||||
public void setConsumeAmount(BigDecimal consumeAmount) {
|
||||
this.consumeAmount = consumeAmount;
|
||||
}
|
||||
|
||||
public Integer getConsumeNumber() {
|
||||
return consumeNumber;
|
||||
}
|
||||
|
||||
public void setConsumeNumber(Integer consumeNumber) {
|
||||
this.consumeNumber = consumeNumber;
|
||||
}
|
||||
|
||||
public BigDecimal getLevelConsume() {
|
||||
return levelConsume;
|
||||
}
|
||||
|
||||
public void setLevelConsume(BigDecimal levelConsume) {
|
||||
this.levelConsume = levelConsume;
|
||||
}
|
||||
|
||||
public Byte getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Byte status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMerchantId() {
|
||||
return merchantId;
|
||||
}
|
||||
|
||||
public void setMerchantId(String merchantId) {
|
||||
this.merchantId = merchantId == null ? null : merchantId.trim();
|
||||
}
|
||||
|
||||
public String getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(String shopId) {
|
||||
this.shopId = shopId == null ? null : shopId.trim();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId == null ? null : userId.trim();
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId == null ? null : parentId.trim();
|
||||
}
|
||||
|
||||
public String getParentLevel() {
|
||||
return parentLevel;
|
||||
}
|
||||
|
||||
public void setParentLevel(String parentLevel) {
|
||||
this.parentLevel = parentLevel == null ? null : parentLevel.trim();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
public String getHeadImg() {
|
||||
return headImg;
|
||||
}
|
||||
|
||||
public void setHeadImg(String headImg) {
|
||||
this.headImg = headImg == null ? null : headImg.trim();
|
||||
}
|
||||
|
||||
public Byte getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(Byte sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getBirthDay() {
|
||||
return birthDay;
|
||||
}
|
||||
|
||||
public void setBirthDay(String birthDay) {
|
||||
this.birthDay = birthDay == null ? null : birthDay.trim();
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone == null ? null : telephone.trim();
|
||||
}
|
||||
|
||||
public Byte getIsVip() {
|
||||
return isVip;
|
||||
}
|
||||
|
||||
public void setIsVip(Byte isVip) {
|
||||
this.isVip = isVip;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code == null ? null : code.trim();
|
||||
}
|
||||
|
||||
public String getDynamicCode() {
|
||||
return dynamicCode;
|
||||
}
|
||||
|
||||
public void setDynamicCode(String dynamicCode) {
|
||||
this.dynamicCode = dynamicCode;
|
||||
}
|
||||
|
||||
|
||||
public Byte getIsAttention() {
|
||||
return isAttention;
|
||||
}
|
||||
|
||||
public void setIsAttention(Byte isAttention) {
|
||||
this.isAttention = isAttention;
|
||||
}
|
||||
|
||||
public Integer getAttentionAt() {
|
||||
return attentionAt;
|
||||
}
|
||||
|
||||
public void setAttentionAt(Integer attentionAt) {
|
||||
this.attentionAt = attentionAt;
|
||||
}
|
||||
|
||||
public Byte getIsShareholder() {
|
||||
return isShareholder;
|
||||
}
|
||||
|
||||
public void setIsShareholder(Byte isShareholder) {
|
||||
this.isShareholder = isShareholder;
|
||||
}
|
||||
|
||||
public Byte getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Byte level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getDistributeType() {
|
||||
return distributeType;
|
||||
}
|
||||
|
||||
public void setDistributeType(String distributeType) {
|
||||
this.distributeType = distributeType == null ? null : distributeType.trim();
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getMiniOpenId() {
|
||||
return miniOpenId;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public void setMiniOpenId(String miniOpenId) {
|
||||
this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim();
|
||||
}
|
||||
|
||||
public String getIsUser() {
|
||||
return isUser;
|
||||
}
|
||||
|
||||
public void setIsUser(String isUser) {
|
||||
this.isUser = isUser;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(String lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Timestamp getJoinTime() {
|
||||
return joinTime;
|
||||
}
|
||||
|
||||
public void setJoinTime(Timestamp joinTime) {
|
||||
this.joinTime = joinTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreateOrderDTO {
|
||||
@NotEmpty
|
||||
private Integer shopId;
|
||||
private String tableId;
|
||||
private Integer userId;
|
||||
@NotEmpty(message = "用餐类型不为空")
|
||||
private String sendType;
|
||||
private String remark = "";
|
||||
private String environment;
|
||||
private String type;
|
||||
|
||||
// 使用的优惠券
|
||||
@Valid
|
||||
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
|
||||
// 使用的积分抵扣数量
|
||||
private Integer pointsNum;
|
||||
}
|
||||
@@ -22,5 +22,5 @@ public class MemberInDTO {
|
||||
// 使用的优惠券
|
||||
private List<Integer> userCouponIds = new ArrayList<>();
|
||||
// 是否使用积分抵扣
|
||||
private boolean usePoints ;
|
||||
private Integer pointsNum ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OrderCartInfoDTO {
|
||||
private BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
private BigDecimal newAddTotalAmount = BigDecimal.ZERO;
|
||||
private List<TbCashierCart> newCashierCarts = new ArrayList<>();
|
||||
private List<TbCashierCart> cashierCarts = new ArrayList<>();
|
||||
private List<Integer> cashierCartIds = new ArrayList<>();
|
||||
private Integer orderId;
|
||||
private TbCashierCart seatCart;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OrderCouponInfoDTO {
|
||||
private TbShopUser shopUser;
|
||||
private List<TbActivateOutRecord> outRecordList = new ArrayList<>();
|
||||
// 满减优惠券
|
||||
private HashMap<Integer, TbUserCouponVo> fullReductionCouponMap = new HashMap<>();
|
||||
// 商品优惠券
|
||||
private HashMap<Integer, TbUserCouponVo> productCouponMap = new HashMap<>();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OrderPriceDTO {
|
||||
private BigDecimal productDiscountAmount = BigDecimal.ZERO;
|
||||
private BigDecimal originAmount = BigDecimal.ZERO;
|
||||
private BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
private BigDecimal packAmount = BigDecimal.ZERO;
|
||||
private boolean hasNewInfo = false;
|
||||
private List<TbOrderDetail> newOrderDetailList = new ArrayList<>();
|
||||
private List<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
||||
private List<Integer> removeOrderDetailIds = new ArrayList<>();
|
||||
private List<TbOrderDetail> orderDetailList = new ArrayList<>();
|
||||
}
|
||||
@@ -11,8 +11,15 @@ public class ShopEatTypeInfoDTO {
|
||||
private boolean isMunchies;
|
||||
private boolean isDineInAfter;
|
||||
private boolean isDineInBefore;
|
||||
// 是否需要餐位费
|
||||
private boolean needSeatFee;
|
||||
// 是否无桌台下单
|
||||
private boolean isNoneTable;
|
||||
// 是否增加masterId
|
||||
private boolean isIncrMaterId;
|
||||
private TbShopInfo shopInfo;
|
||||
private String useType;
|
||||
private boolean isOpenTakeout;
|
||||
private boolean isOpenDineIn;
|
||||
private String tableId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
@Data
|
||||
public class UserCouponInfoDTO {
|
||||
private Integer userCouponId;
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
}
|
||||
@@ -24,6 +24,8 @@ public class TbUserCouponVo {
|
||||
private String useRestrictions;
|
||||
private boolean isUse = false;
|
||||
|
||||
private Integer currentUseNum = 0;
|
||||
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.chaozhanggui.system.cashierservice.annotation.ResultCode;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -31,6 +32,10 @@ public class MsgException extends RuntimeException {
|
||||
this(ResultCode.FAIL, msg, obj);
|
||||
}
|
||||
|
||||
public MsgException(String template, Object... args) {
|
||||
this(ResultCode.FAIL, StrUtil.format(template, args), null);
|
||||
}
|
||||
|
||||
public MsgException(ResultCode code, String msg, Serializable obj) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_queue】的数据库操作Mapper
|
||||
* @createDate 2024-09-13 13:44:26
|
||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
|
||||
*/
|
||||
public interface MpShopUserMapper extends BaseMapper<TbShopUser> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.rabbit;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CreateOrderDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
@@ -52,7 +53,7 @@ public class CartConsumer {
|
||||
else if (jsonObject.getString("type").equals("queryCart") ) {
|
||||
cartService.queryCart(jsonObject);
|
||||
} else if(jsonObject.getString("type").equals("createOrder")){
|
||||
cartService.createOrder(jsonObject);
|
||||
cartService.createOrder(JSONObject.parseObject(message, CreateOrderDTO.class));
|
||||
}
|
||||
// else if(jsonObject.getString("type").equals("clearCart")){
|
||||
// cartService.clearCart(jsonObject);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class RedisCst {
|
||||
public static final String ORDER_PRINT = "ORDER_PRINT:";
|
||||
// 选择人数锁
|
||||
public static final String CHOSE_TABLE_COUNT = "CHOSE_TABLE_COUNT";
|
||||
public static final String ORDER_PRODUCT_NUM = "ORDER_NUM:";
|
||||
|
||||
static final String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:";
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,10 +12,7 @@ import com.chaozhanggui.system.cashierservice.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.MemberInDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.OrderPayDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ActivateInInfoVO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
|
||||
@@ -28,6 +25,7 @@ import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAd
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.service.impl.TbMemberPointsServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp;
|
||||
@@ -192,6 +190,8 @@ public class PayService {
|
||||
private final TbFreeDineConfigService freeDineConfigService;
|
||||
private final TbShopCouponService shopCouponService;
|
||||
private final MpMemberInMapper mpMemberInMapper;
|
||||
private final TbMemberPointsServiceImpl memberPointsService;
|
||||
|
||||
@Qualifier("tbShopCouponService")
|
||||
@Autowired
|
||||
private TbShopCouponService tbShopCouponService;
|
||||
@@ -203,12 +203,13 @@ public class PayService {
|
||||
private TbFreeDineRecordMapper tbFreeDineRecordMapper;
|
||||
private final TbFreeDineRecordService freeDineRecordService;
|
||||
|
||||
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService, TbFreeDineConfigService freeDineConfigService, TbShopCouponService shopCouponService, MpMemberInMapper mpMemberInMapper, TbFreeDineRecordService freeDineRecordService) {
|
||||
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService, TbFreeDineConfigService freeDineConfigService, TbShopCouponService shopCouponService, MpMemberInMapper mpMemberInMapper, TbMemberPointsServiceImpl memberPointsService, TbFreeDineRecordService freeDineRecordService) {
|
||||
this.shopSongOrderService = shopSongOrderService;
|
||||
this.mpShopTableService = mpShopTableService;
|
||||
this.freeDineConfigService = freeDineConfigService;
|
||||
this.shopCouponService = shopCouponService;
|
||||
this.mpMemberInMapper = mpMemberInMapper;
|
||||
this.memberPointsService = memberPointsService;
|
||||
this.freeDineRecordService = freeDineRecordService;
|
||||
}
|
||||
|
||||
@@ -381,7 +382,7 @@ public class PayService {
|
||||
throw new MsgException("支付失败");
|
||||
}
|
||||
|
||||
private BigDecimal getFreeDineOrderInfo(MemberInDTO payDTO) {
|
||||
private BigDecimal getFreeDineOrderInfo(MemberInDTO payDTO, TbUserInfo userInfo) {
|
||||
TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, payDTO.getOrderId())
|
||||
.in(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue(), TableConstant.OrderInfo.Status.PAYING.getValue()));
|
||||
@@ -405,7 +406,7 @@ public class PayService {
|
||||
throw new MsgException("当前店铺未开启与优惠券同享");
|
||||
}
|
||||
|
||||
if (payDTO.isUsePoints() && freeDineConfig.getWithPoints() == 0) {
|
||||
if (payDTO.getPointsNum() != null && freeDineConfig.getWithPoints() == 0) {
|
||||
throw new MsgException("当前店铺未开启与积分同享");
|
||||
}
|
||||
|
||||
@@ -415,6 +416,25 @@ public class PayService {
|
||||
}
|
||||
BigDecimal shouldPayAmount = orderInfo.getOriginAmount().multiply(BigDecimal.valueOf(freeDineConfig.getRechargeTimes()));
|
||||
|
||||
|
||||
// 霸王餐积分抵扣
|
||||
if (payDTO.getPointsNum() != null) {
|
||||
OrderDeductionPointsDTO memberUsablePoints = memberPointsService.getMemberUsablePoints(Long.valueOf(userInfo.getId()), shouldPayAmount);
|
||||
if (!memberUsablePoints.getUsable()) {
|
||||
throw new MsgException(memberUsablePoints.getUnusableReason());
|
||||
}
|
||||
if (payDTO.getPointsNum() < memberUsablePoints.getMinDeductionPoints() || payDTO.getPointsNum() > memberUsablePoints.getMaxUsablePoints()) {
|
||||
throw new MsgException("可抵扣积分区间为: [" + memberUsablePoints.getMinDeductionPoints() + "-" + memberUsablePoints.getMaxUsablePoints() + "]");
|
||||
}
|
||||
|
||||
BigDecimal discountAmount = memberPointsService.calcDeductionAmount(Long.valueOf(userInfo.getId()), shouldPayAmount, payDTO.getPointsNum());
|
||||
orderInfo.setPointsNum(payDTO.getPointsNum());
|
||||
orderInfo.setPointsDiscountAmount(discountAmount);
|
||||
shouldPayAmount = shouldPayAmount.subtract(discountAmount);
|
||||
memberPointsService.deductPoints(Long.valueOf(userInfo.getId()), payDTO.getPointsNum(), "霸王餐充值抵扣", Long.valueOf(orderInfo.getId()));
|
||||
}
|
||||
|
||||
// 霸王餐优惠券抵扣
|
||||
TbFreeDineRecord record = tbFreeDineRecordMapper.selectOne(new LambdaQueryWrapper<TbFreeDineRecord>().eq(TbFreeDineRecord::getOrderId, orderInfo.getId()));
|
||||
if (record == null) {
|
||||
record = new TbFreeDineRecord();
|
||||
@@ -423,41 +443,37 @@ public class PayService {
|
||||
record.setOrderId(orderInfo.getId());
|
||||
record.setOrderAmount(orderInfo.getOrderAmount());
|
||||
if (!payDTO.getUserCouponIds().isEmpty()) {
|
||||
List<TbUserCouponVo> userCouponList = shopCouponService.getActivateCouponByAmount(Integer.valueOf(orderInfo.getShopId()), String.valueOf(payDTO.getUserId()), shouldPayAmount);
|
||||
if (userCouponList.isEmpty()) {
|
||||
throw new MsgException("存在不可用优惠券");
|
||||
}
|
||||
|
||||
ArrayList<ActivateInInfoVO> activateInInfoVOS = new ArrayList<>();
|
||||
for (Integer userCouponId : payDTO.getUserCouponIds()) {
|
||||
TbUserCouponVo userCouponVo = userCouponList.stream().filter(item -> item.getId().equals(userCouponId)).findFirst().orElse(null);
|
||||
if (userCouponVo == null) {
|
||||
List<TbUserCouponVo> userCouponList = shopCouponService.getActivateCouponByAmount(Integer.valueOf(orderInfo.getShopId()), String.valueOf(payDTO.getUserId()), shouldPayAmount);
|
||||
if (userCouponList.isEmpty()) {
|
||||
throw new MsgException("存在不可用优惠券");
|
||||
}
|
||||
|
||||
shouldPayAmount = shouldPayAmount.subtract(userCouponVo.getDiscountAmount());
|
||||
ActivateInInfoVO activateInInfoVO = new ActivateInInfoVO()
|
||||
.setId(userCouponVo.getId())
|
||||
.setCouponId(userCouponVo.getCouponId())
|
||||
.setNum(1);
|
||||
activateInInfoVOS.add(activateInInfoVO);
|
||||
}
|
||||
ArrayList<ActivateInInfoVO> activateInInfoVOS = new ArrayList<>();
|
||||
for (Integer userCouponId : payDTO.getUserCouponIds()) {
|
||||
TbUserCouponVo userCouponVo = userCouponList.stream().filter(item -> item.getId().equals(userCouponId)).findFirst().orElse(null);
|
||||
if (userCouponVo == null) {
|
||||
throw new MsgException("存在不可用优惠券");
|
||||
}
|
||||
|
||||
List<TbShopCoupon> tbShopCoupons = mpShopCouponMapper.selectBatchIds(activateInInfoVOS.stream().map(ActivateInInfoVO::getCouponId).collect(Collectors.toList()));
|
||||
if (tbShopCoupons.size() != payDTO.getUserCouponIds().size()) {
|
||||
throw new MsgException("存在不可用优惠券");
|
||||
}
|
||||
shouldPayAmount = shouldPayAmount.subtract(userCouponVo.getDiscountAmount());
|
||||
ActivateInInfoVO activateInInfoVO = new ActivateInInfoVO()
|
||||
.setId(userCouponVo.getId())
|
||||
.setCouponId(userCouponVo.getCouponId())
|
||||
.setNum(1);
|
||||
activateInInfoVOS.add(activateInInfoVO);
|
||||
}
|
||||
|
||||
// 设置优惠券信息
|
||||
orderInfo.setActivateInInfoList(JSONObject.toJSONString(activateInInfoVOS));
|
||||
orderInfo.setUserCouponAmount(BigDecimal.valueOf(tbShopCoupons.stream().map(TbShopCoupon::getDiscountAmount).reduce(0, Integer::sum)));
|
||||
record.setCouponInfo(JSONObject.toJSONString(userCouponList));
|
||||
List<TbShopCoupon> tbShopCoupons = mpShopCouponMapper.selectBatchIds(activateInInfoVOS.stream().map(ActivateInInfoVO::getCouponId).collect(Collectors.toList()));
|
||||
if (tbShopCoupons.size() != payDTO.getUserCouponIds().size()) {
|
||||
throw new MsgException("存在不可用优惠券");
|
||||
}
|
||||
|
||||
// 设置优惠券信息
|
||||
// orderInfo.seta(JSONObject.toJSONString(activateInInfoVOS));
|
||||
orderInfo.setUserCouponAmount(BigDecimal.valueOf(tbShopCoupons.stream().map(TbShopCoupon::getDiscountAmount).reduce(0, Integer::sum)));
|
||||
record.setCouponInfo(JSONObject.toJSONString(userCouponList));
|
||||
}
|
||||
|
||||
// TODO 霸王餐积分
|
||||
if (payDTO.isUsePoints()) {
|
||||
|
||||
}
|
||||
record.setRechargeAmount(shouldPayAmount);
|
||||
record.setVipUserId(payDTO.getUserId());
|
||||
record.setShopId(Integer.valueOf(orderInfo.getShopId()));
|
||||
@@ -469,8 +485,6 @@ public class PayService {
|
||||
return shouldPayAmount;
|
||||
}
|
||||
|
||||
private void createFreeDineOrder(TbOrderInfo orderInfo) {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result payOrder(String openId, OrderPayDTO payDTO, String ip) throws Exception {
|
||||
@@ -1057,13 +1071,12 @@ public class PayService {
|
||||
BigDecimal payAmount;
|
||||
TbMemberIn memberIn = new TbMemberIn();
|
||||
if (memberInDTO.getOrderId() != null) {
|
||||
payAmount = getFreeDineOrderInfo(memberInDTO);
|
||||
payAmount = getFreeDineOrderInfo(memberInDTO, userInfo);
|
||||
memberIn.setType(TableConstant.MemberIn.Type.FREE_DINE.getValue());
|
||||
// 会员充值
|
||||
}else {
|
||||
payAmount = memberInDTO.getAmount().setScale(2, RoundingMode.DOWN);
|
||||
memberIn.setType(TableConstant.MemberIn.Type.NORMAL.getValue());
|
||||
|
||||
}
|
||||
|
||||
memberIn.setAmount(payAmount);
|
||||
@@ -1560,23 +1573,23 @@ public class PayService {
|
||||
|
||||
Integer shopId = Integer.valueOf(orderInfo.getShopId());
|
||||
// 销毁使用的优惠券
|
||||
if (StrUtil.isNotBlank(orderInfo.getActivateInInfoList())) {
|
||||
ArrayList<TbActivateOutRecord> activateOutRecords = new ArrayList<>();
|
||||
JSONArray activateInfoList = JSONObject.parseArray(orderInfo.getActivateInInfoList());
|
||||
activateInfoList.forEach(item -> {
|
||||
ActivateInInfoVO infoVO = ((JSONObject)item).toJavaObject(ActivateInInfoVO.class);
|
||||
TbActivateOutRecord tbActivateOutRecord = new TbActivateOutRecord();
|
||||
tbActivateOutRecord.setShopId(shopId);
|
||||
tbActivateOutRecord.setGiveId(infoVO.getId());
|
||||
tbActivateOutRecord.setVipUserId(Integer.valueOf(orderInfo.getUserId()));
|
||||
tbActivateOutRecord.setType(TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.getValue());
|
||||
tbActivateOutRecord.setUseNum(infoVO.getNum());
|
||||
tbActivateOutRecord.setStatus(TableConstant.ActivateOutRecord.Status.CLOSED.getValue());
|
||||
tbActivateOutRecord.setCreateTime(DateUtil.date());
|
||||
activateOutRecords.add(tbActivateOutRecord);
|
||||
});
|
||||
shopCouponService.use(shopId, orderInfo.getId(), Integer.valueOf(orderInfo.getUserId()), activateOutRecords);
|
||||
}
|
||||
// if (StrUtil.isNotBlank(orderInfo.getActivateInInfoList())) {
|
||||
// ArrayList<TbActivateOutRecord> activateOutRecords = new ArrayList<>();
|
||||
// JSONArray activateInfoList = JSONObject.parseArray(orderInfo.getActivateInInfoList());
|
||||
// activateInfoList.forEach(item -> {
|
||||
// ActivateInInfoVO infoVO = ((JSONObject)item).toJavaObject(ActivateInInfoVO.class);
|
||||
// TbActivateOutRecord tbActivateOutRecord = new TbActivateOutRecord();
|
||||
// tbActivateOutRecord.setShopId(shopId);
|
||||
// tbActivateOutRecord.setGiveId(infoVO.getId());
|
||||
// tbActivateOutRecord.setVipUserId(Integer.valueOf(orderInfo.getMemberId()));
|
||||
// tbActivateOutRecord.setType(TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.getValue());
|
||||
// tbActivateOutRecord.setUseNum(infoVO.getNum());
|
||||
// tbActivateOutRecord.setStatus(TableConstant.ActivateOutRecord.Status.CLOSED.getValue());
|
||||
// tbActivateOutRecord.setCreateTime(DateUtil.date());
|
||||
// activateOutRecords.add(tbActivateOutRecord);
|
||||
// });
|
||||
// shopCouponService.use(shopId, orderInfo.getId(), Integer.valueOf(orderInfo.getUserId()), activateOutRecords);
|
||||
// }
|
||||
// 更改订单状态
|
||||
orderSuccessPay(orderInfo, payType, payOrderNo);
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbCashierCartService extends IService<TbCashierCart> {
|
||||
/**
|
||||
* 根据就餐类型获取购物车信息
|
||||
* @param shopEatTypeInfoDTO 就餐类型信息
|
||||
* @param userId 用户id
|
||||
* @return 购物车信息
|
||||
*/
|
||||
List<TbCashierCart> selectByShopEatTypeInfo(ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbOrderDetailService extends IService<TbOrderDetail> {
|
||||
|
||||
/**
|
||||
* 根据购物车id和订单id查询订单详情
|
||||
* @param shopId 店铺id
|
||||
* @param cartIdList 购物车id
|
||||
* @param orderId 订单id
|
||||
* @return 详情信息
|
||||
*/
|
||||
List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, List<Integer> cartIdList, Integer orderId);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CouponUseDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
|
||||
@@ -10,6 +11,7 @@ import org.springframework.context.annotation.Primary;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 优惠券(TbShopCoupon)表服务接口
|
||||
@@ -29,4 +31,13 @@ public interface TbShopCouponService {
|
||||
boolean use(Integer shopId,Integer orderId,Integer vipUserId,List<TbActivateOutRecord> param);
|
||||
|
||||
boolean refund(List<TbActivateOutRecord> param);
|
||||
|
||||
/**
|
||||
* 根据金额获取可用优惠券数据
|
||||
* @param tbShopUser 店铺id
|
||||
* @param orderAmount 用户id
|
||||
* @param productIds 商品id
|
||||
* @return 优惠券信息
|
||||
*/
|
||||
List<TbUserCouponVo> getActivateCoupon(TbShopUser tbShopUser, BigDecimal orderAmount, Integer shopId, Set<String> productIds);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbShopUserService extends IService<TbShopUser> {
|
||||
|
||||
/**
|
||||
* 根据店铺id和用户id获取店铺会员信息
|
||||
* @param userId 用户id
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
TbShopUser selectByUserIdAndShopId(String userId, String shopId);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbCashierCartService;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_table】的数据库操作Service实现
|
||||
* @createDate 2024-09-13 13:44:34
|
||||
*/
|
||||
@Service
|
||||
@Primary
|
||||
public class TbCashierCartServiceImpl extends ServiceImpl<MpCashierCartMapper, TbCashierCart>
|
||||
implements TbCashierCartService {
|
||||
|
||||
@Override
|
||||
public List<TbCashierCart> selectByShopEatTypeInfo(ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer userId) {
|
||||
// 查询购物车所有信息
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopInfo().getId())
|
||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||
.eq(TbCashierCart::getStatus, "create");
|
||||
|
||||
// 外带模式
|
||||
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||
queryWrapper.eq(TbCashierCart::getUserId, userId);
|
||||
// 台桌点单
|
||||
} else {
|
||||
queryWrapper.and(q -> q.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId()).or().eq(TbCashierCart::getUserId, userId))
|
||||
.and(q -> q.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()).or().isNull(TbCashierCart::getUseType));
|
||||
}
|
||||
|
||||
// 所有订单信息
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.chaozhanggui.system.cashierservice.service.TbMemberPointsService;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbPointsBasicSettingService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -39,6 +40,7 @@ import java.util.Map;
|
||||
* @since 2.0 2024-10-25
|
||||
*/
|
||||
@Service
|
||||
@Primary
|
||||
public class TbMemberPointsServiceImpl extends ServiceImpl<TbMemberPointsMapper, TbMemberPoints> implements TbMemberPointsService {
|
||||
|
||||
@Resource
|
||||
@@ -285,4 +287,4 @@ public class TbMemberPointsServiceImpl extends ServiceImpl<TbMemberPointsMapper,
|
||||
addPoints(memberId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbCashierCartService;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbOrderDetailService;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_table】的数据库操作Service实现
|
||||
* @createDate 2024-09-13 13:44:34
|
||||
*/
|
||||
@Service
|
||||
@Primary
|
||||
public class TbOrderDetailServiceImpl extends ServiceImpl<MpOrderDetailMapper, TbOrderDetail>
|
||||
implements TbOrderDetailService {
|
||||
@Override
|
||||
public List<TbOrderDetail> selectByCartIdOrOrderId(Integer shopId, List<Integer> cartIdList, Integer orderId) {
|
||||
return list(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, orderId))
|
||||
.eq(TbOrderDetail::getShopId, shopId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,42 +74,42 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
||||
return canUseCoupon;
|
||||
}
|
||||
|
||||
private void setCouponInfo( Map<Integer, JsonObject> coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) {
|
||||
JsonObject json = new JsonObject();
|
||||
boolean isUse = true;
|
||||
TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId());
|
||||
StringBuilder useRestrictions = new StringBuilder("每天 ");
|
||||
if (tbShopCoupon.getType().equals(1)) {
|
||||
if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) {
|
||||
isUse = false;
|
||||
private void setCouponInfo( Map<Integer, JsonObject> coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) {
|
||||
JsonObject json = new JsonObject();
|
||||
boolean isUse = true;
|
||||
TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId());
|
||||
StringBuilder useRestrictions = new StringBuilder("每天 ");
|
||||
if (tbShopCoupon.getType().equals(1)) {
|
||||
if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) {
|
||||
isUse = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) {
|
||||
String[] split = tbShopCoupon.getUserDays().split(",");
|
||||
if (split.length != 7) {
|
||||
useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " ");
|
||||
if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) {
|
||||
String[] split = tbShopCoupon.getUserDays().split(",");
|
||||
if (split.length != 7) {
|
||||
useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " ");
|
||||
}
|
||||
if (!tbShopCoupon.getUserDays().contains(week)) {
|
||||
isUse = false;
|
||||
}
|
||||
}
|
||||
if (!tbShopCoupon.getUserDays().contains(week)) {
|
||||
isUse = false;
|
||||
if (tbShopCoupon.getUseTimeType().equals("custom")) {
|
||||
if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) {
|
||||
isUse = false;
|
||||
}
|
||||
useRestrictions.append(
|
||||
tbShopCoupon.getUseStartTime().format(formatter)
|
||||
+ "-"
|
||||
+ tbShopCoupon.getUseEndTime().format(formatter));
|
||||
} else {
|
||||
useRestrictions.append("全时段");
|
||||
}
|
||||
}
|
||||
if (tbShopCoupon.getUseTimeType().equals("custom")) {
|
||||
if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) {
|
||||
isUse = false;
|
||||
}
|
||||
useRestrictions.append(
|
||||
tbShopCoupon.getUseStartTime().format(formatter)
|
||||
+ "-"
|
||||
+ tbShopCoupon.getUseEndTime().format(formatter));
|
||||
} else {
|
||||
useRestrictions.append("全时段");
|
||||
}
|
||||
useRestrictions.append(" 可用");
|
||||
json.addProperty("isUse", isUse);
|
||||
json.addProperty("useRestrictions", useRestrictions.toString());
|
||||
useRestrictions.append(" 可用");
|
||||
json.addProperty("isUse", isUse);
|
||||
json.addProperty("useRestrictions", useRestrictions.toString());
|
||||
|
||||
coupons.put(tbUserCouponVo.getCouponId(), json);
|
||||
}
|
||||
coupons.put(tbUserCouponVo.getCouponId(), json);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -206,4 +206,32 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbUserCouponVo> getActivateCoupon(TbShopUser tbShopUser, BigDecimal orderAmount, Integer shopId, Set<String> productIds) {
|
||||
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Collections.singletonList(Integer.valueOf(tbShopUser.getId())), shopId);
|
||||
if (tbUserCouponVos.isEmpty()) {
|
||||
return tbUserCouponVos;
|
||||
}
|
||||
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
||||
LocalTime now = LocalTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
//券id 券使用描述
|
||||
Map<Integer, JsonObject> coupons = new HashMap<>();
|
||||
for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) {
|
||||
if (!coupons.containsKey(tbUserCouponVo.getCouponId())) {
|
||||
setCouponInfo(coupons, tbUserCouponVo, orderAmount, week, now, formatter);
|
||||
}
|
||||
JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId());
|
||||
tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString());
|
||||
if (tbUserCouponVo.getType().equals(1)) {
|
||||
tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean());
|
||||
} else if (tbUserCouponVo.getType().equals(2) && couponJson.get("isUse").getAsBoolean()) {
|
||||
if (!productIds.contains(tbUserCouponVo.getProId().toString())) {
|
||||
tbUserCouponVo.setUse(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime));
|
||||
return tbUserCouponVos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopUserMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopUserService;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_table】的数据库操作Service实现
|
||||
* @createDate 2024-09-13 13:44:34
|
||||
*/
|
||||
@Service
|
||||
@Primary
|
||||
public class TbShopUserServiceImpl extends ServiceImpl<MpShopUserMapper, TbShopUser>
|
||||
implements TbShopUserService {
|
||||
|
||||
@Override
|
||||
public TbShopUser selectByUserIdAndShopId(String userId, String shopId) {
|
||||
return getOne(new LambdaQueryWrapper<TbShopUser>()
|
||||
.eq(TbShopUser::getShopId, shopId)
|
||||
.eq(TbShopUser::getUserId, userId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,10 +55,17 @@ public class ShopUtils {
|
||||
boolean isTakeout = isOpenTakeout && ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel);
|
||||
boolean isDineInAfter = isOpenDineIn && !isMunchies && !isTakeout;
|
||||
boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout;
|
||||
boolean hasTable = StrUtil.isNotBlank(tableId);
|
||||
boolean isNoneTable = !hasTable && !isTakeout;
|
||||
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn);
|
||||
boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0;
|
||||
boolean isIncrMasterId = isTakeout || isNoneTable;
|
||||
|
||||
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, tableId);
|
||||
}
|
||||
|
||||
public ShopEatTypeInfoDTO getEatModel(String tableId, Object shopId) {
|
||||
@@ -76,13 +83,20 @@ public class ShopUtils {
|
||||
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
|
||||
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
|
||||
|
||||
boolean isDineInAfter = !isMunchies && !isTakeout;
|
||||
boolean isDineInBefore = isMunchies && !isTakeout;
|
||||
boolean hasTable = StrUtil.isNotBlank(tableId);
|
||||
boolean isNoneTable = !hasTable && !isTakeout;
|
||||
|
||||
|
||||
boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0;
|
||||
boolean isIncrMasterId = isTakeout || isNoneTable;
|
||||
|
||||
|
||||
boolean isOpenTakeout = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.TAKE_OUT.getValue());
|
||||
boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue());
|
||||
boolean isDineInAfter = isOpenDineIn && !isMunchies && !isTakeout;
|
||||
boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout;
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(), isOpenTakeout, isOpenDineIn);
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, tableId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user