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

This commit is contained in:
Tankaikai 2024-10-29 16:05:54 +08:00
commit fd87a1f2e3
9 changed files with 301 additions and 7 deletions

View File

@ -1,6 +1,163 @@
package com.chaozhanggui.system.cashierservice.bean.constant;
import lombok.Getter;
import java.util.Objects;
public interface TableConstant {
String CART_SEAT_ID = "-999";
@Getter
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);
}
}
class ShopTable {
@Getter
public enum State {
IDLE("idle"), CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using"), CLEANING("cleaning");
private final String value;
State(String value) {
this.value = value;
}
}
}
class OrderInfo {
@Getter
public enum Status {
REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"),
UNPAID("unpaid"), PAYING("paying"), RETURN("return");
private final String value;
Status(String value) {
this.value = value;
}
}
@Getter
public enum UseType {
TAKEOUT("takeout"),
DINE_IN_AFTER("dine-in-after"),
DINE_IN_BEFORE("dine-in-before");
private final String value;
UseType(String value) {
this.value = value;
}
public boolean equalsVals(String value) {
return this.value.equals(value);
}
}
}
class CashierCart {
@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 ShopInfo {
@Getter
public enum EatModel {
TAKEOUT("takeout"),
DINE_IN("dine-in");
private final String value;
EatModel(String value) {
this.value = value;
}
public boolean equalsVals(String value) {
return this.value.equals(value);
}
}
}
class MemberIn {
@Getter
public enum Type {
NORMAL(0),
FREE_DINE(1);
private final Integer value;
Type(Integer value) {
this.value = value;
}
public boolean equalsVals(Integer value) {
return Objects.equals(this.value, value);
}
}
}
class ActivateOutRecord {
@Getter
public enum Type {
// 满减
FULL_REDUCTION(1),
// 商品
PRODUCT(2);
private final Integer value;
Type(Integer value) {
this.value = value;
}
public boolean equalsVals(Integer value) {
return Objects.equals(this.value, value);
}
}
@Getter
public enum Status {
CREATE("create"),
CANCEL("cancel"),
// 商品
CLOSED("closed");
private final String value;
Status(String value) {
this.value = value;
}
public boolean equalsVals(String value) {
return this.value.equals(value);
}
}
}
}

View File

@ -1,9 +1,12 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import java.util.List;
/**
* (TbShopPermission)表服务接口
*
@ -12,5 +15,12 @@ import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
*/
public interface MpCashierCartService extends IService<TbCashierCart> {
/**
* 根据id修改状态
* @param cartIds id
* @param status 状态
* @return 是否成功
*/
boolean updateStateByIds(Integer shopId, List<Integer> cartIds, TableConstant.Status status);
}

View File

@ -1,10 +1,13 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
import com.chaozhanggui.system.cashierservice.sign.Result;
import java.util.List;
/**
* (TbShopPermission)表服务接口
*
@ -13,5 +16,13 @@ import com.chaozhanggui.system.cashierservice.sign.Result;
*/
public interface MpOrderDetailService extends IService<TbOrderDetail> {
/**
* 根据购物车id修改详情状态
* @param shopId 店铺id
* @param cartIds 购物车id
* @param status 状态
* @return 是否成功
*/
boolean updateStateByCartIds(Integer shopId, List<Integer> cartIds, TableConstant.Status status);
}

View File

@ -0,0 +1,27 @@
package com.chaozhanggui.system.cashierservice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import java.util.List;
/**
* (TbShopPermission)表服务接口
*
* @author makejava
* @since 2024-09-14 17:08:48
*/
public interface MpOrderInfoService extends IService<TbOrderInfo> {
/**
* 根据id修改详情状态
* @param shopId 店铺id
* @param orderId 订单id
* @param status 状态
* @return 是否成功
*/
boolean updateStateById(Integer shopId, Integer orderId, TableConstant.Status status);
}

View File

@ -95,6 +95,7 @@ public class OrderService {
private final TbShopOpenIdMapper shopOpenIdMapper;
private final MpShopTableMapper mpShopTableMapper;
private final MpOrderInfoService mpOrderInfoService;
@Autowired
TbConsInfoMapper tbConsInfoMapper;
@ -131,12 +132,13 @@ public class OrderService {
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper,
TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper,
TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, MpOrderInfoService mpOrderInfoService,
TbCashierCartMapper tbCashierCartMapper, MpCashierCartService mpCashierCartService) {
this.wxAccountUtil = wxAccountUtil;
this.mpCashierCartMapper = mpCashierCartMapper;
this.shopOpenIdMapper = shopOpenIdMapper;
this.mpShopTableMapper = mpShopTableMapper;
this.mpOrderInfoService = mpOrderInfoService;
this.tbCashierCartMapper = tbCashierCartMapper;
this.mpCashierCartService = mpCashierCartService;
}
@ -498,12 +500,44 @@ public class OrderService {
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
AtomicReference<TbCashierCart> mealCashierCart = new AtomicReference<>();
list.forEach(item -> {
item.setPlaceNum(item.getPlaceNum() == null ? 0 : item.getPlaceNum());
if (item.getProductId().equals("-999")) {
mealCashierCart.set(item);
ArrayList<TbCashierCart> returnCashierCarts = new ArrayList<>();
String orderId = null;
for (TbCashierCart cart : list) {
if (cart.getOrderId() != null) {
orderId = cart.getOrderId();
}
});
if (TableConstant.CashierCart.Status.RETURN.equalsVals(cart.getStatus())) {
returnCashierCarts.add(cart);
}
cart.setPlaceNum(cart.getPlaceNum() == null ? 0 : cart.getPlaceNum());
if (cart.getProductId().equals("-999")) {
mealCashierCart.set(cart);
}
}
// 检查购物车商品是否已经全部退款
if (!returnCashierCarts.isEmpty() && returnCashierCarts.size() == list.size()) {
List<Integer> cartIds = returnCashierCarts.stream().map(TbCashierCart::getId).collect(Collectors.toList());
mpCashierCartService.updateStateByIds(Integer.valueOf(shopId), cartIds, TableConstant.Status.CANCEL);
mpOrderDetailService.updateStateByCartIds(Integer.valueOf(shopId), cartIds, TableConstant.Status.CANCEL);
if (StrUtil.isNotBlank(orderId)) {
mpOrderInfoService.updateStateById(Integer.valueOf(shopId), Integer.valueOf(orderId), TableConstant.Status.CANCEL);
}
String finalMasterId = masterId;
return Result.success(CodeEnum.SUCCESS, new HashMap<String, Object>(){{
put("list", new ArrayList<>());
put("masterId", finalMasterId);
put("num", 0);
put("seatFee", null);
put("amount", new HashMap<String, Object>(){{
put("packAmount", 0);
put("productNum", 0);
put("productSum", 0);
put("totalAmount", 0);
}});
}});
}
// 根据placeNum进行分组
Map<Integer, List<TbCashierCart>> groupedByPlaceNum = list.stream()

View File

@ -1,6 +1,8 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
@ -9,6 +11,8 @@ import com.chaozhanggui.system.cashierservice.service.MpCashierCartService;
import com.chaozhanggui.system.cashierservice.service.MpOrderDetailService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (TbShopPermission)表服务实现类
*
@ -18,5 +22,12 @@ import org.springframework.stereotype.Service;
@Service
public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, TbCashierCart> implements MpCashierCartService {
@Override
public boolean updateStateByIds(Integer shopId, List<Integer> cartIds, TableConstant.Status status) {
return update(new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.in(TbCashierCart::getId, cartIds)
.set(TbCashierCart::getStatus, status.getValue()));
}
}

View File

@ -1,7 +1,9 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopPermissionDao;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
@ -17,6 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (TbShopPermission)表服务实现类
*
@ -26,5 +30,12 @@ import org.springframework.stereotype.Service;
@Service
public class MpOrderDetailServiceImpl extends ServiceImpl<MPOrderDetailMapper, TbOrderDetail> implements MpOrderDetailService {
@Override
public boolean updateStateByCartIds(Integer shopId, List<Integer> cartIds, TableConstant.Status status) {
return update(new LambdaUpdateWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getShopId, shopId)
.in(TbOrderDetail::getCartId, cartIds)
.set(TbOrderDetail::getStatus, status));
}
}

View File

@ -0,0 +1,33 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.service.MpOrderDetailService;
import com.chaozhanggui.system.cashierservice.service.MpOrderInfoService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (TbShopPermission)表服务实现类
*
* @author makejava
* @since 2024-09-14 17:08:49
*/
@Service
public class MpOrderInfoServiceImpl extends ServiceImpl<MPOrderInfoMapper, TbOrderInfo> implements MpOrderInfoService {
@Override
public boolean updateStateById(Integer shopId, Integer orderId, TableConstant.Status status) {
return update(new LambdaUpdateWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getShopId, shopId)
.eq(TbOrderInfo::getId, orderId)
.set(TbOrderInfo::getStatus, status));
}
}

View File

@ -256,8 +256,8 @@ public class FeieyunPrintUtil {
data.append(StrUtil.format("<B>应收:{}</B><BR>", t));
}
if (ObjectUtil.isNotEmpty(detailPO.getPayType()) && ObjectUtil.isNotNull(detailPO.getPayType()) && detailPO.getPayType().equals("deposit")) {
data.append("--------------------------------<BR>");
data.append(StrUtil.format("储值:{}<BR>", detailPO.getReceiptsAmount()));
data.append("--------------------------------<BR>");
data.append(StrUtil.format("积分:{}<BR>", detailPO.getIntegral()));
}
data.append(StrUtil.format("余额:{}<BR>", detailPO.getBalance()));