Merge branch 'prod'
This commit is contained in:
commit
94669c4ab0
|
|
@ -12,6 +12,7 @@ import com.czg.order.vo.OrderInfoVo;
|
|||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -100,4 +101,17 @@ public class AdminOrderController {
|
|||
public CzgResult<Boolean> printOrder(@Validated @RequestBody OrderInfoPrintDTO orderInfoPrintDTO) {
|
||||
return CzgResult.success(orderInfoService.printOrder(StpKit.USER.getShopId(), orderInfoPrintDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/cancelOrder")
|
||||
public CzgResult<Void> cancelOrder(@Validated @RequestBody OrderCannelDTO param) {
|
||||
orderInfoService.cancelledOrder(param.getShopId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/rmPlaceOrder")
|
||||
public CzgResult<Void> cancelledPlaceOrder(@Validated @RequestBody OrderCannelDTO param) {
|
||||
AssertUtil.isNull(param.getPlaceNum(), "{}不能为空", "取消单次");
|
||||
orderInfoService.cancelledPlaceOrder(param.getShopId(), param.getOrderId(), param.getPlaceNum());
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.dto.OrderCannelDTO;
|
||||
import com.czg.order.dto.OrderInfoAddDTO;
|
||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
|
|
@ -9,11 +11,13 @@ import com.czg.order.vo.HistoryOrderVo;
|
|||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
|
|
@ -70,10 +74,30 @@ public class UserOrderController {
|
|||
public CzgResult<Void> upOrderIsDel(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "订单Id");
|
||||
OrderInfo orderInfo = orderInfoService.getById(id);
|
||||
AssertUtil.isNull(orderInfo, "删除失败订单不存在");
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
throw new CzgException("待支付订单不可删除");
|
||||
}
|
||||
orderInfoService.updateChain()
|
||||
.set(OrderInfo::getIsDel, 1)
|
||||
.eq(OrderInfo::getId, id)
|
||||
.update();
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/cancelOrder")
|
||||
@Debounce(value = "#param.orderId")
|
||||
public CzgResult<Void> cancelOrder(@Validated @RequestBody OrderCannelDTO param) {
|
||||
orderInfoService.cancelledOrder(param.getShopId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/rmPlaceOrder")
|
||||
@Debounce(value = "#param.orderId")
|
||||
public CzgResult<Void> cancelledPlaceOrder(@Validated @RequestBody OrderCannelDTO param) {
|
||||
AssertUtil.isNull(param.getPlaceNum(), "{}不能为空", "取消单次");
|
||||
orderInfoService.cancelledPlaceOrder(param.getShopId(), param.getOrderId(), param.getPlaceNum());
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class UserInfoAssetsSummaryDTO {
|
|||
/**
|
||||
* 总积分
|
||||
*/
|
||||
private Integer points;
|
||||
private Integer accountPoints;
|
||||
/**
|
||||
* 可使用优惠券数量
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.order.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class OrderCannelDTO {
|
||||
@NotNull(message = "店铺ID不可为空")
|
||||
private Long shopId;
|
||||
@NotNull(message = "订单ID不可为空")
|
||||
private Long orderId;
|
||||
private Integer placeNum;
|
||||
}
|
||||
|
|
@ -58,4 +58,10 @@ public interface OrderInfoService extends IService<OrderInfo> {
|
|||
|
||||
Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO);
|
||||
|
||||
|
||||
Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId);
|
||||
|
||||
Boolean cancelledOrder(Long shopId, Long orderId);
|
||||
|
||||
Boolean cancelledPlaceOrder(Long shopId, Long orderId, Integer placeNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,5 @@ import java.util.Map;
|
|||
@Data
|
||||
public class HistoryOrderPrintVo extends OrderInfo {
|
||||
private Map<String, List<OrderDetailPrintVo>> detailMap;
|
||||
private long orderNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -340,6 +340,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
long count = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0));
|
||||
ShopUserDTO shopUserDTO = BeanUtil.copyProperties(shopUser, ShopUserDTO.class);
|
||||
shopUserDTO.setCouponNum(count);
|
||||
shopUserDTO.setOrderNumber(orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, userId).eq(OrderInfo::getShopId, shopUser.getShopId()).eq(OrderInfo::getStatus, "done")));
|
||||
return shopUserDTO;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
<select id="selectAssetsSummary" resultType="com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO">
|
||||
SELECT
|
||||
IFNULL(SUM(b.amount), 0) AS amount,
|
||||
IFNULL(SUM(b.account_points), 0) AS points,
|
||||
IFNULL(SUM(b.account_points), 0) AS accountPoints,
|
||||
COUNT(DISTINCT c.id) AS couponNum
|
||||
FROM tb_shop_user AS b
|
||||
LEFT JOIN tb_shop_activate_coupon_record AS c
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.czg.account.vo.HandoverProductListVo;
|
|||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.vo.OrderDetailPrintVo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
|
@ -136,4 +137,6 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
|
|||
* @return 售出商品分类统计
|
||||
*/
|
||||
List<HandoverCategoryListVo> getHandoverCategoryList(Long shopId, String loginTime, String handoverTime);
|
||||
|
||||
int decrMoney(@Param("id") Long id, @Param("amount") BigDecimal amount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.czg.account.entity.ShopInfo;
|
|||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
|
@ -51,12 +52,13 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
|||
private final PrintSignLabel printSignLabel = new PrintSignLabel()
|
||||
.setBr("<BR>")
|
||||
.setCut("")
|
||||
.setCenterBold(new String[]{"<CB>", "</CB>"})
|
||||
.setF(new String[]{"<F>", "</F>"})
|
||||
.setL(new String[]{"<L>", "</L>"})
|
||||
.setS(new String[]{"", ""})
|
||||
.setF(new String[]{"<B>", "</B>"})
|
||||
.setQr(new String[]{"<QR>", "</QR>"})
|
||||
.setCenter(new String[]{"<CB>", "</CB>"})
|
||||
.setCenter(new String[]{"<C>", "</C>"})
|
||||
.setBold(new String[]{"<BOLD>", "</BOLD>"});
|
||||
|
||||
@Override
|
||||
|
|
@ -109,6 +111,9 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
|||
@Override
|
||||
protected void normalOrderPrint(OrderInfo orderInfo, boolean isPre, PrintMachine machine, String balance, List<OrderDetail> detailList) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
long count = orderInfoService.queryChain()
|
||||
.eq(OrderInfo::getTradeDay, orderInfo.getTradeDay())
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()).count();
|
||||
String printerNum = "1";
|
||||
if (StrUtil.isNotBlank(machine.getPrintQty())) {
|
||||
printerNum = machine.getPrintQty().split("\\^")[1];
|
||||
|
|
@ -121,6 +126,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(isPre ? "预结算单" : "结算单")
|
||||
.setRemark(orderInfo.getRemark()).setDiscountAmount(orderInfo.getOriginAmount().subtract(orderInfo.getPayAmount()).toPlainString());
|
||||
printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle() + " #" + count);
|
||||
|
||||
String string = buildOrderPrintData(printInfoDTO, detailList);
|
||||
Object resp = sendPrintRequest(machine.getAddress(), string, null, printerNum);
|
||||
printMachineLogService.save(machine, "结算单", string, resp);
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ public abstract class PrinterHandler {
|
|||
private String outNumber;
|
||||
private String discountAmount;
|
||||
private String discountRadio;
|
||||
private String orderNum;
|
||||
// 是否退款单
|
||||
private boolean isReturn;
|
||||
|
||||
|
|
@ -168,10 +169,10 @@ public abstract class PrinterHandler {
|
|||
wrapper.like(PrintMachine::getPrintType, printType);
|
||||
}
|
||||
List<PrintMachine> list = printMachineService.list(wrapper);
|
||||
for (PrintMachine item : list) {
|
||||
//实际打印以传递的参数为准
|
||||
item.setPrintMethod(printMethod);
|
||||
}
|
||||
// for (PrintMachine item : list) {
|
||||
// //实际打印以传递的参数为准
|
||||
// item.setPrintMethod(printMethod);
|
||||
// }
|
||||
if (list.isEmpty()) {
|
||||
log.error("店铺未配置打印机,店铺id: {}", shopId);
|
||||
return list;
|
||||
|
|
@ -287,7 +288,7 @@ public abstract class PrinterHandler {
|
|||
protected List<OrderDetail> getCanPrintOrderDetails(boolean partPrint, Long orderId, List<OrderDetail> tbOrderDetailList, List<?> categoryIds) {
|
||||
List<Long> productIds = tbOrderDetailList.stream().map(OrderDetail::getProductId).collect(Collectors.toList());
|
||||
|
||||
Map<Long, Boolean> canPrintProMap = partPrint || categoryIds.isEmpty() ? new HashMap<>() :
|
||||
Map<Long, Boolean> canPrintProMap = categoryIds.isEmpty() ? new HashMap<>() :
|
||||
productService.list(new QueryWrapper().in(Product::getCategoryId, categoryIds).in(Product::getId, productIds))
|
||||
.stream().collect(Collectors.toMap(Product::getId, i -> true));
|
||||
|
||||
|
|
@ -372,8 +373,22 @@ public abstract class PrinterHandler {
|
|||
log.info("准备开始打印菜品以及结算单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, false, orderInfo, orderDetailList);
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
switch (machine.getPrintMethod()) {
|
||||
case "all":
|
||||
onlyFrontDesk(machine, false, orderInfo, orderDetailList);
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
break;
|
||||
case "one":
|
||||
log.info("打印机仅打印one");
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
break;
|
||||
case "normal":
|
||||
log.info("打印机仅打印normal");
|
||||
onlyFrontDesk(machine, false, orderInfo, orderDetailList);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("打印方法有误");
|
||||
}
|
||||
}else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,11 +237,10 @@ public interface PrinterImpl {
|
|||
data.append(getFormatLabel(printInfoDTO.getShopName(), signLabelInfo.center, signLabelInfo.f)).append(signLabelInfo.br);
|
||||
// data.append(StrUtil.format("<C><F>{}</F></C><BR>", printInfoDTO.getShopName()));
|
||||
// data.append("<BR>");
|
||||
data.append(signLabelInfo.br);
|
||||
// data.append("<OUT:30>");
|
||||
data.append(getFormatLabel(StrUtil.format("{}【{}】", printInfoDTO.getPrintTitle(), printInfoDTO.getPickupNum()), signLabelInfo.center, signLabelInfo.bold))
|
||||
.append(signLabelInfo.br)
|
||||
data.append(getFormatLabel(StrUtil.format("{}【{}】", printInfoDTO.getPrintTitle(), printInfoDTO.getPickupNum()), signLabelInfo.l, signLabelInfo.center))
|
||||
.append(signLabelInfo.br);
|
||||
|
||||
// data.append(StrUtil.format("<C><BOLD>{}【{}】</BOLD></C><BR>", printInfoDTO.getPrintTitle(), printInfoDTO.getPickupNum()));
|
||||
//if (Objects.nonNull(printInfoDTO.getOutNumber())) {
|
||||
// data.append(StrUtil.format("<CB><BOLD>{}</BOLD></CB>",printInfoDTO.getOutNumber()));
|
||||
|
|
@ -270,7 +269,8 @@ public interface PrinterImpl {
|
|||
// data.append("<S>--------------------------------</S><BR>");
|
||||
for (OrderDetail detail : detailList) {
|
||||
String number = detail.getNum().stripTrailingZeros().toPlainString();
|
||||
String row = getRow(detail.getProductName(), "", number,
|
||||
String row = getRow(detail.getProductName(), "", StrUtil.format("{}{}", number, detail.getReturnNum().compareTo(BigDecimal.ZERO) > 0 ?
|
||||
"(退" + detail.getReturnNum().stripTrailingZeros().toPlainString() + ")" : ""),
|
||||
toPlainStr(detail.getPayAmount().stripTrailingZeros().toPlainString()), 21, 0, 5, 6);
|
||||
data.append(row);
|
||||
if (StrUtil.isNotBlank(detail.getSkuName())) {
|
||||
|
|
@ -375,34 +375,34 @@ public interface PrinterImpl {
|
|||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (isReturn) {
|
||||
builder.append(getFormatLabel(StrUtil.format("{}【退】", pickupNumber), signLabelInfo.center, signLabelInfo.bold))
|
||||
builder.append(getFormatLabel(StrUtil.format("{}【退】", pickupNumber), signLabelInfo.centerBold))
|
||||
.append(signLabelInfo.br)
|
||||
.append(signLabelInfo.br);
|
||||
// builder.append("<C><B>").append(pickupNumber).append("【退】</B></C><BR><BR>");
|
||||
} else {
|
||||
builder.append(getFormatLabel(pickupNumber, signLabelInfo.center, signLabelInfo.bold))
|
||||
builder.append(getFormatLabel(pickupNumber, signLabelInfo.centerBold))
|
||||
.append(signLabelInfo.br)
|
||||
.append(signLabelInfo.br);
|
||||
// builder.append("<C><B>").append(pickupNumber).append("</B></C><BR><BR>");
|
||||
}
|
||||
builder.append(getFormatLabel(StrUtil.format("时间: {}", date), signLabelInfo.l, signLabelInfo.s))
|
||||
builder.append(getFormatLabel(StrUtil.format("时间: {}", date), signLabelInfo.l, signLabelInfo.center))
|
||||
.append(signLabelInfo.br)
|
||||
.append(signLabelInfo.br);
|
||||
// builder.append("<S><L>时间: ").append(date).append(" </L></S><BR><BR><BR>");
|
||||
if (productName.length() > 4) {
|
||||
builder.append(getFormatLabel(StrUtil.format("{} x {}", productName, number.stripTrailingZeros().toPlainString()), signLabelInfo.l))
|
||||
builder.append(getFormatLabel(StrUtil.format("{} x {}", productName, number.stripTrailingZeros().toPlainString()), signLabelInfo.l, signLabelInfo.f, signLabelInfo.center))
|
||||
.append(signLabelInfo.br);
|
||||
// builder.append("<CS:32>").append(productName).append(" x ").append(number).append("</CS><BR>");
|
||||
if (StrUtil.isNotBlank(skuName)) {
|
||||
builder.append(getFormatLabel(skuName, signLabelInfo.l)).append(signLabelInfo.br);
|
||||
builder.append(getFormatLabel("(" + skuName + ")", signLabelInfo.l, signLabelInfo.f, signLabelInfo.center)).append(signLabelInfo.br);
|
||||
// builder.append("<CS:32>").append(skuName).append(" </CS><BR>");
|
||||
}
|
||||
} else {
|
||||
builder.append(getFormatLabel(StrUtil.format("{} x {}", productName, number.stripTrailingZeros().toPlainString()), signLabelInfo.l))
|
||||
builder.append(getFormatLabel(StrUtil.format("{} x {}", productName, number.stripTrailingZeros().toPlainString()), signLabelInfo.l, signLabelInfo.f, signLabelInfo.center))
|
||||
.append(signLabelInfo.br);
|
||||
// builder.append("<B>").append(productName).append(" x ").append(number).append("</B><BR>");
|
||||
if (StrUtil.isNotBlank(skuName)) {
|
||||
builder.append(getFormatLabel(skuName, signLabelInfo.l))
|
||||
builder.append(getFormatLabel("(" + skuName + ")", signLabelInfo.l, signLabelInfo.f, signLabelInfo.center))
|
||||
.append(signLabelInfo.br);
|
||||
// builder.append("<B>").append(skuName).append(" </B><BR>");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.czg.account.entity.ShopInfo;
|
|||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
@ -61,6 +62,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
|||
.setS(new String[]{"<S>", "</S>"})
|
||||
.setQr(new String[]{"<QR>", "</QR>"})
|
||||
.setCenter(new String[]{"<C>", "</C>"})
|
||||
.setCenterBold(new String[]{"<CB>", "</CB>"})
|
||||
.setRs("RS")
|
||||
.setBold(new String[]{"<B>", "</B>"});
|
||||
|
||||
|
|
@ -155,13 +157,16 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
|||
@Override
|
||||
protected void normalOrderPrint(OrderInfo orderInfo, boolean isPre, PrintMachine machine, String balance, List<OrderDetail> detailList) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
long count = orderInfoService.queryChain()
|
||||
.eq(OrderInfo::getTradeDay, orderInfo.getTradeDay())
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()).count();
|
||||
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().toPlainString()).setReturn(isReturn(orderInfo))
|
||||
.setBalance(balance).setPayType((ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType())).setIntegral("0")
|
||||
.setOutNumber(orderInfo.getTakeCode()).setPrintTitle(isPre ? "预结算单" : "结算单")
|
||||
.setRemark(orderInfo.getRemark()).setDiscountAmount(orderInfo.getOriginAmount().subtract(orderInfo.getPayAmount()).toPlainString());
|
||||
|
||||
printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle()+" #"+count);
|
||||
String data = buildOrderPrintData(printInfoDTO, detailList);
|
||||
String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
|
|
@ -177,7 +182,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
|||
|
||||
@Override
|
||||
protected void callNumPrint(PrintMachine machine, String callNum, String shopName, String tableName, String tableNote, String preNum, String codeUrl, LocalDateTime takeTime, String shopNote) {
|
||||
String resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl,shopNote, takeTime);
|
||||
String resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
|
||||
sendPrintRequest(machine.getAddress(), resp, null, "1");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
.eq(OrderInfo::getUserId, param.getUserId())
|
||||
.eq(OrderInfo::getTableCode, CzgStrUtils.getStrOrNull(param.getTableCode()))
|
||||
.eq(OrderInfo::getOrderNo, CzgStrUtils.getStrOrNull(param.getOrderNo()))
|
||||
.eq(OrderInfo::getIsDel, param.getIsDel())
|
||||
.gt(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getStartTime()))
|
||||
.le(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getEndTime()))
|
||||
.in(OrderInfo::getId, like)
|
||||
|
|
@ -145,6 +146,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
public CzgResult<HistoryOrderPrintVo> getOrderByIdPrint(Long orderId) {
|
||||
HistoryOrderPrintVo historyOrderVo = getOneAs(new QueryWrapper()
|
||||
.eq(OrderInfo::getId, orderId), HistoryOrderPrintVo.class);
|
||||
AssertUtil.isNull(historyOrderVo, "订单不存在");
|
||||
List<OrderDetailPrintVo> orderDetails = orderDetailService.getOrderDetailPrint(orderId);
|
||||
Map<String, List<OrderDetailPrintVo>> resultMap = new HashMap<>();
|
||||
// 遍历订单详情列表
|
||||
|
|
@ -159,6 +161,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
resultMap.computeIfAbsent(placeNum.toString(), k -> new ArrayList<>()).add(orderDetail);
|
||||
}
|
||||
historyOrderVo.setDetailMap(resultMap);
|
||||
long count = queryChain()
|
||||
.eq(OrderInfo::getTradeDay, historyOrderVo.getTradeDay())
|
||||
.eq(OrderInfo::getStatus,OrderStatusEnums.DONE.getCode()).count();
|
||||
historyOrderVo.setOrderNum(count);
|
||||
return CzgResult.success(historyOrderVo);
|
||||
}
|
||||
|
||||
|
|
@ -840,7 +846,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
orderInfo.setOriginAmount(param.getOriginAmount());
|
||||
if (param.getOrderAmount() != null && param.getOrderAmount().compareTo(BigDecimal.ZERO) >= 0) {
|
||||
orderInfo.setOrderAmount(param.getOrderAmount());
|
||||
}else {
|
||||
} else {
|
||||
orderInfo.setOrderAmount(BigDecimal.ZERO);
|
||||
}
|
||||
orderInfo.setPackFee(orderInfo.getPackFee().add(param.getPackFee()));
|
||||
|
|
@ -961,4 +967,109 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId) {
|
||||
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getId, orderId).eq(OrderInfo::getShopId, shopId));
|
||||
if (orderInfo == null) {
|
||||
throw new ApiNotPrintException("订单不存在");
|
||||
}
|
||||
|
||||
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||
throw new ApiNotPrintException("订单不处于待支付状态");
|
||||
}
|
||||
|
||||
OrderDetail orderDetail = orderDetailService.getOne(new QueryWrapper().eq(OrderDetail::getId, detailId).eq(OrderDetail::getOrderId, orderId));
|
||||
if (orderDetail == null || !orderDetail.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
throw new ApiNotPrintException("不处于待支付或订单详情不存在");
|
||||
}
|
||||
|
||||
int i = mapper.decrMoney(orderInfo.getId(), orderDetail.getPayAmount().add(orderDetail.getPackAmount()));
|
||||
if (i > 0) {
|
||||
return orderDetailService.removeById(orderDetail.getId());
|
||||
}
|
||||
throw new ApiNotPrintException("操作失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean cancelledOrder(Long shopId, Long orderId) {
|
||||
OrderInfo orderInfo = getById(orderId);
|
||||
if (orderInfo == null) {
|
||||
throw new ApiNotPrintException("订单不存在");
|
||||
}
|
||||
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||
throw new ApiNotPrintException("订单不可取消");
|
||||
}
|
||||
updateChain()
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())
|
||||
.eq(OrderInfo::getShopId, shopId)
|
||||
.eq(OrderInfo::getId, orderId)
|
||||
.update();
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
throw new ApiNotPrintException("操作失败");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean cancelledPlaceOrder(Long shopId, Long orderId, Integer placeNum) {
|
||||
OrderInfo orderInfo = getById(orderId);
|
||||
if (orderInfo == null) {
|
||||
throw new ApiNotPrintException("订单不存在");
|
||||
}
|
||||
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
|
||||
throw new ApiNotPrintException("订单不可取消");
|
||||
}
|
||||
if (orderInfo.getPlaceNum().equals(1)) {
|
||||
updateChain()
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())
|
||||
.eq(OrderInfo::getShopId, shopId)
|
||||
.eq(OrderInfo::getId, orderId);
|
||||
return true;
|
||||
}
|
||||
orderDetailService.remove(new QueryWrapper().eq(OrderDetail::getOrderId, orderId).eq(OrderDetail::getPlaceNum, placeNum));
|
||||
List<OrderDetail> list = orderDetailService.queryChain().eq(OrderDetail::getOrderId, orderId).eq(OrderDetail::getShopId, shopId).list();
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
updateChain()
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())
|
||||
.set(OrderInfo::getOriginAmount, BigDecimal.ZERO)
|
||||
.eq(OrderInfo::getShopId, shopId)
|
||||
.eq(OrderInfo::getId, orderId);
|
||||
return true;
|
||||
} else {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
for (OrderDetail orderDetail : list) {
|
||||
BigDecimal subtract = orderDetail.getNum().subtract(orderDetail.getReturnNum());
|
||||
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal unitPrice;
|
||||
if (orderDetail.getDiscountSaleAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
unitPrice = orderDetail.getDiscountSaleAmount();
|
||||
} else {
|
||||
unitPrice = orderDetail.getPrice();
|
||||
}
|
||||
totalAmount = totalAmount.add((orderDetail.getNum().subtract(orderDetail.getReturnNum())))
|
||||
.multiply(unitPrice);
|
||||
}
|
||||
if (subtract.compareTo(BigDecimal.ZERO) > 0
|
||||
&& orderDetail.getPackAmount().compareTo(BigDecimal.ZERO) > 0
|
||||
&& orderDetail.getPackNumber().compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalAmount = totalAmount.add(orderDetail.getPackAmount().multiply(orderDetail.getPackNumber()));
|
||||
}
|
||||
if (orderDetail.getPlaceNum() > placeNum) {
|
||||
orderDetailService.updateChain()
|
||||
.eq(OrderDetail::getId, orderDetail.getId())
|
||||
.set(OrderDetail::getPlaceNum, orderDetail.getPlaceNum() - 1)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
updateChain().eq(OrderInfo::getId, orderId)
|
||||
.eq(OrderInfo::getShopId, shopId)
|
||||
.set(OrderInfo::getOriginAmount, totalAmount)
|
||||
.set(OrderInfo::getPlaceNum, orderInfo.getPlaceNum() - 1)
|
||||
.update();
|
||||
}
|
||||
throw new ApiNotPrintException("操作失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@
|
|||
)
|
||||
]]>
|
||||
</sql>
|
||||
<update id="decrMoney">
|
||||
update tb_order_info set origin_amount = origin_amount-#{amount}, update_time=now() where id=#{id} and origin_amount-#{amount} >= 0;
|
||||
</update>
|
||||
|
||||
<select id="getHandoverCashAmount" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
|
|
|
|||
Loading…
Reference in New Issue