Compare commits

19 Commits

Author SHA1 Message Date
gong
5ee4c22001 预结算单金额2 2026-03-28 16:42:32 +08:00
gong
73186ac88f 预结算单金额2 2026-03-28 16:40:55 +08:00
gong
7b094ce8c1 预结算单金额 2026-03-28 16:35:52 +08:00
gong
60b961c5c1 台桌订单金额查询 2026-03-28 16:06:15 +08:00
gong
782644cf10 打印问题3 2026-03-28 15:34:20 +08:00
gong
c1c49289d6 打印问题2 2026-03-28 15:28:05 +08:00
gong
e4174b41fc 打印问题 2026-03-28 15:21:46 +08:00
gong
250cd58996 忽略不存在字段 2026-03-28 14:41:39 +08:00
gong
f9ac4b3e22 config info 2026-03-28 14:25:23 +08:00
gong
7d6086311a 台桌添加订单字段 2026-03-28 14:09:34 +08:00
gong
1ae849d24c 台桌添加订单字段 2026-03-28 14:06:18 +08:00
gong
a67354343c 是否允许用户支付 2026-03-28 14:01:28 +08:00
gong
f4a850a4cb 修改计算优惠金额5 2026-03-28 13:42:12 +08:00
gong
37a4af8071 修改计算优惠金额4 2026-03-28 13:38:06 +08:00
gong
35e35e5668 修改计算优惠金额4 2026-03-28 13:35:31 +08:00
gong
0559412985 修改计算优惠金额3 2026-03-28 13:29:32 +08:00
gong
3380003a86 修改计算优惠金额2 2026-03-28 12:23:02 +08:00
gong
8b256623c2 修改计算优惠金额 2026-03-28 11:45:37 +08:00
gong
c6c88358c5 添加测试日志 2026-03-28 10:56:20 +08:00
11 changed files with 134 additions and 24 deletions

View File

@@ -69,6 +69,10 @@ public class ShopConfigDTO implements Serializable {
* 是否允许会员余额支付 1-是 0-否
*/
private Integer isAccountPay;
/**
* 是否允许用户支付
*/
private Integer isUserPay;
/**
* 分店数据同步方式 auto-自动同步 manual-手动同步
*/

View File

@@ -54,6 +54,10 @@ public class ShopInfoEditDTO {
* 是否开启会员余额支付
*/
private Integer isAccountPay;
/**
* 是否允许用户支付
*/
private Integer isUserPay;
/**
* 是否启用满减活动 1-是 0-否
*/

View File

@@ -88,6 +88,10 @@ public class ShopConfig implements Serializable {
* 是否允许会员余额支付 1-是 0-否
*/
private Integer isAccountPay;
/**
* 是否允许用户支付
*/
private Integer isUserPay;
/**
* 分店数据同步方式 auto-自动同步 manual-手动同步
*/

View File

@@ -312,6 +312,11 @@ public class ShopInfo implements Serializable {
*/
@Column(ignore = true)
private Integer isAccountPay;
/**
* 是否允许用户支付
*/
@Column(ignore = true)
private Integer isUserPay;
/**
* 主店名称
*/

View File

@@ -57,6 +57,12 @@ public class ShopTable implements Serializable {
*/
private Integer areaId;
/**
* 区域名称
*/
@Column(ignore = true)
private String areaName;
/**
* 是否接受网络预定
*/

View File

@@ -8,6 +8,7 @@ import lombok.*;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 台桌配置 实体类。
@@ -20,4 +21,16 @@ import java.math.BigDecimal;
public class ShopTableVO extends ShopTable {
private Long orderId;
private Long userId;
/**
* 订单金额
*/
private BigDecimal orderAmount;
/**
* 人数
*/
private Integer personNum;
/**
* 订单创建时间
*/
private Date orderCreateTime;
}

View File

@@ -5,11 +5,25 @@
<mapper namespace="com.czg.service.account.mapper.ShopTableMapper">
<select id="pageInfo" resultType="com.czg.account.vo.ShopTableVO">
select a.*, b.id orderId, b.user_id
select
a.*,
MAX(b.id) as orderId,
MAX(b.user_id) as user_id,
-- 核心:真实金额 = 支付总额 - 退款总额
IFNULL(SUM(d.pay_amount), 0) - IFNULL(SUM(d.return_amount), 0) as orderAmount,
MAX(b.seat_num) as personNum,
MAX(b.create_time) as orderCreateTime,
MAX(ar.name) as areaName
from tb_shop_table as a
left join tb_order_info as b
on a.table_code = b.table_code and b.`status` = 'unpaid' and b.table_code != '' and
b.table_code is not null
on a.table_code = b.table_code
and b.`status` = 'unpaid'
and b.table_code != ''
and b.table_code is not null
left join tb_order_detail as d
on b.id = d.order_id
left join tb_shop_table_area as ar
on a.area_id = ar.id
where a.shop_id=#{shopId}
<if test="areaId != null">
and a.area_id=#{areaId}
@@ -28,6 +42,5 @@
</if>
group by a.id
ORDER BY a.area_id,a.id
</select>
</mapper>

View File

@@ -4,7 +4,9 @@ import com.czg.order.vo.OrderDetailPrintVo;
import com.mybatisflex.core.BaseMapper;
import com.czg.order.entity.OrderDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -18,4 +20,10 @@ public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
List<OrderDetailPrintVo> getOrderDetailPrint(Long orderId);
@Update("UPDATE tb_order_detail SET status = #{status}, order_time = #{orderTime} " +
"WHERE order_id = #{orderId} AND status = 'wait-pay'")
int updateStatusByOrderId(@Param("orderId") Long orderId,
@Param("status") String status,
@Param("orderTime") LocalDateTime orderTime);
}

View File

@@ -95,12 +95,24 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName())
.setPrintType("普通打印").setPickupNum(getPickupNum(orderInfo))
.setOrderNo(orderInfo.getOrderNo()).setTradeDate(DateUtil.format(orderInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss")).setOperator("【POS-1】001").setPayAmount(orderInfo.getPayAmount().toPlainString())
.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())).toPlainString()).setReturn(isReturn(orderInfo))
.setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0")
.setOutNumber(orderInfo.getTakeCode()).setPrintTitle("结算单")
.setOrderNo(orderInfo.getOrderNo())
.setTradeDate(DateUtil.format(orderInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"))
.setOperator("【POS-1】001").setPayAmount(orderInfo.getPayAmount().toPlainString())
.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())).toPlainString())
.setReturn(isReturn(orderInfo))
.setBalance(balance)
.setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()))
.setIntegral("0")
.setOutNumber(orderInfo.getTakeCode())
.setPrintTitle("结算单")
.setRemark(orderInfo.getRemark())
.setDiscountAmount(orderInfo.getOriginAmount().subtract(orderInfo.getPayAmount()).toPlainString());
// 使用累计的总优惠金额,如果为 null 则用原价减去实付计算
.setDiscountAmount(calculateDiscountAmount(orderInfo));
if (orderInfo.getPayAmount() != null && orderInfo.getPayAmount().compareTo(BigDecimal.ZERO) == 0) {
// 设置支付金额为 订单原价-订单优惠金额
printInfoDTO.setPayAmount((new BigDecimal(printInfoDTO.getOriginalAmount()).subtract(new BigDecimal(printInfoDTO.getDiscountAmount()))).toPlainString());
}
String string = buildOrderPrintData(printInfoDTO, detailList);
String o = sendPrintRequest(machine.getAddress(), string, null, printerNum);
printMachineLogService.save(orderInfo.getId(), machine, "结算单", string, o);
@@ -119,7 +131,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
if (StrUtil.isNotBlank(machine.getPrintQty())) {
printerNum = machine.getPrintQty().split("\\^")[1];
}
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName())
.setCount(count)
.setPrintType("普通打印").setPickupNum(getPickupNum(orderInfo))
@@ -128,7 +140,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
.setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0")
.setOutNumber(orderInfo.getTakeCode()).setPrintTitle("结算单")
.setRemark(orderInfo.getRemark())
.setDiscountAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()).subtract(orderInfo.getPayAmount())).toPlainString());
// 使用累计的总优惠金额,如果为 null 则用原价减去实付计算
.setDiscountAmount(calculateDiscountAmount(orderInfo));
printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle());
if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) {
printInfoDTO.setSeatNum(orderInfo.getSeatNum().toString());
@@ -241,7 +254,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
//成功 开机 {"msg":"ok","ret":0,"data":"在线,工作状态正常。","serverExecutedTime":4}
//成功 离线 {"msg":"ok","ret":0,"data":"离线。","serverExecutedTime":7}
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
log.info("飞鹅打印机状态响应: {}", json);
log.info("飞鹅打印机状态响应{}", json);
msg = json.getStr("data");
} catch (Exception e) {
msg = "未知错误";
@@ -249,4 +262,19 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
return msg;
}
/**
* 计算优惠金额:优先使用 discountAllAmount如果为 null 则用原价 - 实付计算
*/
private String calculateDiscountAmount(OrderInfo orderInfo) {
if (orderInfo.getDiscountAllAmount() != null) {
return orderInfo.getDiscountAllAmount().toPlainString();
}
// 兜底计算:原价 + 餐位费 + 打包费 - 实付
BigDecimal originalTotal = orderInfo.getOriginAmount()
.add(orderInfo.getSeatAmount() != null ? orderInfo.getSeatAmount() : BigDecimal.ZERO)
.add(orderInfo.getPackFee() != null ? orderInfo.getPackFee() : BigDecimal.ZERO);
BigDecimal discount = originalTotal.subtract(orderInfo.getPayAmount());
return discount.compareTo(BigDecimal.ZERO) >= 0 ? discount.toPlainString() : "0.00";
}
}

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.PrintMachine;
import com.czg.account.entity.ShopInfo;
@@ -131,7 +132,11 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
.setOriginalAmount(orderInfo.getOriginAmount().toPlainString()).setReturn(isReturn(orderInfo))
.setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0")
.setOutNumber(orderInfo.getTakeCode()).setPrintTitle("退款单")
.setRemark(orderInfo.getRemark()).setDiscountAmount(orderInfo.getOriginAmount().subtract(orderInfo.getPayAmount()).toPlainString());
.setRemark(orderInfo.getRemark())
// 使用累计的总优惠金额null 表示没有优惠
.setDiscountAmount(orderInfo.getDiscountAllAmount() != null
? orderInfo.getDiscountAllAmount().toPlainString()
: "0.00");
String data = buildOrderPrintData(printInfoDTO, detailList);
String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
@@ -151,16 +156,33 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
.eq(OrderInfo::getShopId, orderInfo.getShopId())
.le(OrderInfo::getCreateTime, orderInfo.getCreateTime()));
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName())
.setPrintType("普通打印").setPickupNum(getPickupNum(orderInfo))
.setOrderNo(orderInfo.getOrderNo()).setTradeDate(DateUtil.format(orderInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"))
.setOperator("【POS-1】001").setPayAmount(orderInfo.getPayAmount().toPlainString())
.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())).toPlainString()).setReturn(isReturn(orderInfo))
.setReturn(isReturn(orderInfo))
.setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0")
.setOutNumber(orderInfo.getTakeCode()).setPrintTitle(isPre ? "预结算单" : "结算单")
.setOutNumber(orderInfo.getTakeCode())
.setPrintTitle(isPre ? "预结算单" : "结算单")
.setCount(count)
.setRemark(orderInfo.getRemark())
.setDiscountAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()).subtract(orderInfo.getPayAmount())).toPlainString());
// 使用累计的总优惠金额null 表示没有优惠
.setDiscountAmount(orderInfo.getDiscountAllAmount() != null
? orderInfo.getDiscountAllAmount().toPlainString()
: "0.00");
printInfoDTO.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())).toPlainString());
if (isPre) {
if (orderInfo.getPlaceNum() == 1) {
BigDecimal refundAmount = BigDecimal.ZERO;
for (OrderDetail orderDetail : detailList) {
refundAmount = refundAmount.add(orderDetail.getReturnAmount());
}
printInfoDTO.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()).subtract(refundAmount)).toPlainString());
}
printInfoDTO.setPayAmount(printInfoDTO.getOriginalAmount());
}
printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle());
if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) {
printInfoDTO.setSeatNum(orderInfo.getSeatNum().toString());
@@ -171,6 +193,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
}
String data = buildOrderPrintData(printInfoDTO, detailList);
String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
String printerNum = "1";
if (StrUtil.isNotBlank(machine.getPrintQty())) {
@@ -254,4 +277,13 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
return s;
}
/**
* 计算优惠金额:优先使用 discountAllAmount如果为 null 则返回 0
*/
private String calculateDiscountAmount(OrderInfo orderInfo) {
return orderInfo.getDiscountAllAmount() != null
? orderInfo.getDiscountAllAmount().toPlainString()
: "0.00";
}
}

View File

@@ -35,13 +35,6 @@ public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, Order
@Override
public void updateOrderDetailStatus(Long orderId,String status) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setStatus(status);
orderDetail.setOrderTime(LocalDateTime.now());
update(orderDetail, QueryWrapper.create()
.eq(OrderDetail::getOrderId,orderId)
.eq(OrderDetail::getStatus,"wait-pay")
);
getMapper().updateStatusByOrderId(orderId, status, LocalDateTime.now());
}
}