diff --git a/pom.xml b/pom.xml
index 3debfd4..41b1491 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,7 @@
1.0.0
+ true
8
8
UTF-8
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/bean/constant/TableConstant.java b/src/main/java/com/chaozhanggui/system/cashierservice/bean/constant/TableConstant.java
index 672e01e..33f77d9 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/bean/constant/TableConstant.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/bean/constant/TableConstant.java
@@ -20,6 +20,23 @@ public interface TableConstant {
}
}
+ class Product {
+ @Getter
+ public enum Type {
+ NORMAL("normal"), PACKAGE("package");
+ private final String value;
+
+ Type(String value) {
+ this.value = value;
+ }
+
+ public boolean equalsVals(String value) {
+ return this.value.equals(value);
+ }
+
+ }
+ }
+
class ShopTable {
@Getter
public enum State {
@@ -32,6 +49,18 @@ public interface TableConstant {
}
}
+ class ThirdPartyCoupon {
+ @Getter
+ public enum Plat {
+ MEI_TUAN("meituan");
+ private final String value;
+
+ Plat(String value) {
+ this.value = value;
+ }
+ }
+ }
+
class OrderInfo {
@Getter
public enum Status {
@@ -51,7 +80,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) {
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java
index 7bd5a51..436b46c 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/OrderController.java
@@ -4,9 +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.ChoseCountDTO;
-import com.chaozhanggui.system.cashierservice.entity.dto.ReturnCartDTO;
-import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
+import com.chaozhanggui.system.cashierservice.entity.dto.*;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.service.OrderService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
@@ -18,6 +16,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
@@ -42,9 +42,34 @@ public class OrderController {
String userId = jsonObject.getString("accountId");
return orderService.createCart(cartVo.getMasterId(), cartVo.getProductId(), cartVo.getShopId(), cartVo.getSkuId(),
cartVo.getNumber(), userId, clientType, cartVo.getCartId(), cartVo.getIsGift(),
- cartVo.getIsPack(), cartVo.getUuid(), cartVo.getType(), cartVo.getTableId());
+ cartVo.getIsPack(), cartVo.getUuid(), cartVo.getType(), cartVo.getTableId(), cartVo.getIsPrint(), cartVo.getGroupProductIdList());
}
+ @PutMapping("/print")
+ public Result print(@RequestBody CartPrintDTO printDTO) {
+ return orderService.updatePrint(printDTO);
+ }
+
+ @PostMapping("/temporaryDishes")
+ public Result addTemporaryDishes(@Valid @RequestBody AddTemporaryDishesDTO temporaryDishesDTO) {
+ return Result.success(CodeEnum.SUCCESS, orderService.addTemporaryDishes(temporaryDishesDTO));
+ }
+ /**
+ * 美团核销
+ */
+ @PostMapping("checkCoupon")
+ public Result checkCoupon(@Validated @RequestBody ThirdCouponCheckDTO checkDTO) {
+ return Result.success(CodeEnum.SUCCESS, orderService.checkCoupon(checkDTO));
+ }
+
+
+ @PutMapping("/updatePrice")
+ public Result updatePrice(@Valid @RequestBody UpdatePriceDTO updatePriceDTO) {
+ return Result.success(CodeEnum.SUCCESS, orderService.updatePrice(updatePriceDTO));
+ }
+
+
+
@GetMapping("/queryCart")
public Result queryCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
index 1d4dfa6..87c7fa0 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PayController.java
@@ -16,6 +16,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
+import com.chaozhanggui.system.cashierservice.entity.dto.ReturnOrderDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
import com.chaozhanggui.system.cashierservice.model.PaymentReq;
import com.chaozhanggui.system.cashierservice.service.PayService;
@@ -34,10 +35,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
@CrossOrigin(origins = "*")
@RestController
@@ -196,6 +194,7 @@ public class PayController {
return result;
}
+
/**
* 会员支付
*
@@ -246,7 +245,20 @@ public class PayController {
@RequestBody List list,
@RequestParam("pwd") String pwd,
@RequestParam(defaultValue = "true") boolean isOnline) {
- return payService.returnOrder(list, token, pwd, isOnline);
+ ReturnOrderDTO returnOrderDTO = new ReturnOrderDTO();
+ returnOrderDTO.setOrderId(list.get(0).getOrderId());
+ returnOrderDTO.setNote(list.get(0).getRemark());
+ returnOrderDTO.setPwd(pwd);
+ ArrayList orderDetails = new ArrayList<>();
+ list.forEach(item -> {
+ ReturnOrderDTO.OrderDetail orderDetail = new ReturnOrderDTO.OrderDetail();
+ orderDetail.setId(item.getId());
+ orderDetail.setNum(item.getNum());
+ orderDetails.add(orderDetail);
+ });
+ returnOrderDTO.setOrderDetails(orderDetails);
+ returnOrderDTO.setIsOnline(isOnline);
+ return Result.success(CodeEnum.SUCCESS, payService.returnOrder(returnOrderDTO));
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ShopUnitController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ShopUnitController.java
new file mode 100644
index 0000000..c6f431d
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ShopUnitController.java
@@ -0,0 +1,25 @@
+package com.chaozhanggui.system.cashierservice.controller;
+
+import com.chaozhanggui.system.cashierservice.service.TbShopUnitService;
+import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
+import com.chaozhanggui.system.cashierservice.sign.Result;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/unit")
+public class ShopUnitController {
+ private final TbShopUnitService shopUnitService;
+
+ public ShopUnitController(TbShopUnitService shopUnitService) {
+ this.shopUnitService = shopUnitService;
+ }
+
+ @GetMapping
+ public Result getShopUnit(@RequestParam Integer shopId, @RequestParam(defaultValue = "1") Integer page,
+ @RequestParam(defaultValue = "20") Integer size, @RequestParam(required = false) String name) {
+ return Result.success(CodeEnum.SUCCESS, shopUnitService.getShopUnit(shopId, page, size, name));
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ThirdPartyCouponController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ThirdPartyCouponController.java
new file mode 100644
index 0000000..d4ccc79
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ThirdPartyCouponController.java
@@ -0,0 +1,78 @@
+package com.chaozhanggui.system.cashierservice.controller;
+
+import com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon.CheckCouponDTO;
+import com.chaozhanggui.system.cashierservice.service.ThirdPartyCouponService;
+import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
+import com.chaozhanggui.system.cashierservice.sign.Result;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * 三方团购券
+ */
+@RestController
+@RequestMapping("/thirdPartyCoupon")
+public class ThirdPartyCouponController {
+
+ private final ThirdPartyCouponService thirdPartyCouponService;
+
+ public ThirdPartyCouponController(ThirdPartyCouponService thirdPartyCouponService) {
+ this.thirdPartyCouponService = thirdPartyCouponService;
+ }
+
+ /**
+ * 获取绑定状态
+ * @return 绑定状态
+ */
+ @GetMapping("/state")
+ public Result getState(@RequestParam Integer shopId) {
+ return Result.success(CodeEnum.SUCCESS, thirdPartyCouponService.getState(shopId));
+ }
+
+ /**
+ * 获取美团绑定链接
+ * @return 美团绑定链接
+ */
+ @GetMapping("bindUrl")
+ public Result getBindUrl(@RequestParam Integer shopId) {
+ return Result.success(CodeEnum.SUCCESS, thirdPartyCouponService.getBindUrl(shopId));
+ }
+
+ /**
+ * 解绑美团商家
+ * @return 美团解绑链接
+ */
+ @GetMapping("unBindUrl")
+ public Result getUnBindUrl(@RequestParam Integer shopId) {
+ return Result.success(CodeEnum.SUCCESS, thirdPartyCouponService.getUnBindUrl(shopId));
+ }
+
+ /**
+ * 获取门店客核销券
+ * @return 所有券
+ */
+ @GetMapping("list")
+ public Result getActivateCoupon(@RequestParam Integer shopId, @RequestParam String code) {
+ return Result.success(CodeEnum.SUCCESS, thirdPartyCouponService.getActivateCoupon(shopId, code));
+ }
+
+ /**
+ * 核销券
+ */
+ @PostMapping
+ public Result checkCoupon(@RequestBody CheckCouponDTO checkCouponDTO) {
+ return Result.success(CodeEnum.SUCCESS, thirdPartyCouponService.checkCoupon(checkCouponDTO));
+ }
+
+ /**
+ * 撤销券核销
+ */
+ @DeleteMapping("revoke")
+ public Result revokeCoupon(@RequestBody CheckCouponDTO checkCouponDTO) {
+ return Result.success(CodeEnum.SUCCESS, thirdPartyCouponService.revokeCoupon(checkCouponDTO));
+ }
+
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java
index 945b156..b700813 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord;
import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
import org.springframework.data.domain.Pageable;
import java.util.List;
@@ -64,5 +65,10 @@ public interface TbActivateInRecordMapper {
*/
int deleteById(Integer id);
+
+ @Update("update tb_activate_in_record" +
+ " set over_num = #{overNum}" +
+ " where id = #{id}")
+ int updateOverNum(@Param("id") Integer id, @Param("overNum") Integer overNum);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java
index 82baf85..f595382 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord;
import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
import org.springframework.data.domain.Pageable;
import java.util.List;
@@ -64,5 +65,10 @@ public interface TbActivateOutRecordMapper {
*/
int deleteById(Integer id);
+
+ @Update("update tb_activate_out_record" +
+ " set ref_num = ref_num + #{refNum}" +
+ " where id = #{id}")
+ int updateRefNum(@Param("id") Integer id, @Param("refNum") Integer refNum);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java
index b15b5e8..29711bd 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java
@@ -1,58 +1,40 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbProduct;
-import com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.po.ProConsSkuInfo;
-import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
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 {
- int deleteByPrimaryKey(Integer id);
- int insert(TbProductWithBLOBs record);
-
- int insertSelective(TbProductWithBLOBs record);
-
- TbProductWithBLOBs selectByPrimaryKey(Integer id);
-
- int updateByPrimaryKeySelective(TbProductWithBLOBs record);
-
- int updateByPrimaryKeyWithBLOBs(TbProductWithBLOBs record);
-
- int updateByPrimaryKey(TbProduct record);
-
-
- List selectByShopId(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
- List selectByShopIdAndCheckGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
-
-
-
- List selectByShopIdAndShopType(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
- List selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
- List selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
+ TbProduct selectByPrimaryKey(Integer id);
+ List selectByShopId(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
+ List selectByShopIdAndCheckGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
+ List selectByShopIdAndShopType(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
+ List selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
+ List selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day, @Param("tableId") String tableId);
-
+ @Update("update tb_product set stock_number = stock_number - #{num,jdbcType=INTEGER} where id = #{productId}")
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
List 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);
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/OrderVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/OrderVo.java
index de982e9..031f7b0 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/OrderVo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/OrderVo.java
@@ -19,8 +19,6 @@ public class OrderVo {
private Integer type;
private String sendType;
-
- private String eatModel;
@Min(1)
private Integer seatNum;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
index 7c5abc9..8d778c6 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java
@@ -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,64 +33,147 @@ 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 Integer isPrint;
+ private String useCouponInfo;
+ private int isThirdCoupon;
+ private String proGroupInfo;
+ private String typeEnum;
+ private Integer groupType;
- @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));
+ }
/**
* 根据是否会员充值价格
*/
public void resetTotalAmount() {
+ if (isThirdCoupon == 1) {
+ totalAmount = BigDecimal.ZERO;
+ return;
+ }
if ("false".equals(isPack)) {
packFee = BigDecimal.ZERO;
}
if ("true".equals(isGift)) {
totalAmount = packFee;
- }else {
+ } else {
+ discountSaleAmount = discountSaleAmount == null ? BigDecimal.ZERO : discountSaleAmount;
+ BigDecimal subtract;
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);
+ subtract = memberPrice.subtract(discountSaleAmount);
+ } else {
+ subtract = salePrice.subtract(discountSaleAmount);
+ }
+ totalAmount = totalNumber.multiply(subtract.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : subtract).add(packFee).setScale(2, RoundingMode.DOWN);
+ }
+ }
+
+ /**
+ * 根据是否会员充值价格
+ */
+ public void resetTotalAmount(BigDecimal discountRadio) {
+ if (isThirdCoupon == 1) {
+ totalAmount = BigDecimal.ZERO;
+ return;
+ }
+ if (discountRadio == null) {
+ discountRadio = BigDecimal.ONE;
+ }
+ if ("false".equals(isPack)) {
+ packFee = BigDecimal.ZERO;
+ }
+ if ("true".equals(isGift)) {
+ totalAmount = packFee;
+ } else {
+ discountSaleAmount = discountSaleAmount == null ? BigDecimal.ZERO : discountSaleAmount;
+ BigDecimal subtract;
+ if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
+ subtract = memberPrice.subtract(discountSaleAmount);
+ totalAmount = totalNumber.multiply(subtract).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.DOWN);
+ } else {
+ subtract = salePrice.subtract(discountSaleAmount);
+ totalAmount = totalNumber.multiply(subtract)
+ .add(packFee).multiply(discountRadio).setScale(2, RoundingMode.DOWN);
}
}
}
+
+ /**
+ * 获取总价不包含打包费
+ *
+ */
+ public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) {
+ if (isThirdCoupon == 1) {
+ return BigDecimal.ZERO;
+ }
+ 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.DOWN);
+ }else {
+ return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.DOWN);
+ }
+// if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
+// return num.multiply(memberPrice);
+// } else {
+// return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice);
+// }
+ }
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPoints.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPoints.java
new file mode 100644
index 0000000..74006ef
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPoints.java
@@ -0,0 +1,72 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 会员积分
+ *
+ * @author Tankaikai tankaikai@aliyun.com
+ * @since 2.0 2024-10-25
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("tb_shop_user")
+public class TbMemberPoints {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * id
+ */
+ @TableId(type = IdType.AUTO)
+ private Long id;
+ /**
+ * 店铺id
+ */
+ private Long shopId;
+ /**
+ * 会员id
+ */
+ @TableField(value = "id", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
+ private Long memberId;
+ /**
+ * 会员名称
+ */
+ @TableField("name")
+ private String memberName;
+ /**
+ * 会员头像
+ */
+ @TableField("head_img")
+ private String avatarUrl;
+ /**
+ * 手机号码
+ */
+ @TableField("telephone")
+ private String mobile;
+ /**
+ * 账户积分
+ */
+ @TableField("account_points")
+ private Integer accountPoints;
+ /**
+ * 最近一次积分变动时间
+ */
+ @TableField("last_points_change_time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ private Date lastPointsChangeTime;
+ /**
+ * 最近一次浮动积分
+ */
+ @TableField("last_float_points")
+ private Integer lastFloatPoints;
+ /**
+ * 是否会员 1-是 0-否
+ */
+ @TableField("is_vip")
+ private Integer vip;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPointsLog.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPointsLog.java
new file mode 100644
index 0000000..42c3612
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbMemberPointsLog.java
@@ -0,0 +1,70 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 会员积分变动记录
+ *
+ * @author Tankaikai tankaikai@aliyun.com
+ * @since 2.0 2024-10-25
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("tb_member_points_log")
+public class TbMemberPointsLog {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * id
+ */
+ @TableId(type = IdType.AUTO)
+ private Long id;
+ /**
+ * 店铺id
+ */
+ private Long shopId;
+ /**
+ * 会员id
+ */
+ private Long memberId;
+ /**
+ * 会员名称
+ */
+ private String memberName;
+ /**
+ * 会员头像
+ */
+ private String avatarUrl;
+ /**
+ * 摘要信息(如:兑换某个商品/消费多少钱/充值多少钱/新会员赠送积分等)
+ */
+ private String content;
+ /**
+ * 订单编号
+ */
+ private String orderNo;
+ /**
+ * 手机号码
+ */
+ private String mobile;
+ /**
+ * 浮动类型 add-累加 subtract-扣减
+ */
+ private String floatType;
+ /**
+ * 浮动积分(非0正负数)
+ */
+ private Integer floatPoints;
+ /**
+ * 创建时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ private Date createTime;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java
index a37a3d0..52589da 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java
@@ -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;
@@ -50,4 +50,18 @@ public class TbOrderDetail implements Serializable {
private BigDecimal memberPrice;
private static final long serialVersionUID = 1L;
+ private Integer isMember;
+ private Integer isTemporary;
+ private Integer isThirdCoupon;
+ private Integer isWaitCall;
+ private Integer userCouponId;
+ private String useCouponInfo;
+ private BigDecimal canReturnAmount;
+ private BigDecimal returnAmount;
+ private Integer isPrint;
+
+ private BigDecimal discountSaleAmount;
+ private String discountSaleNote;
+ private String proGroupInfo;
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java
index afdf294..ffbf016 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderInfo.java
@@ -117,6 +117,11 @@ public class TbOrderInfo implements Serializable {
private static final long serialVersionUID = 1L;
private int isPostpaid;
+ private String couponInfoList;
+ private BigDecimal fullCouponDiscountAmount;
+ private BigDecimal pointsDiscountAmount;
+ private String refundRemark;
+ private Integer pointsNum;
public TbOrderInfo(){
super();
@@ -181,4 +186,6 @@ public class TbOrderInfo implements Serializable {
this.payType=payType;
this.tableName=tableName;
}
+
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java
index ce271d4..2f1a764 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProduct.java
@@ -1,11 +1,13 @@
package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
+import java.util.List;
@Data
public class TbProduct implements Serializable {
@@ -15,12 +17,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 +29,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;
@@ -151,5 +78,21 @@ public class TbProduct implements Serializable {
private static final long serialVersionUID = 1L;
+ private String images;
+ private String groupSnap;
+
+ @TableField(exist = false)
+ private List skuList;
+ @TableField(exist = false)
+ private Object groundingSpecInfo;
+ private String specInfo;
+ private String selectSpec;
+ private Integer groupType;
+ @TableField(exist = false)
+ private String unitName;
+ @Transient
+ @TableField(exist = false)
+ private List proGroupVo;
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductStockDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductStockDetail.java
index 1328ac2..bdda082 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductStockDetail.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductStockDetail.java
@@ -12,7 +12,7 @@ public class TbProductStockDetail implements Serializable {
private String productName;
- private Byte isStock;
+ private Integer isStock;
private String specSnap;
@@ -90,11 +90,11 @@ public class TbProductStockDetail implements Serializable {
this.productName = productName == null ? null : productName.trim();
}
- public Byte getIsStock() {
+ public Integer getIsStock() {
return isStock;
}
- public void setIsStock(Byte isStock) {
+ public void setIsStock(Integer isStock) {
this.isStock = isStock;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductWithBLOBs.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductWithBLOBs.java
deleted file mode 100644
index 3302de2..0000000
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProductWithBLOBs.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.chaozhanggui.system.cashierservice.entity;
-
-import lombok.Getter;
-
-import java.io.Serializable;
-import java.util.List;
-
-@Getter
-public class TbProductWithBLOBs extends TbProduct implements Serializable {
- private Object groundingSpecInfo;
- private String images;
-
- private String video;
-
- private String notice;
-
- private String groupSnap;
-
- private String specInfo;
-
- private String selectSpec;
-
- private List> skuList;
-
- private static final long serialVersionUID = 1L;
-
- public void setGroundingSpecInfo(Object groundingSpecInfo) {
- this.groundingSpecInfo = groundingSpecInfo;
- }
-
- public void setSkuList(List> skuList) {
- this.skuList = skuList;
- }
-
- public void setImages(String images) {
- this.images = images == null ? null : images.trim();
- }
-
- public void setVideo(String video) {
- this.video = video == null ? null : video.trim();
- }
-
- public void setNotice(String notice) {
- this.notice = notice == null ? null : notice.trim();
- }
-
- public void setGroupSnap(String groupSnap) {
- this.groupSnap = groupSnap == null ? null : groupSnap.trim();
- }
-
- public void setSpecInfo(String specInfo) {
- this.specInfo = specInfo == null ? null : specInfo.trim();
- }
-
- public void setSelectSpec(String selectSpec) {
- this.selectSpec = selectSpec == null ? null : selectSpec.trim();
- }
-}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java
index 2b3b263..34b5d4c 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java
@@ -1,107 +1,270 @@
package com.chaozhanggui.system.cashierservice.entity;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
+/**
+ * 商品单位
+ * @TableName tb_shop_unit
+ */
+@TableName(value ="tb_shop_unit")
public class TbShopUnit implements Serializable {
+ /**
+ * id
+ */
+ @TableId(type = IdType.AUTO)
private Integer id;
+ /**
+ * 单位名称
+ */
private String name;
+ /**
+ * 小数位(个数大于0,表示小数据精度位数)
+ */
private Integer decimalsDigits;
+ /**
+ * 单位类型(weight代表重量,小数单位,为number代表个数)
+ */
private String unitType;
- private Byte isSystem;
+ /**
+ * 0后台添加 -1系统默认 (公斤、瓶)
+ */
+ private Integer isSystem;
- private Byte status;
+ /**
+ * 预留字段1-正常
+ */
+ private Integer status;
+ /**
+ *
+ */
private String merchantId;
+ /**
+ * 店铺Id
+ */
private String shopId;
+ /**
+ *
+ */
private Long createdAt;
+ /**
+ *
+ */
private Long updatedAt;
+ @TableField(exist = false)
private static final long serialVersionUID = 1L;
+ /**
+ * id
+ */
public Integer getId() {
return id;
}
+ /**
+ * id
+ */
public void setId(Integer id) {
this.id = id;
}
+ /**
+ * 单位名称
+ */
public String getName() {
return name;
}
+ /**
+ * 单位名称
+ */
public void setName(String name) {
- this.name = name == null ? null : name.trim();
+ this.name = name;
}
+ /**
+ * 小数位(个数大于0,表示小数据精度位数)
+ */
public Integer getDecimalsDigits() {
return decimalsDigits;
}
+ /**
+ * 小数位(个数大于0,表示小数据精度位数)
+ */
public void setDecimalsDigits(Integer decimalsDigits) {
this.decimalsDigits = decimalsDigits;
}
+ /**
+ * 单位类型(weight代表重量,小数单位,为number代表个数)
+ */
public String getUnitType() {
return unitType;
}
+ /**
+ * 单位类型(weight代表重量,小数单位,为number代表个数)
+ */
public void setUnitType(String unitType) {
- this.unitType = unitType == null ? null : unitType.trim();
+ this.unitType = unitType;
}
- public Byte getIsSystem() {
+ /**
+ * 0后台添加 -1系统默认 (公斤、瓶)
+ */
+ public Integer getIsSystem() {
return isSystem;
}
- public void setIsSystem(Byte isSystem) {
+ /**
+ * 0后台添加 -1系统默认 (公斤、瓶)
+ */
+ public void setIsSystem(Integer isSystem) {
this.isSystem = isSystem;
}
- public Byte getStatus() {
+ /**
+ * 预留字段1-正常
+ */
+ public Integer getStatus() {
return status;
}
- public void setStatus(Byte status) {
+ /**
+ * 预留字段1-正常
+ */
+ public void setStatus(Integer status) {
this.status = status;
}
+ /**
+ *
+ */
public String getMerchantId() {
return merchantId;
}
+ /**
+ *
+ */
public void setMerchantId(String merchantId) {
- this.merchantId = merchantId == null ? null : merchantId.trim();
+ this.merchantId = merchantId;
}
+ /**
+ * 店铺Id
+ */
public String getShopId() {
return shopId;
}
+ /**
+ * 店铺Id
+ */
public void setShopId(String shopId) {
- this.shopId = shopId == null ? null : shopId.trim();
+ this.shopId = shopId;
}
+ /**
+ *
+ */
public Long getCreatedAt() {
return createdAt;
}
+ /**
+ *
+ */
public void setCreatedAt(Long createdAt) {
this.createdAt = createdAt;
}
+ /**
+ *
+ */
public Long getUpdatedAt() {
return updatedAt;
}
+ /**
+ *
+ */
public void setUpdatedAt(Long updatedAt) {
this.updatedAt = updatedAt;
}
+
+ @Override
+ public boolean equals(Object that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ if (getClass() != that.getClass()) {
+ return false;
+ }
+ TbShopUnit other = (TbShopUnit) that;
+ return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+ && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
+ && (this.getDecimalsDigits() == null ? other.getDecimalsDigits() == null : this.getDecimalsDigits().equals(other.getDecimalsDigits()))
+ && (this.getUnitType() == null ? other.getUnitType() == null : this.getUnitType().equals(other.getUnitType()))
+ && (this.getIsSystem() == null ? other.getIsSystem() == null : this.getIsSystem().equals(other.getIsSystem()))
+ && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
+ && (this.getMerchantId() == null ? other.getMerchantId() == null : this.getMerchantId().equals(other.getMerchantId()))
+ && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
+ && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
+ && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ result = prime * result + ((getDecimalsDigits() == null) ? 0 : getDecimalsDigits().hashCode());
+ result = prime * result + ((getUnitType() == null) ? 0 : getUnitType().hashCode());
+ result = prime * result + ((getIsSystem() == null) ? 0 : getIsSystem().hashCode());
+ result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
+ result = prime * result + ((getMerchantId() == null) ? 0 : getMerchantId().hashCode());
+ result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
+ result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
+ result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [");
+ sb.append("Hash = ").append(hashCode());
+ sb.append(", id=").append(id);
+ sb.append(", name=").append(name);
+ sb.append(", decimalsDigits=").append(decimalsDigits);
+ sb.append(", unitType=").append(unitType);
+ sb.append(", isSystem=").append(isSystem);
+ sb.append(", status=").append(status);
+ sb.append(", merchantId=").append(merchantId);
+ sb.append(", shopId=").append(shopId);
+ sb.append(", createdAt=").append(createdAt);
+ sb.append(", updatedAt=").append(updatedAt);
+ sb.append(", serialVersionUID=").append(serialVersionUID);
+ sb.append("]");
+ return sb.toString();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbThirdPartyCouponRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbThirdPartyCouponRecord.java
new file mode 100644
index 0000000..4332600
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbThirdPartyCouponRecord.java
@@ -0,0 +1,271 @@
+package com.chaozhanggui.system.cashierservice.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *
+ * @TableName tb_third_party_coupon_record
+ */
+@TableName(value ="tb_third_party_coupon_record")
+public class TbThirdPartyCouponRecord implements Serializable {
+ /**
+ *
+ */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 订单id
+ */
+ private Integer orderId;
+
+ /**
+ * 核销状态 1 成功
+ */
+ private Integer state;
+
+ /**
+ * 平台 meituan
+ */
+ private String plat;
+
+ /**
+ * 券码
+ */
+ private String code;
+
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+
+ /**
+ * 核销时间
+ */
+ private Date checkTime;
+
+ /**
+ * 店铺id
+ */
+ private Integer shopId;
+
+ /**
+ * 使用数量
+ */
+ private Integer num;
+
+ /**
+ * 抵扣的购物车id
+ */
+ private String cartIdList;
+
+ @TableField(exist = false)
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ *
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * 订单id
+ */
+ public Integer getOrderId() {
+ return orderId;
+ }
+
+ /**
+ * 订单id
+ */
+ public void setOrderId(Integer orderId) {
+ this.orderId = orderId;
+ }
+
+ /**
+ * 核销状态 1 成功
+ */
+ public Integer getState() {
+ return state;
+ }
+
+ /**
+ * 核销状态 1 成功
+ */
+ public void setState(Integer state) {
+ this.state = state;
+ }
+
+ /**
+ * 平台 meituan
+ */
+ public String getPlat() {
+ return plat;
+ }
+
+ /**
+ * 平台 meituan
+ */
+ public void setPlat(String plat) {
+ this.plat = plat;
+ }
+
+ /**
+ * 券码
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * 券码
+ */
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ /**
+ * 创建时间
+ */
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ /**
+ * 创建时间
+ */
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+
+ /**
+ * 核销时间
+ */
+ public Date getCheckTime() {
+ return checkTime;
+ }
+
+ /**
+ * 核销时间
+ */
+ public void setCheckTime(Date checkTime) {
+ this.checkTime = checkTime;
+ }
+
+ /**
+ * 店铺id
+ */
+ public Integer getShopId() {
+ return shopId;
+ }
+
+ /**
+ * 店铺id
+ */
+ public void setShopId(Integer shopId) {
+ this.shopId = shopId;
+ }
+
+ /**
+ * 使用数量
+ */
+ public Integer getNum() {
+ return num;
+ }
+
+ /**
+ * 使用数量
+ */
+ public void setNum(Integer num) {
+ this.num = num;
+ }
+
+ /**
+ * 抵扣的购物车id
+ */
+ public String getCartIdList() {
+ return cartIdList;
+ }
+
+ /**
+ * 抵扣的购物车id
+ */
+ public void setCartIdList(String cartIdList) {
+ this.cartIdList = cartIdList;
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ if (getClass() != that.getClass()) {
+ return false;
+ }
+ TbThirdPartyCouponRecord other = (TbThirdPartyCouponRecord) that;
+ return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+ && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
+ && (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
+ && (this.getPlat() == null ? other.getPlat() == null : this.getPlat().equals(other.getPlat()))
+ && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
+ && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+ && (this.getCheckTime() == null ? other.getCheckTime() == null : this.getCheckTime().equals(other.getCheckTime()))
+ && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
+ && (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum()))
+ && (this.getCartIdList() == null ? other.getCartIdList() == null : this.getCartIdList().equals(other.getCartIdList()));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+ result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
+ result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
+ result = prime * result + ((getPlat() == null) ? 0 : getPlat().hashCode());
+ result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
+ result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+ result = prime * result + ((getCheckTime() == null) ? 0 : getCheckTime().hashCode());
+ result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
+ result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode());
+ result = prime * result + ((getCartIdList() == null) ? 0 : getCartIdList().hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [");
+ sb.append("Hash = ").append(hashCode());
+ sb.append(", id=").append(id);
+ sb.append(", orderId=").append(orderId);
+ sb.append(", state=").append(state);
+ sb.append(", plat=").append(plat);
+ sb.append(", code=").append(code);
+ sb.append(", createTime=").append(createTime);
+ sb.append(", checkTime=").append(checkTime);
+ sb.append(", shopId=").append(shopId);
+ sb.append(", num=").append(num);
+ sb.append(", cartIdList=").append(cartIdList);
+ sb.append(", serialVersionUID=").append(serialVersionUID);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/AddTemporaryDishesDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/AddTemporaryDishesDTO.java
new file mode 100644
index 0000000..5f0ef51
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/AddTemporaryDishesDTO.java
@@ -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;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CartPrintDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CartPrintDTO.java
new file mode 100644
index 0000000..3b93f8d
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/CartPrintDTO.java
@@ -0,0 +1,14 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class CartPrintDTO {
+ @NotNull
+ private Integer shopId;
+ @NotNull
+ private Integer cartId;
+ private Integer isPrint;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderInfoCouponInfoDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderInfoCouponInfoDTO.java
new file mode 100644
index 0000000..b961219
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderInfoCouponInfoDTO.java
@@ -0,0 +1,14 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord;
+import lombok.Data;
+
+import java.util.Collection;
+import java.util.List;
+
+@Data
+public class OrderInfoCouponInfoDTO {
+ private List outRecordList;
+ private Collection fullReductionCoupon;
+ private Collection productCoupon;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderInfoUserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderInfoUserCouponVo.java
new file mode 100644
index 0000000..c99a42e
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/OrderInfoUserCouponVo.java
@@ -0,0 +1,11 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class OrderInfoUserCouponVo extends TbUserCouponVo {
+ private int returnNum = 0;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ReturnOrderDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ReturnOrderDTO.java
new file mode 100644
index 0000000..47c8842
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ReturnOrderDTO.java
@@ -0,0 +1,32 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.Valid;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class ReturnOrderDTO {
+
+ @Data
+ public static class OrderDetail{
+ @NotNull
+ private Integer id;
+ @NotNull
+ @Min(1)
+ private BigDecimal num;
+ }
+ @NotNull
+ private Integer orderId;
+ @NotEmpty
+ private String note;
+// @NotEmpty
+ private String pwd;
+ @Valid
+ private List orderDetails;
+ private Boolean isOnline;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java
index 6f78fd8..9dac5c7 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ShopEatTypeInfoDTO.java
@@ -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;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ThirdCouponCheckDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ThirdCouponCheckDTO.java
new file mode 100644
index 0000000..76b2180
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/ThirdCouponCheckDTO.java
@@ -0,0 +1,25 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@Data
+public class ThirdCouponCheckDTO {
+ private String type = "meituan";
+ @NotNull
+ private Integer shopId;
+ @NotBlank
+ private String code;
+ @Min(1)
+ private Integer num;
+ @NotNull
+ private Integer orderId;
+ // 核销的对应商品
+ @NotEmpty
+ private List cartId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UpdatePriceDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UpdatePriceDTO.java
new file mode 100644
index 0000000..b05aa64
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/UpdatePriceDTO.java
@@ -0,0 +1,21 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+@Data
+public class UpdatePriceDTO {
+ @NotNull
+ private Integer shopId;
+ @NotNull
+ private Integer cartId;
+ @DecimalMin("0.01")
+ @NotNull
+ private BigDecimal amount;
+// @NotBlank(message = "折扣原因不能为空")
+ private String note;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WaitCallDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WaitCallDTO.java
new file mode 100644
index 0000000..89703ed
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/WaitCallDTO.java
@@ -0,0 +1,19 @@
+package com.chaozhanggui.system.cashierservice.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class WaitCallDTO {
+ @NotNull
+ private Integer shopId;
+ @NotNull
+ private Integer isWaitCall;
+ private Integer orderId;
+ private String code;
+ @NotBlank
+ private String useType;
+ private String tableId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/BaseQueryDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/BaseQueryDTO.java
new file mode 100644
index 0000000..81abd43
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/BaseQueryDTO.java
@@ -0,0 +1,11 @@
+package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class BaseQueryDTO {
+ @NotNull
+ private Integer shopId;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/CheckCouponDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/CheckCouponDTO.java
new file mode 100644
index 0000000..32e0e47
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/CheckCouponDTO.java
@@ -0,0 +1,20 @@
+package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class CheckCouponDTO extends BaseQueryDTO {
+ @NotBlank
+ private String couponCode;
+ @NotNull
+ @Min(1)
+ private Integer num;
+ @NotBlank
+ private String title;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/GetActivateCouponDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/GetActivateCouponDTO.java
new file mode 100644
index 0000000..d601b82
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/GetActivateCouponDTO.java
@@ -0,0 +1,13 @@
+package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotBlank;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class GetActivateCouponDTO extends BaseQueryDTO{
+ @NotBlank
+ private String code;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/RevokeCouponDTO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/RevokeCouponDTO.java
new file mode 100644
index 0000000..e5fdea3
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/thirdcoupon/RevokeCouponDTO.java
@@ -0,0 +1,13 @@
+package com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.validation.constraints.NotBlank;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class RevokeCouponDTO extends BaseQueryDTO{
+ @NotBlank
+ private String couponCode;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/SkuInfoPo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/SkuInfoPo.java
index 2bf1b31..f3feab0 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/SkuInfoPo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/po/SkuInfoPo.java
@@ -9,9 +9,12 @@ public class SkuInfoPo {
private String productName;
private String productSkuName;
- private Integer num;
+ private BigDecimal num;
private BigDecimal priceAmount;
+ private BigDecimal discountSaleAmount;
private BigDecimal packAmount;
private String categoryId;
private BigDecimal price;
+ private BigDecimal memberPrice;
+ private String proGroupInfo;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CartVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CartVo.java
index c66fe1e..849d793 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CartVo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/CartVo.java
@@ -2,9 +2,12 @@ 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;
+import java.util.List;
@Data
public class CartVo {
@@ -12,8 +15,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;
@@ -23,4 +27,8 @@ public class CartVo {
private String masterId;
private String tableId;
private Integer orderId;
+ private Integer isPrint;
+
+ // 套餐商品选择的id信息
+ private List groupProductIdList;
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductGroupVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductGroupVo.java
new file mode 100644
index 0000000..61d7a28
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductGroupVo.java
@@ -0,0 +1,34 @@
+package com.chaozhanggui.system.cashierservice.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ProductGroupVo {
+
+ private Integer count;
+ //选几个
+ private Integer number;
+ //类别
+ private String title;
+
+ //食物
+ private List goods=new ArrayList<>();
+
+ @Data
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Food {
+ private Integer proId;
+ private String proName;
+ private Integer skuId;
+ private String skuName;
+ private BigDecimal price;
+ private String number;
+ private String unitName;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java
new file mode 100644
index 0000000..430e3ae
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java
@@ -0,0 +1,43 @@
+package com.chaozhanggui.system.cashierservice.entity.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class TbUserCouponVo {
+ private Integer id;
+ private BigDecimal fullAmount;
+ private BigDecimal discountAmount;
+ private Integer couponId;
+ private Integer proId;
+ // 商品名称
+ private String productName;
+ private String productCover;
+ //优惠券名称
+ private String name;
+
+ //优惠券类型 1 满减 2 商品券
+ private Integer type;
+ //数量
+ private Integer num;
+ //到期时间
+ private Date endTime;
+ private Long expireTime;
+ private String useRestrictions;
+ private boolean isUse = false;
+ //当前使用数量
+ private BigDecimal currentUseNum;
+ private Integer finalUseNum;
+ private BigDecimal finalDiscountAmount = new BigDecimal(0);
+
+
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ if(endTime!=null){
+ expireTime=endTime.getTime();
+ }
+ }
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpProductStockDetailMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpProductStockDetailMapper.java
new file mode 100644
index 0000000..8482811
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpProductStockDetailMapper.java
@@ -0,0 +1,7 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbProductStockDetail;
+
+public interface MpProductStockDetailMapper extends BaseMapper {
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopUnitMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopUnitMapper.java
new file mode 100644
index 0000000..1bbce49
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopUnitMapper.java
@@ -0,0 +1,20 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.chaozhanggui.system.cashierservice.entity.TbShopUnit;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @author Administrator
+* @description 针对表【tb_shop_unit(商品单位)】的数据库操作Mapper
+* @createDate 2024-11-26 09:36:19
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopUnit
+*/
+@Mapper
+public interface MpShopUnitMapper extends BaseMapper {
+
+
+}
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsLogMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsLogMapper.java
new file mode 100644
index 0000000..201fdb6
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsLogMapper.java
@@ -0,0 +1,16 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 会员积分变动记录
+ *
+ * @author Tankaikai tankaikai@aliyun.com
+ * @since 2.0 2024-10-25
+ */
+@Mapper
+public interface TbMemberPointsLogMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsMapper.java
new file mode 100644
index 0000000..7b24d5c
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbMemberPointsMapper.java
@@ -0,0 +1,16 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 会员积分
+ *
+ * @author Tankaikai tankaikai@aliyun.com
+ * @since 2.0 2024-10-25
+ */
+@Mapper
+public interface TbMemberPointsMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbThirdPartyCouponRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbThirdPartyCouponRecordMapper.java
new file mode 100644
index 0000000..1666b89
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/TbThirdPartyCouponRecordMapper.java
@@ -0,0 +1,18 @@
+package com.chaozhanggui.system.cashierservice.mapper;
+
+import com.chaozhanggui.system.cashierservice.entity.TbThirdPartyCouponRecord;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author Administrator
+* @description 针对表【tb_third_party_coupon_record】的数据库操作Mapper
+* @createDate 2024-11-26 15:06:35
+* @Entity com.chaozhanggui.system.cashierservice.entity.TbThirdPartyCouponRecord
+*/
+public interface TbThirdPartyCouponRecordMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/model/OrderDetailPO.java b/src/main/java/com/chaozhanggui/system/cashierservice/model/OrderDetailPO.java
index dda62d8..7032d06 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/model/OrderDetailPO.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/model/OrderDetailPO.java
@@ -49,12 +49,14 @@ public class OrderDetailPO implements Serializable {
private String amount;
private String spec;
+ private String proGroupInfo;
- public Detail(String productName, String number, String amount, String spec) {
+ public Detail(String productName, String number, String amount, String spec, String proGroupInfo) {
this.productName = productName;
this.number = number;
this.amount = amount;
this.spec = spec;
+ this.proGroupInfo = proGroupInfo;
}
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mybatis/MpShopUserMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mybatis/MpShopUserMapper.java
index 8ae5f05..2b6e9bb 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/mybatis/MpShopUserMapper.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/mybatis/MpShopUserMapper.java
@@ -10,4 +10,7 @@ import java.math.BigDecimal;
public interface MpShopUserMapper extends BaseMapper {
@Update("update tb_shop_user set amount=amount-#{orderAmount}, consume_amount=consume_amount+#{orderAmount} where id=#{vipUserId} and amount-#{orderAmount} >= 0")
long decrBalance(@Param("vipUserId") Integer vipUserId, @Param("orderAmount") BigDecimal orderAmount);
+
+ @Update("update tb_shop_user set amount=amount+#{returnAmount}, consume_amount=consume_amount-#{returnAmount}, updated_at=#{current} where id=#{userId}")
+ void incrBalance(@Param("userId") Integer userId, @Param("shopId") Integer shopId, @Param("returnAmount") BigDecimal returnAmount, @Param("current") long current);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java
index 80bae3a..ae0f4bc 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/ConsMsgConsumer.java
@@ -108,7 +108,7 @@ public class ConsMsgConsumer {
return;
}
- TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(skuWithBLOBs.getProductId()));
+ TbProduct product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(skuWithBLOBs.getProductId()));
if (Objects.isNull(product)) {
log.info("商品信息不存在");
return;
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java
index db67347..f8f77b0 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java
@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.rabbit;
+import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -19,6 +20,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;
@@ -167,21 +169,28 @@ public class PrintMechineConsumer {
List detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
-
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
+ } else {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
+ BigDecimal unitPrice = it.getPrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
+ detailList.add(detail);
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), NumberUtil.mul(it.getNum(),it.getPrice()).toPlainString(), remark);
- detailList.add(detail);
-
});
String balance = "0";
@@ -194,7 +203,8 @@ public class PrintMechineConsumer {
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
- OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
+ OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", originAmount.toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";
@@ -215,19 +225,26 @@ public class PrintMechineConsumer {
List detailList = new ArrayList<>();
tbOrderDetails.stream().forEach(it -> {
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), NumberUtil.mul(it.getNum(),it.getPrice()).toPlainString(), remark);
+ BigDecimal unitPrice = it.getPrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
}
});
@@ -241,11 +258,11 @@ public class PrintMechineConsumer {
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
-
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
+ "【POS-1】001", originAmount.toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
@@ -284,14 +301,25 @@ public class PrintMechineConsumer {
// 重置打印数据
redisTemplate.delete(printKey);
if (!tbOrderDetails.isEmpty()) {
- tbOrderDetails.forEach(it -> {
+ tbOrderDetails.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(it -> {
log.info("开始打印一菜一品票据,:{}", it.getProductName());
- String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
-
- long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
+ long count;
+ Integer isWaitCall = ObjectUtil.defaultIfNull(it.getIsWaitCall(), 0);
+ if (isWaitCall == 1) {
+ it.setProductName("【等叫】" + it.getProductName());
+ }
+ if (it.getIsTemporary() == 1) {
+ it.setProductId(0);
+ it.setProductSkuId(0);
+ it.setProductName("【临】" + it.getProductName());
+ count = 1;
+ } else {
+ String categoryId = tbProductMapper.selectByPrimaryKey(it.getProductId()).getCategoryId();
+ count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+ }
log.info("获取当前类别是否未打印类别:{}", count);
if (count > 0) {
// 统计已打数量
@@ -311,18 +339,20 @@ 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);
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
+ if (it.getIsTemporary() == 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
}
// 将已打印信息加入redis
@@ -331,7 +361,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;
}
@@ -341,14 +371,14 @@ public class PrintMechineConsumer {
data = PrinterUtils.getPrintData("return",
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
- DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), Math.abs(printerNum), remark, null);
+ DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), Math.abs(printerNum), remark, null, it.getProGroupInfo());
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
} else {
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(),
- printerNum, remark, null);
+ printerNum, remark, null, it.getProGroupInfo());
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
@@ -366,7 +396,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, orderDetail.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
@@ -432,9 +463,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, orderDetail.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
@@ -461,22 +493,25 @@ public class PrintMechineConsumer {
if ("postPay".equals(orderInfo.getUseType()) && isPrint(it, orderInfo.getId())) {
return;
}
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
log.info("获取当前类别是否未打印类别:{}", count);
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
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, it.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
@@ -490,20 +525,38 @@ public class PrintMechineConsumer {
private void printReturnTicket(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List categoryInfos, String orderId) {
List details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
- details.parallelStream().forEach(it -> {
- String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
+ details.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(it -> {
+ long count = 0;
+ Integer isWaitCall = ObjectUtil.defaultIfNull(it.getIsWaitCall(), 0);
+ if (isWaitCall == 1) {
+ it.setProductName("【等叫】" + it.getProductName());
+ }
+ if (it.getIsTemporary() == 1) {
+ it.setProductId(0);
+ it.setProductSkuId(0);
+ it.setProductName("【临】" + it.getProductName());
+ } else {
+ String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+ }
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
+ } else {
String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
+ if (it.getIsTemporary() == 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
+ 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, it.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
}
@@ -524,7 +577,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;
}
@@ -537,22 +590,18 @@ public class PrintMechineConsumer {
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
- String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
- log.info("获取当前类别是否未打印类别:{}", count);
-
-
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), NumberUtil.mul(it.getNum(),it.getPrice()).toPlainString(), remark);
+ BigDecimal unitPrice = it.getPrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
-
});
String balance = "0";
@@ -566,11 +615,12 @@ public class PrintMechineConsumer {
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(),
"普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId())
? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
+ "【POS-1】001", originAmount.toPlainString(),
balance, orderInfo.getPayType(), "0",
detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(),
orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
@@ -596,19 +646,25 @@ public class PrintMechineConsumer {
} else {
categoryId = it.getCategoryId();
}
-
-
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
+ BigDecimal unitPrice = it.getSalePrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
}
@@ -623,7 +679,8 @@ public class PrintMechineConsumer {
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
- OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
+ OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", originAmount.toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType = "结算单";
if ("return".equals(orderInfo.getOrderType())) {
@@ -651,8 +708,7 @@ public class PrintMechineConsumer {
List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
- cashierCarts.parallelStream().forEach(it -> {
-
+ cashierCarts.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
@@ -661,11 +717,14 @@ public class PrintMechineConsumer {
}
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@@ -673,7 +732,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, it.getProGroupInfo());
}
});
}
@@ -695,21 +754,21 @@ public class PrintMechineConsumer {
categoryId = it.getCategoryId();
}
-
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
-
log.info("获取当前类别是否未打印类别:{}", count);
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
-
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
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);
}
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java
index 9b792b8..db1e8a5 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/RabbitConstants.java
@@ -70,4 +70,12 @@ public interface RabbitConstants {
// 排号打印
String QUEUE_PRINT_CALL_TABLE = "queue.print.call.table";
String ROUTING_KEY_CALL_TABLE = "routing.call.table";
+ // 会员余额记录
+ String EXCHANGE_BALANCE = "balance_put";
+ String ROUTING_KEY_BALANCE = "balance_routingkey_put";
+
+
+ // 耗材
+ String EXCHANGE_CONS = "cons_collect_put";
+ String ROUTING_KEY_CONS = "cons_collect_routingkey_put";
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java
index cc26ce6..0f7a054 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java
@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
+import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@@ -64,23 +66,25 @@ public class FeiPrinter extends PrinterHandler {
@Override
protected void normalDishesPrint(TbOrderInfo orderInfo, TbOrderDetail orderDetail, TbPrintMachine machine) {
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(orderDetail.getProductSkuId());
- if (sku == null) {
+ if (sku == null && orderDetail.getIsTemporary() == 0) {
log.warn("打印菜品票失败 sku商品不存在: {}", orderDetail);
return;
}
- String remark = sku.getSpecSnap();
+ String remark = sku == null ? "" : 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, orderDetail.getProGroupInfo());
shopPrintLogService.save(machine, "新订单", resp[0], resp[1]);
}
@Override
protected void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List detailList) {
TbShopInfo shopInfo = mpShopInfoMapper.selectById(orderInfo.getShopId());
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
+ "【POS-1】001", originAmount.toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType = "退款单";
@@ -97,10 +101,11 @@ public class FeiPrinter extends PrinterHandler {
@Override
protected void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List detailList) {
TbShopInfo shopInfo = mpShopInfoMapper.selectById(orderInfo.getShopId());
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
+ "【POS-1】001", originAmount.toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType = "结算单";
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/LocalLabelPrinter.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/LocalLabelPrinter.java
index d61639d..0d1f9ed 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/LocalLabelPrinter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/LocalLabelPrinter.java
@@ -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]);
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java
index ee2c163..3708220 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java
@@ -19,6 +19,7 @@ import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -83,38 +84,63 @@ public abstract class PrinterHandler {
* 仅打印制作单「厨房」
*/
private void onlyKitchen(TbPrintMachine machine, TbOrderInfo orderInfo, List tbOrderDetailList, List categoryInfos, boolean isReturn) {
- tbOrderDetailList.forEach(item -> {
+ tbOrderDetailList.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(item -> {
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
+ Integer isWaitCall = ObjectUtil.defaultIfNull(item.getIsWaitCall(), 0);
+ if (isWaitCall == 1) {
+ if (!item.getProductName().startsWith("【等叫】")) {
+ item.setProductName("【等叫】" + item.getProductName());
+ }
+ }
+ Integer isTemporary = ObjectUtil.defaultIfNull(item.getIsTemporary(), 0);
+ String categoryId = "0";
+ if (isTemporary == 1) {
+ item.setProductId(0);
+ item.setProductSkuId(0);
+ if (!item.getProductName().startsWith("【临】")) {
+ item.setProductName("【临】" + item.getProductName());
+ }
+ }
// 台位费不打印
if (item.getProductId().equals(-999)) {
log.info("台位费商品,不打印");
return;
}
- String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
+
+ TbProduct product = tbProductMapper.selectByPrimaryKey(item.getProductId());
+ if (isTemporary == 0) {
+ categoryId = product.getCategoryId();
+ }
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
- if (sku == null) {
+ if (isTemporary == 0 && sku == null) {
log.error("商品不存在, id: {}", item.getProductSkuId());
return;
+ } else if (isTemporary == 1) {
+ sku = new TbProductSkuWithBLOBs();
}
if (StrUtil.isEmpty(machine.getClassifyPrint())) {
log.error("分类打印是空, classifyPrint: {}", machine.getClassifyPrint());
return;
}
+ String finalCategoryId = categoryId;
long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
+ c.getId().toString().equals(finalCategoryId)
).count();
-
- if (machine.getClassifyPrint() != null && "1".equals(machine.getClassifyPrint()) && count == 0) {
- log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
- return;
+ if (isTemporary == 1) {
+ count = 1;
}
+ String classifyPrint = machine.getClassifyPrint();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if("1".equals(classifyPrint) && count == 0) {
- String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
- item.setRemark(remark);
- if (isReturn) {
- returnDishesPrint(orderInfo, item, machine);
- } else {
- normalDishesPrint(orderInfo, item, machine);
+ }else{
+ String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
+ item.setRemark(remark);
+ if (isReturn) {
+ returnDishesPrint(orderInfo, item, machine);
+ } else {
+ normalDishesPrint(orderInfo, item, machine);
+ }
}
});
}
@@ -129,12 +155,27 @@ public abstract class PrinterHandler {
}
List detailList = new ArrayList<>();
tbOrderDetailList.forEach(it -> {
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
+ Integer isTemporary = ObjectUtil.defaultIfNull(it.getIsTemporary(), 0);
String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
+ if (isTemporary == 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(it.getProductSkuId());
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
+ }
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), NumberUtil.mul(it.getNum(),it.getPrice()).toPlainString(), remark);
+ Integer isWaitCall = ObjectUtil.defaultIfNull(it.getIsWaitCall(), 0);
+ if (isWaitCall == 1) {
+ it.setProductName("【等叫】" + it.getProductName());
+ }
+ if (isTemporary == 1) {
+ it.setProductName("【临】" + it.getProductName());
+ }
+ BigDecimal unitPrice = it.getPrice();
+ if(it.getIsMember() == 1){
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
});
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/YxyPrinter.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/YxyPrinter.java
index 55ad0d1..214ddf7 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/YxyPrinter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/YxyPrinter.java
@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.rabbit.print;
+import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
+import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@@ -62,10 +64,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(), orderDetail.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
@@ -74,9 +77,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(), orderDetail.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
@@ -86,9 +91,10 @@ public class YxyPrinter extends PrinterHandler {
@Override
protected void returnOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List detailList) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", getPickupNum(orderInfo),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(),
+ "【POS-1】001", originAmount.toPlainString(), balance, orderInfo.getPayType(),
"0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";
@@ -103,11 +109,11 @@ public class YxyPrinter extends PrinterHandler {
@Override
protected void normalOrderPrint(TbOrderInfo orderInfo, TbPrintMachine machine, String balance, List detailList) {
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
-
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
getPickupNum(orderInfo),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
+ "【POS-1】001", originAmount.toPlainString(), balance,
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
@@ -157,7 +163,7 @@ public class YxyPrinter extends PrinterHandler {
public static void main(String[] args) {
String data = PrinterUtils.getPrintData("", "#3",
DateUtils.getTime(DateUtil.date()), "九度",
- Integer.valueOf("20"), "少冰", "加菜防守打法火速地方啊地上1三大法宝苏俄倒海翻江");
+ Integer.valueOf("20"), "少冰", "加菜防守打法火速地方啊地上1三大法宝苏俄倒海翻江","");
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/resp/PhpCommonResp.java b/src/main/java/com/chaozhanggui/system/cashierservice/resp/PhpCommonResp.java
new file mode 100644
index 0000000..b6a5a04
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/resp/PhpCommonResp.java
@@ -0,0 +1,11 @@
+package com.chaozhanggui.system.cashierservice.resp;
+
+import lombok.Data;
+
+@Data
+public class PhpCommonResp {
+ private String code;
+ private String msg;
+ private long time;
+ private T data;
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java
index 1bc6bab..ec123e0 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java
@@ -1,6 +1,7 @@
package com.chaozhanggui.system.cashierservice.service;
+import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -175,22 +176,40 @@ public class CloudPrinterService {
if ("return".equals(orderInfo.getOrderType())) {
List details = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if (ObjectUtil.isNotEmpty(details) && details.size() > 0) {
- details.parallelStream().forEach(it -> {
+ details.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(it -> {
+ long count = 0;
+ Integer isWaitCall = ObjectUtil.defaultIfNull(it.getIsWaitCall(), 0);
+ if (isWaitCall == 1) {
+ it.setProductName("【等叫】" + it.getProductName());
+ }
+ if (it.getIsTemporary() == 1) {
+ it.setProductId(0);
+ it.setProductSkuId(0);
+ it.setProductName("【临】" + it.getProductName());
+ count = 1;
+ } else {
+ String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
+ count = categoryInfos.stream().filter(c ->
+ c.getId().toString().equals(categoryId)
+ ).count();
+ }
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
-
- if (count > 0) {
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
+ } else {
String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
+ if (it.getIsTemporary() == 0) {
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
+ 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, it.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
}
@@ -215,17 +234,21 @@ public class CloudPrinterService {
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
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, it.getProGroupInfo());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
@@ -249,22 +272,18 @@ public class CloudPrinterService {
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
- String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
- log.info("获取当前类别是否未打印类别:{}", count);
-
-
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), NumberUtil.mul(it.getNum(), it.getPrice()).toPlainString(), remark);
+ BigDecimal unitPrice = it.getPrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
-
});
String balance = "0";
@@ -278,10 +297,11 @@ public class CloudPrinterService {
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
+ "【POS-1】001", originAmount.toPlainString(), balance, orderInfo.getPayType(), "0",
detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
detailPO.setOutNumber(orderInfo.getOutNumber());
String printType = "退款单";
@@ -302,7 +322,7 @@ public class CloudPrinterService {
if (ispre) {
cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "create");
} else {
- cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
+ cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "closed");
}
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
@@ -314,19 +334,25 @@ public class CloudPrinterService {
} else {
categoryId = it.getCategoryId();
}
-
-
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
+ BigDecimal unitPrice = it.getSalePrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
}
@@ -344,10 +370,11 @@ public class CloudPrinterService {
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
+ "【POS-1】001", originAmount.toPlainString(),
balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0",
detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null, orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
String printType = "结算单";
@@ -384,22 +411,18 @@ public class CloudPrinterService {
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
List detailList = new ArrayList<>();
tbOrderDetails.parallelStream().forEach(it -> {
- String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
- log.info("获取当前类别是否未打印类别:{}", count);
-
-
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap();
}
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), NumberUtil.mul(it.getNum(), it.getPrice()).toPlainString(), remark);
+ BigDecimal unitPrice = it.getPrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
detailList.add(detail);
-
});
String balance = "0";
@@ -413,7 +436,8 @@ public class CloudPrinterService {
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
- OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
+ OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", originAmount.toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单";
@@ -443,20 +467,18 @@ public class CloudPrinterService {
categoryId = it.getCategoryId();
}
-
- Long count = categoryInfos.stream().filter(c ->
- c.getId().toString().equals(categoryId)
- ).count();
-
- if (count > 0) {
- TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
- String remark = "";
- if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
- remark = tbProductSkuWithBLOBs.getSpecSnap();
- }
- OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
- detailList.add(detail);
+ TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
+ String remark = "";
+ if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
+ remark = tbProductSkuWithBLOBs.getSpecSnap();
}
+ BigDecimal unitPrice = it.getSalePrice();
+ if (it.getIsMember() == 1) {
+ unitPrice = it.getMemberPrice();
+ }
+ BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
+ OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
+ detailList.add(detail);
});
@@ -469,10 +491,11 @@ public class CloudPrinterService {
}
}
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
+ BigDecimal originAmount = detailList.stream().map(obj -> Convert.toBigDecimal(obj.getAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
- "【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
+ "【POS-1】001", originAmount.toPlainString(),
balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType = "结算单";
@@ -506,7 +529,7 @@ public class CloudPrinterService {
List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
- cashierCarts.parallelStream().forEach(it -> {
+ cashierCarts.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(it -> {
String categoryId;
if (ObjectUtil.isEmpty(it.getCategoryId())) {
@@ -519,15 +542,19 @@ public class CloudPrinterService {
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
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, it.getProGroupInfo());
}
});
}
@@ -545,24 +572,27 @@ public class CloudPrinterService {
if (ispre) {
return Result.fail("预结算单不打印标签");
}
- List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
+ List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "closed");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> {
+ String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(it.getCategoryId().toString())
).count();
+ // 如果是部分打印,并且所属分类不在设置的列表中,则不打印
+ if ("1".equals(classifyPrint) && count == 0) {
- if (count > 0) {
+ } else {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
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);
}
-
}
});
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java
index 546ab2b..5071ede 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ConsService.java
@@ -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");
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java
index c3df527..98d1cc6 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/DutyService.java
@@ -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());
@@ -386,7 +394,7 @@ public class DutyService {
if (tbProductSku == null) {
return;
}
- TbProductWithBLOBs product = productMapper.selectByPrimaryKey(Integer.valueOf(tbProductSku.getProductId()));
+ TbProduct product = productMapper.selectByPrimaryKey(Integer.valueOf(tbProductSku.getProductId()));
if (ObjectUtil.isNotEmpty(product)) {
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java
index 6b2d24c..683107b 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java
@@ -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,29 @@ public interface MpCashierCartService extends IService {
*/
List 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, String proName);
+
+
+ /**
+ * 根据店铺id和购物车id查询信息
+ * @param shopId 店铺id
+ * @param cartId 购物车id
+ * @param statuses 状态
+ */
+ TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses);
+ /**
+ * 根据id查询购物车数据
+ * @param shopId 店铺id
+ * @param orderId 订单id
+ * @param ids 购物车id
+ * @param statuses 状态
+ */
+ List selectByIds(Integer shopId, Integer orderId, List ids, TableConstant.OrderInfo.Status... statuses);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderDetailService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderDetailService.java
index a415f24..9910a74 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderDetailService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderDetailService.java
@@ -1,11 +1,13 @@
package com.chaozhanggui.system.cashierservice.service;
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
import com.chaozhanggui.system.cashierservice.sign.Result;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -36,6 +38,26 @@ public interface MpOrderDetailService extends IService {
* 根据订单id删除详情
* @param orderId 订单id
*/
- boolean removeByOrderId(String orderId);
+ boolean removeByOrderId(Integer orderId);
+
+ /**
+ * 根据购物车id修改detail价格
+ * @param cartId 购物车id
+ * @param totalAmount 总价格
+ */
+ boolean updatePriceByCartId(Integer cartId, BigDecimal saleAmount, BigDecimal totalAmount);
+
+
+ boolean updateFieldByCartId(SFunction field, Object val, List cartIds);
+
+ /**
+ * 根据orderId和id修改detail状态
+ * @param oldOrderStatusEnums 原始订单状态
+ * @param orderStatusEnums 状态
+ * @param orderId 订单id
+ * @param orderDetails detailIds
+ * @return 影响数量
+ */
+ boolean updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status oldOrderStatusEnums, TableConstant.OrderInfo.Status orderStatusEnums, Integer orderId, List orderDetails);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderInfoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderInfoService.java
index fcebf1e..519a76f 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderInfoService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpOrderInfoService.java
@@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -23,5 +24,12 @@ public interface MpOrderInfoService extends IService {
* @return 是否成功
*/
boolean updateStateById(Integer shopId, Integer orderId, TableConstant.Status status);
+
+ boolean incrAmount(Integer orderId, BigDecimal subtract);
+
+ /**
+ * 储值卡退款
+ */
+ void depositReturn(Integer userId, Integer shopId, BigDecimal returnAmount);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
index 0358dd3..f9e1b49 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
@@ -16,15 +16,14 @@ 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.dto.thirdcoupon.CheckCouponDTO;
import com.chaozhanggui.system.cashierservice.entity.po.CartPo;
import com.chaozhanggui.system.cashierservice.entity.po.OrderPo;
import com.chaozhanggui.system.cashierservice.entity.po.QueryCartPo;
import com.chaozhanggui.system.cashierservice.entity.po.SkuInfoPo;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
+import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.exception.NotPrintException;
import com.chaozhanggui.system.cashierservice.mybatis.*;
@@ -46,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@@ -131,10 +131,13 @@ public class OrderService {
@Resource
private MPOrderDetailMapper mpOrderDetailMapper;
+ private final TbThirdPartyCouponRecordService thirdPartyCouponRecordService;
+ private final ThirdPartyCouponService thirdPartyCouponService;
+
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper,
TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, MpOrderInfoService mpOrderInfoService, MpShopTableService mpShopTableService,
- TbCashierCartMapper tbCashierCartMapper, MpCashierCartService mpCashierCartService) {
+ TbCashierCartMapper tbCashierCartMapper, MpCashierCartService mpCashierCartService, TbThirdPartyCouponRecordService thirdPartyCouponRecordService, ThirdPartyCouponService thirdPartyCouponService) {
this.wxAccountUtil = wxAccountUtil;
this.mpCashierCartMapper = mpCashierCartMapper;
this.shopOpenIdMapper = shopOpenIdMapper;
@@ -143,48 +146,138 @@ public class OrderService {
this.mpShopTableService = mpShopTableService;
this.tbCashierCartMapper = tbCashierCartMapper;
this.mpCashierCartService = mpCashierCartService;
+ this.thirdPartyCouponRecordService = thirdPartyCouponRecordService;
+ this.thirdPartyCouponService = thirdPartyCouponService;
}
- 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()
- .eq(TbShopInfo::getId, shopId)
- .eq(TbShopInfo::getStatus, 1));
+ .eq(TbShopInfo::getId, shopId));
if (shopInfo == null) {
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());
+ }
+
+
+ /**
+ * 重置购物车套餐商品信息
+ */
+ private void resetGroupProductCart(List productIds, TbProduct product, TbCashierCart cashierCart) {
+ boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1;
+ boolean isFixGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 0;
+ if (isChoseGroup && productIds != null && !productIds.isEmpty()) {
+ String groupSnap = product.getGroupSnap();
+ if (StrUtil.isNotBlank(groupSnap)) {
+ ArrayList foods = new ArrayList<>();
+ HashMap groupVoHashMap = new HashMap<>();
+ JSONObject.parseArray(groupSnap).forEach(item -> {
+ ProductGroupVo productGroupVo = ((JSONObject) item).toJavaObject(ProductGroupVo.class);
+ productGroupVo.getGoods().forEach(goods -> {
+ groupVoHashMap.put(goods.getProId().toString(), goods);
+ });
+ });
+
+ productIds.forEach(item -> {
+ ProductGroupVo.Food food = groupVoHashMap.get(item.toString());
+ if (food == null) {
+ throw new MsgException("存在无效套餐商品");
+ }
+ ProductGroupVo.Food copyFood = new ProductGroupVo.Food();
+ BeanUtil.copyProperties(copyFood, food);
+ foods.add(copyFood);
+ });
+
+ cashierCart.setProGroupInfo(JSONObject.toJSONString(foods));
+ }
+ } else if (isFixGroup) {
+ String groupSnap = product.getGroupSnap();
+ if (StrUtil.isNotBlank(groupSnap)) {
+ ArrayList foods = new ArrayList<>();
+ HashMap groupVoHashMap = new HashMap<>();
+ JSONObject.parseArray(groupSnap).forEach(item -> {
+ ProductGroupVo productGroupVo = ((JSONObject) item).toJavaObject(ProductGroupVo.class);
+ productGroupVo.getGoods().forEach(goods -> {
+ ProductGroupVo.Food copyFood = new ProductGroupVo.Food();
+ BeanUtil.copyProperties(copyFood, goods);
+ foods.add(copyFood);
+ groupVoHashMap.put(goods.getProId().toString(), copyFood);
+ });
+ });
+
+ cashierCart.setProGroupInfo(JSONObject.toJSONString(groupVoHashMap.values()));
+ }
+ }
}
@Transactional(rollbackFor = Exception.class)
- public Result createCart(String masterId, Integer productId, Integer shopId, Integer skuId, Integer number,
- String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, String tableId) {
- if (productId == null || skuId == null || number == null) {
+ 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, Integer isPrint, List groupProductIdList) {
+ 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()
.eq(TbShopTable::getQrcode, tableId)
@@ -193,27 +286,44 @@ 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());
}
}
+ String finalMasterId = masterId;
LambdaQueryWrapper cartQuery = new LambdaQueryWrapper()
.eq(TbCashierCart::getShopId, shopId)
- .eq(TbCashierCart::getSkuId, skuId)
- .eq(TbCashierCart::getProductId, productId)
- .in(TbCashierCart::getStatus, "create")
- .eq(TbCashierCart::getId, cartId);
-
- TbCashierCart cart = mpCashierCartMapper.selectOne(cartQuery);
-
- // 校验是否是代客下单往期订单
- if (shopEatTypeInfoDTO.isDineInAfter() && cart != null && cart.getPlaceNum() != null && !isSeatCart) {
- return Result.fail("后付费已下单订单仅支持退款");
+ .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
+ .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
+ .and(r -> r.eq(TbCashierCart::getMasterId, finalMasterId).or().isNull(TbCashierCart::getMasterId).or().eq(TbCashierCart::getMasterId, ""))
+ .in(TbCashierCart::getStatus, "create");
+ if (productId != null) {
+ cartQuery.eq(TbCashierCart::getProductId, productId)
+ .eq(TbCashierCart::getSkuId, skuId);
}
+
+ if (cartId != null) {
+ cartQuery.eq(TbCashierCart::getId, cartId);
+ }
+
+ if (StringUtils.isEmpty(masterId)) {
+ boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
+ if (flag) {
+ String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId);
+ Integer foodCode = Integer.parseInt(code) + 1;
+ code = "#" + String.format("%03d", foodCode);
+ redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, foodCode.toString());
+ masterId = code;
+ } else {
+ redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, "1");
+ masterId = "#" + String.format("%03d", 1);
+ }
+ }
+
TbProduct product = null;
TbProductSkuWithBLOBs skuWithBLOBs = null;
- if (!isSeatCart) {
+ if (!isSeatCart && productId != null) {
product = mpProductMapper.selectOne(new LambdaQueryWrapper()
.eq(TbProduct::getId, productId)
.eq(TbProduct::getStatus, 1));
@@ -233,111 +343,140 @@ public class OrderService {
return Result.fail(CodeEnum.PRODUCTSKUERROR);
}
- // 首次加入购物车,并且拥有起售数,设置为起售数
- if (cart == null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0) {
- number = skuWithBLOBs.getSuit();
- // 低于起售,删除商品
- } else if (cart != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number < skuWithBLOBs.getSuit()) {
- delCart(masterId, cartId);
- if (StrUtil.isNotBlank(cart.getOrderId()) && StrUtil.isNotBlank(cart.getTableId())) {
- LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()
- .notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
- .eq(TbCashierCart::getShopId, cart.getShopId());
-
- TbCashierCart finalCart = cart;
- queryWrapper.eq(TbCashierCart::getTableId, cart.getTableId())
- .and(q -> q.or(
- query -> query.eq(TbCashierCart::getMasterId, finalCart.getMasterId())
- .or()
- .isNull(TbCashierCart::getMasterId)
- .or()
- .eq(TbCashierCart::getMasterId, "")
- )
- .or(query -> query.eq(TbCashierCart::getOrderId, finalCart.getOrderId())
- .or()
- .isNull(TbCashierCart::getOrderId)));
-
- List list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
-
- if (list.isEmpty()) {
- tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cart.getOrderId()));
- }
- }
-
- setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), false);
- return Result.success(CodeEnum.SUCCESS, masterId);
- }
// 校验库存
if ("1".equals(product.getIsStock().toString())) {
- if (product.getStockNumber() - number < 0) {
+ // todo 数量为浮点数,库存目前整数, 待同一
+ if (product.getStockNumber() - number.intValue() < 0) {
return Result.fail(CodeEnum.STOCKERROR);
}
}
}
-
-
- if (StringUtils.isEmpty(masterId)) {
- boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
- if (flag) {
- String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId);
- Integer foodCode = Integer.parseInt(code) + 1;
- code = "#" + String.format("%03d", foodCode);
- redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, foodCode.toString());
- masterId = code;
+ boolean needNew = false;
+ List list = cashierCartMapper.selectALlByMasterId(masterId, "create");
+ TbCashierCart cashierCart = null;
+ if (type.equals("edit")) {
+ cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId);
+ if (cashierCart == null) {
+ needNew = true;
} else {
- redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, "1");
- masterId = "#" + String.format("%03d", 1);
+ // 校验是否是代客下单往期订单
+ if (shopEatTypeInfoDTO.isDineInAfter() && cashierCart.getPlaceNum() != null && !isSeatCart) {
+ return Result.fail("后付费已下单订单仅支持退款");
+ }
+
+ if (skuWithBLOBs != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number.compareTo(BigDecimal.valueOf(skuWithBLOBs.getSuit())) < 0) {
+ delCart(masterId, cartId);
+ if (cashierCart.getOrderId() != null && StrUtil.isNotBlank(cashierCart.getTableId())) {
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()
+ .notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
+ .eq(TbCashierCart::getShopId, cashierCart.getShopId());
+
+ TbCashierCart finalCart = cashierCart;
+ queryWrapper.eq(TbCashierCart::getTableId, cashierCart.getTableId())
+ .and(q -> q.or(
+ query -> query.eq(TbCashierCart::getMasterId, finalCart.getMasterId())
+ .or()
+ .isNull(TbCashierCart::getMasterId)
+ .or()
+ .eq(TbCashierCart::getMasterId, "")
+ )
+ .or(query -> query.eq(TbCashierCart::getOrderId, finalCart.getOrderId())
+ .or()
+ .isNull(TbCashierCart::getOrderId)));
+
+ List list1 = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
+
+ if (list1.isEmpty()) {
+ tbOrderInfoMapper.deleteByPrimaryKey(cashierCart.getOrderId());
+ }
+ }
+
+ setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cashierCart), false);
+ return Result.success(CodeEnum.SUCCESS, masterId);
+ }
+
+ cashierCart.setNumber(number);
+ if (product != null) {
+ resetGroupProductCart(groupProductIdList, product, cashierCart);
+ }
+ cashierCart.setTotalNumber(number);
+ cashierCart.setIsPrint(isPrint);
+ cashierCart.setIsPack(isPack);
+ cashierCart.resetTotalAmount();
+ cashierCart.setUuid(uuid);
+ cashierCart.setIsPrint(isPrint);
+ cashierCart.resetTotalAmount();
+ if (product != null) {
+ resetGroupProductCart(groupProductIdList, product, cashierCart);
+ }
+
+ mpCashierCartMapper.updateById(cashierCart);
}
+
}
-
- 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);
+ if (type.equals("add") || needNew) {
+ if (product == null || product.getGroupType() == null || product.getGroupType() != 1) {
+ cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId);
}
- } else {
- List list = cashierCartMapper.selectALlByMasterId(masterId, "create");
- TbCashierCart cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO);
- // 不存在新增
- if (Objects.isNull(cashierCart)) {
+ if (cashierCart != null) {
+ // 校验是否是代客下单往期订单
+ if (shopEatTypeInfoDTO.isDineInAfter() && cashierCart.getPlaceNum() != null && !isSeatCart) {
+ return Result.fail("后付费已下单订单仅支持退款");
+ }
+
+ if (skuWithBLOBs != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number.compareTo(BigDecimal.valueOf(skuWithBLOBs.getSuit())) < 0) {
+ delCart(masterId, cartId);
+ if (cashierCart.getOrderId() != null && StrUtil.isNotBlank(cashierCart.getTableId())) {
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()
+ .notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
+ .eq(TbCashierCart::getShopId, cashierCart.getShopId());
+
+ TbCashierCart finalCart = cashierCart;
+ queryWrapper.eq(TbCashierCart::getTableId, cashierCart.getTableId())
+ .and(q -> q.or(
+ query -> query.eq(TbCashierCart::getMasterId, finalCart.getMasterId())
+ .or()
+ .isNull(TbCashierCart::getMasterId)
+ .or()
+ .eq(TbCashierCart::getMasterId, "")
+ )
+ .or(query -> query.eq(TbCashierCart::getOrderId, finalCart.getOrderId())
+ .or()
+ .isNull(TbCashierCart::getOrderId)));
+
+ List list1 = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
+
+ if (list1.isEmpty()) {
+ tbOrderInfoMapper.deleteByPrimaryKey(cashierCart.getOrderId());
+ }
+ }
+
+ setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cashierCart), false);
+ return Result.success(CodeEnum.SUCCESS, masterId);
+ }
+
+ number = cashierCart.getNumber().add(number);
+ cashierCart.setNumber(number);
+ if (product != null) {
+ resetGroupProductCart(groupProductIdList, product, cashierCart);
+ }
+ cashierCart.setTotalNumber(number);
+ cashierCart.setIsPrint(isPrint);
+ cashierCart.setIsPack(isPack);
+ cashierCart.resetTotalAmount();
+ cashierCart.setUuid(uuid);
+ cashierCart.setIsPrint(isPrint);
+ cashierCart.resetTotalAmount();
+ if (product != null) {
+ resetGroupProductCart(groupProductIdList, product, cashierCart);
+ }
+
+ mpCashierCartMapper.updateById(cashierCart);
+ } else {
+
cashierCart = new TbCashierCart();
cashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
if (product != null) {
@@ -345,12 +484,14 @@ public class OrderService {
cashierCart.setIsSku(product.getTypeEnum());
cashierCart.setName(product.getName());
cashierCart.setCategoryId(product.getCategoryId());
+ cashierCart.setTypeEnum(product.getTypeEnum());
+ cashierCart.setGroupType(product.getGroupType());
}
cashierCart.setCreatedAt(System.currentTimeMillis());
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());
@@ -358,6 +499,7 @@ public class OrderService {
cashierCart.setMemberPrice(skuWithBLOBs.getMemberPrice());
cashierCart.setIsMember(0);
}
+ cashierCart.setIsPrint(isPrint);
cashierCart.setShopId(shopId.toString());
cashierCart.setTradeDay(DateUtils.getDay());
cashierCart.setStatus("create");
@@ -365,9 +507,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,46 +518,34 @@ public class OrderService {
cashierCart.setPackFee(BigDecimal.ZERO);
} else {
if (!isSeatCart) {
- cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
+ cashierCart.setPackFee(number.multiply(product == null ? BigDecimal.ZERO : product.getPackFee()));
}
cashierCart.setTotalAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee()));
-
+ }
+ if (skuWithBLOBs != null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0 && number.compareTo(BigDecimal.valueOf(skuWithBLOBs.getSuit())) < 0) {
+ number = BigDecimal.valueOf(skuWithBLOBs.getSuit());
}
cashierCart.setTotalNumber(number);
- cashierCart.setUserId(Integer.valueOf(userId));
cashierCart.setNumber(number);
+ cashierCart.setUserId(Integer.valueOf(userId));
cashierCart.setUuid(uuid);
cashierCart.setTableId(tableId);
cashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
+ if (product != null) {
+ resetGroupProductCart(groupProductIdList, product, cashierCart);
+ }
list.add(cashierCart);
mpCashierCartMapper.insert(cashierCart);
- } else {
- if (type.equals("add")) {
- cashierCart.setNumber(cashierCart.getNumber() + 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()));
- mpCashierCartMapper.updateById(cashierCart);
}
- cart = cashierCart;
}
-
- setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), true);
+ setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cashierCart), true);
return Result.success(CodeEnum.SUCCESS, masterId);
}
- private TbCashierCart getCashierInfo(Object shopId, Object skuId, Object productId, String tableId, String MasterId, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {
+ private TbCashierCart getCashierInfo(Object shopId, Object skuId, Object productId, String tableId, String MasterId, ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer cartId) {
LambdaQueryWrapper query = new LambdaQueryWrapper()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getSkuId, skuId)
@@ -423,6 +553,10 @@ public class OrderService {
.in(TbCashierCart::getStatus, "create")
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType());
+ if (cartId != null) {
+ query.eq(TbCashierCart::getId, cartId);
+ }
+
if (shopEatTypeInfoDTO.isDineInAfter()) {
query.isNull(TbCashierCart::getPlaceNum);
}
@@ -500,8 +634,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 +655,7 @@ public class OrderService {
List list = mpCashierCartMapper.selectList(queryWrapper);
AtomicReference mealCashierCart = new AtomicReference<>();
ArrayList returnCashierCarts = new ArrayList<>();
- String orderId = null;
+ Integer orderId = null;
for (TbCashierCart cart : list) {
if (cart.getOrderId() != null) {
orderId = cart.getOrderId();
@@ -531,7 +664,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 +676,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(){{
+ return Result.success(CodeEnum.SUCCESS, new HashMap() {{
put("list", new ArrayList<>());
put("masterId", finalMasterId);
put("num", 0);
put("seatFee", null);
- put("amount", new HashMap(){{
+ put("amount", new HashMap() {{
put("packAmount", 0);
put("productNum", 0);
put("productSum", 0);
@@ -586,7 +719,8 @@ public class OrderService {
HashMap 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 +731,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());
+ }
+
+ TbProduct 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 +770,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 +781,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) {
+ TbProduct 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 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 queryWrapper = new LambdaQueryWrapper()
.notIn(TbCashierCart::getStatus, "final", "refund", "closed", "pending")
.eq(TbCashierCart::getShopId, cashierCart.getShopId());
@@ -684,8 +822,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 +890,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 +963,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 +1010,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,50 +1036,65 @@ 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;
+ TbProduct 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());
}
+ orderDetail.setProGroupInfo(cashierCart.getProGroupInfo());
+ orderDetail.setIsTemporary(cashierCart.getIsTemporary());
+ orderDetail.setDiscountSaleNote(cashierCart.getDiscountSaleNote());
+ orderDetail.setDiscountSaleAmount(cashierCart.getDiscountSaleAmount());
+ orderDetail.setIsPrint(cashierCart.getIsPrint());
orderDetail.setMemberPrice(cashierCart.getMemberPrice());
orderDetail.setCreateTime(new Date());
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());
+
orderDetails.add(orderDetail);
// 库存预警校验
- 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;
+ TbProduct finalProduct = product;
+ CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(finalTbProduct, finalProduct, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber().intValue()));
}
}
@@ -1033,6 +1184,7 @@ public class OrderService {
orderDetail.setPackAmount(BigDecimal.ZERO);
}
}
+ updateOrderDetailCanReturn(orderDetails, orderInfo);
mpOrderDetailService.saveOrUpdateBatch(orderDetails);
// 删除已经移除购物车的商品
@@ -1094,6 +1246,28 @@ public class OrderService {
return Result.success(CodeEnum.SUCCESS, orderInfo);
}
+ private void updateOrderDetailCanReturn(List orderDetailList, TbOrderInfo orderInfo) {
+ orderDetailList = orderDetailList.stream().filter(item -> TableConstant.OrderInfo.Status.UNPAID.equalsVals(item.getStatus())).collect(Collectors.toList());
+ BigDecimal totalAmount = BigDecimal.ZERO;
+ BigDecimal lastAmount = BigDecimal.ZERO;
+ BigDecimal lastReturnAmount = BigDecimal.ZERO;
+ BigDecimal orderAmount = orderInfo.getOrderAmount();
+ for (TbOrderDetail orderDetail : orderDetailList) {
+ totalAmount = totalAmount.add(orderDetail.getPriceAmount());
+ }
+ for (TbOrderDetail item : orderDetailList) {
+ if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) || orderInfo.getPointsNum() != null) {
+ BigDecimal canReturnAmount = item.getPriceAmount().divide(totalAmount.subtract(lastAmount), 10, RoundingMode.HALF_DOWN)
+ .multiply(orderAmount.subtract(lastReturnAmount)).setScale(2, RoundingMode.HALF_DOWN);
+ lastReturnAmount = canReturnAmount;
+ lastAmount = item.getPriceAmount();
+ item.setCanReturnAmount(canReturnAmount);
+ } else {
+ item.setCanReturnAmount(item.getPriceAmount());
+ }
+ }
+ }
+
/**
* 获取当前台桌当前下单次数
*
@@ -1267,12 +1441,12 @@ public class OrderService {
}
List list = cashierCartMapper.selectAllByMarketId(day, String.valueOf(cartVo.getShopId()), cartVo.getMasterId());
for (TbCashierCart cashierCart : list) {
- TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
+ TbProduct 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());
@@ -1285,12 +1459,12 @@ 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 queryWrapper = new LambdaQueryWrapper()
.eq(TbCashierCart::getShopId, cartVo.getShopId())
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
+ .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.eq(TbCashierCart::getStatus, "create");
if (shopEatTypeInfoDTO.isDineInAfter()) {
@@ -1300,7 +1474,6 @@ public class OrderService {
// 普通点单
if (StrUtil.isBlank(cartVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, cartVo.getMasterId())
- .eq(TbCashierCart::getTradeDay, day)
.and(query -> query.isNull(TbCashierCart::getTableId)
.or()
.eq(TbCashierCart::getTableId, ""));
@@ -1319,8 +1492,8 @@ public class OrderService {
ArrayList 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;
}
@@ -1329,7 +1502,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));
}
}
@@ -1360,7 +1533,9 @@ public class OrderService {
// 打印退款票据
int finalOrderId = orderId;
ThreadUtil.execute(() -> {
- printMechineConsumer.printReturnTicket(finalOrderId, null);
+ if (finalOrderId != 0) {
+ printMechineConsumer.printReturnTicket(finalOrderId, null);
+ }
});
@@ -1405,12 +1580,28 @@ public class OrderService {
if (Objects.isNull(skuInfoPos) || skuInfoPos.size() < 0) {
skuInfoPos = new ArrayList<>();
}
+ skuInfoPos.forEach(item -> {
+ if (item.getDiscountSaleAmount() != null) {
+ item.setPrice(item.getPrice().subtract(item.getDiscountSaleAmount()));
+ if (item.getMemberPrice() != null) {
+ item.setMemberPrice(item.getMemberPrice().subtract(item.getDiscountSaleAmount()));
+ }
+ }
+ });
orderInfo.setSkuInfos(skuInfoPos);
} else {
List skuInfoPos = tbOrderInfoMapper.selectSkuByOrderId(orderInfo.getId().toString());
if (Objects.isNull(skuInfoPos) || skuInfoPos.size() < 0) {
skuInfoPos = new ArrayList<>();
}
+ skuInfoPos.forEach(item -> {
+ if (item.getDiscountSaleAmount() != null) {
+ item.setPrice(item.getPrice().subtract(item.getDiscountSaleAmount()));
+ if (item.getMemberPrice() != null) {
+ item.setMemberPrice(item.getMemberPrice().subtract(item.getDiscountSaleAmount()));
+ }
+ }
+ });
orderInfo.setSkuInfos(skuInfoPos);
}
@@ -1491,7 +1682,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);
@@ -1510,8 +1701,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);
@@ -1569,10 +1760,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);
@@ -1833,7 +2024,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("店铺信息不存在");
@@ -1878,15 +2069,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);
}
@@ -2023,4 +2214,182 @@ 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, temporaryDishesDTO.getName());
+ // 首次加入
+// 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 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.setUnit(temporaryDishesDTO.getUnit());
+ 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.save(tbCashierCart);
+// }
+
+ if (StrUtil.isNotBlank(temporaryDishesDTO.getTableId())) {
+ setRedisTableCartInfo(temporaryDishesDTO.getTableId(), temporaryDishesDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true);
+ }
+ return tbCashierCart;
+ }
+
+ public Object updatePrice(UpdatePriceDTO updatePriceDTO) {
+ TbCashierCart cashierCart = mpCashierCartService.selectByShopIdAndId(updatePriceDTO.getShopId(), updatePriceDTO.getCartId(), TableConstant.OrderInfo.Status.CREATE);
+ if (cashierCart == null) {
+ throw new MsgException("购物车商品不存在");
+ }
+
+ if (cashierCart.getIsMember() == 0) {
+ if (cashierCart.getSalePrice().subtract(updatePriceDTO.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
+ throw new MsgException("折扣金额不能超过单价");
+ }
+ } else {
+ if (cashierCart.getMemberPrice().subtract(updatePriceDTO.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
+ throw new MsgException("折扣金额不能超过单价");
+ }
+ }
+
+ BigDecimal oldAmount = cashierCart.getTotalAmount();
+ cashierCart.setDiscountSaleAmount(updatePriceDTO.getAmount());
+ cashierCart.resetTotalAmount();
+ cashierCart.setUpdatedAt(DateUtil.date().getTime());
+ cashierCart.setDiscountSaleNote(updatePriceDTO.getNote());
+ cashierCart.setDiscountSaleAmount(updatePriceDTO.getAmount());
+ mpCashierCartService.updateById(cashierCart);
+
+ // 更新订单和detail价格
+ if (cashierCart.getOrderId() != null) {
+ mpOrderDetailService.updatePriceByCartId(cashierCart.getId(), updatePriceDTO.getAmount(), cashierCart.getTotalAmount());
+ mpOrderInfoService.incrAmount(cashierCart.getOrderId(), cashierCart.getTotalAmount().subtract(oldAmount));
+ }
+ return cashierCart;
+ }
+
+ public Object checkCoupon(ThirdCouponCheckDTO checkDTO) {
+ TbOrderInfo orderInfo = mpOrderInfoService.getById(checkDTO.getOrderId());
+ if (orderInfo == null) {
+ throw new MsgException("订单信息不存在");
+ }
+
+ if (!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) {
+ throw new MsgException("订单不为待支付状态");
+ }
+
+ List cashierCarts = mpCashierCartService.selectByIds(checkDTO.getShopId(), checkDTO.getOrderId(), checkDTO.getCartId());
+ if (cashierCarts.size() != checkDTO.getCartId().size()) {
+ throw new MsgException("含有不存在购物车");
+ }
+
+ CheckCouponDTO dto = new CheckCouponDTO();
+ dto.setShopId(checkDTO.getShopId());
+ dto.setCouponCode(checkDTO.getCode());
+ dto.setNum(checkDTO.getNum());
+ thirdPartyCouponService.checkCoupon(dto);
+
+ BigDecimal incrAmount = BigDecimal.ZERO;
+ for (TbCashierCart item : cashierCarts) {
+ item.setIsThirdCoupon(1);
+ incrAmount = incrAmount.add(item.getTotalAmount());
+ }
+ mpCashierCartService.updateBatchById(cashierCarts);
+ mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsThirdCoupon, 1, checkDTO.getCartId());
+ mpOrderInfoService.incrAmount(orderInfo.getId(), incrAmount.negate());
+
+ TbThirdPartyCouponRecord record = new TbThirdPartyCouponRecord();
+ record.setOrderId(orderInfo.getId());
+ record.setCode(checkDTO.getCode());
+ record.setNum(1);
+ record.setState(1);
+ record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue());
+ record.setCreateTime(DateUtil.date());
+ record.setCheckTime(DateUtil.date());
+ record.setShopId(checkDTO.getShopId());
+ record.setCartIdList(JSONObject.toJSONString(checkDTO.getCartId()));
+ thirdPartyCouponRecordService.save(record);
+ return true;
+
+ }
+
+ public Result updatePrint(CartPrintDTO printDTO) {
+ if (printDTO.getIsPrint() == null) {
+ return Result.success(CodeEnum.SUCCESS);
+ }
+ mpCashierCartService.update(new LambdaUpdateWrapper()
+ .eq(TbCashierCart::getShopId, printDTO.getShopId())
+ .eq(TbCashierCart::getId, printDTO.getCartId())
+ .set(TbCashierCart::getIsPrint, printDTO.getIsPrint()));
+
+ mpOrderDetailService.update(new LambdaUpdateWrapper()
+ .eq(TbOrderDetail::getCartId, printDTO.getCartId())
+ .set(TbOrderDetail::getIsPrint, printDTO.getIsPrint()));
+
+ return Result.success(CodeEnum.SUCCESS);
+ }
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
index 8dffbe3..489a943 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java
@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.service;
+import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -14,17 +15,18 @@ import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
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.OrderInfoCouponInfoDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
+import com.chaozhanggui.system.cashierservice.entity.dto.ReturnOrderDTO;
import com.chaozhanggui.system.cashierservice.entity.po.OrderDetailPo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.exception.NotPrintException;
+import com.chaozhanggui.system.cashierservice.mapper.MpProductStockDetailMapper;
+import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
-import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
-import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
-import com.chaozhanggui.system.cashierservice.mybatis.MpShopUserFlowMapper;
-import com.chaozhanggui.system.cashierservice.mybatis.MpShopUserMapper;
+import com.chaozhanggui.system.cashierservice.mybatis.*;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -55,6 +57,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
@@ -137,13 +140,29 @@ public class PayService {
private PlatformTransactionManager transactionManager;
private final MpCashierCartService mpCashierCartService;
+ private final TbShopCouponService shopCouponService;
+ private final MpOrderDetailService mpOrderDetailService;
+ private final MpShopUnitMapper mpShopUnitMapper;
+ private final MpProductStockDetailMapper mpProductStockDetailMapper;
+ private final MpOrderInfoService mpOrderInfoService;
+ private final TbMemberPointsService memberPointsService;
+
+
private final Utils utils;
+ @Autowired
+ private MPOrderInfoMapper mPOrderInfoMapper;
- public PayService(RedisTemplate redisTemplate, MpCashierCartService mpCashierCartService, Utils utils) {
+ public PayService(RedisTemplate redisTemplate, MpCashierCartService mpCashierCartService, TbShopCouponService shopCouponService, MpOrderDetailService mpOrderDetailService, MpShopUnitMapper mpShopUnitMapper, MpProductStockDetailMapper mpProductStockDetailMapper, MpOrderInfoService mpOrderInfoService, Utils utils) {
this.redisTemplate = redisTemplate;
this.mpCashierCartService = mpCashierCartService;
+ this.shopCouponService = shopCouponService;
+ this.mpOrderDetailService = mpOrderDetailService;
+ this.mpShopUnitMapper = mpShopUnitMapper;
+ this.mpProductStockDetailMapper = mpProductStockDetailMapper;
+ this.mpOrderInfoService = mpOrderInfoService;
this.utils = utils;
+ memberPointsService = null;
}
public static void main(String[] args) {
@@ -151,7 +170,7 @@ public class PayService {
}
public Result queryPayType(String shopId) {
- return Result.success(CodeEnum.SUCCESS, tbShopPayTypeMapper.selectByShopId(shopId));
+ return Result.success(SUCCESS, tbShopPayTypeMapper.selectByShopId(shopId));
}
private void clearTableInfoCache(TbOrderInfo orderInfo) {
@@ -355,7 +374,7 @@ public class PayService {
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
- return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
+ return Result.success(SUCCESS, object.getJSONObject("data"));
} else {
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
if (ObjectUtil.isNotNull(status) && "7".equals(status)) {
@@ -558,7 +577,7 @@ public class PayService {
}
}
- return Result.success(CodeEnum.SUCCESS, orderInfo);
+ return Result.success(SUCCESS, orderInfo);
}
@@ -719,7 +738,7 @@ public class PayService {
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
- return Result.success(CodeEnum.SUCCESS);
+ return Result.success(SUCCESS);
}
@Transactional(rollbackFor = Exception.class)
@@ -853,7 +872,7 @@ public class PayService {
producer.balance(baObj.toString());
clearTableInfoCache(orderInfo);
- return Result.success(CodeEnum.SUCCESS);
+ return Result.success(SUCCESS);
}
public Result vipPay(Integer orderId, String token, Integer vipUserId, BigDecimal payAmount, BigDecimal discountAmount) {
@@ -963,7 +982,7 @@ public class PayService {
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
- return Result.success(CodeEnum.SUCCESS);
+ return Result.success(SUCCESS);
}
@@ -1058,7 +1077,7 @@ public class PayService {
redisUtil.del(tableCartKey);
clearTableInfoCache(orderInfo);
- return Result.success(CodeEnum.SUCCESS);
+ return Result.success(SUCCESS);
}
@Transactional(rollbackFor = Exception.class)
@@ -1146,144 +1165,277 @@ public class PayService {
clearTableInfoCache(orderInfo);
- return Result.success(CodeEnum.SUCCESS);
+ return Result.success(SUCCESS);
}
- @Transactional(rollbackFor = Exception.class)
- public Result returnOrder(List list, String token, String pwd, boolean isOnline) {
- if (ObjectUtil.isEmpty(list) || list.size() <= 0) {
- return Result.fail(CodeEnum.PARAM);
+ private HashMap updateReturnOrderInfo(ReturnOrderDTO returnOrderDTO, TbOrderInfo oldOrderInfo, boolean isOnline) {
+ String couponInfoList = oldOrderInfo.getCouponInfoList();
+ OrderInfoCouponInfoDTO couponInfoDTO = null;
+ if (StrUtil.isNotBlank(couponInfoList)) {
+ couponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class);
+ }
+ ArrayList detailIds = new ArrayList<>();
+ HashMap returnNumMap = new HashMap<>();
+ returnOrderDTO.getOrderDetails().forEach(item -> {
+ detailIds.add(item.getId());
+ returnNumMap.put(item.getId().toString(), item.getNum());
+ });
+ List detailList = mPOrderDetailMapper.selectList(new LambdaQueryWrapper()
+// .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId())
+ .eq(TbOrderDetail::getStatus, "closed")
+ .eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId())
+ .in(TbOrderDetail::getId, detailIds)
+ .orderByDesc(TbOrderDetail::getUserCouponId));
+ if (detailList.size() != returnOrderDTO.getOrderDetails().size()) {
+ throw new MsgException("订单明细数量不一致");
}
-
- 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 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;
+ HashMap data = new HashMap<>();
+ BigDecimal returnAmount = BigDecimal.ZERO;
BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal saleAmount = BigDecimal.ZERO;
- BigDecimal feeAmount = BigDecimal.ZERO;
- BigDecimal payAmount = BigDecimal.ZERO;
+ ArrayList remainOrderDetailList = new ArrayList<>();
+ boolean hasNormalReturn = false;
+ for (TbOrderDetail orderDetail : detailList) {
+ // 原始金额
+ BigDecimal originalAmount = orderDetail.getPriceAmount();
+ BigDecimal originalPackAmount = orderDetail.getPackAmount();
+ // 退款数量
+ BigDecimal returnNum = returnNumMap.get(orderDetail.getId().toString());
+ // 剩余数量
+ BigDecimal remainNum = orderDetail.getNum().subtract(returnNum);
+ if (remainNum.compareTo(BigDecimal.ZERO) < 0) {
+ throw new MsgException(StrUtil.format("{}最多可退数量为: {}", orderDetail.getProductName(), orderDetail.getNum()));
+ }
- List detailPos = new ArrayList<>();
-// //判断是否全量退款
-// if(list.size()==orderDetails.size()){
-// //修改主单状态
-// orderInfo.setStatus("rhandoverprintDataefund");
-// orderInfo.setUpdatedAt(System.currentTimeMillis());
-// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
-// }
+ // 将未退款的剩余订单详情重新生成记录
+ BigDecimal packFee = orderDetail.getPackAmount().divide(orderDetail.getNum(), RoundingMode.HALF_UP);
+ BigDecimal returnPackFee = packFee.multiply(returnNum);
+ BigDecimal currentDetailAMount = BigDecimal.ZERO;
+ // 优惠券抵扣商品直接退券
+ if (StrUtil.isNotBlank(orderDetail.getUseCouponInfo())) {
+ data.put("isCouponDiscount", true);
+ TbActivateOutRecord outRecord = JSONObject.parseObject(orderDetail.getUseCouponInfo(), TbActivateOutRecord.class);
+ outRecord.setRefNum(returnNum.intValue());
+ shopCouponService.refund(CollUtil.newArrayList(outRecord));
+ currentDetailAMount = returnNum.multiply(orderDetail.getPrice())
+ .add(returnPackFee);
+ // 移除使用的券
+ couponInfoDTO.getProductCoupon().forEach(item -> {
+ if (Objects.equals(item.getId(), outRecord.getGiveId())) {
+ item.setReturnNum(item.getReturnNum() + outRecord.getRefNum());
+ }
+ });
- List returnDetail = new ArrayList<>();
+ // 使用了满减或积分,获取普通付款商品计算退款比例,退部分现金
+ } else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0) {
+ hasNormalReturn = true;
+ // 计算当前商品占比
+ returnAmount = calcDetailReturnAmount(orderDetail, returnNum);
+ currentDetailAMount = orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
+ .multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN);
+ if (oldOrderInfo.getRefundAmount() == null) {
+ oldOrderInfo.setRefundAmount(BigDecimal.ZERO);
+ }
-// List details=new ArrayList<>();
+// if (ratio.compareTo(BigDecimal.ONE) == 0) {
+// returnAmount = oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount());
+// }else {
+// returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount()).multiply(ratio));
+// }
+ saleAmount = saleAmount.add(orderDetail.getPrice());
+ packAMount = packAMount.add(orderDetail.getPackAmount()
+ .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
+ .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP);
- Map 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");
+ hasNormalReturn = true;
+ saleAmount = saleAmount.add(orderDetail.getPrice());
+ if (remainNum.compareTo(BigDecimal.ZERO) <= 0) {
+ returnAmount = orderDetail.getPriceAmount();
+ packAMount = orderDetail.getPackAmount();
} else {
- detailPo.setStatus("closed");
-
+ currentDetailAMount = orderDetail.getPriceAmount()
+ .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
+ .multiply(returnNum).setScale(2, RoundingMode.HALF_UP);
+ returnAmount = returnAmount.add(currentDetailAMount);
+ packAMount = packAMount.add(orderDetail.getPackAmount()
+ .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
+ .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP);
}
- BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));
+ }
+ returnAmount = returnAmount.setScale(2, RoundingMode.HALF_DOWN);
- 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);
+ if (remainNum.compareTo(BigDecimal.ZERO) > 0) {
+ // 单个打包费
+ TbOrderDetail remainOrderDetail = new TbOrderDetail();
+ BeanUtil.copyProperties(remainOrderDetail, orderDetail);
+ remainOrderDetail.setNum(remainNum);
+ remainOrderDetail.setPriceAmount(originalAmount.subtract(returnAmount));
+ remainOrderDetail.setPackAmount(originalPackAmount.subtract(returnPackFee));
+ remainOrderDetail.setReturnNum(BigDecimal.ZERO);
+ remainOrderDetail.setId(null);
+ remainOrderDetail.setCanReturnAmount(remainOrderDetail.getCanReturnAmount().subtract(returnAmount));
+ remainOrderDetailList.add(remainOrderDetail);
+ orderDetail.setCanReturnAmount(returnAmount);
+ }
-// details.add(new ReturnWTZInfo.ReturnDetail(it.getId()+"",it.getProductSkuId()+"",it.getNum()+""));
+ orderDetail.setNum(returnNum);
+ orderDetail.setPriceAmount(currentDetailAMount);
+ orderDetail.setPackAmount(returnPackFee);
+ orderDetail.setReturnNum(returnNum);
+ orderDetail.setReturnAmount(returnAmount);
+// orderDetail.setStatus(isOnline ? "refunding" : "refund");
+ orderDetail.setStatus("refund");
+ }
+
+ if (returnAmount.compareTo(BigDecimal.ZERO) < 0) {
+ throw new MsgException("退款金额为负数有误");
+ }
+
+ if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0")) <= 0 && oldOrderInfo.getPayAmount().compareTo(BigDecimal.ZERO) != 0) {
+ throw new MsgException("退款金额必须大于0");
+ }
+
+ oldOrderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO));
+
+ // 保存剩余未退款的订单详情
+ if (!remainOrderDetailList.isEmpty()) {
+ mpOrderDetailService.saveBatch(remainOrderDetailList);
+ }
+
+// TbOrderInfo returnOrder = mpOrderInfoService.selectReturnOrderByOrderId(returnOrderDTO.getOrderId());
+ TbOrderInfo returnOrder = new TbOrderInfo();
+ String orderNo = generateOrderNumber();
+ cn.hutool.core.bean.BeanUtil.copyProperties(oldOrderInfo, returnOrder);
+ returnOrder.setId(null);
+ returnOrder.setOrderNo(orderNo);
+ returnOrder.setRefundAmount(returnAmount);
+ returnOrder.setOrderType("return");
+ returnOrder.setStatus(isOnline ? "refunding" : "refund");
+ returnOrder.setUpdatedAt(null);
+ returnOrder.setSystemTime(DateUtil.date().getTime());
+ returnOrder.setCreatedAt(DateUtil.date().getTime());
+ returnOrder.setPayOrderNo(null);
+ returnOrder.setSource(oldOrderInfo.getId());
+ returnOrder.setRefundRemark(returnOrderDTO.getNote());
+ returnOrder.setOrderAmount(returnAmount);
+ returnOrder.setAmount(returnAmount);
+ returnOrder.setSettlementAmount(returnAmount);
+ returnOrder.setPayAmount(returnAmount);
+ mPOrderInfoMapper.insert(returnOrder);
+
+
+ updateStockAndRecord(detailList);
+ mpOrderDetailService.updateBatchById(detailList);
+ data.put("returnOrder", returnOrder);
+ data.put("returnAmount", returnAmount);
+ data.put("hasNormalReturn", hasNormalReturn);
+ return data;
+ }
+
+ private void updateStockAndRecord(List orderDetailList) {
+ // 更新商品库存
+ for (TbOrderDetail detail : orderDetailList) {
+ TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId());
+ TbProduct 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 = mpShopUnitMapper.selectById(product.getUnitId());
+ tbProductStockDetail.setProductName(product.getName());
+ tbProductStockDetail.setIsStock(Integer.valueOf(product.getIsStock()));
+ tbProductStockDetail.setStockSnap(product.getSelectSpec());
+ tbProductStockDetail.setUnitName(shopUnit.getName());
+ tbProductStockDetail.setProductId(product.getId().toString());
+
+ productMapper.incrStock(String.valueOf(product.getId()), detail.getNum());
+ tbProductStockDetail.setLeftNumber(product.getStockNumber());
+ tbProductStockDetail.setStockNumber(detail.getNum().doubleValue());
+
+ productSkuMapper.decrRealSalesNumber(productSku.getId(), detail.getNum().intValue());
+ }
+
+ mpProductStockDetailMapper.insert(tbProductStockDetail);
+ }
+ }
+
+ private void returnCoupon(TbOrderInfo orderInfo, boolean resetInfo) {
+ // 返还优惠券
+ if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) {
+ OrderInfoCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderInfoCouponInfoDTO.class);
+ ArrayList couponIds = new ArrayList<>();
+ couponInfoDTO.getProductCoupon().forEach(item -> {
+ if (item.getReturnNum() >= item.getFinalUseNum()) {
+ couponIds.add(item.getId());
+ }
+ });
+ // 券返还
+ if (!couponInfoDTO.getOutRecordList().isEmpty()) {
+ ArrayList finalReturnList = new ArrayList<>();
+ couponInfoDTO.getOutRecordList().forEach(item -> {
+ if (!couponIds.contains(item.getGiveId())) {
+ item.setRefNum(item.getUseNum());
+ finalReturnList.add(item);
+ }
+ });
+ shopCouponService.refund(finalReturnList);
+ if (resetInfo) {
+ couponInfoDTO.setOutRecordList(new ArrayList<>());
+ orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO));
+ }
}
}
+ }
- 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));
+ @Transactional
+ public Object returnOrder(ReturnOrderDTO returnOrderDTO) {
+ TbOrderInfo orderInfo = mPOrderInfoMapper.selectOne(new LambdaQueryWrapper()
+ .eq(TbOrderInfo::getId, returnOrderDTO.getOrderId())
+ .in(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.REFUND.getValue(),
+ TableConstant.OrderInfo.Status.CLOSED.getValue())
+// .eq(TbOrderInfo::getStatus, "closed")
+ );
+ if (orderInfo == null) {
+ throw new MsgException("订单不处于可退款状态");
+ }
+
+ TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
+ if (shopInfo == null) {
+ throw new MsgException("店铺信息不存在");
+ }
+
+ if ("1".equals(shopInfo.getIsReturn())) {
+ // TODO 密码校验
+ }
+ String payType = orderInfo.getPayType();
+ HashMap returnInfoData = updateReturnOrderInfo(returnOrderDTO, orderInfo, "scanCode".equals(payType) || "wx_lite".equals(payType));
+ TbOrderInfo returnOrderInfo = (TbOrderInfo) returnInfoData.get("returnOrder");
+ BigDecimal returnAmount = (BigDecimal) returnInfoData.get("returnAmount");
+ boolean hasNormalReturn = (boolean) returnInfoData.get("hasNormalReturn");
+ String shopId = orderInfo.getShopId();
+
+// // 线上退款
+ orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(returnOrderInfo.getRefundAmount()));
+ orderInfo.setRefundRemark(returnOrderDTO.getNote());
+ if (hasNormalReturn && ("scanCode".equals(payType) || "wx_lite".equals(payType))) {
+ if (returnOrderDTO.getIsOnline() != null && !returnOrderDTO.getIsOnline()) {
+ mpOrderDetailService.updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status.REFUNDING, TableConstant.OrderInfo.Status.REFUND,
+ returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
+
+ }else {
+ TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
MsgException.checkNull(thirdApply, "支付参数配置错误");
if ("ysk".equals(thirdPayType)) {
@@ -1291,7 +1443,7 @@ public class PayService {
req.setAppId(thirdApply.getAppId());
req.setTimestamp(System.currentTimeMillis());
req.setOrderNumber(orderInfo.getPayOrderNo());
- req.setAmount(String.format("%.2f", newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
+ req.setAmount(String.format("%.2f", returnOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
req.setMercRefundNo(orderInfo.getOrderNo());
req.setRefundReason("退货");
req.setPayPassword(thirdApply.getPayPassword());
@@ -1309,10 +1461,10 @@ public class PayService {
}
} else {
- TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(String.valueOf(orderId));
+ TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(String.valueOf(orderInfo.getId()));
PublicResp 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());
+ returnOrderInfo.getOrderNo(), payment.getTradeNumber(), null, "订单退款",
+ returnOrderInfo.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())) {
@@ -1325,139 +1477,368 @@ public class PayService {
}
}
+ returnOrderInfo.setStatus("refund");
+ mPOrderInfoMapper.updateById(returnOrderInfo);
+ }
- } 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());
+ // 储值卡支付退款
+ } else if ("deposit".equals(payType)) {
+ mpOrderInfoService.depositReturn(Integer.valueOf(orderInfo.getUserId()), Integer.valueOf(orderInfo.getShopId()), returnAmount);
+ mpOrderDetailService.updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status.REFUNDING, TableConstant.OrderInfo.Status.REFUND,
+ returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
+ } else if ("cash".equals(payType)) {
+ mpOrderDetailService.updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status.REFUNDING, TableConstant.OrderInfo.Status.REFUND,
+ returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
+ }
+ orderInfo.setStatus(TableConstant.OrderInfo.Status.CLOSED.getValue());
+ // 订单金额全退,退优惠券以及积分
+ if (orderInfo.getPayAmount().compareTo(orderInfo.getRefundAmount()) <= 0) {
+ long count = mpOrderDetailService.count(new LambdaQueryWrapper()
+ .eq(TbOrderDetail::getOrderId, orderInfo.getId())
+ .eq(TbOrderDetail::getStatus, TableConstant.OrderInfo.Status.CLOSED));
+ if (count == 0) {
+ returnCoupon(orderInfo, true);
+ // 返还积分
+ memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(),
+ "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId()));
}
}
-
- //判断是否修改主单状态
- 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());
-
+ mPOrderInfoMapper.updateById(orderInfo);
+ // 打印退款小票
+// producer.printMechine(newOrderInfo.getId().toString());
+ producer.printMechine(returnOrderInfo.getId().toString());
//修改耗材数据
JSONObject jsonObject1 = new JSONObject();
- jsonObject1.put("orderId", newOrderInfo.getId());
+ jsonObject1.put("orderId", returnOrderInfo.getId());
jsonObject1.put("type", "delete");
- producer.cons(jsonObject1.toString());
+ rabbitMsgUtils.updateCons(jsonObject1);
+ return true;
+ }
- // 更新商品库存
- 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);
+ private BigDecimal calcDetailReturnAmount(TbOrderDetail orderDetail, BigDecimal returnNum) {
+ if (orderDetail.getNum().compareTo(returnNum) == 0) {
+ return orderDetail.getCanReturnAmount();
}
- redisUtil.del("SHOP:CODE:USER:" + "pc" + ":" + orderInfo.getShopId() + ":" + DateUtils.getDay() + TokenUtil.parseParamFromToken(token).getString("accountId"));
+ if (returnNum.compareTo(BigDecimal.ONE) == 0 &&
+ orderDetail.getNum().compareTo(BigDecimal.ONE) > 0 &&
+ orderDetail.getCanReturnAmount().compareTo(new BigDecimal("0.01")) <= 0) {
+ throw new MsgException(orderDetail.getProductName() + "总金额为0.01,请选择全部商品数量退回");
+ }
+ return orderDetail.getCanReturnAmount().divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN).multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN);
+ }
-
- return Result.success(CodeEnum.SUCCESS);
+ @Transactional(rollbackFor = Exception.class)
+ public Result returnOrder(List 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(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 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 detailPos = new ArrayList<>();
+//// //判断是否全量退款
+//// if(list.size()==orderDetails.size()){
+//// //修改主单状态
+//// orderInfo.setStatus("rhandoverprintDataefund");
+//// orderInfo.setUpdatedAt(System.currentTimeMillis());
+//// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
+//// }
+//
+// List returnDetail = new ArrayList<>();
+//
+//// List details=new ArrayList<>();
+//
+// Map 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 map = BeanUtil.transBean2Map(req);
+// req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
+// log.info("merchantOrderReturn req:{}", JSONUtil.toJsonStr(req));
+// ResponseEntity 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 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(SUCCESS);
+ return null;
}
public Result quickPay(String token, String amount, String authCode, String payType) {
@@ -1487,7 +1868,7 @@ public class PayService {
jsonObject.put("amount", tbQuickPay.getAmount());
producer.putOrderCollect(jsonObject.toJSONString());
- return Result.success(CodeEnum.SUCCESS, tbQuickPay);
+ return Result.success(SUCCESS, tbQuickPay);
} else {
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
@@ -1514,7 +1895,7 @@ public class PayService {
tbQuickPay.setTradeNo(object.getJSONObject("data").get("orderNumber").toString());
tbQuickPayMapper.insert(tbQuickPay);
- return Result.success(CodeEnum.SUCCESS, tbQuickPay);
+ return Result.success(SUCCESS, tbQuickPay);
}
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
@@ -1539,7 +1920,7 @@ public class PayService {
jsonObject.put("type", "quick");
jsonObject.put("amount", tbQuickPay.getAmount());
producer.putOrderCollect(jsonObject.toJSONString());
- return Result.success(CodeEnum.SUCCESS, tbQuickPay);
+ return Result.success(SUCCESS, tbQuickPay);
}
if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
@@ -1609,7 +1990,7 @@ public class PayService {
}
}
- return Result.success(CodeEnum.SUCCESS, tbQuickPay);
+ return Result.success(SUCCESS, tbQuickPay);
}
public Result queryQuickPay(String token, int pageNo, int pageSize) {
@@ -1623,7 +2004,7 @@ public class PayService {
List list = tbQuickPayMapper.selectByShopIdAndStaffId(Integer.valueOf(shopId), Integer.valueOf(staffId));
PageInfo pageInfo = new PageInfo(list);
- return Result.success(CodeEnum.SUCCESS, pageInfo);
+ return Result.success(SUCCESS, pageInfo);
}
@@ -1709,7 +2090,7 @@ public class PayService {
groupOrderInfo.setStatus("refund");
}
tbGroupOrderInfoMapper.update(groupOrderInfo);
- return Result.success(CodeEnum.SUCCESS);
+ return Result.success(SUCCESS);
}
public Result getOrderDiscount(String staffId, String orderId, String token) {
@@ -1868,7 +2249,7 @@ public class PayService {
ObjectMapper mapper = new ObjectMapper();
- return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
+ return Result.success(SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
payment.setTradeNumber(scanpayResp.getPayOrderId());
@@ -2027,7 +2408,7 @@ public class PayService {
ObjectMapper mapper = new ObjectMapper();
- return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
+ return Result.success(SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
payment.setTradeNumber(scanpayResp.getPayOrderId());
@@ -2098,7 +2479,7 @@ public class PayService {
}
}
- return Result.success(CodeEnum.SUCCESS, orderInfo);
+ return Result.success(SUCCESS, orderInfo);
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java
index eaede9b..42a4ae2 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java
@@ -1,29 +1,31 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
-import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
+import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.interceptor.LimitSubmitAspect;
+import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
+import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
import java.util.*;
+import java.util.stream.Collectors;
@Service
@Slf4j
@@ -49,6 +51,10 @@ public class ProductService {
private LimitSubmitAspect limitSubmitAspect;
private final RabbitProducer producer;
+ @Autowired
+ private TbShopUnitMapper tbShopUnitMapper;
+ @Autowired
+ private MpShopUnitMapper mpShopUnitMapper;
public ProductService(RabbitProducer producer) {
this.producer = producer;
@@ -71,7 +77,7 @@ public class ProductService {
public Result queryCommodityInfo(String shopId, String categoryId, String commdityName, Integer page, Integer pageSize, String masterId){
- List tbProductWithBLOBs=null;
+ List tbProductWithBLOBs=null;
if(ObjectUtil.isEmpty(categoryId)){
tbProductWithBLOBs=tbProductMapper.selectByShopId(shopId,commdityName);
}else {
@@ -111,7 +117,7 @@ public class ProductService {
}
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
- List tbProductWithBLOBs=null;
+ List tbProductWithBLOBs=null;
PageHelperUtil.startPage(page,pageSize);
if(ObjectUtil.isEmpty(categoryId)){
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName);
@@ -122,9 +128,19 @@ public class ProductService {
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndShopTypeCheckGrounding(shopId,categoryId,commdityName);
}
}
-
+ Map shopUnitsMap = new HashMap<>();
+ Set unitIds = tbProductWithBLOBs.stream().map(TbProduct::getUnitId).collect(Collectors.toSet());
+ if (!unitIds.isEmpty()) {
+ List shopUnits = mpShopUnitMapper.selectBatchIds(unitIds);
+ shopUnitsMap = shopUnits.stream()
+ .collect(Collectors.toMap(
+ unit -> String.valueOf(unit.getId()), // 将 id 转换为 String 类型
+ unit -> unit // 直接使用 TbShopUnit 作为值
+ ));
+ }
String day = DateUtils.getDay();
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
+ Map finalShopUnitsMap = shopUnitsMap;
tbProductWithBLOBs.parallelStream().forEach(it->{
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId);
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
@@ -141,18 +157,23 @@ public class ProductService {
it.setSkuList(skuWithBLOBs);
it.setGroundingSpecInfo(querySpec(Integer.valueOf(shopId), it.getId()));
+ TbShopUnit tbShopUnit = finalShopUnitsMap.get(it.getUnitId());
+ it.setUnitName(tbShopUnit == null ? null : tbShopUnit.getName());
+ if ("package".equals(it.getType())) {
+ it.setProGroupVo(JSONUtil.parseListTNewList(it.getGroupSnap(), ProductGroupVo.class));
+ }
});
}
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
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) {
- TbProductWithBLOBs product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(productId));
+ public void decrStock(String productId, String skuId, BigDecimal decrNum) {
+ TbProduct product = tbProductMapper.selectByPrimaryKey(Integer.valueOf(productId));
if (product.getIsStock() == 1) {
if (tbProductMapper.decrStock(productId, decrNum) < 1) {
throw new MsgException("库存不足,下单失败");
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java
index 742a52a..06d2d7b 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbGroupOrderInfoService.java
@@ -50,7 +50,7 @@ public class TbGroupOrderInfoService {
*/
public Result queryById(Integer id) {
TbGroupOrderInfo tbGroupOrderInfo = tbGroupOrderInfoMapper.queryById(id);
- TbProductWithBLOBs tbProduct = productMapper.selectByPrimaryKey(tbGroupOrderInfo.getProId());
+ TbProduct tbProduct = productMapper.selectByPrimaryKey(tbGroupOrderInfo.getProId());
TbProductSkuWithBLOBs tbProductSku = skuMapper.selectByProduct(tbGroupOrderInfo.getProId());
GroupOrderInfoVo productInfo = new GroupOrderInfoVo();
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java
new file mode 100644
index 0000000..f425e8f
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbMemberPointsService.java
@@ -0,0 +1,30 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+/**
+ * 会员积分
+ *
+ * @author Tankaikai tankaikai@aliyun.com
+ * @since 2.0 2024-10-25
+ */
+public interface TbMemberPointsService extends IService {
+
+
+ /**
+ * 追加积分
+ *
+ * @param memberId 会员id
+ * @param points 积分
+ * @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分)
+ * @param orderId 订单id,可以为空
+ * @throws Exception
+ */
+ boolean addPoints(Long memberId, int points, String content, Long orderId);
+
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopCouponService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopCouponService.java
new file mode 100644
index 0000000..157803f
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopCouponService.java
@@ -0,0 +1,24 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord;
+import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon;
+import org.springframework.http.ResponseEntity;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 优惠券(TbShopCoupon)表服务接口
+ *
+ * @author ww
+ * @since 2024-10-22 15:43:25
+ */
+public interface TbShopCouponService {
+
+ boolean refund(List param);
+
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopUnitService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopUnitService.java
new file mode 100644
index 0000000..7ebffc4
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopUnitService.java
@@ -0,0 +1,17 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.chaozhanggui.system.cashierservice.entity.TbShopUnit;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+* @author Administrator
+* @description 针对表【tb_shop_unit(商品单位)】的数据库操作Service
+* @createDate 2024-11-26 09:36:19
+*/
+public interface TbShopUnitService extends IService {
+
+ Page getShopUnit(Integer shopId, Integer page, Integer size, String name);
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbThirdPartyCouponRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbThirdPartyCouponRecordService.java
new file mode 100644
index 0000000..b9b67f8
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbThirdPartyCouponRecordService.java
@@ -0,0 +1,13 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+import com.chaozhanggui.system.cashierservice.entity.TbThirdPartyCouponRecord;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author Administrator
+* @description 针对表【tb_third_party_coupon_record】的数据库操作Service
+* @createDate 2024-11-26 15:06:35
+*/
+public interface TbThirdPartyCouponRecordService extends IService {
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ThirdPartyCouponService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ThirdPartyCouponService.java
new file mode 100644
index 0000000..b77f44d
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ThirdPartyCouponService.java
@@ -0,0 +1,21 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+
+import com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon.CheckCouponDTO;
+
+import java.util.Map;
+
+public interface ThirdPartyCouponService {
+
+ String getBindUrl(Integer shopId);
+
+ String getUnBindUrl(Integer shopId);
+
+ Map getActivateCoupon(Integer shopId, String code);
+
+ Map checkCoupon(CheckCouponDTO checkCouponDTO);
+
+ Map revokeCoupon(CheckCouponDTO checkCouponDTO);
+
+ Map getState(Integer shopId);
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java
index 3526584..dc5d153 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java
@@ -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,56 @@ public class MpCashierCartServiceImpl extends ServiceImpl query = new LambdaQueryWrapper()
+ .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)
+ .eq(TbCashierCart::getSkuName, proName);
+ }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 queryWrapper = new LambdaQueryWrapper()
+ .eq(TbCashierCart::getShopId, shopId)
+ .eq(TbCashierCart::getId, cartId);
+ if (statuses.length != 0) {
+ queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
+ }
+ return getOne(queryWrapper);
+ }
+ @Override
+ public List selectByIds(Integer shopId, Integer orderId, List ids, TableConstant.OrderInfo.Status... statuses) {
+ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper()
+ .eq(TbCashierCart::getShopId, shopId)
+ .eq(TbCashierCart::getOrderId, orderId)
+ .in(TbCashierCart::getId, ids);
+ if (statuses.length != 0) {
+ queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
+ }
+ return list(queryWrapper);
+ }
+
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderDetailServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderDetailServiceImpl.java
index be5b03c..2510fd6 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderDetailServiceImpl.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderDetailServiceImpl.java
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper;
@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -46,9 +48,39 @@ public class MpOrderDetailServiceImpl extends ServiceImpl()
.eq(TbOrderDetail::getOrderId, orderId));
}
+
+ @Override
+ public boolean updatePriceByCartId(Integer cartId, BigDecimal saleAmount, BigDecimal totalAmount) {
+ return update(new LambdaUpdateWrapper()
+ .eq(TbOrderDetail::getCartId, cartId)
+ .set(TbOrderDetail::getPrice, saleAmount)
+ .set(TbOrderDetail::getPriceAmount, totalAmount));
+ }
+
+ @Override
+ public boolean updateFieldByCartId(SFunction field, Object val, List cartIds) {
+ LambdaUpdateWrapper query = new LambdaUpdateWrapper()
+ .set(field, val);
+ if (!cartIds.isEmpty()) {
+ query.in(TbOrderDetail::getCartId, cartIds);
+ }
+ return update(query);
+ }
+
+ @Override
+ public boolean updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status oldOrderStatusEnums, TableConstant.OrderInfo.Status orderStatusEnums, Integer orderId, List orderDetails) {
+ LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper()
+ .eq(TbOrderDetail::getOrderId, orderId)
+ .in(TbOrderDetail::getId, orderDetails)
+ .set(TbOrderDetail::getStatus, orderStatusEnums.getValue());
+ if (oldOrderStatusEnums != null) {
+ wrapper.eq(TbOrderDetail::getStatus, oldOrderStatusEnums.getValue());
+ }
+ return update(wrapper);
+ }
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderInfoServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderInfoServiceImpl.java
index b743e44..4c6c6c1 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderInfoServiceImpl.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpOrderInfoServiceImpl.java
@@ -1,17 +1,28 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.Hutool;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
+import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
+import com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow;
+import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderInfoMapper;
+import com.chaozhanggui.system.cashierservice.mybatis.MpShopUserFlowMapper;
+import com.chaozhanggui.system.cashierservice.mybatis.MpShopUserMapper;
import com.chaozhanggui.system.cashierservice.service.MpOrderDetailService;
import com.chaozhanggui.system.cashierservice.service.MpOrderInfoService;
+import com.chaozhanggui.system.cashierservice.util.RabbitMsgUtils;
import org.springframework.stereotype.Service;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -23,6 +34,16 @@ import java.util.List;
@Service
public class MpOrderInfoServiceImpl extends ServiceImpl implements MpOrderInfoService {
+ private final MpShopUserMapper mpShopUserMapper;
+ private final MpShopUserFlowMapper mpShopUserFlowMapper;
+ private final RabbitMsgUtils rabbitMsgUtils;
+
+ public MpOrderInfoServiceImpl(MpShopUserMapper mpShopUserMapper, MpShopUserFlowMapper mpShopUserFlowMapper, RabbitMsgUtils rabbitMsgUtils) {
+ this.mpShopUserMapper = mpShopUserMapper;
+ this.mpShopUserFlowMapper = mpShopUserFlowMapper;
+ this.rabbitMsgUtils = rabbitMsgUtils;
+ }
+
@Override
public boolean updateStateById(Integer shopId, Integer orderId, TableConstant.Status status) {
return update(new LambdaUpdateWrapper()
@@ -30,5 +51,50 @@ public class MpOrderInfoServiceImpl extends ServiceImpl()
+ .eq(TbOrderInfo::getId, orderId)
+ .eq(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue())
+ .apply(StrUtil.format("settlement_amount + {} >= 0", subtract))
+ .setSql(StrUtil.format("settlement_amount=settlement_amount+{}", subtract))
+ .setSql(StrUtil.format("order_amount=order_amount+{}", subtract))
+ .setSql(StrUtil.format("amount=amount+{}", subtract))
+ .setSql(StrUtil.format("origin_amount=origin_amount+{}", subtract))
+ );
+ }
+
+ @Override
+ public void depositReturn(Integer userId, Integer shopId, BigDecimal returnAmount) {
+ TbShopUser user = mpShopUserMapper.selectOne(new LambdaQueryWrapper()
+ .eq(TbShopUser::getShopId, shopId)
+ .eq(TbShopUser::getUserId, userId));
+ if (user == null) {
+ throw new MsgException("用户信息不存在");
+ }
+ mpShopUserMapper.incrBalance(user.getId(), shopId, returnAmount, DateUtil.date().getTime());
+
+ TbShopUserFlow flow = new TbShopUserFlow();
+ flow.setShopUserId(user.getId());
+ flow.setBizCode("accountReturnPay");
+ flow.setBizName("会员储值卡退款");
+ flow.setType("+");
+ flow.setAmount(returnAmount);
+ flow.setBalance(user.getAmount().add(returnAmount));
+ flow.setCreateTime(cn.hutool.core.date.DateUtil.date().toTimestamp());
+ flow.setIsReturn("0");
+ mpShopUserFlowMapper.insert(flow);
+
+ JSONObject baObj = new JSONObject();
+ baObj.put("userId", user.getUserId());
+ baObj.put("shopId", user.getShopId());
+ baObj.put("amount", returnAmount);
+ baObj.put("balance", user.getAmount());
+ baObj.put("type", "退款");
+ baObj.put("time", flow.getCreateTime());
+ rabbitMsgUtils.addBalanceRecord(baObj);
+// producer.balance(baObj.toString());
+ }
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java
new file mode 100644
index 0000000..55ac14e
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbMemberPointsServiceImpl.java
@@ -0,0 +1,94 @@
+package com.chaozhanggui.system.cashierservice.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.map.MapProxy;
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbMemberPoints;
+import com.chaozhanggui.system.cashierservice.entity.TbMemberPointsLog;
+import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
+import com.chaozhanggui.system.cashierservice.exception.MsgException;
+import com.chaozhanggui.system.cashierservice.mapper.TbMemberPointsLogMapper;
+import com.chaozhanggui.system.cashierservice.mapper.TbMemberPointsMapper;
+import com.chaozhanggui.system.cashierservice.service.TbMemberPointsService;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 会员积分
+ *
+ * @author Tankaikai tankaikai@aliyun.com
+ * @since 2.0 2024-10-25
+ */
+@Service
+@Primary
+public class TbMemberPointsServiceImpl extends ServiceImpl implements TbMemberPointsService {
+
+ @Resource
+ private TbMemberPointsLogMapper tbMemberPointsLogMapper;
+ @Resource
+ private TbOrderInfoMapper tbOrderInfoMapper;
+
+
+
+ public TbMemberPoints initMemberPoints(Long memberId) {
+ TbMemberPoints entity = super.getOne(Wrappers.lambdaQuery().eq(TbMemberPoints::getMemberId, memberId));
+ if (entity == null) {
+ throw new MsgException("会员信息不存在");
+ }
+ if (entity.getAccountPoints() == null) {
+ entity.setAccountPoints(0);
+ }
+ super.updateById(entity);
+ return entity;
+ }
+
+
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean addPoints(Long memberId, int points, String content, Long orderId) {
+ TbMemberPoints entity = initMemberPoints(memberId);
+ // 增加账户积分
+ entity.setAccountPoints(entity.getAccountPoints() + points);
+ entity.setLastPointsChangeTime(new Date());
+ entity.setLastFloatPoints(points);
+ // 记录积分变动记录
+ TbMemberPointsLog log = new TbMemberPointsLog();
+ log.setShopId(entity.getShopId());
+ log.setMemberId(entity.getMemberId());
+ log.setMemberName(entity.getMemberName());
+ log.setAvatarUrl(entity.getAvatarUrl());
+ log.setMobile(entity.getMobile());
+ log.setContent(content);
+ log.setFloatType("add");
+ log.setFloatPoints(points);
+ log.setCreateTime(new Date());
+ // 有关联订单的需要回置订单表的相关积分使用字段
+ if (orderId != null) {
+ TbOrderInfo orderInfo = tbOrderInfoMapper.selectById(Math.toIntExact(orderId));
+ if (orderInfo != null) {
+ log.setOrderNo(orderInfo.getOrderNo());
+ }
+ }
+ super.updateById(entity);
+ tbMemberPointsLogMapper.insert(log);
+ return true;
+ }
+
+
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java
new file mode 100644
index 0000000..71f97a7
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java
@@ -0,0 +1,53 @@
+package com.chaozhanggui.system.cashierservice.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper;
+import com.chaozhanggui.system.cashierservice.dao.TbActivateOutRecordMapper;
+import com.chaozhanggui.system.cashierservice.dao.TbShopCouponMapper;
+import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord;
+import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord;
+import com.chaozhanggui.system.cashierservice.entity.TbShopCoupon;
+import com.chaozhanggui.system.cashierservice.service.TbShopCouponService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * 优惠券(TbShopCoupon)表服务实现类
+ *
+ * @author ww
+ * @since 2024-10-22 15:43:25
+ */
+@Service("tbShopCouponService")
+@Primary
+public class TbShopCouponServiceImpl implements TbShopCouponService {
+
+ @Autowired
+ private TbActivateInRecordMapper inRecordMapper;
+ @Autowired
+ private TbActivateOutRecordMapper outRecordMapper;
+
+ /**
+ * 退还券
+ *
+ * @param param giveId和 refNum 必传
+ * @return
+ */
+ @Override
+ public boolean refund(List param) {
+ for (TbActivateOutRecord outRecord : param) {
+ outRecord.setUpdateTime(new Date());
+ outRecordMapper.updateRefNum(outRecord.getId(), outRecord.getRefNum());
+ TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId());
+ inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum());
+ inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum());
+ }
+ return true;
+ }
+
+
+}
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopUnitServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopUnitServiceImpl.java
new file mode 100644
index 0000000..5b98286
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopUnitServiceImpl.java
@@ -0,0 +1,33 @@
+package com.chaozhanggui.system.cashierservice.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chaozhanggui.system.cashierservice.entity.TbShopUnit;
+import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
+import com.chaozhanggui.system.cashierservice.service.TbShopUnitService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author Administrator
+* @description 针对表【tb_shop_unit(商品单位)】的数据库操作Service实现
+* @createDate 2024-11-26 09:36:19
+*/
+@Service
+public class TbShopUnitServiceImpl extends ServiceImpl
+ implements TbShopUnitService{
+
+ @Override
+ public Page getShopUnit(Integer shopId, Integer page, Integer size, String name) {
+ LambdaQueryWrapper query = new LambdaQueryWrapper().eq(TbShopUnit::getShopId, shopId);
+ if (StrUtil.isNotBlank(name)) {
+ query.like(TbShopUnit::getName, name);
+ }
+ return page(new Page<>(page, size), query);
+ }
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbThirdPartyCouponRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbThirdPartyCouponRecordServiceImpl.java
new file mode 100644
index 0000000..40700aa
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbThirdPartyCouponRecordServiceImpl.java
@@ -0,0 +1,22 @@
+package com.chaozhanggui.system.cashierservice.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.chaozhanggui.system.cashierservice.entity.TbThirdPartyCouponRecord;
+import com.chaozhanggui.system.cashierservice.service.TbThirdPartyCouponRecordService;
+import com.chaozhanggui.system.cashierservice.mapper.TbThirdPartyCouponRecordMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author Administrator
+* @description 针对表【tb_third_party_coupon_record】的数据库操作Service实现
+* @createDate 2024-11-26 15:06:35
+*/
+@Service
+public class TbThirdPartyCouponRecordServiceImpl extends ServiceImpl
+ implements TbThirdPartyCouponRecordService{
+
+}
+
+
+
+
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/ThirdPartyCouponServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/ThirdPartyCouponServiceImpl.java
new file mode 100644
index 0000000..117e1fd
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/ThirdPartyCouponServiceImpl.java
@@ -0,0 +1,115 @@
+package com.chaozhanggui.system.cashierservice.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
+import com.chaozhanggui.system.cashierservice.entity.dto.thirdcoupon.CheckCouponDTO;
+import com.chaozhanggui.system.cashierservice.exception.MsgException;
+import com.chaozhanggui.system.cashierservice.mybatis.MpShopInfoMapper;
+import com.chaozhanggui.system.cashierservice.resp.PhpCommonResp;
+import com.chaozhanggui.system.cashierservice.service.ThirdPartyCouponService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService {
+
+ private final MpShopInfoMapper mpShopInfoMapper;
+ @Value("${phpServer}")
+ private String phpServerUrl;
+
+ public ThirdPartyCouponServiceImpl(RestTemplate restTemplate, MpShopInfoMapper mpShopInfoMapper) {
+ this.restTemplate = restTemplate;
+ this.mpShopInfoMapper = mpShopInfoMapper;
+ }
+ private final RestTemplate restTemplate;
+
+ private R exec(String url, Integer shopId, T data) {
+ // 获取店铺信息
+ TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId);
+ if (shopInfo == null) {
+ throw new MsgException("店铺信息不存在");
+ }
+
+ // 设置请求头
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("account", shopId.toString());
+
+ // 构造请求实体,根据 data 是否为空设置请求体
+ HttpEntity