Compare commits
14 Commits
5ee4c22001
...
cb869ea18f
| Author | SHA1 | Date | |
|---|---|---|---|
| cb869ea18f | |||
| ccb4973080 | |||
| 5a18941a99 | |||
| 1cebd38da4 | |||
| bb414d2776 | |||
| f7b30a5142 | |||
| 883284c22b | |||
| 66d61dbd5a | |||
| 3b6137c5d2 | |||
| 578b829064 | |||
| 4665f47665 | |||
| 30f8f62e73 | |||
| 8c559b1c0c | |||
|
|
7d619b8260 |
@@ -10,7 +10,7 @@
|
|||||||
MAX(b.id) as orderId,
|
MAX(b.id) as orderId,
|
||||||
MAX(b.user_id) as user_id,
|
MAX(b.user_id) as user_id,
|
||||||
-- 核心:真实金额 = 支付总额 - 退款总额
|
-- 核心:真实金额 = 支付总额 - 退款总额
|
||||||
IFNULL(SUM(d.pay_amount), 0) - IFNULL(SUM(d.return_amount), 0) as orderAmount,
|
IFNULL(SUM( (d.num - d.return_num) * d.unit_price - d.return_amount ), 0) as orderAmount,
|
||||||
MAX(b.seat_num) as personNum,
|
MAX(b.seat_num) as personNum,
|
||||||
MAX(b.create_time) as orderCreateTime,
|
MAX(b.create_time) as orderCreateTime,
|
||||||
MAX(ar.name) as areaName
|
MAX(ar.name) as areaName
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
|||||||
if (StrUtil.isNotBlank(machine.getPrintQty())) {
|
if (StrUtil.isNotBlank(machine.getPrintQty())) {
|
||||||
printerNum = machine.getPrintQty().split("\\^")[1];
|
printerNum = machine.getPrintQty().split("\\^")[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName())
|
PrintInfoDTO printInfoDTO = new PrintInfoDTO().setShopName(shopInfo.getShopName())
|
||||||
.setCount(count)
|
.setCount(count)
|
||||||
.setPrintType("普通打印").setPickupNum(getPickupNum(orderInfo))
|
.setPrintType("普通打印").setPickupNum(getPickupNum(orderInfo))
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印机具体打印方法接口,提供打印元数据获取,具体打印机实现对应方法即可
|
* 打印机具体打印方法接口,提供打印元数据获取,具体打印机实现对应方法即可
|
||||||
@@ -353,11 +352,11 @@ public interface PrinterImpl {
|
|||||||
.append(signLabelInfo.br);
|
.append(signLabelInfo.br);
|
||||||
// data.append(StrUtil.format("<L><BOLD>备注:{}</BOLD></L><BR>", printInfoDTO.getRemark()));
|
// data.append(StrUtil.format("<L><BOLD>备注:{}</BOLD></L><BR>", printInfoDTO.getRemark()));
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(printInfoDTO.getOutNumber())) {
|
// if (Objects.nonNull(printInfoDTO.getOutNumber())) {
|
||||||
data.append(getFormatLabel(printInfoDTO.getOutNumber(), signLabelInfo.center, signLabelInfo.qr))
|
// data.append(getFormatLabel(printInfoDTO.getOutNumber(), signLabelInfo.center, signLabelInfo.qr))
|
||||||
.append(signLabelInfo.br);
|
// .append(signLabelInfo.br);
|
||||||
// data.append("<QR>".concat(printInfoDTO.getOutNumber()).concat("</QR><BR>"));
|
//// data.append("<QR>".concat(printInfoDTO.getOutNumber()).concat("</QR><BR>"));
|
||||||
}
|
// }
|
||||||
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s))
|
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s))
|
||||||
.append(signLabelInfo.br)
|
.append(signLabelInfo.br)
|
||||||
.append(signLabelInfo.br);
|
.append(signLabelInfo.br);
|
||||||
@@ -442,8 +441,8 @@ public interface PrinterImpl {
|
|||||||
builder.append(getFormatLabel("【加急】", signLabelInfo.center, signLabelInfo.bold))
|
builder.append(getFormatLabel("【加急】", signLabelInfo.center, signLabelInfo.bold))
|
||||||
.append(signLabelInfo.br);
|
.append(signLabelInfo.br);
|
||||||
}
|
}
|
||||||
builder.append(getFormatLabel("UP_ORDER_DETAIL:" + orderDetailId, signLabelInfo.center, signLabelInfo.qr))
|
// builder.append(getFormatLabel("UP_ORDER_DETAIL:" + orderDetailId, signLabelInfo.center, signLabelInfo.qr))
|
||||||
.append(signLabelInfo.br);
|
// .append(signLabelInfo.br);
|
||||||
builder.append(signLabelInfo.br)
|
builder.append(signLabelInfo.br)
|
||||||
.append(signLabelInfo.getOut(150))
|
.append(signLabelInfo.getOut(150))
|
||||||
.append(signLabelInfo.cut);
|
.append(signLabelInfo.cut);
|
||||||
@@ -548,7 +547,7 @@ public interface PrinterImpl {
|
|||||||
* @return 添加间距的字符串
|
* @return 添加间距的字符串
|
||||||
*/
|
*/
|
||||||
default String titleAddSpace(String str, int b1) {
|
default String titleAddSpace(String str, int b1) {
|
||||||
int k = 0;
|
int k;
|
||||||
try {
|
try {
|
||||||
k = str.getBytes("GBK").length;
|
k = str.getBytes("GBK").length;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.czg.account.dto.HandoverRecordDTO;
|
import com.czg.account.dto.HandoverRecordDTO;
|
||||||
import com.czg.account.entity.PrintMachine;
|
import com.czg.account.entity.PrintMachine;
|
||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.account.entity.ShopInfo;
|
||||||
@@ -22,6 +21,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -172,21 +172,29 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
|||||||
? orderInfo.getDiscountAllAmount().toPlainString()
|
? orderInfo.getDiscountAllAmount().toPlainString()
|
||||||
: "0.00");
|
: "0.00");
|
||||||
|
|
||||||
printInfoDTO.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())).toPlainString());
|
BigDecimal originalAmount = orderInfo.getOriginAmount()==null?BigDecimal.ZERO:orderInfo.getOriginAmount();
|
||||||
|
printInfoDTO.setOriginalAmount(originalAmount.toPlainString());
|
||||||
if (isPre) {
|
if (isPre) {
|
||||||
if (orderInfo.getPlaceNum() == 1) {
|
originalAmount = BigDecimal.ZERO;
|
||||||
BigDecimal refundAmount = BigDecimal.ZERO;
|
for (OrderDetail orderDetail : detailList) {
|
||||||
for (OrderDetail orderDetail : detailList) {
|
if(orderDetail.getIsGift()==1){
|
||||||
refundAmount = refundAmount.add(orderDetail.getReturnAmount());
|
continue;
|
||||||
|
}else if(orderDetail.getDiscountSaleAmount().compareTo(BigDecimal.ZERO) > 0){
|
||||||
|
originalAmount = originalAmount.add((orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(orderDetail.getRefundNum())).multiply(orderDetail.getUnitPrice()));
|
||||||
|
}else {
|
||||||
|
originalAmount = originalAmount.add((orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(orderDetail.getRefundNum())).multiply(orderDetail.getPrice()));
|
||||||
}
|
}
|
||||||
printInfoDTO.setOriginalAmount((orderInfo.getOriginAmount().add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee()).subtract(refundAmount)).toPlainString());
|
|
||||||
}
|
}
|
||||||
printInfoDTO.setPayAmount(printInfoDTO.getOriginalAmount());
|
printInfoDTO.setOriginalAmount((originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())).toPlainString());
|
||||||
|
printInfoDTO.setPayAmount(originalAmount.add(orderInfo.getSeatAmount()).add(orderInfo.getPackFee())
|
||||||
|
.subtract(orderInfo.getDiscountAllAmount()).setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||||
|
}else {
|
||||||
|
printInfoDTO.setPayAmount(originalAmount.subtract(orderInfo.getDiscountAllAmount()).setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||||
}
|
}
|
||||||
printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle());
|
printInfoDTO.setPrintTitle(printInfoDTO.getPrintTitle());
|
||||||
if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) {
|
if (orderInfo.getSeatNum() != null && orderInfo.getSeatAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
printInfoDTO.setSeatNum(orderInfo.getSeatNum().toString());
|
printInfoDTO.setSeatNum(orderInfo.getSeatNum().toString());
|
||||||
printInfoDTO.setSeatAmount(orderInfo.getSeatAmount().toPlainString());
|
printInfoDTO.setSeatAmount(orderInfo.getSeatAmount().divide(BigDecimal.valueOf(orderInfo.getSeatNum()), 2, RoundingMode.DOWN).toPlainString());
|
||||||
}
|
}
|
||||||
if (orderInfo.getPackFee().compareTo(BigDecimal.ZERO) > 0) {
|
if (orderInfo.getPackFee().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
printInfoDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
printInfoDTO.setPackFee(orderInfo.getPackFee().toPlainString());
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
}
|
}
|
||||||
orderDetails.forEach(item -> item.setOrderTime(DateUtil.date().toLocalDateTime()));
|
orderDetails.forEach(item -> item.setOrderTime(DateUtil.date().toLocalDateTime()));
|
||||||
AssertUtil.isListEmpty(orderDetails, "下单失败 购物车为空");
|
AssertUtil.isListEmpty(orderDetails, "下单失败 购物车为空");
|
||||||
processOrderDetails(orderDetails, param.getLimitRate());
|
processOrderDetails(orderDetails, param.getLimitRate(),param);
|
||||||
//生成订单
|
//生成订单
|
||||||
OrderInfo orderInfo = initOrderInfo(param, shopInfo, table);
|
OrderInfo orderInfo = initOrderInfo(param, shopInfo, table);
|
||||||
orderDetailService.createOrderDetails(orderInfo.getId(), orderDetails);
|
orderDetailService.createOrderDetails(orderInfo.getId(), orderDetails);
|
||||||
@@ -592,8 +592,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
OrderDetail orderDetailUp = new OrderDetail();
|
OrderDetail orderDetailUp = new OrderDetail();
|
||||||
orderDetailUp.setOrderId(targetOrder.getId());
|
orderDetailUp.setOrderId(targetOrder.getId());
|
||||||
orderDetailUp.setPlaceNum(1);
|
orderDetailUp.setPlaceNum(1);
|
||||||
|
QueryWrapper updateWrapper = new QueryWrapper().eq(OrderDetail::getOrderId, sourceOrder.getId());
|
||||||
|
if (CollUtil.isNotEmpty(param.getDetailIds())) {
|
||||||
|
updateWrapper.in(OrderDetail::getId, param.getDetailIds());
|
||||||
|
}
|
||||||
orderDetailService.update(orderDetailUp,
|
orderDetailService.update(orderDetailUp,
|
||||||
new QueryWrapper().eq(OrderDetail::getOrderId, sourceOrder.getId()).in(OrderDetail::getId, param.getDetailIds()));
|
updateWrapper);
|
||||||
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + targetOrder.getId(), "", 60 * 15);
|
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + targetOrder.getId(), "", 60 * 15);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1024,7 +1028,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
*
|
*
|
||||||
* @param orderDetails 订单详情 需要回填
|
* @param orderDetails 订单详情 需要回填
|
||||||
*/
|
*/
|
||||||
private void processOrderDetails(List<OrderDetail> orderDetails, LimitRateDTO limitRate) throws CzgException {
|
private void processOrderDetails(List<OrderDetail> orderDetails, LimitRateDTO limitRate,OrderInfoAddDTO param) throws CzgException {
|
||||||
|
BigDecimal packFee = BigDecimal.ZERO;
|
||||||
for (OrderDetail detail : orderDetails) {
|
for (OrderDetail detail : orderDetails) {
|
||||||
if (!detail.getIsTemporary().equals(1) && detail.getProductId() > 0) {
|
if (!detail.getIsTemporary().equals(1) && detail.getProductId() > 0) {
|
||||||
Product product = productService.getOne(QueryWrapper.create()
|
Product product = productService.getOne(QueryWrapper.create()
|
||||||
@@ -1050,7 +1055,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
detail.setUnitPrice(detail.getPrice());
|
detail.setUnitPrice(detail.getPrice());
|
||||||
}
|
}
|
||||||
detail.setPayAmount(detail.getNum().multiply(detail.getUnitPrice()));
|
detail.setPayAmount(detail.getNum().multiply(detail.getUnitPrice()));
|
||||||
|
packFee = packFee.add(detail.getPackAmount().multiply(detail.getPackNumber()));
|
||||||
}
|
}
|
||||||
|
param.setPackFee(packFee);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -415,6 +415,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
} else {
|
} else {
|
||||||
orderDetail.setStatus(OrderStatusEnums.PART_REFUND.getCode());
|
orderDetail.setStatus(OrderStatusEnums.PART_REFUND.getCode());
|
||||||
}
|
}
|
||||||
|
orderDetail.setReturnAmount(orderDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
|
||||||
} else {
|
} else {
|
||||||
orderDetail.setReturnNum(orderDetail.getReturnNum().add(refNum));
|
orderDetail.setReturnNum(orderDetail.getReturnNum().add(refNum));
|
||||||
if (orderDetail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && orderDetail.getPackNumber().compareTo(orderDetail.getNum().subtract(orderDetail.getReturnNum())) > 0) {
|
if (orderDetail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && orderDetail.getPackNumber().compareTo(orderDetail.getNum().subtract(orderDetail.getReturnNum())) > 0) {
|
||||||
@@ -423,12 +424,9 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
}
|
}
|
||||||
orderDetail.setRefundNo(refPayOrderNo);
|
orderDetail.setRefundNo(refPayOrderNo);
|
||||||
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
|
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
|
||||||
// if (isPay) {
|
|
||||||
orderDetail.setReturnAmount(orderDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
|
|
||||||
if (orderDetail.getReturnAmount().compareTo(orderDetail.getPayAmount()) > 0) {
|
if (orderDetail.getReturnAmount().compareTo(orderDetail.getPayAmount()) > 0) {
|
||||||
orderDetail.setReturnAmount(orderDetail.getPayAmount());
|
orderDetail.setReturnAmount(orderDetail.getPayAmount());
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
orderDetailService.updateById(orderDetail);
|
orderDetailService.updateById(orderDetail);
|
||||||
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
||||||
returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum());
|
returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum());
|
||||||
@@ -441,7 +439,8 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
} else if (isPay) {
|
} else if (isPay) {
|
||||||
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||||
List<OrderDetail> orderDetails = orderDetailService.list(
|
List<OrderDetail> orderDetails = orderDetailService.list(
|
||||||
QueryWrapper.create().select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
|
QueryWrapper.create().select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
|
||||||
|
|||||||
Reference in New Issue
Block a user