feat: 1.临时菜接口 2.购物车数量字段修改为decimal类型
This commit is contained in:
@@ -51,7 +51,7 @@ public interface TableConstant {
|
||||
public enum UseType {
|
||||
TAKEOUT("takeout"),
|
||||
DINE_IN_AFTER("dine-in-after"),
|
||||
DINE_IN_BEFORE("dine-in-before");
|
||||
DINE_IN_BEFORE("dine-in-before"), NONE_TABLE("dine-in");
|
||||
private final String value;
|
||||
|
||||
UseType(String value) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.entity.OrderVo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.AddTemporaryDishesDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnCartDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
|
||||
@@ -18,6 +19,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@Slf4j
|
||||
@@ -45,6 +48,11 @@ public class OrderController {
|
||||
cartVo.getIsPack(), cartVo.getUuid(), cartVo.getType(), cartVo.getTableId());
|
||||
}
|
||||
|
||||
@PostMapping("/temporaryDishes")
|
||||
public Result addTemporaryDishes(@Valid @RequestBody AddTemporaryDishesDTO temporaryDishesDTO) {
|
||||
return Result.success(CodeEnum.SUCCESS, orderService.addTemporaryDishes(temporaryDishesDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/queryCart")
|
||||
public Result queryCart(@RequestHeader("token") String token,
|
||||
@RequestHeader("loginName") String loginName,
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public interface TbProductMapper {
|
||||
@@ -46,13 +47,13 @@ public interface TbProductMapper {
|
||||
List<ProConsSkuInfo> selectBySkuId(Integer skuId);
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number+#{num} WHERE id=#{id}")
|
||||
int incrStock(String id, int num);
|
||||
int incrStock(String id, BigDecimal num);
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
|
||||
int decrStock(String id, int num);
|
||||
int decrStock(String id, BigDecimal num);
|
||||
|
||||
@Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||
int decrStockUnCheck(String id, int num);
|
||||
int decrStockUnCheck(String id, BigDecimal num);
|
||||
|
||||
@Select("select * from tb_product product where product.id=#{productId} and product.shop_id=#{shopId} and product.is_del=0")
|
||||
TbProduct selectByShopIdAndId(@Param("productId") Integer productId, @Param("shopId") Integer shopId);
|
||||
|
||||
@@ -19,8 +19,6 @@ public class OrderVo {
|
||||
private Integer type;
|
||||
|
||||
private String sendType;
|
||||
|
||||
private String eatModel;
|
||||
@Min(1)
|
||||
private Integer seatNum;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
@Data
|
||||
public class TbCashierCart implements Serializable {
|
||||
@@ -12,9 +16,9 @@ public class TbCashierCart implements Serializable {
|
||||
|
||||
private String masterId;
|
||||
|
||||
private String orderId;
|
||||
private Integer orderId;
|
||||
|
||||
private String refOrderId;
|
||||
private Integer refOrderId;
|
||||
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@@ -29,48 +33,62 @@ public class TbCashierCart implements Serializable {
|
||||
private String name;
|
||||
|
||||
private BigDecimal salePrice;
|
||||
private BigDecimal packFee;
|
||||
|
||||
private Integer number;
|
||||
private BigDecimal number;
|
||||
|
||||
private Integer totalNumber;
|
||||
private BigDecimal totalNumber;
|
||||
|
||||
private Integer refundNumber;
|
||||
private BigDecimal refundNumber;
|
||||
|
||||
private String categoryId;
|
||||
private String tradeDay;
|
||||
|
||||
private String status;
|
||||
|
||||
private Byte type;
|
||||
private Integer type;
|
||||
|
||||
private String merchantId;
|
||||
|
||||
private String shopId;
|
||||
private String isPack;
|
||||
private String isGift;
|
||||
private String skuName;
|
||||
private String uuid;
|
||||
|
||||
private Long createdAt;
|
||||
private Long pendingAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String tableId;
|
||||
private String useType;
|
||||
|
||||
private BigDecimal packFee;
|
||||
|
||||
private String tradeDay;
|
||||
|
||||
private String isPack;
|
||||
|
||||
private String isGift;
|
||||
|
||||
private Long pendingAt;
|
||||
|
||||
private String uuid;
|
||||
private String skuName;
|
||||
private Integer placeNum;
|
||||
private String note;
|
||||
private String useType;
|
||||
private String platformType;
|
||||
private BigDecimal memberPrice;
|
||||
// 优惠券id
|
||||
private Integer userCouponId;
|
||||
private BigDecimal memberPrice = BigDecimal.ZERO;
|
||||
private Integer isMember;
|
||||
// 是否临时菜品
|
||||
private Integer isTemporary;
|
||||
private String unit;
|
||||
private BigDecimal discountSaleAmount;
|
||||
private String discountSaleNote;
|
||||
private Boolean isPrint;
|
||||
private String useCouponInfo;
|
||||
|
||||
@TableField(exist = false)
|
||||
private TbProductSpec tbProductSpec;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String selectSpec="";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public void copy(TbCashierCart source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据是否会员充值价格
|
||||
@@ -81,12 +99,58 @@ public class TbCashierCart implements Serializable {
|
||||
}
|
||||
if ("true".equals(isGift)) {
|
||||
totalAmount = packFee;
|
||||
}else {
|
||||
} else {
|
||||
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);
|
||||
totalAmount = totalNumber.multiply(memberPrice).add(packFee);
|
||||
} else {
|
||||
totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据是否会员充值价格
|
||||
*/
|
||||
public void resetTotalAmount(BigDecimal discountRadio) {
|
||||
if (discountRadio == null) {
|
||||
discountRadio = BigDecimal.ONE;
|
||||
}
|
||||
if ("false".equals(isPack)) {
|
||||
packFee = BigDecimal.ZERO;
|
||||
}
|
||||
if ("true".equals(isGift)) {
|
||||
totalAmount = packFee;
|
||||
} else {
|
||||
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio);
|
||||
} else {
|
||||
totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总价不包含打包费
|
||||
*
|
||||
*/
|
||||
public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) {
|
||||
if (discountRadio == null) {
|
||||
discountRadio = new BigDecimal("1");
|
||||
}
|
||||
if (num == null) {
|
||||
num = totalNumber;
|
||||
}
|
||||
|
||||
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
return num.multiply(memberPrice).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP);
|
||||
}else {
|
||||
return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
// if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// return num.multiply(memberPrice);
|
||||
// } else {
|
||||
// return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class TbOrderDetail implements Serializable {
|
||||
|
||||
private Integer productSkuId;
|
||||
|
||||
private Integer num;
|
||||
private Integer returnNum;
|
||||
private BigDecimal num;
|
||||
private BigDecimal returnNum;
|
||||
|
||||
private String productName;
|
||||
private String status;
|
||||
|
||||
@@ -15,12 +15,6 @@ public class TbProduct implements Serializable {
|
||||
|
||||
private Integer specId;
|
||||
|
||||
private String sourcePath;
|
||||
|
||||
private Integer brandId;
|
||||
|
||||
private String merchantId;
|
||||
|
||||
private String shopId;
|
||||
|
||||
private String name;
|
||||
@@ -33,103 +27,34 @@ public class TbProduct implements Serializable {
|
||||
|
||||
private BigDecimal lowPrice;
|
||||
|
||||
private BigDecimal lowMemberPrice;
|
||||
|
||||
private String unitId;
|
||||
|
||||
private String unitSnap;
|
||||
|
||||
private String coverImg;
|
||||
|
||||
private String shareImg;
|
||||
|
||||
private String videoCoverImg;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer limitNumber;
|
||||
|
||||
private Integer productScore;
|
||||
|
||||
private Byte status;
|
||||
|
||||
private String failMsg;
|
||||
|
||||
private Byte isRecommend;
|
||||
|
||||
private Byte isHot;
|
||||
|
||||
private Byte isNew;
|
||||
|
||||
private Byte isOnSale;
|
||||
|
||||
private Byte isShow;
|
||||
|
||||
private String typeEnum;
|
||||
|
||||
/**
|
||||
* 是否共享库存
|
||||
*/
|
||||
private Byte isDistribute;
|
||||
|
||||
private Byte isDel;
|
||||
|
||||
private Byte isStock;
|
||||
|
||||
private Byte isPauseSale;
|
||||
|
||||
private Byte isFreeFreight;
|
||||
|
||||
private Long freightId;
|
||||
|
||||
private String strategyType;
|
||||
|
||||
private Integer strategyId;
|
||||
|
||||
private Byte isVip;
|
||||
|
||||
private Byte isDelete;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
private Double baseSalesNumber;
|
||||
|
||||
private Integer realSalesNumber;
|
||||
|
||||
private Integer salesNumber;
|
||||
|
||||
private Integer thumbCount;
|
||||
|
||||
private Integer storeCount;
|
||||
|
||||
private Integer furnishMeal;
|
||||
|
||||
private Integer furnishExpress;
|
||||
|
||||
private Integer furnishDraw;
|
||||
|
||||
private Integer furnishVir;
|
||||
|
||||
private Byte isCombo;
|
||||
|
||||
private Byte isShowCash;
|
||||
|
||||
private Byte isShowMall;
|
||||
|
||||
private Byte isNeedExamine;
|
||||
|
||||
private Byte showOnMallStatus;
|
||||
|
||||
private Long showOnMallTime;
|
||||
|
||||
private String showOnMallErrorMsg;
|
||||
|
||||
private Byte enableLabel;
|
||||
|
||||
private String taxConfigId;
|
||||
|
||||
private String specTableHeaders;
|
||||
|
||||
private Integer stockNumber;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class AddTemporaryDishesDTO {
|
||||
@NotEmpty
|
||||
private String masterId;
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
private String tableId;
|
||||
@NotBlank(message = "菜品名不为空")
|
||||
private String name;
|
||||
@NotNull(message = "分类不为空")
|
||||
private Integer categoryId;
|
||||
@Min(value = 0, message = "价格最低为0")
|
||||
private BigDecimal price;
|
||||
@NotNull
|
||||
@DecimalMin(value = "0.01")
|
||||
private BigDecimal num;
|
||||
@NotBlank(message = "单位不为空")
|
||||
private String unit;
|
||||
private String note;
|
||||
private Integer vipUserId;
|
||||
}
|
||||
@@ -7,13 +7,24 @@ import lombok.Data;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ShopEatTypeInfoDTO {
|
||||
// 是否外带
|
||||
private boolean isTakeout;
|
||||
// 是否快餐
|
||||
private boolean isMunchies;
|
||||
// 是否后付费
|
||||
private boolean isDineInAfter;
|
||||
// 是否先付费
|
||||
private boolean isDineInBefore;
|
||||
// 是否需要餐位费
|
||||
private boolean needSeatFee;
|
||||
// 是否无桌台下单
|
||||
private boolean isNoneTable;
|
||||
// 是否增加masterId
|
||||
private boolean isIncrMaterId;
|
||||
private boolean isMemberPrice;
|
||||
private TbShopInfo shopInfo;
|
||||
private String useType;
|
||||
private Object shopId;
|
||||
private String tableId;
|
||||
private String sendType;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class CartVo {
|
||||
@@ -12,8 +14,9 @@ public class CartVo {
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
private Integer skuId;
|
||||
@Min(1)
|
||||
private Integer number;
|
||||
@NotNull
|
||||
@DecimalMin("0.01")
|
||||
private BigDecimal number;
|
||||
private String isPack;
|
||||
private String isGift;
|
||||
private String status;
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -311,10 +312,10 @@ public class PrintMechineConsumer {
|
||||
|
||||
|
||||
if (info != null) {
|
||||
isReturn = it.getNum() - Integer.parseInt(info) < 0;
|
||||
printerNum = it.getNum() - Integer.parseInt(info);
|
||||
isReturn = it.getNum().intValue() - Integer.parseInt(info) < 0;
|
||||
printerNum = it.getNum().intValue() - Integer.parseInt(info);
|
||||
} else {
|
||||
printerNum = it.getNum();
|
||||
printerNum = it.getNum().intValue();
|
||||
}
|
||||
|
||||
log.info("已打印数量, {}, 未打印数量: {}", info, printerNum);
|
||||
@@ -331,7 +332,7 @@ public class PrintMechineConsumer {
|
||||
redisTemplate.expire(printKey, 24, TimeUnit.HOURS);
|
||||
|
||||
// 已打印不再打印
|
||||
if (info != null && it.getNum() - Integer.parseInt(info) == 0) {
|
||||
if (info != null && it.getNum().intValue() - Integer.parseInt(info) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -366,7 +367,8 @@ public class PrintMechineConsumer {
|
||||
TbOrderDetail orderDetail = (TbOrderDetail) item;
|
||||
String data = PrinterUtils.getPrintData("return",
|
||||
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark(), null);
|
||||
// todo 修改为bigdecimal
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum().intValue(), orderDetail.getRemark(), null);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
|
||||
@@ -432,9 +434,10 @@ public class PrintMechineConsumer {
|
||||
printProductSet.forEach(item -> {
|
||||
log.info("已删除订单,打印退款票据, {}", item);
|
||||
TbOrderDetail orderDetail = (TbOrderDetail) item;
|
||||
// todo 修改为bigdecimal
|
||||
String data = PrinterUtils.getPrintData("return",
|
||||
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), orderDetail.getRemark(), null);
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum().intValue(), orderDetail.getRemark(), null);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
|
||||
@@ -474,9 +477,10 @@ public class PrintMechineConsumer {
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
// todo 修改为bigdecimal
|
||||
String data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
|
||||
it.getNum(), remark, null);
|
||||
it.getNum().intValue(), remark, null);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
@@ -502,8 +506,10 @@ public class PrintMechineConsumer {
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ?
|
||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark, null);
|
||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum().intValue(), remark, null);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
@@ -524,7 +530,7 @@ public class PrintMechineConsumer {
|
||||
if (info == null) {
|
||||
return false;
|
||||
}
|
||||
orderDetail.setNum(orderDetail.getNum() - Integer.parseInt(info));
|
||||
orderDetail.setNum(orderDetail.getNum().subtract(new BigDecimal(info)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -673,7 +679,7 @@ public class PrintMechineConsumer {
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo, DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo, DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber().intValue(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -709,7 +715,7 @@ public class PrintMechineConsumer {
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
for (int i = 0; i < it.getNumber(); i++) {
|
||||
for (int i = 0; i < it.getNumber().intValue(); i++) {
|
||||
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,10 @@ public class FeiPrinter extends PrinterHandler {
|
||||
return;
|
||||
}
|
||||
String remark = sku.getSpecSnap();
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
String[] resp = FeieyunPrintUtil.getPrintData(machine.getAddress(), orderInfo,
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), remark);
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum().intValue(), remark);
|
||||
shopPrintLogService.save(machine, "新订单", resp[0], resp[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ public class LocalLabelPrinter extends PrinterHandler {
|
||||
log.warn("打印菜品标签票失败 sku商品不存在: {}", orderDetail);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < orderDetail.getNum(); i++) {
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
for (int i = 0; i < orderDetail.getNum().intValue(); i++) {
|
||||
String[] resp = FeieyunPrintUtil.printLabelMsg(machine.getAddress(), orderInfo.getTableName(), orderDetail.getProductName(),
|
||||
1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), sku.getSalePrice().toPlainString(), sku.getSpecSnap());
|
||||
shopPrintLogService.save(machine, "新订单", resp[0], resp[1]);
|
||||
|
||||
@@ -62,10 +62,11 @@ public class YxyPrinter extends PrinterHandler {
|
||||
|
||||
@Override
|
||||
protected void returnDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
String data = PrinterUtils.getPrintData("return", getPickupNum(orderInfo),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(),
|
||||
Math.abs(orderDetail.getNum()), orderDetail.getRemark(), orderDetail.getNote());
|
||||
orderDetail.getNum().abs().intValue(), orderDetail.getRemark(), orderDetail.getNote());
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
@@ -74,9 +75,11 @@ public class YxyPrinter extends PrinterHandler {
|
||||
|
||||
@Override
|
||||
protected void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
String data = PrinterUtils.getPrintData("", getPickupNum(orderInfo),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(),
|
||||
orderDetail.getNum(), orderDetail.getRemark(), orderDetail.getNote());
|
||||
orderDetail.getNum().intValue(), orderDetail.getRemark(), orderDetail.getNote());
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
|
||||
@@ -189,8 +189,10 @@ public class CloudPrinterService {
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
String data = PrinterUtils.getPrintData("return", orderInfo.getPayType().equals("wx_lite") ?
|
||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark, null);
|
||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum().intValue(), remark, null);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
@@ -223,9 +225,10 @@ public class CloudPrinterService {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
String data = PrinterUtils.getPrintData("", orderInfo.getOrderType().equals("miniapp") ?
|
||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark, null);
|
||||
orderInfo.getTableName() : orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber().intValue(), remark, null);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
|
||||
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
@@ -526,8 +529,9 @@ public class CloudPrinterService {
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo, DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo, DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber().intValue(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -558,8 +562,9 @@ public class CloudPrinterService {
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
for (int i = 0; i < it.getNumber(); i++) {
|
||||
for (int i = 0; i < it.getNumber().intValue(); i++) {
|
||||
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ConsService {
|
||||
flow.setConName(tbConsInfo.getConName());
|
||||
flow.setProSkuId(proskuCon.getProductSkuId());
|
||||
if("create".equals(type)){
|
||||
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
|
||||
amount=proskuCon.getSurplusStock().multiply(orderDetail.getNum());
|
||||
|
||||
flow.setAmount(amount);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ConsService {
|
||||
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
}else if("delete".equals(type)){
|
||||
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate();
|
||||
amount=proskuCon.getSurplusStock().multiply(orderDetail.getNum()).negate();
|
||||
|
||||
flow.setAmount(amount.abs());
|
||||
flow.setBizCode("cancelCart");
|
||||
|
||||
@@ -181,14 +181,16 @@ public class DutyService {
|
||||
ShopUserDutyDetail shopUserDutyDetail = new ShopUserDutyDetail();
|
||||
shopUserDutyDetail.setDutyId(shopUserDuty.getId());
|
||||
shopUserDutyDetail.setAmount(orderDetail.getPriceAmount());
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum().intValue());
|
||||
shopUserDutyDetail.setSkuId(orderDetail.getProductSkuId());
|
||||
shopUserDutyDetail.setSkuName(orderDetail.getProductSkuName());
|
||||
shopUserDutyDetail.setProductId(orderDetail.getProductId());
|
||||
shopUserDutyDetail.setProductName(orderDetail.getProductName());
|
||||
detaiList.add(shopUserDutyDetail);
|
||||
// productSkuMapper.updateByskuId(orderDetail.getProductSkuId(), orderDetail.getNum());
|
||||
subInventory(shopId, orderDetail.getProductSkuId(), orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
subInventory(shopId, orderDetail.getProductSkuId(), orderDetail.getNum().intValue());
|
||||
}
|
||||
if (detaiList.size() > 0) {
|
||||
shopUserDutyDetailMapper.batchInsert(detaiList);
|
||||
@@ -214,14 +216,15 @@ public class DutyService {
|
||||
for (TbOrderDetail orderDetail : list) {
|
||||
if (map.containsKey(orderDetail.getProductSkuId())) {
|
||||
ShopUserDutyDetail shopUserDutyDetail = map.get(orderDetail.getProductSkuId());
|
||||
shopUserDutyDetail.setNum(shopUserDutyDetail.getNum() + orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
shopUserDutyDetail.setNum(shopUserDutyDetail.getNum() + orderDetail.getNum().intValue());
|
||||
shopUserDutyDetail.setAmount(shopUserDutyDetail.getAmount().add(orderDetail.getPriceAmount().add(orderDetail.getPackAmount())));
|
||||
shopUserDutyDetailMapper.updateByPrimaryKeySelective(shopUserDutyDetail);
|
||||
} else {
|
||||
ShopUserDutyDetail shopUserDutyDetail = new ShopUserDutyDetail();
|
||||
shopUserDutyDetail.setDutyId(shopUserDuty.getId());
|
||||
shopUserDutyDetail.setAmount(orderDetail.getPriceAmount());
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum());
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum().intValue());
|
||||
shopUserDutyDetail.setSkuId(orderDetail.getProductSkuId());
|
||||
shopUserDutyDetail.setSkuName(orderDetail.getProductSkuName());
|
||||
shopUserDutyDetail.setProductId(orderDetail.getProductId());
|
||||
@@ -230,7 +233,8 @@ public class DutyService {
|
||||
|
||||
}
|
||||
// productSkuMapper.updateByskuId(orderDetail.getProductSkuId(), orderDetail.getNum());
|
||||
subInventory(shopId, orderDetail.getProductSkuId(), orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
subInventory(shopId, orderDetail.getProductSkuId(), orderDetail.getNum().intValue());
|
||||
}
|
||||
if (detaiList.size() > 0) {
|
||||
shopUserDutyDetailMapper.batchInsert(detaiList);
|
||||
@@ -295,7 +299,9 @@ public class DutyService {
|
||||
ShopUserDutyDetail shopUserDutyDetail = new ShopUserDutyDetail();
|
||||
shopUserDutyDetail.setDutyId(shopUserDuty.getId());
|
||||
shopUserDutyDetail.setAmount(orderDetail.getPriceAmount());
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum().intValue());
|
||||
shopUserDutyDetail.setSkuId(orderDetail.getProductSkuId());
|
||||
shopUserDutyDetail.setSkuName(orderDetail.getProductSkuName());
|
||||
shopUserDutyDetail.setProductId(orderDetail.getProductId());
|
||||
@@ -326,14 +332,16 @@ public class DutyService {
|
||||
for (TbOrderDetail orderDetail : list) {
|
||||
if (map.containsKey(orderDetail.getProductSkuId())) {
|
||||
ShopUserDutyDetail shopUserDutyDetail = map.get(orderDetail.getProductSkuId());
|
||||
shopUserDutyDetail.setNum(shopUserDutyDetail.getNum() + orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
shopUserDutyDetail.setNum(shopUserDutyDetail.getNum() + orderDetail.getNum().intValue());
|
||||
shopUserDutyDetail.setAmount(shopUserDutyDetail.getAmount().add(orderDetail.getPriceAmount().add(orderDetail.getPackAmount())));
|
||||
shopUserDutyDetailMapper.updateByPrimaryKeySelective(shopUserDutyDetail);
|
||||
} else {
|
||||
ShopUserDutyDetail shopUserDutyDetail = new ShopUserDutyDetail();
|
||||
shopUserDutyDetail.setDutyId(shopUserDuty.getId());
|
||||
shopUserDutyDetail.setAmount(orderDetail.getPriceAmount());
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum());
|
||||
// todo 修改为bigdecimal
|
||||
shopUserDutyDetail.setNum(orderDetail.getNum().intValue());
|
||||
shopUserDutyDetail.setSkuId(orderDetail.getProductSkuId());
|
||||
shopUserDutyDetail.setSkuName(orderDetail.getProductSkuName());
|
||||
shopUserDutyDetail.setProductId(orderDetail.getProductId());
|
||||
|
||||
@@ -4,6 +4,7 @@ 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 com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,5 +37,21 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||
*/
|
||||
List<TbCashierCart> selectCart(String useType, String masterId, Integer orderId, Integer shopId, TableConstant.OrderInfo.Status... statusList);
|
||||
|
||||
|
||||
/**
|
||||
* 根据就餐信息查询购物车信息
|
||||
* @param shopEatTypeInfoDTO 就餐信息
|
||||
* @return 购物车信息
|
||||
*/
|
||||
TbCashierCart selectOneCartByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer productId, Integer skuId, boolean isGift, boolean isTemp);
|
||||
|
||||
|
||||
/**
|
||||
* 根据店铺id和购物车id查询信息
|
||||
* @param shopId 店铺id
|
||||
* @param cartId 购物车id
|
||||
* @param statuses 状态
|
||||
*/
|
||||
TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,6 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
|
||||
* 根据订单id删除详情
|
||||
* @param orderId 订单id
|
||||
*/
|
||||
boolean removeByOrderId(String orderId);
|
||||
boolean removeByOrderId(Integer orderId);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,7 @@ import com.chaozhanggui.system.cashierservice.bean.*;
|
||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ChoseCountDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnCartDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.OrderPo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo;
|
||||
@@ -145,7 +142,39 @@ public class OrderService {
|
||||
this.mpCashierCartService = mpCashierCartService;
|
||||
}
|
||||
|
||||
private ShopEatTypeInfoDTO checkEatModel(Integer shopId, String eatModel) {
|
||||
/**
|
||||
* 校验就餐模式是否存在并返回就餐类型信息
|
||||
*
|
||||
* @param tableId 台桌id
|
||||
* @param shopId 店铺id
|
||||
* @return 就餐类型信息
|
||||
*/
|
||||
public ShopEatTypeInfoDTO checkEatModel(Object shopId, String tableId) {
|
||||
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
return getShopEatTypeInfoDTO(shopId, eatModel, tableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验就餐模式是否存在并返回就餐类型信息
|
||||
*
|
||||
* @param tableId 台桌id
|
||||
* @param shopId 店铺id
|
||||
* @return 就餐类型信息
|
||||
*/
|
||||
public ShopEatTypeInfoDTO checkEatModel(Object shopId, String tableId, String useType) {
|
||||
String eatModel = OrderUseTypeEnum.TAKEOUT.getValue().equals(useType) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
return getShopEatTypeInfoDTO(shopId, eatModel, tableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过店铺id和就餐模式获取当前店铺的就餐类型信息
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param eatModel 就餐模式
|
||||
* @param tableId 台桌id
|
||||
* @return just餐类型信息
|
||||
*/
|
||||
private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel, String tableId) {
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
|
||||
.eq(TbShopInfo::getId, shopId)
|
||||
.eq(TbShopInfo::getStatus, 1));
|
||||
@@ -153,38 +182,42 @@ public class OrderService {
|
||||
throw new MsgException("店铺信息不存在");
|
||||
}
|
||||
|
||||
if (!"take-out".equals(eatModel) && !shopInfo.getEatModel().contains(eatModel)) {
|
||||
if (!shopInfo.getEatModel().contains(eatModel)) {
|
||||
throw new MsgException("当前店铺未开启此就餐模式");
|
||||
}
|
||||
|
||||
boolean isTakeout = ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel);
|
||||
// 是否是快餐版/先付费
|
||||
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
|
||||
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
|
||||
|
||||
boolean isDineInAfter = !isMunchies && !isTakeout;
|
||||
boolean isDineInBefore = isMunchies && !isTakeout;
|
||||
boolean needSeatFee = !isTakeout && (shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0);
|
||||
boolean hasTable = StrUtil.isNotBlank(tableId);
|
||||
// 是否先付费
|
||||
boolean isDineInAfter = hasTable && !isMunchies && !isTakeout;
|
||||
// 是否后付费
|
||||
boolean isDineInBefore = hasTable && isMunchies && !isTakeout;
|
||||
// 是否无台桌
|
||||
boolean isNoneTable = !hasTable && !isTakeout;
|
||||
boolean isMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1;
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isMemberPrice, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(), isTakeout ? OrderSendTypeEnums.TAKE_SELF.getValue() : OrderSendTypeEnums.TABLE.getValue());
|
||||
boolean needSeatFee = !isTakeout && (shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0);
|
||||
boolean isIncrMasterId = isTakeout || isNoneTable;
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, isMemberPrice, shopInfo, isTakeout ? TableConstant.OrderInfo.UseType.TAKEOUT.getValue() :
|
||||
isDineInBefore ? TableConstant.OrderInfo.UseType.DINE_IN_BEFORE.getValue() : isNoneTable ? TableConstant.OrderInfo.UseType.NONE_TABLE.getValue() : TableConstant.OrderInfo.UseType.DINE_IN_AFTER.getValue(),
|
||||
shopId, tableId, isTakeout ? OrderSendTypeEnums.TAKE_SELF.getValue() : OrderSendTypeEnums.TABLE.getValue());
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result createCart(String masterId, Integer productId, Integer shopId, Integer skuId, Integer number,
|
||||
public Result createCart(String masterId, Integer productId, Integer shopId, Integer skuId, BigDecimal number,
|
||||
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, String tableId) {
|
||||
if (productId == null || skuId == null || number == null) {
|
||||
if (number == null) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
|
||||
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(shopId, eatModel);
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(shopId, tableId);
|
||||
|
||||
|
||||
// 台桌点单
|
||||
boolean isSeatCart = TableConstant.CashierCart.ID.equals(productId.toString());
|
||||
boolean isSeatCart = productId != null && TableConstant.CashierCart.ID.equals(productId.toString());
|
||||
if ((StrUtil.isNotBlank(tableId))) {
|
||||
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, tableId)
|
||||
@@ -193,17 +226,19 @@ public class OrderService {
|
||||
if (shopTable == null) {
|
||||
return Result.fail("台桌不处于开台或空闲状态");
|
||||
}
|
||||
if (shopEatTypeInfoDTO.isNeedSeatFee() && number > shopTable.getMaxCapacity() && isSeatCart) {
|
||||
if (shopEatTypeInfoDTO.isNeedSeatFee() && number.intValue() > shopTable.getMaxCapacity() && isSeatCart) {
|
||||
return Result.fail("当前台桌最大人数未: " + shopTable.getMaxCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> cartQuery = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
.eq(TbCashierCart::getSkuId, skuId)
|
||||
.eq(TbCashierCart::getProductId, productId)
|
||||
.in(TbCashierCart::getStatus, "create")
|
||||
.eq(TbCashierCart::getId, cartId);
|
||||
if (productId != null) {
|
||||
cartQuery.eq(TbCashierCart::getProductId, productId)
|
||||
.eq(TbCashierCart::getSkuId, skuId);
|
||||
}
|
||||
|
||||
TbCashierCart cart = mpCashierCartMapper.selectOne(cartQuery);
|
||||
|
||||
@@ -213,7 +248,7 @@ public class OrderService {
|
||||
}
|
||||
TbProduct product = null;
|
||||
TbProductSkuWithBLOBs skuWithBLOBs = null;
|
||||
if (!isSeatCart) {
|
||||
if (!isSeatCart && productId != null) {
|
||||
product = mpProductMapper.selectOne(new LambdaQueryWrapper<TbProduct>()
|
||||
.eq(TbProduct::getId, productId)
|
||||
.eq(TbProduct::getStatus, 1));
|
||||
@@ -235,11 +270,11 @@ public class OrderService {
|
||||
|
||||
// 首次加入购物车,并且拥有起售数,设置为起售数
|
||||
if (cart == null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0) {
|
||||
number = skuWithBLOBs.getSuit();
|
||||
number = BigDecimal.valueOf(skuWithBLOBs.getSuit());
|
||||
// 低于起售,删除商品
|
||||
} else if (cart != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number < skuWithBLOBs.getSuit()) {
|
||||
} else if (cart != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number.compareTo(BigDecimal.valueOf(skuWithBLOBs.getSuit())) < 0) {
|
||||
delCart(masterId, cartId);
|
||||
if (StrUtil.isNotBlank(cart.getOrderId()) && StrUtil.isNotBlank(cart.getTableId())) {
|
||||
if (cart.getOrderId() != null && StrUtil.isNotBlank(cart.getTableId())) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
|
||||
.eq(TbCashierCart::getShopId, cart.getShopId());
|
||||
@@ -270,7 +305,8 @@ public class OrderService {
|
||||
|
||||
// 校验库存
|
||||
if ("1".equals(product.getIsStock().toString())) {
|
||||
if (product.getStockNumber() - number < 0) {
|
||||
// todo 数量为浮点数,库存目前整数, 待同一
|
||||
if (product.getStockNumber() - number.intValue() < 0) {
|
||||
return Result.fail(CodeEnum.STOCKERROR);
|
||||
}
|
||||
}
|
||||
@@ -294,47 +330,15 @@ public class OrderService {
|
||||
|
||||
if (Objects.nonNull(cart)) {
|
||||
//查询现有规格商品
|
||||
if ("edit".equals(type) && !cart.getSkuId().equals(skuId.toString())) {
|
||||
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId.toString(), shopId.toString(), skuId.toString(), DateUtils.getDay(), uuid, tableId);
|
||||
if (Objects.nonNull(cashierCart)) {
|
||||
cashierCart.setNumber(cashierCart.getNumber() + number);
|
||||
cashierCart.setTotalNumber(cashierCart.getNumber() + number);
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCartMapper.updateByPrimaryKey(cashierCart);
|
||||
cashierCartMapper.deleteByPrimaryKey(cart.getId());
|
||||
cart = cashierCart;
|
||||
}
|
||||
} else {
|
||||
cart.setSkuId(skuId.toString());
|
||||
cart.setNumber(number);
|
||||
cart.setIsGift(isGift);
|
||||
cart.setIsPack(isPack);
|
||||
if (isPack.equals("false")) {
|
||||
cart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (!isSeatCart) {
|
||||
cart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
}else{
|
||||
cart.setPackFee(BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
if (isGift.equals("false")) {
|
||||
if (!isSeatCart) {
|
||||
cart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()).add(cart.getPackFee()));
|
||||
}else {
|
||||
cart.setTotalAmount(new BigDecimal(number).multiply(cart.getSalePrice()).add(cart.getPackFee()));
|
||||
}
|
||||
} else {
|
||||
cart.setTotalAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
cart.setTotalNumber(number);
|
||||
cart.setUuid(uuid);
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
||||
}
|
||||
cart.setNumber(number);
|
||||
cart.setIsGift(isGift);
|
||||
cart.setIsPack(isPack);
|
||||
cart.setTotalNumber(number);
|
||||
cart.resetTotalAmount();
|
||||
cart.setUuid(uuid);
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
||||
} else {
|
||||
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
||||
|
||||
TbCashierCart cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO);
|
||||
// 不存在新增
|
||||
if (Objects.isNull(cashierCart)) {
|
||||
@@ -350,7 +354,7 @@ public class OrderService {
|
||||
cashierCart.setMasterId(masterId);
|
||||
cashierCart.setUuid(uuid);
|
||||
cashierCart.setMerchantId(userId);
|
||||
cashierCart.setProductId(productId.toString());
|
||||
cashierCart.setProductId(productId == null ? null : productId.toString());
|
||||
if (skuWithBLOBs != null) {
|
||||
cashierCart.setSalePrice(skuWithBLOBs.getSalePrice());
|
||||
cashierCart.setSkuId(skuWithBLOBs.getId().toString());
|
||||
@@ -365,9 +369,9 @@ public class OrderService {
|
||||
cashierCart.setIsGift(isGift);
|
||||
if (isGift.equals("false")) {
|
||||
if (isSeatCart) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(cashierCart.getSalePrice()));
|
||||
}else {
|
||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
|
||||
cashierCart.setTotalAmount(number.multiply(cashierCart.getSalePrice()));
|
||||
} else {
|
||||
cashierCart.setTotalAmount(number.multiply(skuWithBLOBs.getSalePrice()));
|
||||
}
|
||||
} else {
|
||||
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||
@@ -376,7 +380,7 @@ public class OrderService {
|
||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (!isSeatCart) {
|
||||
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
cashierCart.setPackFee(number.multiply(product.getPackFee()));
|
||||
}
|
||||
cashierCart.setTotalAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee()));
|
||||
|
||||
@@ -391,18 +395,12 @@ public class OrderService {
|
||||
mpCashierCartMapper.insert(cashierCart);
|
||||
} else {
|
||||
if (type.equals("add")) {
|
||||
cashierCart.setNumber(cashierCart.getNumber() + number);
|
||||
cashierCart.setNumber(cashierCart.getNumber().add(number));
|
||||
} else {
|
||||
cashierCart.setNumber(number);
|
||||
}
|
||||
if (isPack.equals("false")) {
|
||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (!isSeatCart) {
|
||||
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
}
|
||||
}
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
|
||||
|
||||
cashierCart.resetTotalAmount();
|
||||
mpCashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
|
||||
@@ -500,8 +498,7 @@ public class OrderService {
|
||||
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||
}
|
||||
|
||||
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(Integer.valueOf(shopId), eatModel);
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(Integer.valueOf(shopId), tableId);
|
||||
String day = DateUtils.getDay();
|
||||
|
||||
String finalMasterId1 = masterId;
|
||||
@@ -522,7 +519,7 @@ public class OrderService {
|
||||
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
|
||||
AtomicReference<TbCashierCart> mealCashierCart = new AtomicReference<>();
|
||||
ArrayList<TbCashierCart> returnCashierCarts = new ArrayList<>();
|
||||
String orderId = null;
|
||||
Integer orderId = null;
|
||||
for (TbCashierCart cart : list) {
|
||||
if (cart.getOrderId() != null) {
|
||||
orderId = cart.getOrderId();
|
||||
@@ -531,7 +528,7 @@ public class OrderService {
|
||||
returnCashierCarts.add(cart);
|
||||
}
|
||||
cart.setPlaceNum(cart.getPlaceNum() == null ? 0 : cart.getPlaceNum());
|
||||
if (cart.getProductId().equals("-999")) {
|
||||
if (cart.getProductId() != null && cart.getProductId().equals("-999")) {
|
||||
mealCashierCart.set(cart);
|
||||
}
|
||||
}
|
||||
@@ -543,18 +540,18 @@ public class OrderService {
|
||||
// mpCashierCartService.updateStateByIds(Integer.valueOf(shopId), cartIds, TableConstant.Status.CLOSED);
|
||||
// mpOrderDetailService.updateStateByCartIds(Integer.valueOf(shopId), cartIds, TableConstant.Status.CLOSED);
|
||||
mpOrderDetailService.removeByCartIds(cartIds);
|
||||
if (StrUtil.isNotBlank(orderId)) {
|
||||
if (orderId != null) {
|
||||
mpOrderInfoService.removeById(orderId);
|
||||
// mpOrderInfoService.updateStateById(Integer.valueOf(shopId), Integer.valueOf(orderId), TableConstant.Status.CANCELLED);
|
||||
}
|
||||
|
||||
String finalMasterId = masterId;
|
||||
return Result.success(CodeEnum.SUCCESS, new HashMap<String, Object>(){{
|
||||
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("amount", new HashMap<String, Object>() {{
|
||||
put("packAmount", 0);
|
||||
put("productNum", 0);
|
||||
put("productSum", 0);
|
||||
@@ -586,7 +583,8 @@ public class OrderService {
|
||||
HashMap<String, Object> productNumMap = new HashMap<>();
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
productNumMap.putIfAbsent(cashierCart.getProductId() + cashierCart.getSkuId(), 1);
|
||||
productSum += cashierCart.getNumber();
|
||||
// todo 数量为浮点数
|
||||
productSum += cashierCart.getNumber().intValue();
|
||||
if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
|
||||
masterId = cashierCart.getMasterId();
|
||||
}
|
||||
@@ -597,18 +595,23 @@ public class OrderService {
|
||||
if (cashierCart.getIsPack().equals("true") && !isReturn) {
|
||||
packAmount = packAmount.add(cashierCart.getPackFee());
|
||||
}
|
||||
TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
if (Objects.nonNull(skuWithBLOBs)) {
|
||||
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
|
||||
}
|
||||
TbProductWithBLOBs tbProduct = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if (Objects.nonNull(tbProduct)) {
|
||||
cashierCart.setSelectSpec(tbProduct.getSelectSpec());
|
||||
if (tbProduct.getSpecId() != null) {
|
||||
TbProductSpec tbProductSpec = tbProductSpecMapper.selectByPrimaryKey(tbProduct.getSpecId());
|
||||
cashierCart.setTbProductSpec(tbProductSpec);
|
||||
|
||||
if (cashierCart.getIsTemporary() == null || cashierCart.getIsTemporary() == 0) {
|
||||
TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
if (Objects.nonNull(skuWithBLOBs)) {
|
||||
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
|
||||
}
|
||||
|
||||
TbProductWithBLOBs tbProduct = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if (Objects.nonNull(tbProduct)) {
|
||||
// cashierCart.setSelectSpec(tbProduct.getSelectSpec());
|
||||
if (tbProduct.getSpecId() != null) {
|
||||
TbProductSpec tbProductSpec = tbProductSpecMapper.selectByPrimaryKey(tbProduct.getSpecId());
|
||||
// cashierCart.setTbProductSpec(tbProductSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
map.put("masterId", masterId);
|
||||
@@ -631,8 +634,7 @@ public class OrderService {
|
||||
return Result.fail(CARTEXIST);
|
||||
}
|
||||
|
||||
String eatModel = StrUtil.isBlank(cashierCart.getTableId()) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(Integer.valueOf(cashierCart.getShopId()), eatModel);
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(Integer.valueOf(cashierCart.getShopId()), cashierCart.getTableId());
|
||||
|
||||
// 校验是否是代客下单往期订单
|
||||
if (shopEatTypeInfoDTO.isDineInAfter() && cashierCart.getPlaceNum() != null) {
|
||||
@@ -643,24 +645,24 @@ public class OrderService {
|
||||
return Result.success(CodeEnum.SUCCESS, returnCart(dto));
|
||||
}
|
||||
|
||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if (ObjectUtil.isEmpty(product)) {
|
||||
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
||||
if (cashierCart.getIsTemporary() == null || cashierCart.getIsTemporary() == 0) {
|
||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if (ObjectUtil.isEmpty(product)) {
|
||||
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
||||
}
|
||||
|
||||
// 数量减少, 返还库存
|
||||
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
|
||||
if (message != null) {
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), new BigDecimal(message));
|
||||
}
|
||||
}
|
||||
|
||||
// 数量减少, 返还库存
|
||||
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
|
||||
if (message != null) {
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Integer.parseInt(message));
|
||||
}
|
||||
|
||||
List<String> skuIds = new ArrayList<>();
|
||||
skuIds.add(cashierCart.getSkuId());
|
||||
cashierCartMapper.deleteByPrimaryKey(cartId);
|
||||
|
||||
if (StrUtil.isNotBlank(cashierCart.getOrderId()) && StrUtil.isNotBlank(cashierCart.getTableId())) {
|
||||
if (cashierCart.getOrderId() != null && StrUtil.isNotBlank(cashierCart.getTableId())) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
|
||||
.eq(TbCashierCart::getShopId, cashierCart.getShopId());
|
||||
@@ -684,8 +686,8 @@ public class OrderService {
|
||||
if (list.isEmpty()) {
|
||||
ThreadUtil.execute(() -> {
|
||||
log.info("购物车数量改变,开始校验订单是否为空");
|
||||
printMechineConsumer.printReturnTicket(Integer.valueOf(cashierCart.getOrderId()), null);
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
|
||||
printMechineConsumer.printReturnTicket(cashierCart.getOrderId(), null);
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(cashierCart.getOrderId());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -752,11 +754,9 @@ public class OrderService {
|
||||
throw new MsgException("店铺信息不存在");
|
||||
}
|
||||
|
||||
ShopEatTypeInfoDTO eatTypeInfoDTO = checkEatModel(orderVo.getShopId(), orderVo.getTableId());
|
||||
|
||||
orderVo.setEatModel(StrUtil.isBlank(orderVo.getTableId()) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue());
|
||||
ShopEatTypeInfoDTO eatTypeInfoDTO = checkEatModel(orderVo.getShopId(), orderVo.getEatModel());
|
||||
|
||||
if (ShopInfoEatModelEnum.DINE_IN.getValue().equals(orderVo.getEatModel()) && StrUtil.isBlank(orderVo.getEatModel())) {
|
||||
if (ShopInfoEatModelEnum.DINE_IN.getValue().equals(eatTypeInfoDTO.getUseType()) && StrUtil.isBlank(eatTypeInfoDTO.getUseType())) {
|
||||
throw new MsgException("店内就餐必须选择桌码");
|
||||
}
|
||||
|
||||
@@ -827,12 +827,12 @@ public class OrderService {
|
||||
Integer orderId = null;
|
||||
int cartCount = 0;
|
||||
for (TbCashierCart cart : list) {
|
||||
if (StrUtil.isNotBlank(cart.getOrderId())) {
|
||||
orderId = Integer.valueOf(cart.getOrderId());
|
||||
if (cart.getOrderId() != null) {
|
||||
orderId = cart.getOrderId();
|
||||
}
|
||||
cashierIds.add(cart.getId());
|
||||
if ("-999".equals(cart.getProductId())) {
|
||||
mealNum = cart.getNumber();
|
||||
mealNum = cart.getNumber().intValue();
|
||||
}
|
||||
|
||||
if (TableConstant.OrderInfo.Status.CREATE.equalsVals(cart.getStatus()) && !TableConstant.CashierCart.ID.equals(cart.getProductId())) {
|
||||
@@ -874,24 +874,24 @@ public class OrderService {
|
||||
}
|
||||
|
||||
TbOrderDetail orderDetail = null;
|
||||
if (StrUtil.isNotBlank(cashierCart.getOrderId())) {
|
||||
orderDetail = oldOrderDetailMap.get(cashierCart.getOrderId() + cashierCart.getId());
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderDetail = oldOrderDetailMap.get(cashierCart.getOrderId().toString() + cashierCart.getId());
|
||||
}
|
||||
|
||||
if (orderDetail == null) {
|
||||
orderDetail = new TbOrderDetail();
|
||||
// 已经加入修改了库存数量,返还或减少库存
|
||||
addOrderDetailList.add(orderDetail);
|
||||
if (!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
|
||||
if (!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) && cashierCart.getIsTemporary() == 0) {
|
||||
productService.decrStock(cashierCart.getProductId(), cashierCart.getSkuId(), cashierCart.getNumber());
|
||||
}
|
||||
} else {
|
||||
if (!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
|
||||
int subVal = cashierCart.getNumber() - orderDetail.getNum();
|
||||
if (!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) && cashierCart.getIsTemporary() == 0) {
|
||||
BigDecimal subVal = cashierCart.getNumber().subtract(orderDetail.getNum());
|
||||
// 减少了数量
|
||||
if (subVal < 0) {
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Math.abs(subVal));
|
||||
} else if (subVal > 0) {
|
||||
if (subVal.compareTo(BigDecimal.ZERO) < 0) {
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), subVal.abs());
|
||||
} else if (subVal.compareTo(BigDecimal.ZERO) > 0) {
|
||||
productService.decrStock(cashierCart.getProductId(), cashierCart.getSkuId(), subVal);
|
||||
}
|
||||
}
|
||||
@@ -900,22 +900,26 @@ public class OrderService {
|
||||
if (orderDetail.getPlaceNum() == null) {
|
||||
orderDetail.setPlaceNum(currentPlaceNum);
|
||||
}
|
||||
|
||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if ("takeaway".equals(orderVo.getSendType()) || "takeself".equals(orderVo.getSendType())) {
|
||||
if (Objects.nonNull(product.getPackFee())) {
|
||||
packAMount = packAMount.add(product.getPackFee());
|
||||
orderDetail.setPackAmount(product.getPackFee());
|
||||
TbProductSkuWithBLOBs tbProduct = null;
|
||||
TbProductWithBLOBs product = null;
|
||||
if (cashierCart.getIsTemporary() == 0) {
|
||||
product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if ("takeaway".equals(orderVo.getSendType()) || "takeself".equals(orderVo.getSendType())) {
|
||||
if (Objects.nonNull(product.getPackFee())) {
|
||||
packAMount = packAMount.add(product.getPackFee());
|
||||
orderDetail.setPackAmount(product.getPackFee());
|
||||
}
|
||||
}
|
||||
tbProduct = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
if (Objects.nonNull(tbProduct)) {
|
||||
saleAmount = saleAmount.add(tbProduct.getSalePrice());
|
||||
}
|
||||
orderDetail.setProductSkuName(tbProduct == null ? null : tbProduct.getSpecSnap());
|
||||
}
|
||||
|
||||
TbProductSkuWithBLOBs tbProduct = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||
|
||||
feeAmount = cashierCart.getPackFee();
|
||||
if (Objects.nonNull(tbProduct)) {
|
||||
saleAmount = saleAmount.add(tbProduct.getSalePrice());
|
||||
}
|
||||
|
||||
|
||||
if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
|
||||
saleAmount = saleAmount.add(shopInfo.getTableFee());
|
||||
@@ -926,17 +930,18 @@ public class OrderService {
|
||||
orderDetail.setNum(cashierCart.getNumber());
|
||||
orderDetail.setPrice(cashierCart.getSalePrice());
|
||||
orderDetail.setPriceAmount(cashierCart.getTotalAmount());
|
||||
orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId()));
|
||||
orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId()));
|
||||
orderDetail.setProductSkuName(tbProduct == null ? null : tbProduct.getSpecSnap());
|
||||
if (cashierCart.getIsTemporary() == 0) {
|
||||
orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId()));
|
||||
orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId()));
|
||||
}
|
||||
orderDetail.setProductName(cashierCart.getName());
|
||||
orderDetail.setShopId(orderVo.getShopId());
|
||||
orderDetail.setStatus("unpaid");
|
||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||
orderDetail.setUseType(cashierCart.getUseType());
|
||||
orderDetail.setCartId(cashierCart.getId());
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderId = cashierCart.getOrderId();
|
||||
}
|
||||
orderDetail.setIsMember(cashierCart.getIsMember());
|
||||
|
||||
@@ -944,8 +949,11 @@ public class OrderService {
|
||||
|
||||
|
||||
// 库存预警校验
|
||||
if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
|
||||
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(tbProduct, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber()));
|
||||
if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) && cashierCart.getIsTemporary() == 0) {
|
||||
// todo 修改为bigdecimal
|
||||
TbProductSkuWithBLOBs finalTbProduct = tbProduct;
|
||||
TbProductWithBLOBs finalProduct = product;
|
||||
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(finalTbProduct, finalProduct, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber().intValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,10 +1279,10 @@ public class OrderService {
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if ("true".equals(cartVo.getStatus())) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(product.getPackFee())));
|
||||
cashierCart.setPackFee(new BigDecimal(cashierCart.getTotalNumber()).multiply(product.getPackFee()));
|
||||
cashierCart.setTotalAmount(cashierCart.getTotalNumber().multiply(cashierCart.getSalePrice().add(product.getPackFee())));
|
||||
cashierCart.setPackFee(cashierCart.getTotalNumber().multiply(product.getPackFee()));
|
||||
} else {
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice()));
|
||||
cashierCart.setTotalAmount(cashierCart.getTotalNumber().multiply(cashierCart.getSalePrice()));
|
||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||
}
|
||||
cashierCart.setIsPack(cartVo.getStatus());
|
||||
@@ -1287,8 +1295,7 @@ public class OrderService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result clearCart(CartVo cartVo) {
|
||||
String day = DateUtils.getDay();
|
||||
String eatModel = StrUtil.isBlank(cartVo.getTableId()) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(cartVo.getShopId(), eatModel);
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(cartVo.getShopId(), cartVo.getTableId());
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, cartVo.getShopId())
|
||||
@@ -1321,8 +1328,8 @@ public class OrderService {
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
TbCashierCart cart = null;
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
if (StrUtil.isNotBlank(cashierCart.getOrderId())) {
|
||||
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderId = cashierCart.getOrderId();
|
||||
cart = cashierCart;
|
||||
}
|
||||
|
||||
@@ -1331,7 +1338,7 @@ public class OrderService {
|
||||
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
if (message != null) {
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Integer.parseInt(message));
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), new BigDecimal(message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,7 +1500,7 @@ public class OrderService {
|
||||
|
||||
TbOrderDetail orderDetail = orderDetailMapper.selectByOrderIdAndSkuId(orderId, Integer.valueOf(cashierCart.getSkuId()));
|
||||
if (Objects.nonNull(orderDetail)) {
|
||||
orderDetail.setNum(orderDetail.getNum() + cashierCart.getNumber());
|
||||
orderDetail.setNum(orderDetail.getNum().add(cashierCart.getNumber()));
|
||||
orderDetail.setPriceAmount(orderDetail.getPriceAmount().add(cashierCart.getTotalAmount()));
|
||||
orderDetail.setPackAmount(orderDetail.getPackAmount().add(cashierCart.getPackFee()));
|
||||
modityOrderDetails.add(orderDetail);
|
||||
@@ -1512,8 +1519,8 @@ public class OrderService {
|
||||
orderDetail.setStatus("unpaid");
|
||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||
masterId = cashierCart.getMasterId();
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderId = cashierCart.getOrderId();
|
||||
}
|
||||
}
|
||||
orderDetails.add(orderDetail);
|
||||
@@ -1571,10 +1578,10 @@ public class OrderService {
|
||||
}
|
||||
boolean flag = true;
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
flag = false;
|
||||
}
|
||||
cashierCart.setOrderId(orderId + "");
|
||||
cashierCart.setOrderId(orderId);
|
||||
cashierCart.setStatus("closed");
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
||||
@@ -1835,7 +1842,7 @@ public class OrderService {
|
||||
|
||||
public Object choseCount(ChoseCountDTO choseCountDTO) {
|
||||
return Utils.runFunAndCheckKey(() -> {
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(choseCountDTO.getShopId(), ShopInfoEatModelEnum.DINE_IN.getValue());
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(choseCountDTO.getShopId(), "八嘎");
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(choseCountDTO.getShopId());
|
||||
if (shopInfo == null) throw new NotPrintException("店铺信息不存在");
|
||||
|
||||
@@ -1880,15 +1887,15 @@ public class OrderService {
|
||||
tbCashierCart.setProductId("-999");
|
||||
tbCashierCart.setSkuId("-999");
|
||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||
tbCashierCart.setNumber(choseCountDTO.getNum());
|
||||
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
|
||||
tbCashierCart.setNumber(BigDecimal.valueOf(choseCountDTO.getNum()));
|
||||
tbCashierCart.setTotalNumber(BigDecimal.valueOf(choseCountDTO.getNum()));
|
||||
tbCashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
|
||||
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||
mpCashierCartMapper.insert(tbCashierCart);
|
||||
} else {
|
||||
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
|
||||
tbCashierCart.setNumber(choseCountDTO.getNum());
|
||||
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
|
||||
tbCashierCart.setNumber(BigDecimal.valueOf(choseCountDTO.getNum()));
|
||||
tbCashierCart.setTotalNumber(BigDecimal.valueOf(choseCountDTO.getNum()));
|
||||
mpCashierCartMapper.updateById(tbCashierCart);
|
||||
}
|
||||
|
||||
@@ -2025,4 +2032,64 @@ public class OrderService {
|
||||
.set(TbShopTable::getUpdatedAt, System.currentTimeMillis())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 临时菜添加
|
||||
*
|
||||
* @param temporaryDishesDTO 临时菜信息
|
||||
*/
|
||||
public Object addTemporaryDishes(AddTemporaryDishesDTO temporaryDishesDTO) {
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(temporaryDishesDTO.getShopId(), temporaryDishesDTO.getTableId());
|
||||
|
||||
TbCashierCart tbCashierCart = mpCashierCartService.selectOneCartByShopEatType(shopEatTypeInfoDTO, temporaryDishesDTO.getMasterId(), null, null, false, true);
|
||||
// 首次加入
|
||||
if (tbCashierCart == null) {
|
||||
tbCashierCart = new TbCashierCart();
|
||||
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||
tbCashierCart.setCreatedAt(System.currentTimeMillis());
|
||||
tbCashierCart.setIsSku("0");
|
||||
if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) {
|
||||
tbCashierCart.setTableId(shopEatTypeInfoDTO.getTableId());
|
||||
}
|
||||
tbCashierCart.setName(temporaryDishesDTO.getName());
|
||||
tbCashierCart.setSalePrice(temporaryDishesDTO.getPrice());
|
||||
tbCashierCart.setMasterId(temporaryDishesDTO.getMasterId());
|
||||
tbCashierCart.setShopId(String.valueOf(temporaryDishesDTO.getShopId()));
|
||||
tbCashierCart.setTradeDay(DateUtils.getDay());
|
||||
tbCashierCart.setStatus("create");
|
||||
tbCashierCart.setIsPack("false");
|
||||
tbCashierCart.setIsGift("false");
|
||||
tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice()));
|
||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||
tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum());
|
||||
tbCashierCart.setNumber(temporaryDishesDTO.getNum());
|
||||
tbCashierCart.setCategoryId(String.valueOf(temporaryDishesDTO.getCategoryId()));
|
||||
tbCashierCart.setNote(temporaryDishesDTO.getNote());
|
||||
tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue());
|
||||
tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && temporaryDishesDTO.getVipUserId() != null ? 1 : 0);
|
||||
tbCashierCart.setIsTemporary(1);
|
||||
tbCashierCart.setUnit(temporaryDishesDTO.getUnit());
|
||||
mpCashierCartService.save(tbCashierCart);
|
||||
|
||||
} else {
|
||||
tbCashierCart.setIsMember(temporaryDishesDTO.getVipUserId() == null ? 0 : 1);
|
||||
tbCashierCart.setNote(temporaryDishesDTO.getNote());
|
||||
tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice()));
|
||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||
tbCashierCart.setIsPack("false");
|
||||
tbCashierCart.setIsGift("false");
|
||||
tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum());
|
||||
tbCashierCart.setNumber(temporaryDishesDTO.getNum());
|
||||
tbCashierCart.setUpdatedAt(DateUtil.date().getTime());
|
||||
tbCashierCart.setIsTemporary(1);
|
||||
tbCashierCart.setUnit(temporaryDishesDTO.getUnit());
|
||||
mpCashierCartService.updateById(tbCashierCart);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(temporaryDishesDTO.getTableId())) {
|
||||
setRedisTableCartInfo(temporaryDishesDTO.getTableId(), temporaryDishesDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true);
|
||||
}
|
||||
return tbCashierCart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,313 +1151,314 @@ public class PayService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result returnOrder(List<TbOrderDetail> list, String token, String pwd, boolean isOnline) {
|
||||
if (ObjectUtil.isEmpty(list) || list.size() <= 0) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
|
||||
|
||||
Integer orderId = list.get(0).getOrderId();
|
||||
|
||||
String remark = list.get(0).getRemark();
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
if (ObjectUtil.isEmpty(orderInfo) || orderInfo.getStatus().equals("refund")) {
|
||||
return Result.fail(CodeEnum.ORDERSTATUSERROR);
|
||||
}
|
||||
|
||||
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
||||
|
||||
|
||||
if ("1".equals(shopInfo.getIsReturn())) {
|
||||
if (ObjectUtil.isEmpty(pwd)) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
|
||||
|
||||
TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
|
||||
if (Objects.isNull(account)) {
|
||||
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
||||
}
|
||||
if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
|
||||
return Result.fail(CodeEnum.PWDNOSET);
|
||||
}
|
||||
if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
|
||||
return Result.fail(CodeEnum.PWDERROE);
|
||||
}
|
||||
}
|
||||
|
||||
List<TbOrderDetail> orderDetails = tbOrderDetailMapper.selectAllByOrderIdAndStatus(list, orderId.toString());
|
||||
|
||||
|
||||
String merchantId = orderInfo.getMerchantId();
|
||||
String shopId = orderInfo.getShopId();
|
||||
String day = DateUtils.getDay();
|
||||
String masterId = orderInfo.getMasterId();
|
||||
String payType = orderInfo.getPayType();
|
||||
String orderNo = generateReturnOrderNumber();
|
||||
if (!isOnline) {
|
||||
orderNo = "XX" + orderNo;
|
||||
}
|
||||
BigDecimal orderAmount = orderInfo.getPayAmount();
|
||||
|
||||
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
BigDecimal packAMount = BigDecimal.ZERO;
|
||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
BigDecimal feeAmount = BigDecimal.ZERO;
|
||||
BigDecimal payAmount = BigDecimal.ZERO;
|
||||
|
||||
List<OrderDetailPo> detailPos = new ArrayList<>();
|
||||
// //判断是否全量退款
|
||||
// if(list.size()==orderDetails.size()){
|
||||
// //修改主单状态
|
||||
// orderInfo.setStatus("rhandoverprintDataefund");
|
||||
// orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
// if (ObjectUtil.isEmpty(list) || list.size() <= 0) {
|
||||
// return Result.fail(CodeEnum.PARAM);
|
||||
// }
|
||||
|
||||
List<TbOrderDetail> returnDetail = new ArrayList<>();
|
||||
|
||||
// List<ReturnWTZInfo.ReturnDetail> details=new ArrayList<>();
|
||||
|
||||
Map<Integer, Integer> map1 = new HashMap<>();
|
||||
for (TbOrderDetail orderDetail : list) {
|
||||
if (Objects.isNull(orderDetail.getNum())) {
|
||||
map1.put(orderDetail.getId(), 0);
|
||||
} else {
|
||||
map1.put(orderDetail.getId(), orderDetail.getNum());
|
||||
}
|
||||
}
|
||||
for (TbOrderDetail it : orderDetails) {
|
||||
it = tbOrderDetailMapper.selectByPrimaryKey(it.getId());
|
||||
if (it.getStatus().equals("closed")) {
|
||||
if (it.getStatus().equals("refund")) {
|
||||
continue;
|
||||
}
|
||||
if (map1.get(it.getId()) > it.getNum() - it.getReturnNum()) {
|
||||
return Result.fail("可退数量:" + (it.getNum() - it.getReturnNum()));
|
||||
}
|
||||
if (map1.get(it.getId()) == 0) {
|
||||
map1.put(it.getId(), it.getNum());
|
||||
}
|
||||
OrderDetailPo detailPo = new OrderDetailPo();
|
||||
// totalAmount = totalAmount.add(it.getPriceAmount());
|
||||
totalAmount = totalAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
saleAmount = saleAmount.add(it.getPrice());
|
||||
|
||||
payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
|
||||
.multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
//
|
||||
// payAmount=payAmount.add(it.getPriceAmount());
|
||||
packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
|
||||
detailPo.setId(it.getId());
|
||||
if (map1.get(it.getId()) + it.getReturnNum() >= it.getNum()) {
|
||||
detailPo.setStatus("refund");
|
||||
} else {
|
||||
detailPo.setStatus("closed");
|
||||
|
||||
}
|
||||
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));
|
||||
|
||||
detailPo.setReturnNum(map1.get(it.getId()));
|
||||
detailPos.add(detailPo);
|
||||
it.setNum(map1.get(it.getId()));
|
||||
it.setReturnNum(0);
|
||||
it.setPriceAmount(returnAmount);
|
||||
it.setStatus("closed");
|
||||
it.setCreateTime(new Date());
|
||||
it.setUpdateTime(null);
|
||||
returnDetail.add(it);
|
||||
|
||||
// details.add(new ReturnWTZInfo.ReturnDetail(it.getId()+"",it.getProductSkuId()+"",it.getNum()+""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TbOrderInfo newOrderInfo = new TbOrderInfo(orderNo, totalAmount, packAMount, totalAmount, saleAmount, totalAmount, feeAmount, orderInfo.getTableId(),
|
||||
"table", "return", merchantId, shopId,
|
||||
"", (byte) 1, day, masterId, "refund", payAmount, orderInfo.getPayType(), orderInfo.getTableName());
|
||||
|
||||
// 线上退款
|
||||
if (isOnline) {
|
||||
if ("scanCode".equals(payType) || "wx_lite".equals(payType)) {
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(merchantId));
|
||||
MsgException.checkNull(thirdApply, "支付参数配置错误");
|
||||
|
||||
if ("ysk".equals(thirdPayType)) {
|
||||
ReturnOrderReq req = new ReturnOrderReq();
|
||||
req.setAppId(thirdApply.getAppId());
|
||||
req.setTimestamp(System.currentTimeMillis());
|
||||
req.setOrderNumber(orderInfo.getPayOrderNo());
|
||||
req.setAmount(String.format("%.2f", newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||
req.setMercRefundNo(orderInfo.getOrderNo());
|
||||
req.setRefundReason("退货");
|
||||
req.setPayPassword(thirdApply.getPayPassword());
|
||||
Map<String, Object> map = BeanUtil.transBean2Map(req);
|
||||
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
log.info("merchantOrderReturn req:{}", JSONUtil.toJsonStr(req));
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(gateWayUrl.concat("merchantOrder/returnOrder"), req, String.class);
|
||||
log.info("merchantOrderReturn:{}", response.getBody());
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
if (!object.get("code").equals("0")) {
|
||||
MsgException.check(true, "退款渠道调用失败");
|
||||
}
|
||||
// newOrderInfo.setPayOrderNo(object.getJSONObject("data").getString("refundOrderNumber"));
|
||||
}
|
||||
} else {
|
||||
|
||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(String.valueOf(orderId));
|
||||
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(),
|
||||
newOrderInfo.getOrderNo(), payment.getTradeNumber(), null, "订单退款",
|
||||
newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
||||
|
||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
if ("000000".equals(publicResp.getCode())) {
|
||||
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
|
||||
MsgException.check(true, "退款渠道调用失败");
|
||||
}
|
||||
} else {
|
||||
MsgException.check(true, "退款渠道调用失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if ("deposit".equals(payType)) {
|
||||
TbShopUser user = tbShopUserMapper.selectByUserIdAndShopId(orderInfo.getUserId(), orderInfo.getShopId());
|
||||
if (ObjectUtil.isNull(user) || ObjectUtil.isEmpty(user)) {
|
||||
user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNull(user) || ObjectUtil.isEmpty(user)) {
|
||||
return Result.fail(ACCOUNTEIXST);
|
||||
}
|
||||
|
||||
if (!user.getShopId().equals(orderInfo.getShopId())) {
|
||||
return Result.fail(ACCOUNTEIXST);
|
||||
}
|
||||
|
||||
|
||||
newOrderInfo.setMemberId(orderInfo.getMemberId());
|
||||
newOrderInfo.setUserId(orderInfo.getUserId());
|
||||
|
||||
user.setAmount(user.getAmount().add(newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||
user.setConsumeAmount(user.getConsumeAmount().subtract(newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||
user.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(user);
|
||||
|
||||
|
||||
TbShopUserFlow flow = new TbShopUserFlow();
|
||||
flow.setShopUserId(user.getId());
|
||||
flow.setBizCode("accountReturnPay");
|
||||
flow.setBizName("会员储值卡退款");
|
||||
flow.setType("+");
|
||||
flow.setAmount(newOrderInfo.getPayAmount());
|
||||
flow.setBalance(user.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
flow.setIsReturn("0");
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
JSONObject baObj = new JSONObject();
|
||||
baObj.put("userId", user.getUserId());
|
||||
baObj.put("shopId", user.getShopId());
|
||||
baObj.put("amount", newOrderInfo.getPayAmount());
|
||||
baObj.put("balance", user.getAmount());
|
||||
baObj.put("type", "退款");
|
||||
baObj.put("time", flow.getCreateTime());
|
||||
producer.balance(baObj.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否修改主单状态
|
||||
BigDecimal returnAmount = tbOrderDetailMapper.selectByOrderId(orderId.toString());
|
||||
if (N.egt(returnAmount.add(payAmount), orderAmount)) {
|
||||
orderInfo.setStatus("refund");
|
||||
}
|
||||
|
||||
|
||||
orderInfo.setRemark(remark);
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
//添加退单数据
|
||||
newOrderInfo.setSource(orderId);
|
||||
tbOrderInfoMapper.insert(newOrderInfo);
|
||||
|
||||
//更新子单表
|
||||
if (ObjectUtil.isNotEmpty(detailPos) && detailPos.size() > 0) {
|
||||
tbOrderDetailMapper.updateBatchOrderDetail(detailPos);
|
||||
}
|
||||
|
||||
//添加子表信息
|
||||
if (ObjectUtil.isNotEmpty(returnDetail) && returnDetail.size() > 0) {
|
||||
tbOrderDetailMapper.batchInsert(returnDetail, newOrderInfo.getId().toString());
|
||||
}
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("type", "return");
|
||||
jsonObject.put("orderId", 0);
|
||||
jsonObject.put("amount", newOrderInfo.getPayAmount());
|
||||
// jsonObject.put("data",new ReturnWTZInfo(orderId+"",newOrderInfo.getPayAmount(),details));
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
|
||||
producer.printMechine(newOrderInfo.getId().toString());
|
||||
|
||||
|
||||
//修改耗材数据
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("orderId", newOrderInfo.getId());
|
||||
jsonObject1.put("type", "delete");
|
||||
producer.cons(jsonObject1.toString());
|
||||
|
||||
// 更新商品库存
|
||||
for (TbOrderDetail detail : returnDetail) {
|
||||
detail = tbOrderDetailMapper.selectByPrimaryKey(detail.getId());
|
||||
|
||||
TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId());
|
||||
TbProductWithBLOBs product = productMapper.selectByPrimaryKey(detail.getProductId());
|
||||
|
||||
TbProductStockDetail tbProductStockDetail = new TbProductStockDetail();
|
||||
tbProductStockDetail.setCreatedAt(System.currentTimeMillis());
|
||||
tbProductStockDetail.setUpdatedAt(System.currentTimeMillis());
|
||||
tbProductStockDetail.setShopId(detail.getShopId().toString());
|
||||
tbProductStockDetail.setSourcePath("NORMAL");
|
||||
tbProductStockDetail.setType("退单");
|
||||
tbProductStockDetail.setSubType((byte) 1);
|
||||
tbProductStockDetail.setRemark("退单: " + detail.getOrderId());
|
||||
tbProductStockDetail.setOrderId(String.valueOf(detail.getOrderId()));
|
||||
|
||||
if (ObjectUtil.isNotEmpty(product)) {
|
||||
TbShopUnit shopUnit = shopUnitMapper.selectByPrimaryKey(Integer.valueOf(product.getUnitId()));
|
||||
|
||||
tbProductStockDetail.setProductName(product.getName());
|
||||
tbProductStockDetail.setIsStock(product.getIsStock());
|
||||
tbProductStockDetail.setStockSnap(product.getSelectSpec());
|
||||
tbProductStockDetail.setUnitName(shopUnit.getName());
|
||||
tbProductStockDetail.setProductId(product.getId().toString());
|
||||
|
||||
productMapper.updateStockById(product.getId(), detail.getReturnNum() * -1);
|
||||
|
||||
tbProductStockDetail.setLeftNumber(product.getStockNumber());
|
||||
tbProductStockDetail.setStockNumber(Double.valueOf(detail.getReturnNum()));
|
||||
productSkuMapper.decrRealSalesNumber(productSku.getId(), detail.getReturnNum());
|
||||
}
|
||||
|
||||
productStockDetailMapper.insert(tbProductStockDetail);
|
||||
}
|
||||
redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + orderInfo.getShopId() + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
|
||||
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
//
|
||||
// Integer orderId = list.get(0).getOrderId();
|
||||
//
|
||||
// String remark = list.get(0).getRemark();
|
||||
//
|
||||
// TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
// if (ObjectUtil.isEmpty(orderInfo) || orderInfo.getStatus().equals("refund")) {
|
||||
// return Result.fail(CodeEnum.ORDERSTATUSERROR);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
||||
//
|
||||
//
|
||||
// if ("1".equals(shopInfo.getIsReturn())) {
|
||||
// if (ObjectUtil.isEmpty(pwd)) {
|
||||
// return Result.fail(CodeEnum.PARAM);
|
||||
// }
|
||||
// String accountId = TokenUtil.parseParamFromToken(token).getString("accountId");
|
||||
//
|
||||
// TbmerchantAccount account = tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(accountId));
|
||||
// if (Objects.isNull(account)) {
|
||||
// return Result.fail(CodeEnum.ACCOUNTEIXST);
|
||||
// }
|
||||
// if (Objects.isNull(account.getPwd()) || ObjectUtil.isEmpty(account.getPwd())) {
|
||||
// return Result.fail(CodeEnum.PWDNOSET);
|
||||
// }
|
||||
// if (!account.getPwd().equals(MD5Util.encrypt(pwd.concat(account.getAccount()).concat(account.getId().toString())))) {
|
||||
// return Result.fail(CodeEnum.PWDERROE);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<TbOrderDetail> orderDetails = tbOrderDetailMapper.selectAllByOrderIdAndStatus(list, orderId.toString());
|
||||
//
|
||||
//
|
||||
// String merchantId = orderInfo.getMerchantId();
|
||||
// String shopId = orderInfo.getShopId();
|
||||
// String day = DateUtils.getDay();
|
||||
// String masterId = orderInfo.getMasterId();
|
||||
// String payType = orderInfo.getPayType();
|
||||
// String orderNo = generateReturnOrderNumber();
|
||||
// if (!isOnline) {
|
||||
// orderNo = "XX" + orderNo;
|
||||
// }
|
||||
// BigDecimal orderAmount = orderInfo.getPayAmount();
|
||||
//
|
||||
//
|
||||
// BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
// BigDecimal packAMount = BigDecimal.ZERO;
|
||||
// BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
// BigDecimal feeAmount = BigDecimal.ZERO;
|
||||
// BigDecimal payAmount = BigDecimal.ZERO;
|
||||
//
|
||||
// List<OrderDetailPo> detailPos = new ArrayList<>();
|
||||
//// //判断是否全量退款
|
||||
//// if(list.size()==orderDetails.size()){
|
||||
//// //修改主单状态
|
||||
//// orderInfo.setStatus("rhandoverprintDataefund");
|
||||
//// orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
//// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//// }
|
||||
//
|
||||
// List<TbOrderDetail> returnDetail = new ArrayList<>();
|
||||
//
|
||||
//// List<ReturnWTZInfo.ReturnDetail> details=new ArrayList<>();
|
||||
//
|
||||
// Map<Integer, BigDecimal> map1 = new HashMap<>();
|
||||
// for (TbOrderDetail orderDetail : list) {
|
||||
// if (Objects.isNull(orderDetail.getNum())) {
|
||||
// map1.put(orderDetail.getId(), 0);
|
||||
// } else {
|
||||
// map1.put(orderDetail.getId(), orderDetail.getNum());
|
||||
// }
|
||||
// }
|
||||
// for (TbOrderDetail it : orderDetails) {
|
||||
// it = tbOrderDetailMapper.selectByPrimaryKey(it.getId());
|
||||
// if (it.getStatus().equals("closed")) {
|
||||
// if (it.getStatus().equals("refund")) {
|
||||
// continue;
|
||||
// }
|
||||
// if (map1.get(it.getId()).compareTo(it.getNum().subtract(it.getReturnNum())) < 0) {
|
||||
// return Result.fail("可退数量:" + (it.getNum().subtract(it.getReturnNum())));
|
||||
// }
|
||||
// if (map1.get(it.getId()) == 0) {
|
||||
// map1.put(it.getId(), it.getNum());
|
||||
// }
|
||||
// OrderDetailPo detailPo = new OrderDetailPo();
|
||||
//// totalAmount = totalAmount.add(it.getPriceAmount());
|
||||
// totalAmount = totalAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
// saleAmount = saleAmount.add(it.getPrice());
|
||||
//
|
||||
// payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
|
||||
// .multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
////
|
||||
//// payAmount=payAmount.add(it.getPriceAmount());
|
||||
// packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
//
|
||||
// detailPo.setId(it.getId());
|
||||
// if (map1.get(it.getId()) + it.getReturnNum() >= it.getNum()) {
|
||||
// detailPo.setStatus("refund");
|
||||
// } else {
|
||||
// detailPo.setStatus("closed");
|
||||
//
|
||||
// }
|
||||
// BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));
|
||||
//
|
||||
// detailPo.setReturnNum(map1.get(it.getId()));
|
||||
// detailPos.add(detailPo);
|
||||
// it.setNum(map1.get(it.getId()));
|
||||
// it.setReturnNum(0);
|
||||
// it.setPriceAmount(returnAmount);
|
||||
// it.setStatus("closed");
|
||||
// it.setCreateTime(new Date());
|
||||
// it.setUpdateTime(null);
|
||||
// returnDetail.add(it);
|
||||
//
|
||||
//// details.add(new ReturnWTZInfo.ReturnDetail(it.getId()+"",it.getProductSkuId()+"",it.getNum()+""));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// TbOrderInfo newOrderInfo = new TbOrderInfo(orderNo, totalAmount, packAMount, totalAmount, saleAmount, totalAmount, feeAmount, orderInfo.getTableId(),
|
||||
// "table", "return", merchantId, shopId,
|
||||
// "", (byte) 1, day, masterId, "refund", payAmount, orderInfo.getPayType(), orderInfo.getTableName());
|
||||
//
|
||||
// // 线上退款
|
||||
// if (isOnline) {
|
||||
// if ("scanCode".equals(payType) || "wx_lite".equals(payType)) {
|
||||
// TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(merchantId));
|
||||
// MsgException.checkNull(thirdApply, "支付参数配置错误");
|
||||
//
|
||||
// if ("ysk".equals(thirdPayType)) {
|
||||
// ReturnOrderReq req = new ReturnOrderReq();
|
||||
// req.setAppId(thirdApply.getAppId());
|
||||
// req.setTimestamp(System.currentTimeMillis());
|
||||
// req.setOrderNumber(orderInfo.getPayOrderNo());
|
||||
// req.setAmount(String.format("%.2f", newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||
// req.setMercRefundNo(orderInfo.getOrderNo());
|
||||
// req.setRefundReason("退货");
|
||||
// req.setPayPassword(thirdApply.getPayPassword());
|
||||
// Map<String, Object> map = BeanUtil.transBean2Map(req);
|
||||
// req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
// log.info("merchantOrderReturn req:{}", JSONUtil.toJsonStr(req));
|
||||
// ResponseEntity<String> response = restTemplate.postForEntity(gateWayUrl.concat("merchantOrder/returnOrder"), req, String.class);
|
||||
// log.info("merchantOrderReturn:{}", response.getBody());
|
||||
// if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
// JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
// if (!object.get("code").equals("0")) {
|
||||
// MsgException.check(true, "退款渠道调用失败");
|
||||
// }
|
||||
//// newOrderInfo.setPayOrderNo(object.getJSONObject("data").getString("refundOrderNumber"));
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(String.valueOf(orderId));
|
||||
// PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(),
|
||||
// newOrderInfo.getOrderNo(), payment.getTradeNumber(), null, "订单退款",
|
||||
// newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
||||
//
|
||||
// if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
// if ("000000".equals(publicResp.getCode())) {
|
||||
// if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
|
||||
// MsgException.check(true, "退款渠道调用失败");
|
||||
// }
|
||||
// } else {
|
||||
// MsgException.check(true, "退款渠道调用失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// } else if ("deposit".equals(payType)) {
|
||||
// TbShopUser user = tbShopUserMapper.selectByUserIdAndShopId(orderInfo.getUserId(), orderInfo.getShopId());
|
||||
// if (ObjectUtil.isNull(user) || ObjectUtil.isEmpty(user)) {
|
||||
// user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (ObjectUtil.isNull(user) || ObjectUtil.isEmpty(user)) {
|
||||
// return Result.fail(ACCOUNTEIXST);
|
||||
// }
|
||||
//
|
||||
// if (!user.getShopId().equals(orderInfo.getShopId())) {
|
||||
// return Result.fail(ACCOUNTEIXST);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// newOrderInfo.setMemberId(orderInfo.getMemberId());
|
||||
// newOrderInfo.setUserId(orderInfo.getUserId());
|
||||
//
|
||||
// user.setAmount(user.getAmount().add(newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||
// user.setConsumeAmount(user.getConsumeAmount().subtract(newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
|
||||
// user.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbShopUserMapper.updateByPrimaryKeySelective(user);
|
||||
//
|
||||
//
|
||||
// TbShopUserFlow flow = new TbShopUserFlow();
|
||||
// flow.setShopUserId(user.getId());
|
||||
// flow.setBizCode("accountReturnPay");
|
||||
// flow.setBizName("会员储值卡退款");
|
||||
// flow.setType("+");
|
||||
// flow.setAmount(newOrderInfo.getPayAmount());
|
||||
// flow.setBalance(user.getAmount());
|
||||
// flow.setCreateTime(new Date());
|
||||
// flow.setIsReturn("0");
|
||||
// tbShopUserFlowMapper.insert(flow);
|
||||
//
|
||||
//
|
||||
// JSONObject baObj = new JSONObject();
|
||||
// baObj.put("userId", user.getUserId());
|
||||
// baObj.put("shopId", user.getShopId());
|
||||
// baObj.put("amount", newOrderInfo.getPayAmount());
|
||||
// baObj.put("balance", user.getAmount());
|
||||
// baObj.put("type", "退款");
|
||||
// baObj.put("time", flow.getCreateTime());
|
||||
// producer.balance(baObj.toString());
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //判断是否修改主单状态
|
||||
// BigDecimal returnAmount = tbOrderDetailMapper.selectByOrderId(orderId.toString());
|
||||
// if (N.egt(returnAmount.add(payAmount), orderAmount)) {
|
||||
// orderInfo.setStatus("refund");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// orderInfo.setRemark(remark);
|
||||
// orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// //添加退单数据
|
||||
// newOrderInfo.setSource(orderId);
|
||||
// tbOrderInfoMapper.insert(newOrderInfo);
|
||||
//
|
||||
// //更新子单表
|
||||
// if (ObjectUtil.isNotEmpty(detailPos) && detailPos.size() > 0) {
|
||||
// tbOrderDetailMapper.updateBatchOrderDetail(detailPos);
|
||||
// }
|
||||
//
|
||||
// //添加子表信息
|
||||
// if (ObjectUtil.isNotEmpty(returnDetail) && returnDetail.size() > 0) {
|
||||
// tbOrderDetailMapper.batchInsert(returnDetail, newOrderInfo.getId().toString());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("token", token);
|
||||
// jsonObject.put("type", "return");
|
||||
// jsonObject.put("orderId", 0);
|
||||
// jsonObject.put("amount", newOrderInfo.getPayAmount());
|
||||
//// jsonObject.put("data",new ReturnWTZInfo(orderId+"",newOrderInfo.getPayAmount(),details));
|
||||
// producer.putOrderCollect(jsonObject.toJSONString());
|
||||
//
|
||||
//
|
||||
// producer.printMechine(newOrderInfo.getId().toString());
|
||||
//
|
||||
//
|
||||
// //修改耗材数据
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.put("orderId", newOrderInfo.getId());
|
||||
// jsonObject1.put("type", "delete");
|
||||
// producer.cons(jsonObject1.toString());
|
||||
//
|
||||
// // 更新商品库存
|
||||
// for (TbOrderDetail detail : returnDetail) {
|
||||
// detail = tbOrderDetailMapper.selectByPrimaryKey(detail.getId());
|
||||
//
|
||||
// TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId());
|
||||
// TbProductWithBLOBs product = productMapper.selectByPrimaryKey(detail.getProductId());
|
||||
//
|
||||
// TbProductStockDetail tbProductStockDetail = new TbProductStockDetail();
|
||||
// tbProductStockDetail.setCreatedAt(System.currentTimeMillis());
|
||||
// tbProductStockDetail.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbProductStockDetail.setShopId(detail.getShopId().toString());
|
||||
// tbProductStockDetail.setSourcePath("NORMAL");
|
||||
// tbProductStockDetail.setType("退单");
|
||||
// tbProductStockDetail.setSubType((byte) 1);
|
||||
// tbProductStockDetail.setRemark("退单: " + detail.getOrderId());
|
||||
// tbProductStockDetail.setOrderId(String.valueOf(detail.getOrderId()));
|
||||
//
|
||||
// if (ObjectUtil.isNotEmpty(product)) {
|
||||
// TbShopUnit shopUnit = shopUnitMapper.selectByPrimaryKey(Integer.valueOf(product.getUnitId()));
|
||||
//
|
||||
// tbProductStockDetail.setProductName(product.getName());
|
||||
// tbProductStockDetail.setIsStock(product.getIsStock());
|
||||
// tbProductStockDetail.setStockSnap(product.getSelectSpec());
|
||||
// tbProductStockDetail.setUnitName(shopUnit.getName());
|
||||
// tbProductStockDetail.setProductId(product.getId().toString());
|
||||
//
|
||||
// productMapper.updateStockById(product.getId(), detail.getReturnNum() * -1);
|
||||
//
|
||||
// tbProductStockDetail.setLeftNumber(product.getStockNumber());
|
||||
// tbProductStockDetail.setStockNumber(Double.valueOf(detail.getReturnNum()));
|
||||
// productSkuMapper.decrRealSalesNumber(productSku.getId(), detail.getReturnNum());
|
||||
// }
|
||||
//
|
||||
// productStockDetailMapper.insert(tbProductStockDetail);
|
||||
// }
|
||||
// redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + orderInfo.getShopId() + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
|
||||
//
|
||||
//
|
||||
// return Result.success(CodeEnum.SUCCESS);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Result quickPay(String token, String amount, String authCode, String payType) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@@ -147,11 +148,11 @@ public class ProductService {
|
||||
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||
}
|
||||
|
||||
public void incrStock(String productId, String skuId, int addNum) {
|
||||
public void incrStock(String productId, String skuId, BigDecimal addNum) {
|
||||
tbProductMapper.incrStock(productId, addNum);
|
||||
}
|
||||
|
||||
public void decrStock(String productId, String skuId, int decrNum) {
|
||||
public void decrStock(String productId, String skuId, BigDecimal decrNum) {
|
||||
TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(productId));
|
||||
if (product.getIsStock() == 1) {
|
||||
if (tbProductMapper.decrStock(productId, decrNum) < 1) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
@@ -9,6 +10,7 @@ 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.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.MpCashierCartService;
|
||||
@@ -59,5 +61,43 @@ public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, T
|
||||
}
|
||||
return list(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbCashierCart selectOneCartByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer productId, Integer skuId, boolean isGift, boolean isTemp) {
|
||||
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
|
||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||
.isNull(TbCashierCart::getPlaceNum)
|
||||
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
||||
.eq(TbCashierCart::getStatus, "create")
|
||||
.eq(TbCashierCart::getIsGift, isGift)
|
||||
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
|
||||
if (isTemp) {
|
||||
query.isNull(TbCashierCart::getProductId).isNull(TbCashierCart::getSkuId).eq(TbCashierCart::getIsTemporary, 1);
|
||||
}else {
|
||||
query.eq(TbCashierCart::getProductId, productId)
|
||||
.eq(TbCashierCart::getSkuId, skuId);
|
||||
}
|
||||
|
||||
// 外带只查询pc和收银机商品
|
||||
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||
query.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||
.in(TbCashierCart::getPlatformType, "pc", "cash");
|
||||
} else {
|
||||
query.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId());
|
||||
}
|
||||
|
||||
return getOne(query);
|
||||
}
|
||||
@Override
|
||||
public TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
.eq(TbCashierCart::getId, cartId);
|
||||
if (statuses.length != 0) {
|
||||
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
|
||||
}
|
||||
return getOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<MPOrderDetailMapper, T
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeByOrderId(String orderId) {
|
||||
public boolean removeByOrderId(Integer orderId) {
|
||||
return remove(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user