Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
Tankaikai
2024-11-08 09:53:37 +08:00
27 changed files with 1493 additions and 87 deletions

View File

@@ -45,6 +45,7 @@ public class LoginFilter implements Filter {
"cashierService/home",//首页 "cashierService/home",//首页
"cashierService/order/testMessage",//首页 "cashierService/order/testMessage",//首页
"cashierService/common/**",//通用接口 "cashierService/common/**",//通用接口
"cashierService/tbShopShare/**",//通用接口
"cashierService/distirict/**",//首页其它接口 "cashierService/distirict/**",//首页其它接口
// "cashierService/login/**",//登录部分接口不校验 // "cashierService/login/**",//登录部分接口不校验

View File

@@ -121,16 +121,23 @@ public class ProductController {
public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) { public Result choseEatModel(@Validated @RequestBody ChoseEatModelDTO choseEatModelDTO) {
List<TbCashierCart> cashierCartList = cartService.choseEatModel(choseEatModelDTO); List<TbCashierCart> cashierCartList = cartService.choseEatModel(choseEatModelDTO);
BigDecimal amount = BigDecimal.ZERO; BigDecimal amount = BigDecimal.ZERO;
BigDecimal memberAmount = BigDecimal.ZERO;
ArrayList<TbCashierCart> cashierCarts = new ArrayList<>(); ArrayList<TbCashierCart> cashierCarts = new ArrayList<>();
TbCashierCart seatFee = null;
for (TbCashierCart item : cashierCartList) { for (TbCashierCart item : cashierCartList) {
if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) { if (!TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
cashierCarts.add(item); cashierCarts.add(item);
amount = amount.add(item.getSalePrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee()));
memberAmount = memberAmount.add(item.getMemberPrice().multiply(BigDecimal.valueOf(item.getTotalNumber())).add(item.getPackFee()));
}else {
seatFee = item;
} }
amount = amount.add(item.getTotalAmount());
} }
HashMap<String, Object> data = new HashMap<>(); HashMap<String, Object> data = new HashMap<>();
data.put("amount", amount); data.put("amount", amount);
data.put("memberAmount", memberAmount);
data.put("info", cashierCarts); data.put("info", cashierCarts);
data.put("seatFee", seatFee);
return Result.success(CodeEnum.SUCCESS, data); return Result.success(CodeEnum.SUCCESS, data);
} }

View File

@@ -0,0 +1,75 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.service.TbShopShareService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 店铺分享(TbShopShare)表控制层
*
* @author ww
* @since 2024-11-07 14:36:27
*/
@RestController
@RequestMapping("tbShopShare")
public class TbShopShareController {
@Autowired
private TbShopShareService tbShopShareService;
@Autowired
private TbShopShareRecordService tbShopShareRecordService;
/**
* 通过主键查询单条数据
*
* @param shopId 主键
* @return 单条数据
*/
@GetMapping("getByShopId")
public Result queryById(@RequestParam Integer shopId) {
return Result.successWithData(tbShopShareService.queryByShopId(shopId));
}
/**
* 查询
*
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
@GetMapping("record")
public Result queryByPage(TbShopShareRecord tbShopShareRecord) {
return Result.successWithData(tbShopShareRecordService.query(tbShopShareRecord));
}
/**
* 进入页面
*
* @param tbShopShareRecord 实体
* @return 新增结果
*/
@PostMapping("open")
public Result open(@RequestBody TbShopShareRecord tbShopShareRecord) {
return tbShopShareRecordService.insert(tbShopShareRecord);
}
/**
* 领取优惠券
*
* @param tbShopShareRecord 实体
* @return 新增结果
*/
@PostMapping("receive")
public Result receive(@RequestBody TbShopShareRecord tbShopShareRecord) {
return tbShopShareRecordService.receive(tbShopShareRecord);
}
}

View File

@@ -0,0 +1,69 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopShare;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* 店铺分享(TbShopShare)表数据库访问层
*
* @author ww
* @since 2024-11-07 14:36:27
*/
public interface TbShopShareMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TbShopShare queryById(Integer id);
TbShopShare queryByShopId(Integer shopId);
/**
* 查询数据
*
* @param tbShopShare 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<TbShopShare> queryAll(TbShopShare tbShopShare, @Param("pageable") Pageable pageable);
/**
* 新增数据
*
* @param tbShopShare 实例对象
* @return 影响行数
*/
int insert(TbShopShare tbShopShare);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<TbShopShare> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TbShopShare> entities);
/**
* 修改数据
*
* @param tbShopShare 实例对象
* @return 影响行数
*/
int update(TbShopShare tbShopShare);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
}

View File

@@ -0,0 +1,75 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* (TbShopShareRecord)表数据库访问层
*
* @author ww
* @since 2024-11-07 15:50:03
*/
public interface TbShopShareRecordMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TbShopShareRecord queryById(Integer id);
TbShopShareRecord queryByData(
@Param("shareId") Integer shareId, @Param("shopId") Integer shopId,
@Param("invitedId") Integer invitedId, @Param("beInvitedId") Integer beInvitedId);
TbShopShareRecord queryByDataByBeInvited(
@Param("shareId") Integer shareId, @Param("shopId") Integer shopId,
@Param("beInvitedId") Integer beInvitedId);
/**
* 查询数据
*
* @param tbShopShareRecord 查询条件
* @return 对象列表
*/
List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord);
/**
* 新增数据
*
* @param tbShopShareRecord 实例对象
* @return 影响行数
*/
int insert(TbShopShareRecord tbShopShareRecord);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<TbShopShareRecord> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TbShopShareRecord> entities);
/**
* 修改数据
*
* @param tbShopShareRecord 实例对象
* @return 影响行数
*/
int update(TbShopShareRecord tbShopShareRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
}

View File

@@ -17,6 +17,8 @@ public interface TbUserInfoMapper {
TbUserInfo selectByPrimaryKey(Integer id); TbUserInfo selectByPrimaryKey(Integer id);
String selectNameByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbUserInfo record); int updateByPrimaryKeySelective(TbUserInfo record);
int updateByPrimaryKey(TbUserInfo record); int updateByPrimaryKey(TbUserInfo record);

View File

@@ -73,6 +73,7 @@ public class TbActivateInRecord implements Serializable {
private Date updateTime; private Date updateTime;
private String couponJson; private String couponJson;
private String source;
public Integer getId() { public Integer getId() {
@@ -219,5 +220,13 @@ public class TbActivateInRecord implements Serializable {
this.couponJson = couponJson; this.couponJson = couponJson;
} }
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
} }

View File

@@ -34,6 +34,8 @@ public class TbCashierCart implements Serializable {
private String skuName; private String skuName;
private BigDecimal salePrice; private BigDecimal salePrice;
// 会员价
private BigDecimal memberPrice = BigDecimal.ZERO;
private BigDecimal packFee; private BigDecimal packFee;
private Integer number; private Integer number;
@@ -74,6 +76,9 @@ public class TbCashierCart implements Serializable {
// 使用的优惠券id // 使用的优惠券id
private Integer userCouponId; private Integer userCouponId;
// 是否是会员
private Integer isMember;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public String getSkuName() { public String getSkuName() {
@@ -83,4 +88,13 @@ public class TbCashierCart implements Serializable {
return ""; return "";
} }
} }
public void resetTotalAmount() {
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee);
}else {
totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee);
}
}
} }

View File

@@ -17,7 +17,7 @@ import lombok.Data;
@Data @Data
public class TbFreeDineConfig implements Serializable { public class TbFreeDineConfig implements Serializable {
/** /**
* *
*/ */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; private Integer id;
@@ -25,7 +25,7 @@ public class TbFreeDineConfig implements Serializable {
/** /**
* 是否启用 * 是否启用
*/ */
private Integer enable; private Integer enable = 0;
/** /**
* 充值多少倍免单 * 充值多少倍免单
@@ -147,4 +147,4 @@ public class TbFreeDineConfig implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

View File

@@ -45,6 +45,7 @@ public class TbOrderDetail implements Serializable {
private Integer placeNum; private Integer placeNum;
private String useType; private String useType;
private String note; private String note;
private BigDecimal memberPrice;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@@ -0,0 +1,132 @@
package com.chaozhanggui.system.cashierservice.entity;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.Date;
import java.io.Serializable;
import java.util.List;
/**
* 店铺分享(TbShopShare)实体类
*
* @author ww
* @since 2024-11-07 14:36:27
*/
@Data
public class TbShopShare implements Serializable {
private static final long serialVersionUID = 955264376724636315L;
private Integer id;
/**
* 店铺Id
*/
private Integer shopId;
/**
* 标题
*/
private String title;
/**
* 分享封面图
*/
private String shareImg;
/**
* 邀请顶部图
*/
private String invitedImg;
/**
* 被邀顶部图
*/
private String beInvitedImg;
/**
* 活动开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
* 活动结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/**
* 新用户获得券
*/
private String newCoupon;
/**
* 邀请人数
*/
private Integer invitedNum;
/**
* 奖励券
*/
private String rewardCoupon;
/**
* 获取方法 get-新用户领取获得 use-新用户使用获得
*/
private String getMethod;
/**
* 0 关闭 1 开启
*/
private Integer status;
@TableField(exist = false)
private List<ShareCoupons> newCoupons;
@TableField(exist = false)
private List<ShareCoupons> rewardCoupons;
public void setNewCoupon(String newCoupon) {
this.newCoupon = newCoupon;
if(StringUtils.isNotBlank(newCoupon)){
this.newCoupons = JSONUtil.parseListTNewList(newCoupon,ShareCoupons.class);
}
}
public void setRewardCoupon(String rewardCoupon) {
this.rewardCoupon = rewardCoupon;
if(StringUtils.isNotBlank(rewardCoupon)){
this.rewardCoupons = JSONUtil.parseListTNewList(rewardCoupon,ShareCoupons.class);
}
}
public void setNewCoupons(List<ShareCoupons> newCoupons) {
this.newCoupons = newCoupons;
if(CollectionUtil.isNotEmpty(newCoupons)){
this.newCoupon = JSONUtil.toJSONString(newCoupons);
}
}
public void setRewardCoupons(List<ShareCoupons> rewardCoupons) {
this.rewardCoupons = rewardCoupons;
if(CollectionUtil.isNotEmpty(rewardCoupons)){
this.rewardCoupon = JSONUtil.toJSONString(rewardCoupons);
}
}
@Data
public static class ShareCoupons {
//优惠券Id
private Integer couponId;
//优惠券名称
private String couponName;
//优惠券数量
private Integer couponNum;
//1 满减 2 商品
private Integer type;
//满多少金额
private Integer fullAmount;
//优惠多少金额
private Integer discountAmount;
//使用描述
private String useDetail;
//商品描述
private List<String> gives;
}
}

View File

@@ -0,0 +1,156 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import java.io.Serializable;
/**
* (TbShopShareRecord)实体类
*
* @author ww
* @since 2024-11-07 15:50:04
*/
public class TbShopShareRecord implements Serializable {
private static final long serialVersionUID = -41620929736900271L;
private Integer id;
/**
* tb_shop_share 主键Id
*/
private Integer shareId;
/**
* 店铺Id
*/
private Integer shopId;
/**
* 邀请人id
*/
private Integer invitedId;
/**
* 邀请人名称
*/
private String invitedName;
/**
* 被邀请人Id
*/
private Integer beInvitedId;
/**
* 被邀请人名称
*/
private String beInvitedName;
/**
* 奖励券获得方式 get/use 领取获得/使用获得
*/
private String method;
/**
* 1 未领取 2 已领取 3 已使用
*/
private Integer status;
/**
* 生效时间/获得奖励的时间
*/
private Date rewardTime;
private Date createTime;
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShareId() {
return shareId;
}
public void setShareId(Integer shareId) {
this.shareId = shareId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getInvitedId() {
return invitedId;
}
public void setInvitedId(Integer invitedId) {
this.invitedId = invitedId;
}
public String getInvitedName() {
return invitedName;
}
public void setInvitedName(String invitedName) {
this.invitedName = invitedName;
}
public Integer getBeInvitedId() {
return beInvitedId;
}
public void setBeInvitedId(Integer beInvitedId) {
this.beInvitedId = beInvitedId;
}
public String getBeInvitedName() {
return beInvitedName;
}
public void setBeInvitedName(String beInvitedName) {
this.beInvitedName = beInvitedName;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getRewardTime() {
return rewardTime;
}
public void setRewardTime(Date rewardTime) {
this.rewardTime = rewardTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@@ -23,4 +23,6 @@ public class MemberInDTO {
private Integer userCouponId; private Integer userCouponId;
// 是否使用积分抵扣 // 是否使用积分抵扣
private Integer pointsNum ; private Integer pointsNum ;
private String payType;
} }

View File

@@ -21,5 +21,6 @@ public class ShopEatTypeInfoDTO {
private String useType; private String useType;
private boolean isOpenTakeout; private boolean isOpenTakeout;
private boolean isOpenDineIn; private boolean isOpenDineIn;
private boolean isMemberPrice;
private String tableId; private String tableId;
} }

View File

@@ -16,6 +16,7 @@ import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum; import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.*; import com.chaozhanggui.system.cashierservice.entity.dto.*;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.*; import com.chaozhanggui.system.cashierservice.mapper.*;
@@ -152,7 +153,6 @@ public class CartService {
String tableId = jsonObject.getString("tableId"); String tableId = jsonObject.getString("tableId");
String shopId = jsonObject.getString("shopId"); String shopId = jsonObject.getString("shopId");
Integer userId = jsonObject.getInteger("userId"); Integer userId = jsonObject.getInteger("userId");
BigDecimal amount = BigDecimal.ZERO;
JSONArray array = new JSONArray(); JSONArray array = new JSONArray();
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(tableId, shopId); ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.getEatModel(tableId, shopId);
@@ -165,25 +165,6 @@ public class CartService {
boolean ignoreTableFee = shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1; boolean ignoreTableFee = shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1;
TbCashierCart seatCartInfo = null; TbCashierCart seatCartInfo = null;
// if (redisUtil.exists(tableCartKey)) {
// JSONArray jsonArray = JSON.parseArray(redisUtil.getMessage(tableCartKey));
// for (int i = 0; i < jsonArray.size(); i++) {
// JSONObject object = array.getJSONObject(i);
// TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
// if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) {
// amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
// }
//
// if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
// seatCartInfo = cashierCart;
// if (!ignoreTableFee) {
// array.add(cashierCart);
// }
// }else {
// array.add(cashierCart);
// }
// }
// } else {
// 查询购物车所有信息 // 查询购物车所有信息
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>() LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
@@ -199,6 +180,9 @@ public class CartService {
queryWrapper.eq(TbCashierCart::getUserId, userId); queryWrapper.eq(TbCashierCart::getUserId, userId);
} }
BigDecimal amount = BigDecimal.ZERO;
BigDecimal memberAmount = BigDecimal.ZERO;
List<TbCashierCart> tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper); List<TbCashierCart> tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(tbCashierCarts)) { if (!CollectionUtils.isEmpty(tbCashierCarts)) {
for (TbCashierCart cashierCart : tbCashierCarts) { for (TbCashierCart cashierCart : tbCashierCarts) {
@@ -208,8 +192,12 @@ public class CartService {
array.add(cashierCart); array.add(cashierCart);
} }
if (cashierCart.getIsVip().equals((byte) 1)) continue; if (cashierCart.getIsVip().equals((byte) 1)) continue;
if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) { if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) && cashierCart.getNumber() > 0) {
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); amount = amount.add(cashierCart.getSalePrice().multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 &&
cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice();
memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
} }
} }
redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L); redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L);
@@ -228,6 +216,7 @@ public class CartService {
jsonObject1.put("type", "addCart"); jsonObject1.put("type", "addCart");
jsonObject1.put("data", array); jsonObject1.put("data", array);
jsonObject1.put("amount", amount); jsonObject1.put("amount", amount);
jsonObject1.put("memberAmount", memberAmount);
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false); PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false);
} }
@@ -357,17 +346,21 @@ public class CartService {
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
ArrayList<TbCashierCart> cashierCartArrayList = new ArrayList<>(); ArrayList<TbCashierCart> cashierCartArrayList = new ArrayList<>();
BigDecimal amount = BigDecimal.ZERO; BigDecimal amount = BigDecimal.ZERO;
BigDecimal memberAmount = BigDecimal.ZERO;
try { try {
if (redisUtil.exists(tableCartKey)) { if (redisUtil.exists(tableCartKey)) {
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey)); JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
if (Objects.isNull(array) || array.isEmpty()) { if (Objects.isNull(array) || array.isEmpty()) {
if (type == 1) { if (type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId, TbCashierCart cashierCart = addCart(productId, skuId,
jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO);
jsonArray.add(cashierCart); jsonArray.add(cashierCart);
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum()); cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
cashierCartArrayList.add(cashierCart); cashierCartArrayList.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 &&
cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice();
memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
} }
} else { } else {
@@ -410,8 +403,7 @@ public class CartService {
if (isVip != null && isVip == 1) { if (isVip != null && isVip == 1) {
cashierCart.setTotalAmount(BigDecimal.ZERO); cashierCart.setTotalAmount(BigDecimal.ZERO);
} else { } else {
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()) cashierCart.resetTotalAmount();
.multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
} }
cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
mpCashierCartMapper.updateById(cashierCart); mpCashierCartMapper.updateById(cashierCart);
@@ -424,6 +416,9 @@ public class CartService {
jsonArray.add(cashierCart); jsonArray.add(cashierCart);
cashierCartArrayList.add(cashierCart); cashierCartArrayList.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 &&
cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice();
memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
if ("-999".equals(cashierCart.getProductId())) { if ("-999".equals(cashierCart.getProductId())) {
hasSeat = true; hasSeat = true;
@@ -432,16 +427,20 @@ public class CartService {
if (flag && type == 1) { if (flag && type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId, TbCashierCart cashierCart = addCart(productId, skuId,
jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO);
jsonArray.add(cashierCart); jsonArray.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 &&
cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice();
memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
} }
} }
} else { } else {
if (type == 1) { if (type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId, TbCashierCart cashierCart = addCart(productId, skuId,
jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout()); jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO);
if (!TableConstant.CART_SEAT_ID.equals(productId)) { if (!TableConstant.CART_SEAT_ID.equals(productId)) {
jsonArray.add(cashierCart); jsonArray.add(cashierCart);
} }
@@ -449,6 +448,10 @@ public class CartService {
cashierCartArrayList.add(cashierCart); cashierCartArrayList.add(cashierCart);
if (isVip != 1) { if (isVip != 1) {
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
BigDecimal mPrice = cashierCart.getIsMember() != null && cashierCart.getIsMember() == 1 &&
cashierCart.getMemberPrice() != null && cashierCart.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? cashierCart.getMemberPrice() : cashierCart.getSalePrice();
memberAmount = memberAmount.add(mPrice.multiply(BigDecimal.valueOf(cashierCart.getTotalNumber())).add(cashierCart.getPackFee()));
} }
} }
} }
@@ -469,6 +472,7 @@ public class CartService {
data.put("data", jsonArray); data.put("data", jsonArray);
data.put("seatFee", BeanUtil.copyProperties(seatCost, TbCashierCart.class)); data.put("seatFee", BeanUtil.copyProperties(seatCost, TbCashierCart.class));
data.put("amount", amount); data.put("amount", amount);
data.put("memberAmount", memberAmount);
data.put("reqData", jsonObject); data.put("reqData", jsonObject);
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(data), tableCartKey, "", false); PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(data), tableCartKey, "", false);
} catch (Exception e) { } catch (Exception e) {
@@ -573,8 +577,14 @@ public class CartService {
} }
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception { String tableId, String shopId, Integer isVip, String note, ShopEatTypeInfoDTO shopEatTypeInfoDTO) throws Exception {
try { try {
// 查询用户信息
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(String.valueOf(userId), shopId);
if (shopUser == null) {
throw new MsgException("用户不存在");
}
TbProduct product = productMapper.selectById(Integer.valueOf(productId)); TbProduct product = productMapper.selectById(Integer.valueOf(productId));
String key = tableId + "-" + shopId; String key = tableId + "-" + shopId;
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
@@ -621,9 +631,13 @@ public class CartService {
cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
cashierCart.setPackFee(BigDecimal.ZERO); cashierCart.setPackFee(BigDecimal.ZERO);
cashierCart.setRefundNumber(0); cashierCart.setRefundNumber(0);
if (shopEatTypeInfoDTO.isMemberPrice() && shopUser.getIsVip() == 1) {
cashierCart.setMemberPrice(productSku.getMemberPrice());
cashierCart.setIsMember(1);
}
cashierCart.setTradeDay(DateUtils.getDay()); cashierCart.setTradeDay(DateUtils.getDay());
// 打包费 // 打包费
if (isTakeout && product.getPackFee() != null) { if (shopEatTypeInfoDTO.isTakeout() && product.getPackFee() != null) {
cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num))); cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num)));
} }
if (isVip == 1) { if (isVip == 1) {
@@ -632,7 +646,7 @@ public class CartService {
cashierCart.setSalePrice(BigDecimal.ZERO); cashierCart.setSalePrice(BigDecimal.ZERO);
} else { } else {
cashierCart.setIsVip((byte) 0); cashierCart.setIsVip((byte) 0);
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee()))); cashierCart.resetTotalAmount();
} }
cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue()); cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
mpCashierCartMapper.insert(cashierCart); mpCashierCartMapper.insert(cashierCart);
@@ -998,6 +1012,7 @@ public class CartService {
orderInfo.setTradeDay(DateUtils.getDay()); orderInfo.setTradeDay(DateUtils.getDay());
orderInfo.setUseType(eatTypeInfoDTO.getUseType()); orderInfo.setUseType(eatTypeInfoDTO.getUseType());
orderInfo.setCreatedAt(DateUtil.current()); orderInfo.setCreatedAt(DateUtil.current());
orderInfo.setOrderType("miniapp");
orderInfo.setProductCouponDiscountAmount(priceDTO.getProductDiscountAmount()); orderInfo.setProductCouponDiscountAmount(priceDTO.getProductDiscountAmount());
if (seatCart != null) { if (seatCart != null) {
@@ -1075,6 +1090,7 @@ public class CartService {
orderDetail.setProductSkuName(productSku.getSpecSnap()); orderDetail.setProductSkuName(productSku.getSpecSnap());
} }
orderDetail.setMemberPrice(cashierCart.getMemberPrice());
orderDetail.setNote(cashierCart.getNote()); orderDetail.setNote(cashierCart.getNote());
orderDetail.setCreateTime(DateUtil.date().toTimestamp()); orderDetail.setCreateTime(DateUtil.date().toTimestamp());
orderDetail.setNum(cashierCart.getNumber()); orderDetail.setNum(cashierCart.getNumber());
@@ -1193,7 +1209,7 @@ public class CartService {
} }
private OrderCartInfoDTO getCartInfoForOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, List<TbCashierCart> allCartList, TbShopTable shopTable) { private OrderCartInfoDTO getCartInfoForOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, List<TbCashierCart> allCartList, TbShopTable shopTable, TbShopUser shopUser) {
OrderCartInfoDTO infoDTO = new OrderCartInfoDTO(); OrderCartInfoDTO infoDTO = new OrderCartInfoDTO();
// 就餐人数 // 就餐人数
ArrayList<Integer> cashierIds = new ArrayList<>(); ArrayList<Integer> cashierIds = new ArrayList<>();
@@ -1201,6 +1217,16 @@ public class CartService {
Integer orderId = null; Integer orderId = null;
for (TbCashierCart tbCashierCart : allCartList) { for (TbCashierCart tbCashierCart : allCartList) {
cashierIds.add(tbCashierCart.getId()); cashierIds.add(tbCashierCart.getId());
// 设置会员信息及价格
if (shopUser.getIsVip() == 0) {
tbCashierCart.setIsMember(0);
}else {
if (!TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) {
TbProductSkuWithBLOBs sku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(tbCashierCart.getSkuId()));
tbCashierCart.setIsMember(sku.getMemberPrice() != null && sku.getMemberPrice().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0);
}
}
tbCashierCart.resetTotalAmount();
if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) { if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) {
seatInfo = tbCashierCart; seatInfo = tbCashierCart;
} }
@@ -1274,6 +1300,8 @@ public class CartService {
if (tbUserInfo == null) { if (tbUserInfo == null) {
MsgException.throwException("生成订单失败"); MsgException.throwException("生成订单失败");
} }
// 用户信息
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId); TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
// 获取当前下单次数和用餐类型 // 获取当前下单次数和用餐类型
@@ -1293,7 +1321,7 @@ public class CartService {
TbShopTable shopTable = getTableInfoByEatType(shopEatTypeInfoDTO); TbShopTable shopTable = getTableInfoByEatType(shopEatTypeInfoDTO);
// 获取详细的购物车信息 // 获取详细的购物车信息
OrderCartInfoDTO cartInfoDTO = getCartInfoForOrder(shopEatTypeInfoDTO, cashierCartList, shopTable); OrderCartInfoDTO cartInfoDTO = getCartInfoForOrder(shopEatTypeInfoDTO, cashierCartList, shopTable, tbShopUser);
// 获取订单信息 // 获取订单信息
TbOrderInfo orderInfo = null; TbOrderInfo orderInfo = null;

View File

@@ -594,7 +594,7 @@ public class PayService {
} }
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount())); user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount())); user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getOrderAmount()));
user.setConsumeNumber(user.getConsumeNumber() + 1); user.setConsumeNumber(user.getConsumeNumber() + 1);
user.setUpdatedAt(System.currentTimeMillis()); user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(user); tbShopUserMapper.updateByPrimaryKeySelective(user);
@@ -1087,6 +1087,11 @@ public class PayService {
return Result.fail("支付通道不存在"); return Result.fail("支付通道不存在");
} }
if ("aliPay".equals(memberInDTO.getPayType()) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) {
return Result.fail("店铺未配置支付宝小程序appId");
}
// 霸王餐活动充值 // 霸王餐活动充值
BigDecimal payAmount; BigDecimal payAmount;
TbMemberIn memberIn = new TbMemberIn(); TbMemberIn memberIn = new TbMemberIn();
@@ -1142,12 +1147,17 @@ public class PayService {
} }
} }
} else { } else {
String smallAppid = thirdApply.getSmallAppid();
if ("aliPay".equals(memberInDTO.getPayType())) {
smallAppid = thirdApply.getAlipaySmallAppid();
}
String convertPayType = "aliPay".equals(memberInDTO.getPayType()) ? "ALIPAY" : "WECHAT";
String orderNo = DateUtils.getsdfTimesSS(); String orderNo = DateUtils.getsdfTimesSS();
PublicResp<WxScanPayResp> publicResp = thirdPayService PublicResp<WxScanPayResp> publicResp = thirdPayService
.scanpay(thirdUrl, thirdApply.getAppId(), .scanpay(thirdUrl, thirdApply.getAppId(),
"会员充值", "会员充值", payAmount "会员充值", "会员充值", payAmount
.multiply(new BigDecimal(100)).longValue(), "WECHAT", .multiply(new BigDecimal(100)).longValue(), convertPayType,
thirdApply.getSmallAppid(), memberInDTO.getOpenId(), ip, orderNo, thirdApply.getStoreId(), smallAppid, memberInDTO.getOpenId(), ip, orderNo, thirdApply.getStoreId(),
callInBack, null, thirdApply.getAppToken()); callInBack, null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) { if ("000000".equals(publicResp.getCode())) {

View File

@@ -21,6 +21,7 @@ import com.chaozhanggui.system.cashierservice.entity.vo.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper; import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper; import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpShopInfoMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper; import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper;
import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisCst;
import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
@@ -107,9 +108,13 @@ public class ProductService {
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired @Autowired
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
private final TbFreeDineConfigService freeDineConfigService;
@Autowired
private MpShopInfoMapper mpShopInfoMapper;
public ProductService(ShopUtils shopUtils) { public ProductService(ShopUtils shopUtils, TbFreeDineConfigService freeDineConfigService) {
this.shopUtils = shopUtils; this.shopUtils = shopUtils;
this.freeDineConfigService = freeDineConfigService;
} }
private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO, String tableId, Object shopId) { private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO, String tableId, Object shopId) {
@@ -167,6 +172,12 @@ public class ProductService {
concurrentMap.put("storeInfo", shopInfo); concurrentMap.put("storeInfo", shopInfo);
concurrentMap.put("distance", distance); concurrentMap.put("distance", distance);
TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId != null ? shopId.toString() : tbShopTable.getShopId().toString()); TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId != null ? shopId.toString() : tbShopTable.getShopId().toString());
TbFreeDineConfig freeDineConfig = freeDineConfigService.getOne(new LambdaQueryWrapper<TbFreeDineConfig>()
.eq(TbFreeDineConfig::getShopId, shopId));
if (freeDineConfig == null) {
freeDineConfig = new TbFreeDineConfig();
}
concurrentMap.put("freeDingConfig", freeDineConfig);
try { try {
if (ObjectUtil.isEmpty(shopUser)) { if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
@@ -214,21 +225,22 @@ public class ProductService {
Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null;
//招牌菜 //招牌菜
List<TbProduct> tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); List<TbProduct> tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId));
concurrentMap.put("hots", handleDate(tbProducts,true,1,false)); TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
concurrentMap.put("hots", handleDate(tbProducts,true,1,false, shopInfo));
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id); List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) {
//热销 //热销
TbProductGroup hot = new TbProductGroup(); TbProductGroup hot = new TbProductGroup();
hot.setName("热销"); hot.setName("热销");
List<TbProduct> hots = tbProductMapper.selectHot(shopId); List<TbProduct> hots = tbProductMapper.selectHot(shopId);
hot.setProducts(handleDate(hots,true,1,false)); hot.setProducts(handleDate(hots,true,1,false, shopInfo));
//商品 //商品
groupList.parallelStream().forEach(g -> { groupList.parallelStream().forEach(g -> {
if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime()));
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in); List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
g.setProducts(handleDate(products,false,g.getIsSale(),false)); g.setProducts(handleDate(products,false,g.getIsSale(),false, shopInfo));
} else { } else {
g.setProducts(new ArrayList<>()); g.setProducts(new ArrayList<>());
} }
@@ -442,7 +454,8 @@ public class ProductService {
* @param check 是否校验可售 * @param check 是否校验可售
* @return * @return
*/ */
public List<TbProduct> handleDate(List<TbProduct> products,boolean check,Integer isSale,boolean isVip){ public List<TbProduct> handleDate(List<TbProduct> products,boolean check,Integer isSale,boolean isVip, TbShopInfo shopInfo){
boolean isMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1;
if (!CollectionUtils.isEmpty(products)) { if (!CollectionUtils.isEmpty(products)) {
products.parallelStream().forEach(it -> { products.parallelStream().forEach(it -> {
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId())); TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
@@ -481,6 +494,10 @@ public class ProductService {
if (lowMemberPrice == null || lowMemberPrice.compareTo(item.getMemberPrice()) > 0) { if (lowMemberPrice == null || lowMemberPrice.compareTo(item.getMemberPrice()) > 0) {
lowMemberPrice = item.getMemberPrice(); lowMemberPrice = item.getMemberPrice();
} }
if (item.getMemberPrice() == null || item.getMemberPrice().compareTo(BigDecimal.ZERO) <= 0) {
item.setMealPrice(item.getSalePrice());
}
} }
// 销量 // 销量
it.setStockNumber(sum.intValue()); it.setStockNumber(sum.intValue());
@@ -492,7 +509,7 @@ public class ProductService {
it.setLowPrice(lowerPrice); it.setLowPrice(lowerPrice);
// 会员价 // 会员价
if (lowMemberPrice == null) { if (lowMemberPrice == null || !isMemberPrice) {
lowMemberPrice = BigDecimal.ZERO; lowMemberPrice = BigDecimal.ZERO;
} }
it.setLowMemberPrice(lowMemberPrice); it.setLowMemberPrice(lowMemberPrice);
@@ -894,6 +911,7 @@ public class ProductService {
tbCashierCart.setProductId(TableConstant.CART_SEAT_ID); tbCashierCart.setProductId(TableConstant.CART_SEAT_ID);
tbCashierCart.setSkuId(TableConstant.CART_SEAT_ID); tbCashierCart.setSkuId(TableConstant.CART_SEAT_ID);
tbCashierCart.setPackFee(BigDecimal.ZERO); tbCashierCart.setPackFee(BigDecimal.ZERO);
tbCashierCart.setMemberPrice(shopInfo.getTableFee());
tbCashierCart.setNumber(choseCountDTO.getNum()); tbCashierCart.setNumber(choseCountDTO.getNum());
tbCashierCart.setTotalNumber(choseCountDTO.getNum()); tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());

View File

@@ -0,0 +1,62 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import java.util.List;
/**
* (TbShopShareRecord)表服务接口
*
* @author ww
* @since 2024-11-07 15:50:04
*/
public interface TbShopShareRecordService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TbShopShareRecord queryById(Integer id);
/**
* 分页查询
*
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord);
Result receive(TbShopShareRecord tbShopShareRecord);
/**
* 新增数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
Result insert(TbShopShareRecord tbShopShareRecord);
/**
* 修改数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
TbShopShareRecord update(TbShopShareRecord tbShopShareRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Integer id);
void give(TbShopShareRecord shareRecord, Integer userId);
}

View File

@@ -0,0 +1,24 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.TbShopShare;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
/**
* 店铺分享(TbShopShare)表服务接口
*
* @author ww
* @since 2024-11-07 14:36:27
*/
public interface TbShopShareService {
/**
* 通过ID查询单条数据
*
* @param shopId 主键
* @return 实例对象
*/
TbShopShare queryByShopId(Integer shopId);
}

View File

@@ -7,10 +7,12 @@ import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto; import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto;
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo; import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
import com.chaozhanggui.system.cashierservice.service.TbShopCouponService; import com.chaozhanggui.system.cashierservice.service.TbShopCouponService;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -43,6 +45,12 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
@Resource @Resource
private TbActivateOutRecordMapper outRecordMapper; private TbActivateOutRecordMapper outRecordMapper;
@Autowired
private TbShopShareRecordMapper shareRecordMapper;
@Autowired
private TbShopShareRecordService shareRecordService;
@Override @Override
public List<TbUserCouponVo> getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) { public List<TbUserCouponVo> getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) {
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId)); TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId));
@@ -74,42 +82,42 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
return canUseCoupon; return canUseCoupon;
} }
private void setCouponInfo( Map<Integer, JsonObject> coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) { private void setCouponInfo(Map<Integer, JsonObject> coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
boolean isUse = true; boolean isUse = true;
TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId()); TbShopCoupon tbShopCoupon = couponMapper.queryById(tbUserCouponVo.getCouponId());
StringBuilder useRestrictions = new StringBuilder("每天 "); StringBuilder useRestrictions = new StringBuilder("每天 ");
if (tbShopCoupon.getType().equals(1)) { if (tbShopCoupon.getType().equals(1)) {
if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) { if (amount.compareTo(new BigDecimal(tbShopCoupon.getFullAmount())) < 0) {
isUse = false; isUse = false;
}
} }
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.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());
coupons.put(tbUserCouponVo.getCouponId(), json);
} }
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.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());
coupons.put(tbUserCouponVo.getCouponId(), json);
}
@Override @Override
@@ -174,6 +182,14 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List<TbActivateOutRecord> param) { public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List<TbActivateOutRecord> param) {
for (TbActivateOutRecord outRecord : param) { for (TbActivateOutRecord outRecord : param) {
TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId()); TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId());
if (inRecord.getSource().equals("invited")) {
TbShopShareRecord shareRecord = shareRecordMapper.queryById(inRecord.getSourceActId());
if (shareRecord.getMethod().equals("use")) {
shareRecord.setStatus(3);
shareRecordService.give(shareRecord,shareRecord.getInvitedId());
shareRecordMapper.update(shareRecord);
}
}
inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum()); inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum());
inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum()); inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum());

View File

@@ -0,0 +1,262 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* (TbShopShareRecord)表服务实现类
*
* @author ww
* @since 2024-11-07 15:50:04
*/
@Primary
@Service
public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
@Autowired
private TbShopShareMapper tbShopShareMapper;
@Autowired
private TbShopShareRecordMapper tbShopShareRecordMapper;
@Autowired
private TbShopUserMapper shopUserMapper;
@Autowired
private TbCouponProductMapper couProductMapper;
@Autowired
private TbShopCouponMapper couponMapper;
@Autowired
private TbActivateInRecordMapper activateInRecordMapper;
@Autowired
private TbUserInfoMapper userInfoMapper;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public TbShopShareRecord queryById(Integer id) {
return this.tbShopShareRecordMapper.queryById(id);
}
/**
* 分页查询
*
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
@Override
public List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord) {
List<TbShopShareRecord> records = tbShopShareRecordMapper.query(tbShopShareRecord);
for (TbShopShareRecord shareRecord : records) {
shareRecord.setBeInvitedName(userInfoMapper.selectNameByPrimaryKey(shareRecord.getBeInvitedId()));
}
return records;
}
@Override
public Result receive(TbShopShareRecord tbShopShareRecord) {
// TbShopShareRecord query = tbShopShareRecordMapper.queryByDataByBeInvited(
// tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(), tbShopShareRecord.getBeInvitedId());
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
if (query.getStatus() == 1) {
give(query, query.getBeInvitedId());
if (query.getMethod().equals("get")) {
give(query, query.getInvitedId());
}
query.setRewardTime(new Date());
query.setStatus(2);
query.setUpdateTime(new Date());
tbShopShareRecordMapper.update(query);
return Result.successWithData("领取成功。");
} else {
return Result.fail("不可重复领取。");
}
}
/**
* 新增数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
@Override
public Result insert(TbShopShareRecord tbShopShareRecord) {
TbShopUser shopUserInfo = getShopUserInfo(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
if (query == null) {
TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId());
tbShopShareRecord.setMethod(tbShopShare.getGetMethod());
tbShopShareRecord.setShopId(tbShopShareRecord.getShopId());
tbShopShareRecord.setCreateTime(new Date());
tbShopShareRecord.setUpdateTime(new Date());
}else {
query.setUpdateTime(new Date());
}
if (shopUserInfo == null) {
if (query != null) {
query.setStatus(1);
tbShopShareRecordMapper.update(query);
} else {
tbShopShareRecord.setStatus(1);
tbShopShareRecordMapper.insert(tbShopShareRecord);
}
saveShopUser(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
} else {
if (query != null) {
query.setStatus(0);
tbShopShareRecordMapper.update(query);
} else {
tbShopShareRecord.setStatus(0);
tbShopShareRecordMapper.insert(tbShopShareRecord);
}
}
if (query == null) {
query = tbShopShareRecord;
}
return Result.successWithData(query);
}
/**
* 修改数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
@Override
public TbShopShareRecord update(TbShopShareRecord tbShopShareRecord) {
this.tbShopShareRecordMapper.update(tbShopShareRecord);
return this.queryById(tbShopShareRecord.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Integer id) {
return this.tbShopShareRecordMapper.deleteById(id) > 0;
}
public TbShopUser getShopUserInfo(Integer userId, Integer shopId) {
return shopUserMapper.selectByUserIdAndShopId(userId.toString(), shopId.toString());
}
public void saveShopUser(Integer userId, Integer shopId) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(userId);
TbShopUser shopUser = new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(tbUserInfo.getTelephone());
shopUser.setAmount(BigDecimal.ZERO);
shopUser.setIsVip(Byte.parseByte("0"));
shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(shopId.toString());
shopUser.setUserId(userId.toString());
shopUser.setMiniOpenId(tbUserInfo.getMiniAppOpenId());
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
}
@Override
public void give(TbShopShareRecord shareRecord, Integer userId) {
TbShopShare shopShare = tbShopShareMapper.queryById(shareRecord.getShareId());
TbShopUser tbShopUser = getShopUserInfo(userId, shareRecord.getShopId());
if (userId.equals(shareRecord.getInvitedId())) {
giveCoupon(shopShare, tbShopUser, shopShare.getRewardCoupons());
} else if (userId.equals(shareRecord.getBeInvitedId())) {
giveCoupon(shopShare, tbShopUser, shopShare.getNewCoupons());
}
}
public void giveCoupon(TbShopShare shopShare, TbShopUser tbShopUser, List<TbShopShare.ShareCoupons> coupons) {
for (TbShopShare.ShareCoupons newCoupon : coupons) {
TbShopCoupon tbShopCoupon = couponMapper.queryById(newCoupon.getCouponId());
Date start = new Date();
Date end = new Date();
if ("fixed".equals(tbShopCoupon.getValidityType())) {
//固定时间
end = DateUtil.offsetDay(new Date(), tbShopCoupon.getValidDays());
} else if ("custom".equals(tbShopCoupon.getValidityType())) {
//自定义时间
start = tbShopCoupon.getValidStartTime();
end = tbShopCoupon.getValidEndTime();
}
if (tbShopCoupon != null) {
List<TbActivateInRecord> actGiveRecords = new ArrayList<>();
if (tbShopCoupon.getType() == 1) {
//满减
TbActivateInRecord record = new TbActivateInRecord();
record.setVipUserId(Integer.valueOf(tbShopUser.getId()));
record.setCouponId(tbShopCoupon.getId());
record.setName("" + tbShopCoupon.getFullAmount() + "" + tbShopCoupon.getDiscountAmount());
record.setFullAmount(tbShopCoupon.getFullAmount());
record.setDiscountAmount(tbShopCoupon.getDiscountAmount());
record.setType(1);
record.setNum(newCoupon.getCouponNum());
record.setOverNum(newCoupon.getCouponNum());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setSourceActId(shopShare.getId());
record.setUseStartTime(start);
record.setUseEndTime(end);
record.setSource("invited");
actGiveRecords.add(record);
} else if (tbShopCoupon.getType() == 2) {
//商品卷
List<TbCouponProduct> tbCouponProducts = couProductMapper.queryAllByCouponId(tbShopCoupon.getId());
for (TbCouponProduct actPro : tbCouponProducts) {
TbActivateInRecord record = new TbActivateInRecord();
record.setVipUserId(Integer.valueOf(tbShopUser.getId()));
record.setCouponId(tbShopCoupon.getId());
record.setName("商品卷");
record.setType(2);
record.setProId(actPro.getProductId());
record.setNum(actPro.getNum() * tbShopCoupon.getNumber());
record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setSourceActId(shopShare.getId());
record.setUseStartTime(start);
record.setUseEndTime(end);
record.setSource("invited");
actGiveRecords.add(record);
}
}
activateInRecordMapper.insertBatch(actGiveRecords);
}
}
}
}

View File

@@ -0,0 +1,104 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.chaozhanggui.system.cashierservice.dao.TbCouponProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopCouponMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopShareMapper;
import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon;
import com.chaozhanggui.system.cashierservice.entity.TbShopShare;
import com.chaozhanggui.system.cashierservice.service.TbShopShareService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.format.DateTimeFormatter;
/**
* 店铺分享(TbShopShare)表服务实现类
*
* @author ww
* @since 2024-11-07 14:36:27
*/
@Primary
@Service
public class TbShopShareServiceImpl implements TbShopShareService {
@Autowired
private TbShopShareMapper tbShopShareMapper;
@Autowired
private TbShopCouponMapper couponMapper;
@Autowired
private TbCouponProductMapper couProductMapper;
@Override
public TbShopShare queryByShopId(Integer shopId) {
TbShopShare tbShopShare = tbShopShareMapper.queryByShopId(shopId);
if (tbShopShare != null) {
if (CollectionUtil.isNotEmpty(tbShopShare.getNewCoupons())) {
for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) {
TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId());
if (coupon != null) {
if (coupon.getType() == 1) {
//满减
newCoupon.setType(1);
newCoupon.setFullAmount(coupon.getFullAmount());
newCoupon.setDiscountAmount(coupon.getDiscountAmount());
newCoupon.setUseDetail(setCouponInfo(coupon));
} else if (coupon.getType() == 2) {
//商品
newCoupon.setType(2);
newCoupon.setUseDetail(setCouponInfo(coupon));
newCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), newCoupon.getCouponNum()));
}
}
}
}
if (CollectionUtil.isNotEmpty(tbShopShare.getRewardCoupons())) {
for (TbShopShare.ShareCoupons rewardCoupon : tbShopShare.getRewardCoupons()) {
TbShopCoupon coupon = couponMapper.queryById(rewardCoupon.getCouponId());
if (coupon != null) {
if (coupon.getType() == 1) {
//满减
rewardCoupon.setType(1);
rewardCoupon.setFullAmount(coupon.getFullAmount());
rewardCoupon.setDiscountAmount(coupon.getDiscountAmount());
rewardCoupon.setUseDetail(setCouponInfo(coupon));
} else if (coupon.getType() == 2) {
//商品
rewardCoupon.setType(2);
rewardCoupon.setUseDetail(setCouponInfo(coupon));
rewardCoupon.setGives(couProductMapper.queryProsByActivateId(coupon.getId(), rewardCoupon.getCouponNum()));
}
}
}
}
}
return tbShopShare;
}
private String setCouponInfo(TbShopCoupon tbShopCoupon) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
StringBuilder useRestrictions = new StringBuilder("每天 ");
if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) {
String[] split = tbShopCoupon.getUserDays().split(",");
if (split.length != 7) {
useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " ");
}
}
if (StringUtils.isNotBlank(tbShopCoupon.getUseTimeType()) && tbShopCoupon.getUseTimeType().equals("custom")) {
useRestrictions.append(
tbShopCoupon.getUseStartTime().format(formatter)
+ "-"
+ tbShopCoupon.getUseEndTime().format(formatter));
} else {
useRestrictions.append("全时段");
}
useRestrictions.append(" 可用");
return useRestrictions.toString();
}
}

View File

@@ -57,15 +57,16 @@ public class ShopUtils {
boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout; boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout;
boolean hasTable = StrUtil.isNotBlank(tableId); boolean hasTable = StrUtil.isNotBlank(tableId);
boolean isNoneTable = !hasTable && !isTakeout; boolean isNoneTable = !hasTable && !isTakeout;
boolean isOpenMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1;
boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0; boolean needSeatFee = !isTakeout && (shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0);
boolean isIncrMasterId = isTakeout || isNoneTable; boolean isIncrMasterId = isTakeout || isNoneTable;
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() : 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); isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, isOpenMemberPrice, tableId);
} }
public ShopEatTypeInfoDTO getEatModel(String tableId, Object shopId) { public ShopEatTypeInfoDTO getEatModel(String tableId, Object shopId) {
@@ -95,8 +96,10 @@ public class ShopUtils {
boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue()); boolean isOpenDineIn = shopInfo.getEatModel().contains(ShopInfoEatModelEnum.DINE_IN.getValue());
boolean isDineInAfter = isOpenDineIn && !isMunchies && !isTakeout; boolean isDineInAfter = isOpenDineIn && !isMunchies && !isTakeout;
boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout; boolean isDineInBefore = isOpenDineIn && isMunchies && !isTakeout;
boolean isOpenMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1;
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() : 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); isDineInBefore ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : isDineInAfter ? OrderUseTypeEnum.DINE_IN_AFTER.getValue() : null, isOpenTakeout, isOpenDineIn, isOpenMemberPrice,tableId);
} }
} }

View File

@@ -21,10 +21,11 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="couponJson" column="coupon_json" jdbcType="VARCHAR"/> <result property="couponJson" column="coupon_json" jdbcType="VARCHAR"/>
<result property="source" column="source" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json </sql> id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json,source </sql>
<!--查询单个--> <!--查询单个-->
<select id="queryById" resultMap="TbActivateInRecordMap"> <select id="queryById" resultMap="TbActivateInRecordMap">
@@ -173,15 +174,15 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
<!--新增所有列--> <!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true"> <insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json) insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json,source)
values (#{vipUserId}, #{couponId}, #{name}, #{type}, #{proId}, #{fullAmount}, #{discountAmount}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{useStartTime}, #{useEndTime}, #{createTime}, #{updateTime}, #{couponJson}) values (#{vipUserId}, #{couponId}, #{name}, #{type}, #{proId}, #{fullAmount}, #{discountAmount}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{useStartTime}, #{useEndTime}, #{createTime}, #{updateTime}, #{couponJson} , #{source})
</insert> </insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json) insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json, source)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
(#{entity.vipUserId}, #{entity.couponId}, #{entity.name}, #{entity.type}, #{entity.proId}, #{entity.fullAmount}, #{entity.discountAmount}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.useStartTime}, #{entity.useEndTime}, #{entity.createTime}, #{entity.updateTime}, #{entity.couponJson}) (#{entity.vipUserId}, #{entity.couponId}, #{entity.name}, #{entity.type}, #{entity.proId}, #{entity.fullAmount}, #{entity.discountAmount}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.useStartTime}, #{entity.useEndTime}, #{entity.createTime}, #{entity.updateTime}, #{entity.couponJson}, #{entity.source})
</foreach> </foreach>
</insert> </insert>

View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopShareMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbShopShare" id="TbShopShareMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="shareImg" column="share_img" jdbcType="VARCHAR"/>
<result property="invitedImg" column="invited_img" jdbcType="VARCHAR"/>
<result property="beInvitedImg" column="be_invited_img" jdbcType="VARCHAR"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="newCoupon" column="new_coupon" jdbcType="VARCHAR"/>
<result property="invitedNum" column="invited_num" jdbcType="INTEGER"/>
<result property="rewardCoupon" column="reward_coupon" jdbcType="VARCHAR"/>
<result property="getMethod" column="get_method" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id
, shop_id, title, share_img, invited_img, be_invited_img, start_time, end_time, new_coupon, invited_num, reward_coupon, get_method, status </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbShopShareMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share
where id = #{id}
</select>
<select id="queryByShopId" resultMap="TbShopShareMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share
where shop_id = #{shopId}
and status = 1
AND now() &gt; start_time
AND now() &lt; end_time
</select>
<!--查询指定行数据-->
<select id="queryAll" resultMap="TbShopShareMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="shopId != null">
and shop_id = #{shopId}
</if>
<if test="title != null and title != ''">
and title = #{title}
</if>
<if test="shareImg != null and shareImg != ''">
and share_img = #{shareImg}
</if>
<if test="invitedImg != null and invitedImg != ''">
and invited_img = #{invitedImg}
</if>
<if test="beInvitedImg != null and beInvitedImg != ''">
and be_invited_img = #{beInvitedImg}
</if>
<if test="startTime != null">
and start_time = #{startTime}
</if>
<if test="endTime != null">
and end_time = #{endTime}
</if>
<if test="newCoupon != null and newCoupon != ''">
and new_coupon = #{newCoupon}
</if>
<if test="invitedNum != null">
and invited_num = #{invitedNum}
</if>
<if test="rewardCoupon != null and rewardCoupon != ''">
and reward_coupon = #{rewardCoupon}
</if>
<if test="getMethod != null and getMethod != ''">
and get_method = #{getMethod}
</if>
<if test="status != null">
and status = #{status}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_shop_share(shop_id, title, share_img, invited_img, be_invited_img, start_time, end_time,
new_coupon, invited_num, reward_coupon, get_method, status)
values (#{shopId}, #{title}, #{shareImg}, #{invitedImg}, #{beInvitedImg}, #{startTime}, #{endTime},
#{newCoupon}, #{invitedNum}, #{rewardCoupon}, #{getMethod}, #{status})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_shop_share(shop_id, title, share_img, invited_img, be_invited_img, start_time, end_time,
new_coupon, invited_num, reward_coupon, get_method, status)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.shopId}, #{entity.title}, #{entity.shareImg}, #{entity.invitedImg}, #{entity.beInvitedImg},
#{entity.startTime}, #{entity.endTime}, #{entity.newCoupon}, #{entity.invitedNum}, #{entity.rewardCoupon},
#{entity.getMethod}, #{entity.status})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_shop_share
<set>
<if test="shopId != null">
shop_id = #{shopId},
</if>
<if test="title != null and title != ''">
title = #{title},
</if>
<if test="shareImg != null and shareImg != ''">
share_img = #{shareImg},
</if>
<if test="invitedImg != null and invitedImg != ''">
invited_img = #{invitedImg},
</if>
<if test="beInvitedImg != null and beInvitedImg != ''">
be_invited_img = #{beInvitedImg},
</if>
<if test="startTime != null">
start_time = #{startTime},
</if>
<if test="endTime != null">
end_time = #{endTime},
</if>
<if test="newCoupon != null and newCoupon != ''">
new_coupon = #{newCoupon},
</if>
<if test="invitedNum != null">
invited_num = #{invitedNum},
</if>
<if test="rewardCoupon != null and rewardCoupon != ''">
reward_coupon = #{rewardCoupon},
</if>
<if test="getMethod != null and getMethod != ''">
get_method = #{getMethod},
</if>
<if test="status != null">
status = #{status},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tb_shop_share
where id = #{id}
</delete>
</mapper>

View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbShopShareRecordMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord" id="TbShopShareRecordMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="shareId" column="share_id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="invitedId" column="invited_id" jdbcType="INTEGER"/>
<result property="invitedName" column="invited_name" jdbcType="VARCHAR"/>
<result property="beInvitedId" column="be_invited_id" jdbcType="INTEGER"/>
<result property="method" column="method" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="rewardTime" column="reward_time" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
, share_id, shop_id, invited_id, invited_name, be_invited_id, method, status, reward_time, create_time, update_time </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where id = #{id}
</select>
<select id="queryByData" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where share_id = #{shareId}
and shop_id = #{shopId}
and invited_id = #{invitedId}
and be_invited_id = #{beInvitedId}
</select>
<select id="queryByDataByBeInvited" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where share_id = #{shareId}
and shop_id = #{shopId}
and be_invited_id = #{beInvitedId}
</select>
<select id="query" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="shareId != null">
and share_id = #{shareId}
</if>
<if test="shopId != null">
and shop_id = #{shopId}
</if>
<if test="invitedId != null">
and invited_id = #{invitedId}
</if>
<if test="invitedName != null and invitedName != ''">
and invited_name = #{invitedName}
</if>
<if test="beInvitedId != null">
and be_invited_id = #{beInvitedId}
</if>
<if test="method != null and method != ''">
and method = #{method}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="rewardTime != null">
and reward_time = #{rewardTime}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_shop_share_record(share_id, shop_id, invited_id, invited_name, be_invited_id, method, status,
reward_time, create_time, update_time)
values (#{shareId}, #{shopId}, #{invitedId}, #{invitedName}, #{beInvitedId}, #{method}, #{status},
#{rewardTime}, #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_shop_share_record(share_id, shop_id, invited_id, invited_name, be_invited_id, method, status,
reward_time, create_time, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.shareId}, #{entity.shopId}, #{entity.invitedId}, #{entity.invitedName}, #{entity.beInvitedId},
#{entity.method}, #{entity.status}, #{entity.rewardTime}, #{entity.createTime}, #{entity.updateTime})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_shop_share_record
<set>
<if test="shareId != null">
share_id = #{shareId},
</if>
<if test="shopId != null">
shop_id = #{shopId},
</if>
<if test="invitedId != null">
invited_id = #{invitedId},
</if>
<if test="invitedName != null and invitedName != ''">
invited_name = #{invitedName},
</if>
<if test="beInvitedId != null">
be_invited_id = #{beInvitedId},
</if>
<if test="method != null and method != ''">
method = #{method},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="rewardTime != null">
reward_time = #{rewardTime},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tb_shop_share_record
where id = #{id}
</delete>
</mapper>

View File

@@ -67,6 +67,14 @@
from tb_user_info from tb_user_info
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
<select id="selectNameByPrimaryKey" parameterType="java.lang.Integer" resultType="string">
select
nick_name
from tb_user_info
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_user_info delete from tb_user_info
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}