From 2fb2667b292392b81c8671c2953e23699108821a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 18 Nov 2024 11:40:40 +0800 Subject: [PATCH 001/170] =?UTF-8?q?feat:=20=E5=8F=B0=E6=A1=8C=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=A0=B9=E6=8D=AEdetail=E8=A1=A8=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/mapper/TbCashierCartMapper.java | 3 +++ .../impl/shopimpl/TbShopTableServiceImpl.java | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java index 82d62dd1..6e8c29da 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java @@ -48,4 +48,7 @@ public interface TbCashierCartMapper extends BaseMapper { @Update("update tb_cashier_cart set status=#{status}, total_amount=(number+#{changeNum})*sale_price,number=number+#{changeNum},total_number=total_number+#{changeNum} " + "where id=#{id}") int updateNumAmountStatus(Integer id, String status, Integer changeNum); + + @Select("select a.* from tb_cashier_cart as a left join tb_order_detail as b on a.id=b.cart_id where a.shop_id=#{shopId} and a.status=#{state} and a.created_at>#{time} and b.id is not null;") + List selectPlaceCart(Integer shopId, long time, String state); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index fe28005b..7722c9ef 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -263,12 +263,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { List tbShopTableList = shopTablePage.getRecords(); ArrayList> infoList = new ArrayList<>(); - List cartList = tbCashierCartMapper.selectList(new LambdaQueryWrapper() - .eq(TbCashierCart::getShopId, criteria.getShopId()) -// .eq(TbCashierCart::getTableId, date.getQrcode()) - .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) - .eq(TbCashierCart::getStatus, "create")); +// List cartList = tbCashierCartMapper.selectList(new LambdaQueryWrapper() +// .eq(TbCashierCart::getShopId, criteria.getShopId()) +//// .eq(TbCashierCart::getTableId, date.getQrcode()) +// .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) +// .eq(TbCashierCart::getStatus, "create")); + List cartList = tbCashierCartMapper.selectPlaceCart(criteria.getShopId(), DateUtil.offsetDay(DateUtil.date(), -1).getTime(), "create"); HashMap countMap = new HashMap<>(); cartList.forEach(item -> { Integer count = countMap.computeIfAbsent(item.getTableId(), k -> 1); @@ -290,8 +291,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { for (TbShopTable date : tbShopTableList) { if (StrUtil.isBlank(date.getQrcode())) { date.setStatus("unbind"); - } else if (countMap.get(date.getQrcode()) != null && countMap.get(date.getQrcode()) < 1 && !TableStateEnum.CLEANING.getState().equals(date.getStatus()) - ) { + } else if (countMap.get(date.getQrcode()) != null && countMap.get(date.getQrcode()) < 1 && !TableStateEnum.CLEANING.getState().equals(date.getStatus())) { date.setStatus("idle"); mpShopTableMapper.update(null, new LambdaUpdateWrapper() .eq(TbShopTable::getQrcode, date.getQrcode()) From f101d85c9ed9b6bf4b5e5b7483c5fb1292ed0b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 18 Nov 2024 11:45:07 +0800 Subject: [PATCH 002/170] =?UTF-8?q?feat:=20=E5=8F=B0=E6=A1=8C=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=A0=B9=E6=8D=AEdetail=E8=A1=A8=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 7722c9ef..741f754f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -291,7 +291,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { for (TbShopTable date : tbShopTableList) { if (StrUtil.isBlank(date.getQrcode())) { date.setStatus("unbind"); - } else if (countMap.get(date.getQrcode()) != null && countMap.get(date.getQrcode()) < 1 && !TableStateEnum.CLEANING.getState().equals(date.getStatus())) { + } else if ((countMap.get(date.getQrcode()) == null || countMap.get(date.getQrcode()) < 1) && !TableStateEnum.CLEANING.getState().equals(date.getStatus())) { date.setStatus("idle"); mpShopTableMapper.update(null, new LambdaUpdateWrapper() .eq(TbShopTable::getQrcode, date.getQrcode()) From b208a0ad92442edf6775a671ee09c52a7cbc8542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 18 Nov 2024 11:46:52 +0800 Subject: [PATCH 003/170] =?UTF-8?q?feat:=20=E5=8F=96=E6=B6=88=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/order/TbOrderInfoServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 7f016b97..21df7134 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -714,6 +714,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), "订单取消返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); } + } catch (Exception e) { + log.error("返还订单积分优惠券失败: 订单信息: {}", orderInfo); + log.error("异常信息: ", e); + }finally { mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId()); mpOrderDetailService.updateStatusByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId()); @@ -725,9 +729,6 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { .set(TbOrderInfo::getPointsNum, 0) .set(TbOrderInfo::getUpdatedAt, cn.hutool.core.date.DateUtil.current()) .set(TbOrderInfo::getStatus, "cancelled")); - } catch (Exception e) { - log.error("取消订单失败: 订单信息: {}", orderInfo); - log.error("异常信息: ", e); } }); // List ids = tbOrderInfos.stream().map(TbOrderInfo::getId).collect(Collectors.toList()); From ca82c8a59f6a9080e013c883ed031ed688925154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 18 Nov 2024 13:53:34 +0800 Subject: [PATCH 004/170] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BB=B7=E5=AD=97=E6=AE=B5=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 6 +++++ .../dto/shoptable/AddTemporaryDishesDTO.java | 27 +++++++++++++++++++ .../ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../impl/shopimpl/TbShopTableServiceImpl.java | 7 +++++ .../service/shop/TbShopTableService.java | 8 ++++++ 5 files changed, 49 insertions(+) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index d36df365..bf4bf30c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -76,6 +76,12 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.addCartForUser(addCartDTO)); } + @PostMapping("/temporaryDishes") + @ApiOperation("代客下单/shop/table") + public ResponseEntity addTemporaryDishes(@Valid @RequestBody AddTemporaryDishesDTO temporaryDishesDTO) { + return ResponseEntity.ok(tbShopTableService.addTemporaryDishes(temporaryDishesDTO)); + } + @PutMapping("/choseModel") @ApiOperation("代客下单/shop/table") public ResponseEntity choseModel(@Valid @RequestBody ChoseModelDTO choseModelDTO) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java new file mode 100644 index 00000000..c6e2b2f4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java @@ -0,0 +1,27 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +@Data +public class AddTemporaryDishesDTO { + @NotEmpty + private String masterId; + @NotNull + private Integer shopId; + private String tableId; + @NotNull + @Min(1) + private Integer num; + private boolean isPack; + private boolean isGift; + private String note; + // 用餐类型 + @NotBlank + private String useType; + private Integer vipUserId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index d33d9489..4f55578e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -130,6 +130,7 @@ public class TbOrderDetail implements Serializable { private BigDecimal memberPrice; private Integer userCouponId; + private Integer isMember; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 741f754f..ab2f0172 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -614,6 +614,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { return tbCashierCart; } + + @Override + public TbCashierCart addTemporaryDishes(AddTemporaryDishesDTO temporaryDishesDTO) { + return null; + } + private void setRedisTableCartInfo(String tableId, String shopId, List tbCashierCartList, boolean isAdd) { String tableCartKey = RedisConstant.getTableCartKey(tableId, shopId); String tableCart = redisTemplate.opsForValue().get(tableCartKey); @@ -1518,6 +1524,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setUseType(cashierCart.getUseType()); orderDetail.setProductImg(cashierCart.getCoverImg()); orderDetail.setCartId(cashierCart.getId()); + orderDetail.setIsMember(cashierCart.getIsMember()); orderDetail.setOrderId(orderInfo == null ? null : orderInfo.getId()); priceDTO.getOrderDetailList().add(orderDetail); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 10be0f97..ca10d873 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -98,6 +98,13 @@ public interface TbShopTableService { TbCashierCart addCartForUser(AddCartDTO addCartDTO); + /** + * 添加临时菜 + * @param temporaryDishesDTO 临时菜信息 + */ + TbCashierCart addTemporaryDishes(AddTemporaryDishesDTO temporaryDishesDTO); + + void removeCart(RemoveCartDTO removeCartDTO); void returnCart(ReturnCartDTO returnCartDTO); @@ -149,4 +156,5 @@ public interface TbShopTableService { Object getShopState(Integer shopId, String tableId); Object bindQrcode(BindTableQrCodeDTO bindTableQrCodeDTO); + } From ec3ec9eac9eec0f2fe40a020f38003e1cff9ee05 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 18 Nov 2024 14:36:34 +0800 Subject: [PATCH 005/170] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A1=A8=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/pojo/product/TbProduct.java | 142 ------------------ .../product/TbProductSkuRepository.java | 12 ++ .../shop/TbShopUserDutyDetailRepository.java | 15 -- .../productimpl/TbProductServiceImpl.java | 39 +++-- .../java/cn/ysk/cashier/vo/ProductExtVO.java | 30 ---- .../java/cn/ysk/cashier/vo/TbProductVo.java | 118 +-------------- 6 files changed, 32 insertions(+), 324 deletions(-) delete mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 9a7adb1e..77c2ff2e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -50,9 +50,6 @@ public class TbProduct implements Serializable { @TableId(type = IdType.AUTO) private Integer id; - @Column(name = "`source_path`") - @ApiModelProperty(value = "商品来源 NORMAL普通商品 --,SCORE积分商品") - private String sourcePath="NORMAL"; @Column(name = "`merchant_id`") @ApiModelProperty(value = "商户Id") @@ -66,10 +63,6 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "商品名称") private String name; - @Column(name = "`type`") - @ApiModelProperty(value = "商品类型(属性):REAL- 实物商品 VIR---虚拟商品") - private String type = "REAL"; - @Column(name = "`pack_fee`") @ApiModelProperty(value = "包装费") private BigDecimal packFee; @@ -95,10 +88,6 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "商品规格") private Integer specId; - @Column(name = "`brand_id`") - @ApiModelProperty(value = "品牌Id") - private Integer brandId; - @Column(name = "`short_title`") @ApiModelProperty(value = "短标题--促销语") private String shortTitle; @@ -107,72 +96,27 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "lowMemberPrice") private BigDecimal lowMemberPrice; - @Column(name = "`unit_snap`") - @ApiModelProperty(value = "单位镜像") - private String unitSnap; - - @Column(name = "`share_img`") - @ApiModelProperty(value = "商品分享图") - private String shareImg; - @Column(name = "`images`") @ApiModelProperty(value = "商品图片(第一张为缩略图,其他为详情)") private String images; - @Column(name = "`video`") - @ApiModelProperty(value = "商品视频URL地址") - private String video; - - @Column(name = "`video_cover_img`") - @ApiModelProperty(value = "视频封面图") - private String videoCoverImg; - @Column(name = "`sort`") @ApiModelProperty(value = "排序") private Integer sort = 0; - @Column(name = "`limit_number`") - @ApiModelProperty(value = "0-不限购") - private Integer limitNumber = 0; - - @Column(name = "`product_score`") - @ApiModelProperty(value = "商品赚送积分") - private Integer productScore; - @Column(name = "`status`",nullable = false) @NotNull @ApiModelProperty(value = "0--待审核 1审核通过 -1审核失败 -2违规下架") private Integer status = 0; - @Column(name = "`fail_msg`") - @ApiModelProperty(value = "审核失败原因") - private String failMsg; - - @Column(name = "`is_recommend`") - @ApiModelProperty(value = "是否推荐,店铺推荐展示") - private Integer isRecommend = 0; - @Column(name = "`is_hot`") @ApiModelProperty(value = "是否热销") private Integer isHot = 0; - @Column(name = "`is_new`") - @ApiModelProperty(value = "是否新品") - private Integer isNew; - - @Column(name = "`is_on_sale`") - @ApiModelProperty(value = "是否促销1-是0-否") - private Integer isOnSale = 0; - - @Column(name = "`is_show`") - @ApiModelProperty(value = "是否展示0-下架 1上架---废弃") - private Integer isShow = 0; - @Column(name = "`type_enum`") @ApiModelProperty(value = "商品规格:0-单规格 1多规格") private String typeEnum; - @Column(name = "`is_del`",nullable = false) @NotNull @ApiModelProperty(value = "是否回收站 0-否,1回收站") @@ -186,36 +130,6 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "是否暂停销售") private Integer isPauseSale = 0; - @Column(name = "`is_free_freight`",nullable = false) - @NotNull - @ApiModelProperty(value = "是否免邮1-是 0-否") - private Integer isFreeFreight=1; - - @Column(name = "`freight_id`") - @ApiModelProperty(value = "邮费模版") - private Long freightId; - - @Column(name = "`strategy_type`") - @ApiModelProperty(value = "商品当前生效策略") - private String strategyType; - - @Column(name = "`strategy_id`") - @ApiModelProperty(value = "策略Id") - private Integer strategyId = 1; - - @Column(name = "`is_vip`") - @ApiModelProperty(value = "vip专属") - private Integer isVip = 0; - - @Column(name = "`is_delete`",nullable = false) - @NotNull - @ApiModelProperty(value = "是否删除") - private Integer isDelete = 0; - - @Column(name = "`notice`") - @ApiModelProperty(value = "购买须知") - private String notice; - @Column(name = "`created_at`") @ApiModelProperty(value = "createdAt") private Long createdAt; @@ -224,26 +138,6 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "updatedAt") private Long updatedAt; - @Column(name = "`base_sales_number`") - @ApiModelProperty(value = "基础出售数量") - private Double baseSalesNumber =0.00; - - @Column(name = "`real_sales_number`") - @ApiModelProperty(value = "实际销量") - private Integer realSalesNumber = 0; - - @Column(name = "`sales_number`") - @ApiModelProperty(value = "合计销量") - private Integer salesNumber = 0; - - @Column(name = "`thumb_count`") - @ApiModelProperty(value = "点赞次数") - private Integer thumbCount = 0; - - @Column(name = "`store_count`") - @ApiModelProperty(value = "收藏次数") - private Integer storeCount = 0; - @Column(name = "`furnish_meal`") @ApiModelProperty(value = "支持堂食") private Integer furnishMeal = 0; @@ -260,46 +154,10 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "支持虚拟") private Integer furnishVir = 0; - @Column(name = "`is_combo`") - @ApiModelProperty(value = "是否套餐") - private Integer isCombo =0; - @Column(name = "`group_snap`") @ApiModelProperty(value = "套餐内容") private String groupSnap; - @Column(name = "`is_show_cash`") - @ApiModelProperty(value = "isShowCash") - private Integer isShowCash =0; - - @Column(name = "`is_show_mall`") - @ApiModelProperty(value = "isShowMall") - private Integer isShowMall = 0; - - @Column(name = "`is_need_examine`") - @ApiModelProperty(value = "是否需要审核") - private Integer isNeedExamine = 0; - - @Column(name = "`show_on_mall_status`") - @ApiModelProperty(value = "线上商城展示状态0待审核 -1 异常 1正常") - private Integer showOnMallStatus = 1; - - @Column(name = "`show_on_mall_time`") - @ApiModelProperty(value = "提交审核时间") - private Long showOnMallTime; - - @Column(name = "`show_on_mall_error_msg`") - @ApiModelProperty(value = "线上商城展示失败原因") - private String showOnMallErrorMsg; - - @Column(name = "`enable_label`") - @ApiModelProperty(value = "使用标签打印 选择 是 并在 前台>本机设置 勾选打印标签后,收银完成后会自动打印对应数量的标签数") - private Integer enableLabel = 0; - - @Column(name = "`tax_config_id`") - @ApiModelProperty(value = "税率") - private String taxConfigId; - @Column(name = "spec_info") @ApiModelProperty(value = "specInfo") private String specInfo; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java index ba6dcd1f..c04d9045 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java @@ -50,4 +50,16 @@ public interface TbProductSkuRepository extends JpaRepository searchProRealSalesNumber(@Param("ids") List ids); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java index c4db86fa..160b739a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java @@ -1,12 +1,7 @@ package cn.ysk.cashier.repository.shop; -import javax.persistence.Tuple; import cn.ysk.cashier.pojo.TbShopUserDutyDetail; -import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; - -import java.util.List; /** * @author lyf @@ -14,14 +9,4 @@ import java.util.List; public interface TbShopUserDutyDetailRepository extends JpaRepository { - @Query(value = "SELECT " + - "sum( num ), " + - "product_id " + - "FROM " + - "tb_shop_user_duty_detail " + - "WHERE " + - "product_id IN :ids " + - "GROUP BY " + - "product_id",nativeQuery = true) - List searchUUserDutyDetail(@Param("ids") List ids); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index a694e328..f069f840 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -68,7 +68,6 @@ public class TbProductServiceImpl implements TbProductService { private final TbProductSkuRepository tbProductSkuRepository; private final TbShopUnitRepository tbShopUnitRepository; private final TbProductSpecRepository tbProductSpecRepository; - private final TbProductSkuMapper TbProductSkuMapper; private final TbProductSkuResultRepository tbProductSkuResultRepository; private final TbShopCategoryRepository tbShopCategoryRepository; private final TbShopUserDutyDetailRepository tbShopUserDutyDetailRe; @@ -149,7 +148,7 @@ public class TbProductServiceImpl implements TbProductService { //销量 List objects = new ArrayList<>(); if (!productIdInt.isEmpty()) { - objects = tbShopUserDutyDetailRe.searchUUserDutyDetail(productIdInt); + objects = tbProductSkuRepository.searchProRealSalesNumber(productIdInt); } //组装 List tbProductVoList = new ArrayList<>(); @@ -218,8 +217,10 @@ public class TbProductServiceImpl implements TbProductService { } else { for (Object[] o : objects) { if (((Integer) o[1]).equals(product.getId())) { - BigDecimal bigDecimal = (BigDecimal) o[0]; - tbProductVo.setRealSalesNumber(bigDecimal.doubleValue()); + if (o[0] != null) { + BigDecimal bigDecimal = (BigDecimal) o[0]; + tbProductVo.setRealSalesNumber(bigDecimal.doubleValue()); + } } } } @@ -248,16 +249,16 @@ public class TbProductServiceImpl implements TbProductService { productNewVo.setLowPrice(product.getLowPrice().toString()); productNewVo.setStockNumber(Double.valueOf(product.getStockNumber())); List tbProductSkus = tbProductSkuRepository.searchSku(product.getId().toString()); - if ("sku".equals(product.getTypeEnum())){ - if(tbProductSkus.size() > 1){ + if ("sku".equals(product.getTypeEnum())) { + if (tbProductSkus.size() > 1) { BigDecimal maxPrice = tbProductSkus.stream().map(TbProductSku::getSalePrice).max(BigDecimal::compareTo).get(); if (maxPrice.compareTo(new BigDecimal(productNewVo.getLowPrice())) == 0) { - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice()); - }else { - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice() + "~¥" + maxPrice); + productNewVo.setLowPrice("¥" + productNewVo.getLowPrice()); + } else { + productNewVo.setLowPrice("¥" + productNewVo.getLowPrice() + "~¥" + maxPrice); } - }else { - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice()); + } else { + productNewVo.setLowPrice("¥" + productNewVo.getLowPrice()); } } ViewConSku viewConSku = new ViewConSku(); @@ -265,7 +266,7 @@ public class TbProductServiceImpl implements TbProductService { viewConSku.setProductId(product.getId()); Example query = Example.of(viewConSku); List skuCons = viewConSkuRepository.findAll(query); - if(product.getTypeEnum().equals("sku")){ + if (product.getTypeEnum().equals("sku")) { //规格填充 productNewVo.setSkuList(convert(tbProductSkus)); //耗材弹窗选项 @@ -276,11 +277,11 @@ public class TbProductServiceImpl implements TbProductService { } } } - productNewVo.setConInfos(CollectionUtils.isEmpty(skuCons)? Collections.emptyList() :skuCons); + productNewVo.setConInfos(CollectionUtils.isEmpty(skuCons) ? Collections.emptyList() : skuCons); products.add(productNewVo); } Map result = PageUtil.toPage(products, page.getTotalElements()); - result.put("warnLine",warnLine); + result.put("warnLine", warnLine); return result; } @@ -431,8 +432,6 @@ public class TbProductServiceImpl implements TbProductService { product.setImages(resources.getImages().toString()); } product.setIsDel(0); - product.setIsDelete(0); - product.setIsFreeFreight(1); product.setStatus(1); product.setCreatedAt(Instant.now().toEpochMilli()); product.setUpdatedAt(Instant.now().toEpochMilli()); @@ -442,7 +441,6 @@ public class TbProductServiceImpl implements TbProductService { //套餐内容 if (!resources.getGroupSnap().isEmpty()) { product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); - product.setIsCombo(1); } if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) { List collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList()); @@ -527,15 +525,12 @@ public class TbProductServiceImpl implements TbProductService { } if (!"group".equals(product.getTypeEnum())) { if (resources.getCategoryId() == null) throw new BadRequestException("商品分类不可为空"); - product.setIsCombo(0); product.setGroupSnap(null); if (resources.getNotices() != null && resources.getNotices().getId() != null) { noticeRepository.deleteById(resources.getNotices().getId()); } } product.setIsDel(0); - product.setIsDelete(0); - product.setIsFreeFreight(1); product.setStatus(1); product.setUpdatedAt(Instant.now().toEpochMilli()); product.setImages(resources.getImages().toString()); @@ -546,7 +541,8 @@ public class TbProductServiceImpl implements TbProductService { //套餐内容 if (!resources.getGroupSnap().isEmpty()) { product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); - product.setIsCombo(1); + } else { + throw new BadRequestException("套餐内容不可为空"); } if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) { List collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList()); @@ -607,7 +603,6 @@ public class TbProductServiceImpl implements TbProductService { } - @Transactional(rollbackFor = Exception.class) @Override public void upProSort(TbProductSortCriteria param) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java deleted file mode 100644 index 7aaa405e..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.ysk.cashier.vo; - -import lombok.Data; -import org.hibernate.annotations.Formula; - -import java.math.BigDecimal; -import java.math.BigInteger; - -/** - * @author lyf - */ -@Data -public class ProductExtVO { - private BigInteger productId; - - private String productName; - - private Object productNum; - private Object amount; - - public ProductExtVO(BigInteger productId, String productName, Object productNum, Object amount) { - this.productId = productId; - this.productName = productName; - this.productNum = productNum; - this.amount = amount; - } - - public ProductExtVO() { - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java index d2ca7771..b69c7560 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java @@ -25,27 +25,16 @@ public class TbProductVo { private Integer id; - - private String sourcePath; - - private String merchantId; - private String shopId; - private String name; - private String type; - - private BigDecimal packFee; - private BigDecimal lowPrice; - private Integer unitId; private String coverImg; @@ -56,155 +45,54 @@ public class TbProductVo { private Integer specId; - - private Integer brandId; - - private String shortTitle; - private BigDecimal lowMemberPrice; - - private String unitSnap; - - private String shareImg; - private JSONArray images; - - private String video; - - - private String videoCoverImg; - - private Integer sort; - private Integer limitNumber; - - private Integer productScore; - - private Integer status; - private String failMsg; - - private Integer isRecommend; - - private Integer isHot; - - private Integer isNew; - - private Integer isOnSale; - - private Integer isShow; - - private String typeEnum; - private Integer isDel; - private Integer isStock; - private Integer isPauseSale; - - private Integer isFreeFreight; - - - private Long freightId; - - - private String strategyType; - - - private Integer strategyId; - - private Integer isVip; - - private Integer isDelete; - - - private String notice; - - private Long createdAt; - private Long updatedAt; - - private Double baseSalesNumber; - - //销量 - private Double realSalesNumber; - //库存 - private Double stockNumber; - - - private Integer salesNumber; - - private Integer thumbCount; - - - private Integer storeCount; - - private Integer furnishMeal; + private Double realSalesNumber; + + private Double stockNumber; private Integer furnishExpress; - private Integer furnishDraw; - private Integer furnishVir; - - private Integer isCombo; - - private JSONArray groupSnap; - - private Integer isShowCash; - - - private Integer isShowMall; - - - private Integer isNeedExamine; - - - private Integer showOnMallStatus; - - - private Long showOnMallTime; - - private String showOnMallErrorMsg; - - - private Integer enableLabel; - - private String taxConfigId; - private String unitName; private List skuList; From 3e55cc848c0f7d12cc0f4bb7ea99142d8b0c3be2 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 18 Nov 2024 17:44:56 +0800 Subject: [PATCH 006/170] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/mybatis/entity/TbShopShare.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java index 757bba78..dd517168 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.apache.commons.lang3.StringUtils; @@ -36,10 +37,12 @@ public class TbShopShare extends Model { private String invitedImg; //被邀顶部图 private String beInvitedImg; - //活动开始时间 - private Date startTime; //活动结束时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date endTime; + //活动开始时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date startTime; //新用户获得券 private String newCoupon; //邀请num人数 可获奖励券 From ee647ae2d8f1a2dad550f59caed507c28b8f53b6 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 18 Nov 2024 17:52:58 +0800 Subject: [PATCH 007/170] =?UTF-8?q?=E5=88=86=E4=BA=AB=E6=B4=BB=E5=8A=A8=20?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/mybatis/entity/TbShopShare.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java index dd517168..00ac8cbb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java @@ -38,11 +38,9 @@ public class TbShopShare extends Model { //被邀顶部图 private String beInvitedImg; //活动结束时间 - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date endTime; + private String endTime; //活动开始时间 - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date startTime; + private String startTime; //新用户获得券 private String newCoupon; //邀请num人数 可获奖励券 From 432e382d6bf93be16fa27791f8a2e2d984ad724c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 09:25:38 +0800 Subject: [PATCH 008/170] =?UTF-8?q?feat:=20=E4=B8=B4=E6=97=B6=E8=8F=9C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/shoptable/AddTemporaryDishesDTO.java | 9 +- .../mybatis/service/MpCashierCartService.java | 12 ++- .../impl/MpCashierCartServiceImpl.java | 38 ++++++- .../ysk/cashier/pojo/order/TbCashierCart.java | 2 + .../ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../impl/shopimpl/TbShopTableServiceImpl.java | 98 ++++++++++++++++--- 6 files changed, 144 insertions(+), 16 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java index c6e2b2f4..eec2eb62 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java @@ -6,6 +6,7 @@ import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; @Data public class AddTemporaryDishesDTO { @@ -14,11 +15,15 @@ public class AddTemporaryDishesDTO { @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 @Min(1) private Integer num; - private boolean isPack; - private boolean isGift; private String note; // 用餐类型 @NotBlank diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java index 0121bd73..26a7d74c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java @@ -60,9 +60,11 @@ public interface MpCashierCartService extends IService { /** * 根据店就餐模式查询购物车 * @param shopEatTypeInfoDTO 就餐模式 + * @param masterId 取餐码 + * @param statuses 状态 为空默认查询 create return * @return 购物车信息 */ - List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId); + List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses); /** * 根据订单id和状态获取购物车数据 @@ -73,5 +75,13 @@ public interface MpCashierCartService extends IService { boolean updateMemberAndAmountByOrderId(Integer orderId, boolean isMember); + + /** + * 根据就餐信息查询购物车信息 + * @param shopEatTypeInfoDTO 就餐信息 + * @return 购物车信息 + */ + TbCashierCart selectOneCartByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer productId, Integer skuId, boolean isGift, boolean isTemp); + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java index 94ca64a6..58c19d44 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.TableConstant; @@ -108,14 +109,19 @@ public class MpCashierCartServiceImpl extends ServiceImpl selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId) { + public List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId()) .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) - .in(TbCashierCart::getStatus, "create", "return") .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) .and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); + if (statuses.length == 0) { + queryWrapper.in(TbCashierCart::getStatus, "create", "return"); + }else { + queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses)); + } + // 非堂食校验台桌状态 if (shopEatTypeInfoDTO.isTakeout()) { queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) @@ -139,5 +145,33 @@ 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); + }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); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 0fdca385..df1863f2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -168,6 +168,8 @@ public class TbCashierCart implements Serializable { private Integer userCouponId; private BigDecimal memberPrice = BigDecimal.ZERO; private Integer isMember; + // 是否临时菜品 + private Integer isTemporary; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 4f55578e..9e1b4227 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -131,6 +131,7 @@ public class TbOrderDetail implements Serializable { private BigDecimal memberPrice; private Integer userCouponId; private Integer isMember; + private Integer isTemporary; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index ab2f0172..4396fa49 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -570,15 +570,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setCategoryId(product.getCategoryId()); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); -// tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() == null ? 0 : 1); - tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); +// tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); if (tbCashierCart.getIsMember() == 1) { tbCashierCart.setMemberPrice(productSku.getMemberPrice()); } cashierCartRepository.save(tbCashierCart); } else { - tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); @@ -617,7 +617,56 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public TbCashierCart addTemporaryDishes(AddTemporaryDishesDTO temporaryDishesDTO) { - return null; + temporaryDishesDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(temporaryDishesDTO.getUseType()) ? null : temporaryDishesDTO.getTableId()); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(temporaryDishesDTO.getShopId(), temporaryDishesDTO.getTableId(), temporaryDishesDTO.getUseType()); + + TbCashierCart tbCashierCart = mpCashierCartService.selectOneCartByShopEatType(shopEatTypeInfoDTO, temporaryDishesDTO.getMasterId(), null, null, false, true); + // 首次加入 + if (tbCashierCart == null) { + tbCashierCart = new TbCashierCart(); + tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); + tbCashierCart.setCreatedAt(System.currentTimeMillis()); + tbCashierCart.setIsSku("0"); + if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + tbCashierCart.setTableId(shopEatTypeInfoDTO.getTableId()); + } + tbCashierCart.setName(temporaryDishesDTO.getName()); + tbCashierCart.setSalePrice(temporaryDishesDTO.getPrice()); + tbCashierCart.setMasterId(temporaryDishesDTO.getMasterId()); + tbCashierCart.setShopId(String.valueOf(temporaryDishesDTO.getShopId())); + tbCashierCart.setTradeDay(DateUtils.getDay()); + tbCashierCart.setStatus("create"); + tbCashierCart.setIsPack("false"); + tbCashierCart.setIsGift("false"); + tbCashierCart.setTotalAmount(new BigDecimal(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); + cashierCartRepository.save(tbCashierCart); + + } else { + tbCashierCart.setIsMember(temporaryDishesDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setNote(temporaryDishesDTO.getNote()); + tbCashierCart.setTotalAmount(new BigDecimal(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.current()); + tbCashierCart.setIsTemporary(1); + cashierCartMapper.updateById(tbCashierCart); + } + + if (StrUtil.isNotBlank(temporaryDishesDTO.getTableId())) { + setRedisTableCartInfo(temporaryDishesDTO.getTableId(), temporaryDishesDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true); + } + return tbCashierCart; } private void setRedisTableCartInfo(String tableId, String shopId, List tbCashierCartList, boolean isAdd) { @@ -847,7 +896,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { List records = cartPage.getRecords(); ArrayList skuIds = new ArrayList<>(); - records.forEach(item -> skuIds.add(Integer.valueOf(item.getSkuId()))); + records.forEach(item -> { + if (item.getSkuId() != null) { + skuIds.add(Integer.valueOf(item.getSkuId())); + } + }); AtomicReference mealCashierCart = new AtomicReference<>(); @@ -858,7 +911,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { ArrayList> infos = new ArrayList<>(); records.forEach(item -> { - if (item.getProductId().equals("-999")) { + if (item.getProductId() != null && item.getProductId().equals("-999")) { mealCashierCart.set(item); return; } @@ -1305,7 +1358,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { }); HashMap> usedCouponMap = new HashMap<>(); ArrayList outRecords = new ArrayList<>(); + ArrayList resetCouponList = new ArrayList<>(); for (TbCashierCart cashierCart : newCashierCarts) { + if (!couponMap.isEmpty()) { + resetCouponList.add(cashierCart); + cashierCart.setUserCouponId(null); + } discountAmount = reduceProCoupon(couponMap, cashierCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId); } @@ -1314,6 +1372,20 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpCashierCartService.saveBatch(balanceCartList); } // 更新购物车信息 + if (!resetCouponList.isEmpty()) { + // 取消之前使用的历史券 + ArrayList resetCartIds = new ArrayList<>(); + resetCouponList.forEach(item -> { + if (item.getUserCouponId() == null) { + resetCartIds.add(item.getId()); + } + }); + if (!resetCartIds.isEmpty()) { + mpCashierCartService.update(new LambdaUpdateWrapper() + .in(TbCashierCart::getId, resetCartIds) + .set(TbCashierCart::getUserCouponId, null)); + } + } mpCashierCartService.updateBatchById(newCashierCarts); couponInfoDTO.setOutRecordList(outRecords); @@ -1490,7 +1562,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { priceDTO.setOriginAmount(priceDTO.getOriginAmount().add(cashierCart.getTotalAmount())); } - TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); TbOrderDetail orderDetail = null; if (cashierCart.getOrderId() != null) { orderDetail = oldOrderDetailMap.get(cashierCart.getOrderId().toString() + cashierCart.getId()); @@ -1502,8 +1573,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { priceDTO.getNewOrderDetailList().add(orderDetail); } - if (Objects.nonNull(productSku)) { - orderDetail.setProductSkuName(productSku.getSpecSnap()); + if (cashierCart.getIsTemporary() == null || cashierCart.getIsTemporary() == 0) { + TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); + if (Objects.nonNull(productSku)) { + orderDetail.setProductSkuName(productSku.getSpecSnap()); + } + + orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId())); + orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); } orderDetail.setUserCouponId(cashierCart.getUserCouponId()); @@ -1513,8 +1590,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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.setProductName(cashierCart.getName()); orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId())); orderDetail.setPackAmount(cashierCart.getPackFee()); @@ -1525,6 +1600,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setProductImg(cashierCart.getCoverImg()); orderDetail.setCartId(cashierCart.getId()); orderDetail.setIsMember(cashierCart.getIsMember()); + orderDetail.setIsTemporary(cashierCart.getIsTemporary()); orderDetail.setOrderId(orderInfo == null ? null : orderInfo.getId()); priceDTO.getOrderDetailList().add(orderDetail); } From 2f521d5dc99dfe794b637c64613e921f0dee38b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 09:40:44 +0800 Subject: [PATCH 009/170] =?UTF-8?q?feat:=20=E4=B8=B4=E6=97=B6=E8=8F=9C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/dto/shoptable/UpdateCartDTO.java | 2 - .../impl/shopimpl/TbShopTableServiceImpl.java | 39 ++++++++++++------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index db07564f..e5497eef 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -10,9 +10,7 @@ import javax.validation.constraints.NotNull; public class UpdateCartDTO { @NotNull private Integer cartId; - @NotNull private Integer skuId; - @NotNull private Integer productId; @NotNull private Integer shopId; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 4396fa49..471b2c1c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -429,23 +429,30 @@ public class TbShopTableServiceImpl implements TbShopTableService { cashierCartRepository.deleteById(updateCartDTO.getCartId()); return null; } - TbProductSku productSku = productMapper.selectSkuByIdAndShopId(updateCartDTO.getShopId(), updateCartDTO.getSkuId()); - TbProduct product = productMapper.selectByIdAndShopId(updateCartDTO.getShopId(), updateCartDTO.getProductId()); - if (product == null || productSku == null) { - throw new BadRequestException("商品不存在或已下架, id: " + updateCartDTO.getSkuId()); + + TbProduct product = null; + if (updateCartDTO.getProductId() != null && updateCartDTO.getSkuId() != null) { + TbProductSku productSku = productMapper.selectSkuByIdAndShopId(updateCartDTO.getShopId(), updateCartDTO.getSkuId()); + product = productMapper.selectByIdAndShopId(updateCartDTO.getShopId(), updateCartDTO.getProductId()); + if (product == null || productSku == null) { + throw new BadRequestException("商品不存在或已下架, id: " + updateCartDTO.getSkuId()); + } + + tbCashierCart.setCoverImg(product.getCoverImg()); + tbCashierCart.setIsSku(product.getTypeEnum()); + tbCashierCart.setName(product.getName()); + tbCashierCart.setProductId(String.valueOf(product.getId())); + tbCashierCart.setSalePrice(productSku.getSalePrice()); + tbCashierCart.setSkuId(productSku.getId().toString()); + tbCashierCart.setCategoryId(product.getCategoryId()); } - tbCashierCart.setCoverImg(product.getCoverImg()); + tbCashierCart.setCreatedAt(System.currentTimeMillis()); - tbCashierCart.setIsSku(product.getTypeEnum()); - tbCashierCart.setName(product.getName()); - tbCashierCart.setProductId(String.valueOf(product.getId())); - tbCashierCart.setSalePrice(productSku.getSalePrice()); - tbCashierCart.setSkuId(productSku.getId().toString()); tbCashierCart.setTradeDay(DateUtils.getDay()); tbCashierCart.setStatus("create"); - tbCashierCart.setSalePrice(productSku.getSalePrice()); - tbCashierCart.setTotalAmount(new BigDecimal(updateCartDTO.getNum()).multiply(productSku.getSalePrice())); + tbCashierCart.setSalePrice(tbCashierCart.getSalePrice()); + tbCashierCart.setTotalAmount(new BigDecimal(updateCartDTO.getNum()).multiply(tbCashierCart.getSalePrice())); tbCashierCart.setNote(updateCartDTO.getNote()); if (updateCartDTO.getIsPack() != null) { @@ -453,7 +460,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setPackFee(BigDecimal.ZERO); tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(BigDecimal.valueOf(updateCartDTO.getNum()))); } else { - tbCashierCart.setPackFee(new BigDecimal(updateCartDTO.getNum()).multiply(product.getPackFee())); + if (product != null) { + tbCashierCart.setPackFee(new BigDecimal(updateCartDTO.getNum()).multiply(product.getPackFee())); + } tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(BigDecimal.valueOf(updateCartDTO.getNum())) .add(tbCashierCart.getPackFee())); } @@ -467,7 +476,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setTotalNumber(updateCartDTO.getNum()); tbCashierCart.setNumber(updateCartDTO.getNum()); - tbCashierCart.setCategoryId(product.getCategoryId()); tbCashierCartMapper.updateById(tbCashierCart); if (tbCashierCart.getOrderId() != null && StrUtil.isNotBlank(updateCartDTO.getNote())) { @@ -1707,7 +1715,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { private void updateCartAndStock(List newAddCashierCarts, TbOrderInfo orderInfo, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { // 更新购物车记录的orderId for (TbCashierCart cashierCart : newAddCashierCarts) { - if (!"-999".equals(cashierCart.getProductId())) { + // 不为座位费临时菜扣除库存 + if (!"-999".equals(cashierCart.getProductId()) && cashierCart.getIsTemporary() != null && cashierCart.getIsTemporary() == 0) { TbProduct product = productMapper.selectById(cashierCart.getProductId()); TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); From 9c9203d93dd951423f76e2833c519edaa94c2725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 09:50:49 +0800 Subject: [PATCH 010/170] =?UTF-8?q?feat:=20=E4=B8=B4=E6=97=B6=E8=8F=9C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 471b2c1c..a4ee952d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -789,8 +789,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { TbOrderDetail tbOrderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper() .eq(TbOrderDetail::getShopId, removeCartDTO.getShopId()) .eq(TbOrderDetail::getCartId, cashierCart.getId()) - .eq(TbOrderDetail::getProductId, cashierCart.getProductId()) - .eq(TbOrderDetail::getProductSkuId, cashierCart.getSkuId()) .eq(TbOrderDetail::getOrderId, cashierCart.getOrderId())); if (tbOrderDetail == null) { throw new BadRequestException("购物车商品不存在或已退单"); From 41e505e2f4d5ab27655ff937c6d3c9126a270b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 10:08:19 +0800 Subject: [PATCH 011/170] =?UTF-8?q?feat:=20=E4=B8=B4=E6=97=B6=E8=8F=9C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 21df7134..52f21943 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -202,7 +202,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { TbOrderDetail seatInfo = null; ArrayList detailList = new ArrayList<>(); for (TbFullOrderDetail detail : details) { - if (TableConstant.CART_SEAT_ID.equals(detail.getProductId().toString())) { + if (detail.getProductId() != null && TableConstant.CART_SEAT_ID.equals(detail.getProductId().toString())) { seatInfo = detail; } else { detailList.add(detail); From e8dd3778ac3862ffe1a14e5920a4c40a199e89b5 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 10:23:51 +0800 Subject: [PATCH 012/170] =?UTF-8?q?=E5=95=86=E5=93=81=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/pojo/product/TbProduct.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 77c2ff2e..431002a4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -113,8 +113,12 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "是否热销") private Integer isHot = 0; + @Column(name = "`type`") + @ApiModelProperty(value = "商品类型(属性):普通商品 normal 套餐商品 package 称重商品 weigh 团购券 coupon") + private String type; + @Column(name = "`type_enum`") - @ApiModelProperty(value = "商品规格:0-单规格 1多规格") + @ApiModelProperty(value = "商品规格:normal-单规格 sku-多规格") private String typeEnum; @Column(name = "`is_del`",nullable = false) From ffde65a731bf3dd96b7b30890bcb3b42282cbb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 11:37:02 +0800 Subject: [PATCH 013/170] =?UTF-8?q?feat:=201.=E7=82=B9=E9=A4=90num?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=B8=BAdecimal=E7=B1=BB=E5=9E=8B=202.?= =?UTF-8?q?=E7=94=A8=E9=A4=90=E4=BA=BA=E6=95=B0=E6=A0=B9=E6=8D=AEtableId?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEuseType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/dto/shoptable/AddCartDTO.java | 10 +- .../dto/shoptable/AddTemporaryDishesDTO.java | 11 +- .../cashier/dto/shoptable/ReturnCartDTO.java | 6 +- .../cashier/dto/shoptable/ReturnOrderDTO.java | 3 +- .../cashier/dto/shoptable/UpdateCartDTO.java | 6 +- .../mybatis/mapper/TbCashierCartMapper.java | 3 +- .../mybatis/mapper/TbOrderDetailMapper.java | 3 +- .../mybatis/mapper/TbProducSkutMapper.java | 4 +- .../mybatis/mapper/TbProductMapper.java | 8 +- .../ysk/cashier/pojo/order/TbCashierCart.java | 18 ++- .../ysk/cashier/pojo/order/TbOrderDetail.java | 4 +- .../product/TbProductRepository.java | 4 +- .../impl/order/TbOrderInfoServiceImpl.java | 15 +- .../productimpl/TbProductServiceImpl.java | 4 +- .../impl/shopimpl/TbShopTableServiceImpl.java | 143 +++++++++--------- .../service/product/TbProductService.java | 5 +- .../cn/ysk/cashier/utils/WxAccountUtil.java | 4 +- .../java/cn/ysk/cashier/utils/WxMsgUtils.java | 4 +- .../cn/ysk/cashier/vo/TbUserCouponVo.java | 2 +- 19 files changed, 141 insertions(+), 116 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java index 6e4d085b..44335aaf 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java @@ -2,10 +2,8 @@ package cn.ysk.cashier.dto.shoptable; import lombok.Data; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.*; +import java.math.BigDecimal; @Data public class AddCartDTO { @@ -19,8 +17,8 @@ public class AddCartDTO { private Integer shopId; private String tableId; @NotNull - @Min(1) - private Integer num; + @DecimalMin("0.01") + private BigDecimal num; private boolean isPack; private boolean isGift; private Integer cartId; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java index eec2eb62..bd0e0cde 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddTemporaryDishesDTO.java @@ -2,10 +2,7 @@ package cn.ysk.cashier.dto.shoptable; import lombok.Data; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.*; import java.math.BigDecimal; @Data @@ -22,8 +19,10 @@ public class AddTemporaryDishesDTO { @Min(value = 0, message = "价格最低为0") private BigDecimal price; @NotNull - @Min(1) - private Integer num; + @DecimalMin(value = "0.01") + private BigDecimal num; + @NotBlank(message = "单位不为空") + private String unit; private String note; // 用餐类型 @NotBlank diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnCartDTO.java index f8a9cc43..87239935 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnCartDTO.java @@ -2,8 +2,10 @@ package cn.ysk.cashier.dto.shoptable; import lombok.Data; +import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; @Data public class ReturnCartDTO { @@ -13,7 +15,7 @@ public class ReturnCartDTO { private Integer shopId; private Long tableId; @NotNull - @Min(value = 1, message = "最小数量为1") - private Integer num; + @DecimalMin(value = "0.01", message = "最小数量为0.01") + private BigDecimal num; private String note; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnOrderDTO.java index 75dc893c..54e1fe2d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnOrderDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ReturnOrderDTO.java @@ -6,6 +6,7 @@ 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 @@ -17,7 +18,7 @@ public class ReturnOrderDTO { private Integer id; @NotNull @Min(1) - private Integer num; + private BigDecimal num; } @NotNull private Integer orderId; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index e5497eef..97b094c0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -2,9 +2,11 @@ package cn.ysk.cashier.dto.shoptable; import lombok.Data; +import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; @Data public class UpdateCartDTO { @@ -15,8 +17,8 @@ public class UpdateCartDTO { @NotNull private Integer shopId; @NotNull - @Min(0) - private Integer num; + @DecimalMin("0") + private BigDecimal num; private String note; private Boolean isPack; private Boolean isGift; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java index 6e8c29da..2d86fa55 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java @@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import java.math.BigDecimal; import java.util.List; public interface TbCashierCartMapper extends BaseMapper { @@ -47,7 +48,7 @@ public interface TbCashierCartMapper extends BaseMapper { */ @Update("update tb_cashier_cart set status=#{status}, total_amount=(number+#{changeNum})*sale_price,number=number+#{changeNum},total_number=total_number+#{changeNum} " + "where id=#{id}") - int updateNumAmountStatus(Integer id, String status, Integer changeNum); + int updateNumAmountStatus(Integer id, String status, BigDecimal changeNum); @Select("select a.* from tb_cashier_cart as a left join tb_order_detail as b on a.id=b.cart_id where a.shop_id=#{shopId} and a.status=#{state} and a.created_at>#{time} and b.id is not null;") List selectPlaceCart(Integer shopId, long time, String state); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbOrderDetailMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbOrderDetailMapper.java index 415eb6ce..ff9623cb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbOrderDetailMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbOrderDetailMapper.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import java.math.BigDecimal; import java.util.List; public interface TbOrderDetailMapper extends BaseMapper { @@ -19,7 +20,7 @@ public interface TbOrderDetailMapper extends BaseMapper { */ @Update("update tb_order_detail set status=#{status}, price_amount=(num+#{changeNum})*price,num=num+#{changeNum} " + "where id=#{id}") - int updateNumAmountStatus(Integer id, String status, int changeNum); + int updateNumAmountStatus(Integer id, String status, BigDecimal changeNum); /** * 查询包含打包费和是否赠送的订单详情信息 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java index 66fb09e5..dbfa6e0b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java @@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import java.math.BigDecimal; + public interface TbProducSkutMapper extends BaseMapper { @@ -29,5 +31,5 @@ public interface TbProducSkutMapper extends BaseMapper { int decrStockUnCheck(String id, int num); @Update("update tb_product_sku set real_sales_number=real_sales_number-#{num} WHERE id=#{skuId}") - int decrRealSalesNumber(@Param("skuId") Integer skuId, @Param("num") Integer num); + int decrRealSalesNumber(@Param("skuId") Integer skuId, @Param("num") BigDecimal num); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java index e8448908..bfe3676d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java @@ -8,6 +8,8 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import org.springframework.data.jpa.repository.Query; +import java.math.BigDecimal; + public interface TbProductMapper extends BaseMapper { @Select("select * from tb_product_sku as sku where sku.is_del=0 and sku.is_grounding=1 and sku.is_pause_sale=0 and sku.shop_id=#{shopId} and sku.id=#{skuId}") @@ -17,11 +19,11 @@ public interface TbProductMapper extends BaseMapper { TbProduct selectByIdAndShopId(@Param("shopId") Integer shopId, @Param("id") Integer id); @Update("update tb_product set stock_number=stock_number+#{addNum} WHERE id=#{id}") - int incrStock(@Param("id") Integer id, @Param("addNum") Integer addNum); + int incrStock(@Param("id") Integer id, @Param("addNum") BigDecimal addNum); @Update("update tb_product set stock_number=stock_number-#{decrNum} WHERE id=#{productId} and stock_number-#{decrNum} >= 0") - int decrStock(@Param("productId") Integer productId, @Param("decrNum") int decrNum); + int decrStock(@Param("productId") Integer productId, @Param("decrNum") BigDecimal decrNum); @Update("update tb_product set stock_number=stock_number-#{num} WHERE id=#{id}") - int decrStockUnCheck(Integer id, int num); + int decrStockUnCheck(Integer id, BigDecimal num); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index df1863f2..9bbd0a1d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -85,15 +85,15 @@ public class TbCashierCart implements Serializable { @Column(name = "`number`", nullable = false) @NotNull @ApiModelProperty(value = "结余数量") - private Integer number; + private BigDecimal number; @Column(name = "`total_number`") @ApiModelProperty(value = "总下单数量") - private Integer totalNumber; + private BigDecimal totalNumber; @Column(name = "`refund_number`") @ApiModelProperty(value = "退单数量") - private Integer refundNumber; + private BigDecimal refundNumber; @Column(name = "`category_id`") @ApiModelProperty(value = "分类Id") @@ -170,6 +170,7 @@ public class TbCashierCart implements Serializable { private Integer isMember; // 是否临时菜品 private Integer isTemporary; + private String unit; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); @@ -186,9 +187,9 @@ public class TbCashierCart implements Serializable { totalAmount = packFee; } else { if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee); + totalAmount = totalNumber.multiply(memberPrice).add(packFee); } else { - totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee); + totalAmount = totalNumber.multiply(salePrice).add(packFee); } } } @@ -197,14 +198,15 @@ public class TbCashierCart implements Serializable { * 获取总价不包含打包费 * */ - public BigDecimal getTotalAmountByNum(Integer num) { + public BigDecimal getTotalAmountByNum(BigDecimal num) { if (num == null) { num = totalNumber; } if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - return BigDecimal.valueOf(num).multiply(memberPrice); + return num.multiply(memberPrice); } else { - return BigDecimal.valueOf(num).multiply(salePrice); + return num.multiply(salePrice); } } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 9e1b4227..295fed68 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -61,7 +61,7 @@ public class TbOrderDetail implements Serializable { @Column(name = "`num`") @ApiModelProperty(value = "num") - private Integer num; + private BigDecimal num; @Column(name = "`product_name`") @ApiModelProperty(value = "productName") @@ -103,7 +103,7 @@ public class TbOrderDetail implements Serializable { @Transient @ApiModelProperty(value = "退单数量") @TableField(exist = false) - private Integer refundNumber; + private BigDecimal refundNumber; @Column(name = "`is_vip`") @ApiModelProperty(value = "isVip") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index eb19aa14..0d2fbb15 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -34,7 +34,7 @@ public interface TbProductRepository extends JpaRepository, @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=pro.stockNumber+:number WHERE pro.id =:productId") - void incrProductStockNumber(Integer productId, Integer number); + void incrProductStockNumber(Integer productId, BigDecimal number); @Transactional @Modifying @@ -44,7 +44,7 @@ public interface TbProductRepository extends JpaRepository, @Modifying @Query("update TbProduct set stockNumber=stockNumber+:num where id=:id") - void incrStock(@Param("id") Integer id, @Param("num") Integer num); + void incrStock(@Param("id") Integer id, @Param("num") BigDecimal num); @Query("select product from TbProduct product where product.shopId=:shopId") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 52f21943..4e96acc2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -178,17 +178,26 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { List details = tbOrderDetailMapper.selectFullInfoByOrderId(tbOrderInfo.getId()); if (!tbOrderInfo.getOrderType().equals("return")) { List tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId()); - Map map; + Map map; if (!CollectionUtils.isEmpty(tbOrderInfos)) { List ids = tbOrderInfos.stream().map(TbOrderInfo::getId).collect(Collectors.toList()); List refundOrderDetail = tbOrderDetailRepository.searchDetailByOrderIds(ids); - map = refundOrderDetail.stream().collect(Collectors.groupingBy(TbOrderDetail::getProductSkuId, Collectors.summingInt(TbOrderDetail::getNum))); + map = refundOrderDetail.stream() + .collect(Collectors.groupingBy( + TbOrderDetail::getProductSkuId, + Collectors.reducing( + BigDecimal.ZERO, + TbOrderDetail::getNum, + BigDecimal::add + ) + )); + refundAmount = tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add); } else { map = new HashMap<>(); } details.parallelStream().forEach(detail -> { - Integer refundNumber = map.get(detail.getProductSkuId()); + BigDecimal refundNumber = map.get(detail.getProductSkuId()); if (refundNumber != null) { detail.setRefundNumber(refundNumber); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index f069f840..5ac1de9c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -735,12 +735,12 @@ public class TbProductServiceImpl implements TbProductService { } @Override - public void incrStockNumber(String productId, Integer number) { + public void incrStockNumber(String productId, BigDecimal number) { tbProductRepository.incrProductStockNumber(Integer.valueOf(productId), number); } @Override - public void returnStockByPro(Integer productId, Integer productSkuId, Integer num) { + public void returnStockByPro(Integer productId, Integer productSkuId, BigDecimal num) { if (productId > 0) { log.info("开始返还库存,订单超时取消,商品id:{}", productId); TbProduct product = tbProductRepository.findById(productId).orElse(null); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index a4ee952d..f681ecd4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -425,7 +425,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("已下单商品仅支持退单操作"); } - if (updateCartDTO.getNum() == 0) { + if (updateCartDTO.getNum().compareTo(BigDecimal.ZERO) == 0) { cashierCartRepository.deleteById(updateCartDTO.getCartId()); return null; } @@ -452,18 +452,18 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setTradeDay(DateUtils.getDay()); tbCashierCart.setStatus("create"); tbCashierCart.setSalePrice(tbCashierCart.getSalePrice()); - tbCashierCart.setTotalAmount(new BigDecimal(updateCartDTO.getNum()).multiply(tbCashierCart.getSalePrice())); + tbCashierCart.setTotalAmount(updateCartDTO.getNum().multiply(tbCashierCart.getSalePrice())); tbCashierCart.setNote(updateCartDTO.getNote()); if (updateCartDTO.getIsPack() != null) { if (!updateCartDTO.getIsPack()) { tbCashierCart.setPackFee(BigDecimal.ZERO); - tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(BigDecimal.valueOf(updateCartDTO.getNum()))); + tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(updateCartDTO.getNum())); } else { if (product != null) { - tbCashierCart.setPackFee(new BigDecimal(updateCartDTO.getNum()).multiply(product.getPackFee())); + tbCashierCart.setPackFee(updateCartDTO.getNum().multiply(product.getPackFee())); } - tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(BigDecimal.valueOf(updateCartDTO.getNum())) + tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(updateCartDTO.getNum()) .add(tbCashierCart.getPackFee())); } tbCashierCart.setIsPack(updateCartDTO.getIsPack() ? "true" : "false"); @@ -559,14 +559,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setIsPack(String.valueOf(addCartDTO.isPack())); tbCashierCart.setIsGift(String.valueOf(addCartDTO.isGift())); tbCashierCart.setSalePrice(productSku.getSalePrice()); - tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); + tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice())); tbCashierCart.setSkuName(productSku.getSpecSnap()); // 设置打包费 if (!addCartDTO.isPack() && !shopEatTypeInfoDTO.isTakeout()) { tbCashierCart.setPackFee(BigDecimal.ZERO); } else { tbCashierCart.setPackFee(product.getPackFee() != null ? - product.getPackFee().multiply(BigDecimal.valueOf(addCartDTO.getNum())) : BigDecimal.ZERO); + product.getPackFee().multiply(addCartDTO.getNum()) : BigDecimal.ZERO); tbCashierCart.setTotalAmount(tbCashierCart.getTotalAmount().add(tbCashierCart.getPackFee())); } @@ -588,12 +588,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else { tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); tbCashierCart.setNote(addCartDTO.getNote()); - tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); + tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice())); if (!addCartDTO.isPack()) { tbCashierCart.setPackFee(BigDecimal.ZERO); } else { - tbCashierCart.setPackFee(new BigDecimal(addCartDTO.getNum()).multiply(product.getPackFee())); + tbCashierCart.setPackFee(addCartDTO.getNum().multiply(product.getPackFee())); tbCashierCart.setTotalAmount(tbCashierCart.getTotalAmount().add(tbCashierCart.getPackFee())); } @@ -610,7 +610,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 设置打包费 if (shopEatTypeInfoDTO.isTakeout()) { tbCashierCart.setPackFee(product.getPackFee() != null ? - product.getPackFee().multiply(BigDecimal.valueOf(addCartDTO.getNum())) : BigDecimal.ZERO); + product.getPackFee().multiply(addCartDTO.getNum()) : BigDecimal.ZERO); } cashierCartMapper.updateById(tbCashierCart); } @@ -646,7 +646,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setStatus("create"); tbCashierCart.setIsPack("false"); tbCashierCart.setIsGift("false"); - tbCashierCart.setTotalAmount(new BigDecimal(temporaryDishesDTO.getNum()).multiply(temporaryDishesDTO.getPrice())); + tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); tbCashierCart.setPackFee(BigDecimal.ZERO); tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum()); tbCashierCart.setNumber(temporaryDishesDTO.getNum()); @@ -655,12 +655,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && temporaryDishesDTO.getVipUserId() != null ? 1 : 0); tbCashierCart.setIsTemporary(1); + tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); cashierCartRepository.save(tbCashierCart); } else { tbCashierCart.setIsMember(temporaryDishesDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setNote(temporaryDishesDTO.getNote()); - tbCashierCart.setTotalAmount(new BigDecimal(temporaryDishesDTO.getNum()).multiply(temporaryDishesDTO.getPrice())); + tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); tbCashierCart.setPackFee(BigDecimal.ZERO); tbCashierCart.setIsPack("false"); tbCashierCart.setIsGift("false"); @@ -668,6 +669,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setNumber(temporaryDishesDTO.getNum()); tbCashierCart.setUpdatedAt(DateUtil.current()); tbCashierCart.setIsTemporary(1); + tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); cashierCartMapper.updateById(tbCashierCart); } @@ -761,7 +763,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("购物车商品不存在或已退单"); } - if (removeCartDTO.getNum() > cashierCart.getNumber()) { + if (removeCartDTO.getNum().compareTo(cashierCart.getNumber()) > 0) { throw new BadRequestException("最大退菜数量为: {}", cashierCart.getNumber()); } @@ -810,7 +812,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { returnCart.setNumber(removeCartDTO.getNum()); returnCart.setId(null); returnCart.setTotalNumber(removeCartDTO.getNum()); - BigDecimal returnCartAmount = returnCart.getSalePrice().multiply(BigDecimal.valueOf(returnCart.getNumber())); + BigDecimal returnCartAmount = returnCart.getSalePrice().multiply(returnCart.getNumber()); returnCart.setTotalAmount(returnCartAmount); returnCart.setStatus("return"); cashierCartMapper.insert(returnCart); @@ -826,8 +828,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { returnOrderDetail.setRefundRemark(removeCartDTO.getNote()); orderDetailMapper.insert(returnOrderDetail); - cashierCartMapper.updateNumAmountStatus(cashierCart.getId(), cashierCart.getStatus(), -returnCart.getNumber()); - orderDetailMapper.updateNumAmountStatus(orderDetail.getId(), orderDetail.getStatus(), -returnCart.getNumber()); + cashierCartMapper.updateNumAmountStatus(cashierCart.getId(), cashierCart.getStatus(), returnCart.getNumber().negate()); + orderDetailMapper.updateNumAmountStatus(orderDetail.getId(), orderDetail.getStatus(), returnCart.getNumber().negate()); if (TableConstant.OrderInfo.UseType.DINE_IN_AFTER.equalsVals(tbOrderDetail.getUseType()) && !isSeatCart) { rabbitMsgUtils.printDishesTicket(returnOrderDetail.getOrderId(), true, returnOrderDetail); } @@ -837,9 +839,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (cashierCart.getOrderId() != null) { // 减少订单金额 - orderInfoMapper.updateOrderAmount(cashierCart.getOrderId(), orderDetail.getPriceAmount().divide(BigDecimal.valueOf(orderDetail.getNum()), RoundingMode.HALF_UP) - .multiply(BigDecimal.valueOf(removeCartDTO.getNum())), orderDetail.getPackAmount().divide(BigDecimal.valueOf(orderDetail.getNum()), RoundingMode.HALF_UP) - .multiply(BigDecimal.valueOf(removeCartDTO.getNum()))); + orderInfoMapper.updateOrderAmount(cashierCart.getOrderId(), orderDetail.getPriceAmount().divide(orderDetail.getNum(), RoundingMode.HALF_UP) + .multiply(removeCartDTO.getNum()), orderDetail.getPackAmount().divide(orderDetail.getNum(), RoundingMode.HALF_UP) + .multiply(removeCartDTO.getNum())); } @@ -986,7 +988,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { * @param skuId sku * @param addNum 增加的库存数量 */ - public void incrStock(Integer productId, Integer skuId, Integer addNum) { + public void incrStock(Integer productId, Integer skuId, BigDecimal addNum) { productMapper.incrStock(productId, addNum); } @@ -997,7 +999,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { * @param skuId sku * @param decrNum 减少的数量 */ - public void decrStock(Integer productId, String skuId, int decrNum) { + public void decrStock(Integer productId, String skuId, BigDecimal decrNum) { TbProduct product = productMapper.selectById(productId); if (product.getIsStock() == 1) { if (productMapper.decrStock(productId, decrNum) < 1) { @@ -1042,14 +1044,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (cashierCart.getOrderId() != null) { String message = redisTemplate.opsForValue().get(RedisConstant.ORDER_PRODUCT_NUM + cashierCart.getId()); if (message != null) { - int lastNum = Integer.parseInt(message); + BigDecimal lastNum = new BigDecimal(message); // 数量减少, 返还库存 - if (lastNum > cashierCart.getNumber()) { - incrStock(Integer.parseInt(cashierCart.getProductId()), Integer.parseInt(cashierCart.getSkuId()), lastNum - cashierCart.getNumber()); + if (lastNum.compareTo(cashierCart.getNumber()) > 0) { + incrStock(Integer.parseInt(cashierCart.getProductId()), Integer.parseInt(cashierCart.getSkuId()), lastNum.subtract(cashierCart.getNumber())); } else { - decrStock(Integer.parseInt(cashierCart.getProductId()), cashierCart.getSkuId(), cashierCart.getNumber() - lastNum); + decrStock(Integer.parseInt(cashierCart.getProductId()), cashierCart.getSkuId(), cashierCart.getNumber().subtract(lastNum)); } - redisTemplate.opsForValue().set(RedisConstant.ORDER_PRODUCT_NUM + cashierCart.getId(), cashierCart.getNumber().toString(), 24 * 60 * 60, TimeUnit.SECONDS); + redisTemplate.opsForValue().set(RedisConstant.ORDER_PRODUCT_NUM + cashierCart.getId(), cashierCart.getNumber().toPlainString(), 24 * 60 * 60, TimeUnit.SECONDS); } return false; @@ -1095,7 +1097,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { * * @param productSku sku */ - private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, Integer num) { + private void checkWarnLineAndSendMsg(TbProductSku productSku, TbProduct product, Integer shopId, BigDecimal num) { TbShopInfo shopInfo = shopInfoRepository.getById(shopId); if (product.getWarnLine() == null) { return; @@ -1108,9 +1110,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (product.getStockNumber() == null) { product.setStockNumber(0); } - if (product.getStockNumber() - num <= product.getWarnLine()) { + if (product.getStockNumber() - num.doubleValue() <= product.getWarnLine()) { wxMsgUtils.aboardStockMsg(shopInfo.getShopName(), shopId, product.getName(), - product.getStockNumber() - num); + product.getStockNumber() - num.doubleValue()); } } @@ -1266,7 +1268,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { List tbUserCouponVos = couponMap.get(productId); if (tbUserCouponVos == null || tbUserCouponVos.isEmpty()) return null; for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { - if (tbUserCouponVo.getCurrentUseNum() > 0) { + if (tbUserCouponVo.getCurrentUseNum().compareTo(BigDecimal.ZERO) > 0) { return tbUserCouponVo; } } @@ -1277,22 +1279,22 @@ public class TbShopTableServiceImpl implements TbShopTableService { List> usedCouponMap, BigDecimal discountAmount, ArrayList balanceCartList, ArrayList outRecords, Integer memberId) { TbUserCouponVo couponVo = getCanUseCoupon(couponMap, cashierCart.getProductId()); - if (couponVo != null && couponVo.getCurrentUseNum() > 0) { + if (couponVo != null && couponVo.getCurrentUseNum().compareTo(BigDecimal.ZERO) > 0) { BigDecimal currentUseNum; List tbUserCouponVos = usedCouponMap.computeIfAbsent(Integer.valueOf(cashierCart.getProductId()), k -> new ArrayList<>()); tbUserCouponVos.add(couponVo); TbCashierCart balanceCart = null; - if (cashierCart.getNumber() < couponVo.getCurrentUseNum()) { + if (cashierCart.getNumber().compareTo(couponVo.getCurrentUseNum()) < 0) { cashierCart.setUserCouponId(couponVo.getId()); discountAmount = discountAmount.add(cashierCart.getTotalAmountByNum(null)); - couponVo.setCurrentUseNum(couponVo.getCurrentUseNum() - cashierCart.getNumber()); - currentUseNum = BigDecimal.valueOf(cashierCart.getNumber()); + couponVo.setCurrentUseNum(couponVo.getCurrentUseNum().subtract(cashierCart.getNumber())); + currentUseNum = cashierCart.getNumber(); // 优惠券数量小于购物车数量,分割购物车数据 - }else if (cashierCart.getNumber() > couponVo.getCurrentUseNum()) { - currentUseNum = BigDecimal.valueOf(couponVo.getCurrentUseNum()); - BigDecimal cartNum = BigDecimal.valueOf(cashierCart.getNumber()); - int balanceNum = cashierCart.getTotalNumber() - couponVo.getCurrentUseNum(); + }else if (cashierCart.getNumber().compareTo(couponVo.getCurrentUseNum()) > 0) { + currentUseNum = couponVo.getCurrentUseNum(); + BigDecimal cartNum = BigDecimal.valueOf(cashierCart.getNumber().intValue()); + BigDecimal balanceNum = cashierCart.getTotalNumber().subtract(couponVo.getCurrentUseNum()); BigDecimal singlePackFee = cashierCart.getPackFee().divide(cartNum, RoundingMode.HALF_UP); cashierCart.setPackFee(singlePackFee.multiply(currentUseNum)); BigDecimal totalAmountByNum = cashierCart.getTotalAmountByNum(couponVo.getCurrentUseNum()); @@ -1301,14 +1303,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { cashierCart.setTotalNumber(couponVo.getCurrentUseNum()); cashierCart.setUserCouponId(couponVo.getId()); discountAmount = discountAmount.add(totalAmountByNum); - couponVo.setCurrentUseNum(couponVo.getCurrentUseNum() - cashierCart.getNumber()); - currentUseNum = BigDecimal.valueOf(cashierCart.getNumber()); + couponVo.setCurrentUseNum(couponVo.getCurrentUseNum().subtract(cashierCart.getNumber())); + currentUseNum = cashierCart.getNumber(); // 创建结余购物车 balanceCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class); - BigDecimal num = BigDecimal.valueOf(balanceNum); + BigDecimal num = balanceNum; balanceCart.setUserCouponId(null); balanceCart.setId(null); balanceCart.setNumber(balanceNum); @@ -1317,10 +1319,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum).add(singlePackFee.multiply(num))); balanceCartList.add(balanceCart); } else { - currentUseNum = BigDecimal.valueOf(cashierCart.getNumber()); + currentUseNum =cashierCart.getNumber(); discountAmount = discountAmount.add(cashierCart.getTotalAmount()); cashierCart.setUserCouponId(couponVo.getId()); - couponVo.setCurrentUseNum(couponVo.getCurrentUseNum() - cashierCart.getNumber()); + couponVo.setCurrentUseNum(couponVo.getCurrentUseNum().subtract(cashierCart.getNumber())); } // 消耗并返还商品优惠券 Integer shopId = Integer.valueOf(cashierCart.getShopId()); @@ -1350,7 +1352,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal discountAmount = BigDecimal.ZERO; HashMap> couponMap = new HashMap<>(); couponInfoDTO.getProductCouponMap().values().forEach(item -> { - if (item.getCurrentUseNum() <= 0) { + if (item.getCurrentUseNum().compareTo(BigDecimal.ZERO) <= 0) { return; } List tbUserCouponVos = couponMap.get(item.getProId().toString()); @@ -1431,7 +1433,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (couponVo.getNum() < item.getNum()) { throw new BadRequestException(couponVo.getName() + "数量不足: " + couponVo.getNum()); } - couponVo.setCurrentUseNum(item.getNum()); + couponVo.setCurrentUseNum(BigDecimal.valueOf(item.getNum())); infoDTO.getFullReductionCouponMap().put(couponVo.getId(), couponVo); return; } @@ -1439,7 +1441,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (couponVo == null) { throw new BadRequestException("存在不可用优惠券"); } - couponVo.setCurrentUseNum(item.getNum()); + couponVo.setCurrentUseNum(BigDecimal.valueOf(item.getNum())); couponVo.setFinalUseNum(item.getNum()); infoDTO.getProductCouponMap().put(item.getUserCouponId(), couponVo); }); @@ -1654,7 +1656,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderInfo.setUseType(eatTypeInfoDTO.getUseType()); if (seatCart != null) { orderInfo.setSeatAmount(seatCart.getTotalAmount()); - orderInfo.setSeatCount(seatCart.getNumber()); + orderInfo.setSeatCount(seatCart.getNumber().intValue()); } if (createOrderDTO.getVipUserId() != null) { orderInfo.setMemberId(String.valueOf(shopUser.getId())); @@ -2004,7 +2006,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbActivateOutRecord.setGiveId(couponVo.getId()); tbActivateOutRecord.setVipUserId(payDTO.getVipUserId()); tbActivateOutRecord.setType(TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.getValue()); - tbActivateOutRecord.setUseNum(couponVo.getCurrentUseNum()); + tbActivateOutRecord.setUseNum(couponVo.getCurrentUseNum().intValue()); tbActivateOutRecord.setStatus(TableConstant.ActivateOutRecord.Status.CLOSED.getValue()); tbActivateOutRecord.setCreateTime(DateUtil.date()); tbActivateOutRecord.setRefNum(0); @@ -2455,6 +2457,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("当前台桌最大人数为: " + shopTable.getMaxCapacity()); } + choseCountDTO.setUseType(!TableConstant.OrderInfo.UseType.TAKEOUT.equalsVals(choseCountDTO.getUseType()) + && StrUtil.isBlank(choseCountDTO.getTableId()) ? TableConstant.OrderInfo.UseType.NONE_TABLE.getValue() : choseCountDTO.getUseType()); + LambdaQueryWrapper query = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, choseCountDTO.getShopId()) .and(q -> q.eq(TbCashierCart::getMasterId, choseCountDTO.getMasterId()).or().isNull(TbCashierCart::getMasterId).or().eq(TbCashierCart::getMasterId, "")) @@ -2482,16 +2487,16 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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.setUseType(choseCountDTO.getUseType()); tbCashierCartMapper.insert(tbCashierCart); } else { tbCashierCart.setMemberPrice(shopInfo.getTableFee()); tbCashierCart.setStatus(TableConstant.CashierCart.Status.CREATE.getValue()); 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())); tbCashierCart.setUseType(choseCountDTO.getUseType()); tbCashierCartMapper.updateById(tbCashierCart); } @@ -2613,7 +2618,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpCashierCartService.update(new LambdaUpdateWrapper() .eq(TbCashierCart::getId, item.getId()) .set(TbCashierCart::getPackFee, product.getPackFee() != null ? - product.getPackFee().multiply(BigDecimal.valueOf(item.getNumber())) : BigDecimal.ZERO) + product.getPackFee().multiply(item.getNumber()) : BigDecimal.ZERO) .set(TbCashierCart::getTableId, null) .set(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue()) .set(TbCashierCart::getIsPack, "true")); @@ -2628,7 +2633,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { TbProduct product = productMap.get(item.getProductId().toString()); // 设置打包费 item.setPackAmount(product.getPackFee() != null ? - product.getPackFee().multiply(BigDecimal.valueOf(item.getNum())) : BigDecimal.ZERO); + product.getPackFee().multiply(item.getNum()) : BigDecimal.ZERO); }); if (!detailList.isEmpty()) { @@ -2653,7 +2658,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private HashMap updateReturnOrderInfo(ReturnOrderDTO returnOrderDTO, TbOrderInfo oldOrderInfo, boolean isOnline) { ArrayList detailIds = new ArrayList<>(); - HashMap returnNumMap = new HashMap<>(); + HashMap returnNumMap = new HashMap<>(); returnOrderDTO.getOrderDetails().forEach(item -> { detailIds.add(item.getId()); returnNumMap.put(item.getId().toString(), item.getNum()); @@ -2675,20 +2680,20 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (orderDetail.getUserCouponId() != null) { throw new BadRequestException("选择了优惠券抵扣商品,无法退款"); } - Integer returnNum = returnNumMap.get(orderDetail.getId().toString()); - int remainNum = orderDetail.getNum() - returnNum; - if (remainNum < 0) { + BigDecimal returnNum = returnNumMap.get(orderDetail.getId().toString()); + BigDecimal remainNum = orderDetail.getNum().subtract(returnNum); + if (remainNum.compareTo(BigDecimal.ZERO) < 0) { throw new BadRequestException("{}最多可退数量为: {}", orderDetail.getProductName(), orderDetail.getNum()); } // 将未退款的剩余订单详情重新生成记录 - BigDecimal packFee = orderDetail.getPackAmount().divide(BigDecimal.valueOf(orderDetail.getNum()), RoundingMode.HALF_UP); - if (remainNum > 0) { + BigDecimal packFee = orderDetail.getPackAmount().divide(orderDetail.getNum(), RoundingMode.HALF_UP); + if (remainNum.compareTo(BigDecimal.ZERO) > 0) { // 单个打包费 - BigDecimal remainPackFee = packFee.multiply(BigDecimal.valueOf(remainNum)); + BigDecimal remainPackFee = packFee.multiply(remainNum); TbOrderDetail remainOrderDetail = BeanUtil.copyProperties(orderDetail, TbOrderDetail.class); remainOrderDetail.setNum(remainNum); - remainOrderDetail.setPriceAmount(BigDecimal.valueOf(remainNum).multiply(orderDetail.getPrice()) + remainOrderDetail.setPriceAmount(remainNum.multiply(orderDetail.getPrice()) .add(remainPackFee)); remainOrderDetail.setPackAmount(remainPackFee); remainOrderDetail.setReturnNum("0"); @@ -2697,16 +2702,16 @@ public class TbShopTableServiceImpl implements TbShopTableService { } returnAmount = returnAmount.add(orderDetail.getPriceAmount() - .divide(new BigDecimal(orderDetail.getNum()), 2, RoundingMode.DOWN) - .multiply(BigDecimal.valueOf(returnNum))); + .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) + .multiply(returnNum)); saleAmount = saleAmount.add(orderDetail.getPrice()); packAMount = packAMount.add(orderDetail.getPackAmount() - .divide(new BigDecimal(orderDetail.getNum()), 2, RoundingMode.DOWN) - .multiply(BigDecimal.valueOf(returnNum))); + .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) + .multiply(returnNum)); - BigDecimal returnPackFee = packFee.multiply(BigDecimal.valueOf(returnNum)); + BigDecimal returnPackFee = packFee.multiply(returnNum); orderDetail.setNum(returnNum); - orderDetail.setPriceAmount(BigDecimal.valueOf(returnNum).multiply(orderDetail.getPrice()) + orderDetail.setPriceAmount(returnNum.multiply(orderDetail.getPrice()) .add(returnPackFee)); orderDetail.setPackAmount(returnPackFee); orderDetail.setRefundNumber(returnNum); @@ -2785,7 +2790,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { productMapper.incrStock(product.getId(), detail.getNum()); tbProductStockDetail.setLeftNumber(product.getStockNumber()); - tbProductStockDetail.setStockNumber(Double.valueOf(detail.getNum())); + tbProductStockDetail.setStockNumber(detail.getNum().doubleValue()); producSkutMapper.decrRealSalesNumber(productSku.getId(), detail.getNum()); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java index 82661bc2..762618e2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java @@ -8,6 +8,7 @@ import cn.ysk.cashier.dto.product.TbProductDto; import cn.ysk.cashier.dto.product.TbProductQueryCriteria; import org.springframework.data.domain.Pageable; +import java.math.BigDecimal; import java.util.Map; import java.util.List; import java.io.IOException; @@ -96,7 +97,7 @@ public interface TbProductService { * @param productId 商品id * @param number 增加数量 */ - void incrStockNumber(String productId, Integer number); + void incrStockNumber(String productId, BigDecimal number); /** * 返还库存 @@ -104,7 +105,7 @@ public interface TbProductService { * @param productSkuId sku * @param num 数量 */ - void returnStockByPro(Integer productId, Integer productSkuId, Integer num); + void returnStockByPro(Integer productId, Integer productSkuId, BigDecimal num); Object activateProduct(Integer page, Integer size, Integer categoryId, Integer shopId, Integer productId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxAccountUtil.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxAccountUtil.java index 4d5cd717..7cdb9f6f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxAccountUtil.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxAccountUtil.java @@ -133,10 +133,10 @@ public class WxAccountUtil { } - public void sendStockMsg(String shopName, String productName, int stock, String openId, ShopWxMsgTypeEnum shopWxMsgTypeEnum, Integer shopId) { + public void sendStockMsg(String shopName, String productName, double stock, String openId, ShopWxMsgTypeEnum shopWxMsgTypeEnum, Integer shopId) { stock = Math.max(stock, 0); - Integer finalStock = stock; + double finalStock = stock; Map data = new HashMap() {{ put("thing22", new HashMap() {{ put("value", shopName); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java index 94385cda..14f69e6d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/WxMsgUtils.java @@ -95,11 +95,11 @@ public class WxMsgUtils { } } - public void aboardStockMsg(String shopName, Integer shopId, String proName, Integer stock) { + public void aboardStockMsg(String shopName, Integer shopId, String proName, double stock) { if (!checkIsOpen(shopId, ShopWxMsgTypeEnum.OPERATION_MSG)) { return; } - + List openIds = tbShopOpenIdService.lambdaQuery() .eq(TbShopOpenId::getShopId, shopId) .eq(TbShopOpenId::getStatus, 1) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java index ea03ff86..5fbdc139 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java @@ -28,7 +28,7 @@ public class TbUserCouponVo { private String useRestrictions; private boolean isUse = false; //当前使用数量 - private Integer currentUseNum; + private BigDecimal currentUseNum; private Integer finalUseNum; private BigDecimal finalDiscountAmount = new BigDecimal(0); From b6e85f897f0725bb6d08a08da4bb32ebd352e7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 13:41:37 +0800 Subject: [PATCH 014/170] =?UTF-8?q?feat:=20=E8=B4=AD=E7=89=A9=E8=BD=A6?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?decimal=EF=BC=8Cjpa=E7=9B=B8=E5=85=B3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/TbOrderDetailRepository.java | 4 ++-- .../service/impl/SummaryServiceImpl.java | 2 +- .../vo/TbOrderSalesCountByDayV2Vo.java | 6 +++--- .../cashier/vo/TbOrderSalesCountByDayVo.java | 20 +++++++++---------- .../cashier/vo/TbOrderSalesCountByTable.java | 12 +++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java index 41ee7359..01cd41ed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java @@ -171,8 +171,8 @@ public interface TbOrderDetailRepository extends JpaRepository skus = new ArrayList<>(); - public TbOrderSalesCountByDayV2Vo(String name, Integer productId, String cateName,String typeEnum, Long salesNum, Long refNum, BigDecimal salesAmount, BigDecimal refAmount) { + public TbOrderSalesCountByDayV2Vo(String name, Integer productId, String cateName,String typeEnum, BigDecimal salesNum, BigDecimal refNum, BigDecimal salesAmount, BigDecimal refAmount) { this.name = name; this.productId = productId; this.typeEnum = typeEnum; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByDayVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByDayVo.java index 6635bad5..601d0387 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByDayVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByDayVo.java @@ -12,21 +12,21 @@ public class TbOrderSalesCountByDayVo { private String cateName; private String unitName; private BigDecimal price; - private Long salesNum; - private Long refNum; + private BigDecimal salesNum; + private BigDecimal refNum; private BigDecimal salesAmount; private BigDecimal refAmount; - private Long num; + private BigDecimal num; private Integer productId; private Integer productSkuId; - public TbOrderSalesCountByDayVo(Long salesNum, Long refNum) { + public TbOrderSalesCountByDayVo(BigDecimal salesNum, BigDecimal refNum) { this.salesNum = salesNum; this.refNum = refNum; } public TbOrderSalesCountByDayVo(String productName, String productSkuName, String cateName,String unitName,BigDecimal price, - Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount) { + BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount) { this.productName = productName; this.productSkuName = productSkuName; this.cateName = cateName; @@ -42,7 +42,7 @@ public class TbOrderSalesCountByDayVo { public TbOrderSalesCountByDayVo(String productName, String productSkuName, String cateName,String unitName,BigDecimal price, - Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount, Integer productId, Integer productSkuId) { + BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount, Integer productId, Integer productSkuId) { this.productName = productName; this.productSkuName = productSkuName; this.cateName = cateName; @@ -58,7 +58,7 @@ public class TbOrderSalesCountByDayVo { count(); } - public TbOrderSalesCountByDayVo(Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount) { + public TbOrderSalesCountByDayVo(BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount) { this.salesNum = salesNum; this.refNum = refNum; this.salesAmount = salesAmount; @@ -68,9 +68,9 @@ public class TbOrderSalesCountByDayVo { } public void count(){ - if (salesNum == null) salesNum = 0l; - if (refNum == null) refNum = 0l; - salesNum = salesNum - refNum; + if (salesNum == null) salesNum = BigDecimal.ZERO; + if (refNum == null) refNum = BigDecimal.ZERO; + salesNum = salesNum.subtract(refNum); if (salesAmount == null) salesAmount = BigDecimal.ZERO; if (refAmount == null) refAmount = BigDecimal.ZERO; salesAmount = salesAmount.subtract(refAmount); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByTable.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByTable.java index b1b8a8ed..da84cd35 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByTable.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbOrderSalesCountByTable.java @@ -14,17 +14,17 @@ public class TbOrderSalesCountByTable { private String cateName; private String unitName; private BigDecimal price; - private Long salesNum; - private Long refNum; + private BigDecimal salesNum; + private BigDecimal refNum; private BigDecimal salesAmount; private BigDecimal refAmount; - private Long num; + private BigDecimal num; private Integer productId; private Integer productSkuId; private String tableId; public TbOrderSalesCountByTable(String productName, String productSkuName, String cateName,String unitName,BigDecimal price, - Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount) { + BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount) { this.productName = productName; this.productSkuName = productSkuName; this.cateName = cateName; @@ -39,7 +39,7 @@ public class TbOrderSalesCountByTable { } public TbOrderSalesCountByTable(String productName, String productSkuName, String cateName,String unitName,BigDecimal price, - Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount, + BigDecimal salesNum, BigDecimal refNum, BigDecimal num, BigDecimal salesAmount, BigDecimal refAmount, Integer productId, Integer productSkuId, String tableId) { this.productName = productName; this.productSkuName = productSkuName; @@ -58,7 +58,7 @@ public class TbOrderSalesCountByTable { } public void count(){ - salesNum=salesNum-refNum; + salesNum= salesNum.subtract(refNum); salesAmount=salesAmount.subtract(refAmount); } From d73edc9277ecd43a0f7f2ce68f0818a52cf3b680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 13:53:38 +0800 Subject: [PATCH 015/170] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E8=A1=A8?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E5=AD=97=E6=AE=B5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 5ac1de9c..4150064d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -759,7 +759,6 @@ public class TbProductServiceImpl implements TbProductService { queryWrapper.eq("is_del", 0) .in("type_enum", "sku", "normal") .eq("shop_id", shopId) - .eq("is_delete", 0) .eq("status", 1) .eq("is_pause_sale", 0); From 832d737aa0b95d78333a6c675e341169dca05c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 15:06:20 +0800 Subject: [PATCH 016/170] =?UTF-8?q?feat:=20=E5=8D=95=E5=93=81=E6=94=B9?= =?UTF-8?q?=E4=BB=B7=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 6 ++++- .../cashier/dto/shoptable/UpdatePriceDTO.java | 22 ++++++++++++++++ .../mybatis/service/MpCashierCartService.java | 7 +++++ .../mybatis/service/MpOrderDetailService.java | 8 ++++++ .../mybatis/service/MpOrderInfoService.java | 2 ++ .../impl/MpCashierCartServiceImpl.java | 11 ++++++++ .../impl/MpOrderDetailServiceImpl.java | 9 +++++++ .../service/impl/MpOrderInfoServiceImpl.java | 16 ++++++++++++ .../ysk/cashier/pojo/order/TbCashierCart.java | 6 +++-- .../ysk/cashier/pojo/order/TbOrderDetail.java | 2 ++ .../impl/shopimpl/TbShopTableServiceImpl.java | 26 +++++++++++++++++++ .../service/shop/TbShopTableService.java | 6 +++++ 12 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index bf4bf30c..f98f6329 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -77,11 +77,15 @@ public class TbPlaceController { } @PostMapping("/temporaryDishes") - @ApiOperation("代客下单/shop/table") public ResponseEntity addTemporaryDishes(@Valid @RequestBody AddTemporaryDishesDTO temporaryDishesDTO) { return ResponseEntity.ok(tbShopTableService.addTemporaryDishes(temporaryDishesDTO)); } + @PutMapping("/updatePrice") + public ResponseEntity updatePrice(@Valid @RequestBody UpdatePriceDTO updatePriceDTO) { + return ResponseEntity.ok(tbShopTableService.updatePrice(updatePriceDTO)); + } + @PutMapping("/choseModel") @ApiOperation("代客下单/shop/table") public ResponseEntity choseModel(@Valid @RequestBody ChoseModelDTO choseModelDTO) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java new file mode 100644 index 00000000..120d93e9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +@Data +public class UpdatePriceDTO { + @NotNull + private Integer shopId; + @NotNull + private Integer cartId; + @DecimalMin("0.01") + @NotNull + private BigDecimal saleAmount; + @NotBlank(message = "折扣原因不能为空") + private String note; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java index 26a7d74c..36009ac5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java @@ -83,5 +83,12 @@ public interface MpCashierCartService extends IService { */ TbCashierCart selectOneCartByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer productId, Integer skuId, boolean isGift, boolean isTemp); + /** + * 根据店铺id和购物车id查询信息 + * @param shopId 店铺id + * @param cartId 购物车id + * @param statuses 状态 + */ + TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java index 4c1b57ab..6083494f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java @@ -7,6 +7,7 @@ import cn.ysk.cashier.pojo.order.TbFullOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderDetail; import com.baomidou.mybatisplus.extension.service.IService; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -63,5 +64,12 @@ public interface MpOrderDetailService extends IService { * @param orderId 订单id */ boolean updateStatusByOrderId(TableConstant.OrderInfo.Status status, Integer orderId); + + /** + * 根据购物车id修改detail价格 + * @param cartId 购物车id + * @param totalAmount 总价格 + */ + boolean updatePriceByCartId(Integer cartId, BigDecimal saleAmount, BigDecimal totalAmount); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java index fe49c351..6dda692a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java @@ -6,6 +6,7 @@ import cn.ysk.cashier.pojo.order.TbOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderInfo; import com.baomidou.mybatisplus.extension.service.IService; +import java.math.BigDecimal; import java.util.List; /** @@ -40,5 +41,6 @@ public interface MpOrderInfoService extends IService { */ TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status); + boolean incrAmount(Integer orderId, BigDecimal subtract); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java index 58c19d44..60fb0a4d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java @@ -173,5 +173,16 @@ public class MpCashierCartServiceImpl extends ServiceImpl 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); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java index 9faa520a..d6010748 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -68,5 +69,13 @@ public class MpOrderDetailServiceImpl extends ServiceImpl() + .eq(TbOrderDetail::getCartId, cartId) + .set(TbOrderDetail::getPrice, saleAmount) + .set(TbOrderDetail::getPriceAmount, totalAmount)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java index 230128b8..976ce91e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper; import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper; @@ -12,6 +13,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.math.BigDecimal; + /** * (TbShopPermission)表服务实现类 * @@ -40,5 +43,18 @@ public class MpOrderInfoServiceImpl extends ServiceImpl() + .eq(TbOrderInfo::getId, orderId) + .eq(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue()) + .apply("settlement_amount + {0} >= 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)) + ); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 9bbd0a1d..56264e2f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -171,6 +171,8 @@ public class TbCashierCart implements Serializable { // 是否临时菜品 private Integer isTemporary; private String unit; + private BigDecimal discountSaleAmount; + private String discountSaleNote; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); @@ -189,7 +191,7 @@ public class TbCashierCart implements Serializable { if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { totalAmount = totalNumber.multiply(memberPrice).add(packFee); } else { - totalAmount = totalNumber.multiply(salePrice).add(packFee); + totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee); } } } @@ -205,7 +207,7 @@ public class TbCashierCart implements Serializable { if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { return num.multiply(memberPrice); } else { - return num.multiply(salePrice); + return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice); } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 295fed68..fa7c253c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -132,6 +132,8 @@ public class TbOrderDetail implements Serializable { private Integer userCouponId; private Integer isMember; private Integer isTemporary; + private String discountSaleNote; + public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index f681ecd4..b8be293f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2895,4 +2895,30 @@ public class TbShopTableServiceImpl implements TbShopTableService { return true; } + + @Override + public TbCashierCart updatePrice(UpdatePriceDTO updatePriceDTO) { + TbCashierCart cashierCart = mpCashierCartService.selectByShopIdAndId(updatePriceDTO.getShopId(), updatePriceDTO.getCartId(), TableConstant.OrderInfo.Status.CREATE); + if (cashierCart == null) { + throw new BadRequestException("购物车商品不存在"); + } + + if (updatePriceDTO.getSaleAmount().compareTo(cashierCart.getSalePrice()) == 0) { + return cashierCart; + } + + BigDecimal newTotalPrice = updatePriceDTO.getSaleAmount().multiply(cashierCart.getTotalNumber()).add(cashierCart.getPackFee()); + cashierCart.setTotalAmount(newTotalPrice); + cashierCart.setUpdatedAt(DateUtil.current()); + cashierCart.setDiscountSaleNote(updatePriceDTO.getNote()); + cashierCart.setDiscountSaleAmount(updatePriceDTO.getSaleAmount()); + mpCashierCartService.updateById(cashierCart); + + // 更新订单和detail价格 + if (cashierCart.getOrderId() != null) { + mpOrderDetailService.updatePriceByCartId(cashierCart.getId(), updatePriceDTO.getSaleAmount(), newTotalPrice); + mpOrderInfoService.incrAmount(cashierCart.getOrderId(), newTotalPrice.subtract(cashierCart.getTotalAmount())); + } + return cashierCart; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index ca10d873..6c32f853 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -157,4 +157,10 @@ public interface TbShopTableService { Object bindQrcode(BindTableQrCodeDTO bindTableQrCodeDTO); + /** + * 修改购物车价格 + * @param updatePriceDTO 价格信息 + */ + TbCashierCart updatePrice(UpdatePriceDTO updatePriceDTO); + } From 53e7443817d409f13dd3a70474fb1fbfda29c56d Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 15:08:35 +0800 Subject: [PATCH 017/170] =?UTF-8?q?=E5=95=86=E5=93=81=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A7=B0=E9=87=8D=E5=95=86=E5=93=81=20=E5=92=8C=20=E5=A5=97?= =?UTF-8?q?=E9=A4=90=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/utils/ListUtil.java | 11 ++- .../ysk/cashier/pojo/product/TbProduct.java | 63 ++++++++++------ .../product/TbProductRepository.java | 2 +- .../productimpl/TbProductServiceImpl.java | 73 ++++++++++--------- .../cn/ysk/cashier/vo/ProductGroupVo.java | 34 +++++++++ .../java/cn/ysk/cashier/vo/TbProductVo.java | 38 +++++----- 6 files changed, 144 insertions(+), 77 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java index ae821ec4..f42d52e4 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java @@ -102,10 +102,13 @@ public class ListUtil { } - public static String listChangeString(List listString){ - return listString.stream() - .map(Object::toString) - .collect(Collectors.joining(", ")); + public static String listToJsonString(List list) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.writeValueAsString(list); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } } public static String mapToString(Map map) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 431002a4..04598356 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -50,11 +50,6 @@ public class TbProduct implements Serializable { @TableId(type = IdType.AUTO) private Integer id; - - @Column(name = "`merchant_id`") - @ApiModelProperty(value = "商户Id") - private String merchantId = "PLANT_ID"; - @Column(name = "`shop_id`") @ApiModelProperty(value = "店铺id") private String shopId; @@ -135,28 +130,16 @@ public class TbProduct implements Serializable { private Integer isPauseSale = 0; @Column(name = "`created_at`") - @ApiModelProperty(value = "createdAt") + @ApiModelProperty(value = "创建时间") private Long createdAt; @Column(name = "`updated_at`") - @ApiModelProperty(value = "updatedAt") + @ApiModelProperty(value = "更新时间") private Long updatedAt; - @Column(name = "`furnish_meal`") - @ApiModelProperty(value = "支持堂食") - private Integer furnishMeal = 0; - - @Column(name = "`furnish_express`") - @ApiModelProperty(value = "支持配送") - private Integer furnishExpress = 0; - - @Column(name = "`furnish_draw`") - @ApiModelProperty(value = "支持自提") - private Integer furnishDraw = 0; - - @Column(name = "`furnish_vir`") - @ApiModelProperty(value = "支持虚拟") - private Integer furnishVir = 0; + @Column(name = "`group_type`") + @ApiModelProperty(value = "套餐类型 0固定套餐 1可选套餐") + private Integer groupType; @Column(name = "`group_snap`") @ApiModelProperty(value = "套餐内容") @@ -194,6 +177,42 @@ public class TbProduct implements Serializable { @ApiModelProperty("库存警戒线") private Integer warnLine = 0; + @Column(name = "show_type") + @ApiModelProperty("堂食 table 自取 dine 配送 delivery 快递 express") + private String showType; + + @Column(name = "weight") + @ApiModelProperty("称重 价格/千克") + private BigDecimal weight; + + @Column(name = "is_temp_price") + @ApiModelProperty("是否允许临时改价") + private Integer isTempPrice = 0; + + @Column(name = "day_limit") + @ApiModelProperty("日销售上限") + private Integer dayLimit = 0; + + @Column(name = "single_order_limit") + @ApiModelProperty("每单销售上限") + private Integer singleOrderLimit = 0; + + @Column(name = "single_people_limit") + @ApiModelProperty("每人销售上限") + private Integer singlePeopleLimit = 0; + + @Column(name = "days") + @ApiModelProperty("周数组 周一,周二,周日") + private String days; + + @Column(name = "start_time") + @ApiModelProperty("可用开始时间") + private String startTime; + + @Column(name = "end_time") + @ApiModelProperty("可用结束时间") + private String endTime; + @Transient @TableField(exist = false) private TbProductSkuResult skuResult; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index eb19aa14..845be3a5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -24,7 +24,7 @@ public interface TbProductRepository extends JpaRepository, @Query("SELECT product from TbProduct product where product.id in :productIds order by product.sort") List findByIds(List productIds); - @Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true) + @Query(value = "update tb_product set status = -1 and is_del = 1 where id in :productIds",nativeQuery = true) @Modifying void updateByStatus(List productIds); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index f069f840..fe562882 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.service.impl.productimpl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.domain.ViewConSku; import cn.ysk.cashier.cons.repository.ViewConSkuRepository; @@ -29,6 +30,7 @@ import cn.ysk.cashier.service.TbPlatformDictService; import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.shop.TbCouponCategoryService; import cn.ysk.cashier.utils.*; +import cn.ysk.cashier.vo.ProductGroupVo; import cn.ysk.cashier.vo.TbProductNewVo; import cn.ysk.cashier.vo.TbProductVo; import com.alibaba.fastjson.JSONArray; @@ -304,9 +306,6 @@ public class TbProductServiceImpl implements TbProductService { public TbProductVo findByProductId(Integer id) throws Exception { TbProduct tbProduct = tbProductRepository.findById(id).orElseGet(TbProduct::new); - //单位 -// CompletableFuture tbShopUnits = CompletableFuture.supplyAsync(() -> -// tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId()) ? null : tbProduct.getUnitId()))); //sku CompletableFuture> tbProductSkus = CompletableFuture.supplyAsync(() -> tbProductSkuRepository.searchSku(tbProduct.getId().toString())); @@ -314,24 +313,20 @@ public class TbProductServiceImpl implements TbProductService { CompletableFuture tbProductSpec = CompletableFuture.supplyAsync(() -> tbProductSpecRepository.searchSpec(tbProduct.getSpecId())); -// Threads.call(tbShopUnits, tbProductSkus, tbProductSpec); Threads.call(tbProductSkus, tbProductSpec); //组装 TbProductVo tbProductVo = new TbProductVo(); -// tbProductVo.setStockNumber(tbProduct.getStockNumber() == null ? 0.00 : tbProduct.getStockNumber()); tbProductVo.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? Integer.valueOf(tbProduct.getCategoryId()) : null); - //单位 -// if (tbProduct.getUnitId() == null) { -// tbProductVo.setUnitId(null); -// tbProductVo.setUnitName(null); -// } - //套餐 - if (tbProduct.getGroupSnap() == null) { - tbProductVo.setGroupSnap(new JSONArray()); - } else { - tbProductVo.setGroupSnap(ListUtil.stringChangeList(tbProduct.getGroupSnap())); - } + BeanUtils.copyProperties(tbProduct, tbProductVo); + //套餐 + if(tbProduct.getType().equals("package")){ + if (tbProduct.getGroupSnap() == null) { + tbProductVo.setProGroupVo(null); + } else { + tbProductVo.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); + } + } tbProductVo.setStockNumber(Double.valueOf(tbProduct.getStockNumber())); if (!org.apache.commons.lang3.StringUtils.isBlank(tbProduct.getImages())) { tbProductVo.setImages(ListUtil.stringChangeList(tbProduct.getImages())); @@ -364,7 +359,7 @@ public class TbProductServiceImpl implements TbProductService { Optional skuResult = tbProductSkuResultRepository.findById(tbProductVo.getId()); tbProductVo.setSkuSnap(skuResult.get().getTagSnap()); } - if ("group".equals(tbProductVo.getTypeEnum())) { + if ("coupon".equals(tbProductVo.getType())) { if (StringUtils.isNotBlank(tbProduct.getGroupCategoryId())) { JSONArray objects = ListUtil.stringChangeList(tbProduct.getGroupCategoryId()); for (Object groupCategoryId : objects) { @@ -419,7 +414,7 @@ public class TbProductServiceImpl implements TbProductService { if (CollectionUtils.isEmpty(resources.getSkuList())) { throw new BadRequestException("商品规格不可为空"); } - if (!"group".equals(resources.getTypeEnum())) { + if (!"coupon".equals(resources.getType())) { if (resources.getCategoryId() == null) { throw new BadRequestException("必填内容未填写"); } @@ -437,11 +432,11 @@ public class TbProductServiceImpl implements TbProductService { product.setUpdatedAt(Instant.now().toEpochMilli()); List lowPrice = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); product.setLowPrice(lowPrice.get(0)); - if ("group".equals(resources.getTypeEnum())) { - //套餐内容 - if (!resources.getGroupSnap().isEmpty()) { - product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); - } + if ("coupon".equals(resources.getType())) { +// //套餐内容 +// if (!resources.getGroupSnap().isEmpty()) { +// product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); +// } if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) { List collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList()); product.setGroupCategoryId(collect.toString()); @@ -452,6 +447,12 @@ public class TbProductServiceImpl implements TbProductService { } } } + if("package".equals(resources.getType())){ + //套餐内容 + if (!resources.getProGroupVo().isEmpty()) { + product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); + } + } TbProduct save = tbProductRepository.save(product); if (save.getId() == null) { @@ -478,7 +479,7 @@ public class TbProductServiceImpl implements TbProductService { productSkuResult.setTagSnap(resources.getSkuSnap()); productSkuResult.setId(save.getId()); tbProductSkuResultRepository.save(productSkuResult); - } else if ("group".equals(resources.getTypeEnum())) { + } else if ("coupon".equals(resources.getType())) { TbPurchaseNotice notices = resources.getNotices(); if (StringUtils.isBlank(notices.getDateUsed()) && StringUtils.isBlank(notices.getAvailableTime()) @@ -523,7 +524,7 @@ public class TbProductServiceImpl implements TbProductService { throw new BadRequestException("规格数据异常"); } } - if (!"group".equals(product.getTypeEnum())) { + if (!"coupon".equals(product.getType())) { if (resources.getCategoryId() == null) throw new BadRequestException("商品分类不可为空"); product.setGroupSnap(null); if (resources.getNotices() != null && resources.getNotices().getId() != null) { @@ -537,13 +538,13 @@ public class TbProductServiceImpl implements TbProductService { product.setStockNumber(resources.getStockNumber().intValue()); List lowPrices = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); product.setLowPrice(lowPrices.get(0)); - if ("group".equals(resources.getTypeEnum())) { - //套餐内容 - if (!resources.getGroupSnap().isEmpty()) { - product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); - } else { - throw new BadRequestException("套餐内容不可为空"); - } + if ("coupon".equals(resources.getType())) { +// //套餐内容 +// if (!resources.getGroupSnap().isEmpty()) { +// product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); +// } else { +// throw new BadRequestException("套餐内容不可为空"); +// } if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) { List collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList()); product.setGroupCategoryId(collect.toString()); @@ -558,6 +559,12 @@ public class TbProductServiceImpl implements TbProductService { } else { product.setCategoryId(resources.getCategoryId().toString()); } + if("package".equals(resources.getType())){ + //套餐内容 + if (CollectionUtil.isNotEmpty(resources.getProGroupVo())) { + product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); + } + } TbProduct save = tbProductRepository.save(product); //sku @@ -581,7 +588,7 @@ public class TbProductServiceImpl implements TbProductService { tbProductSkuResultRepository.save(productSkuResult); } else { tbProductSkuResultRepository.deleteByIdN(save.getId()); - if ("group".equals(resources.getTypeEnum())) { + if ("coupon".equals(resources.getType())) { TbPurchaseNotice notices = resources.getNotices(); if (StringUtils.isBlank(notices.getDateUsed()) && StringUtils.isBlank(notices.getAvailableTime()) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java new file mode 100644 index 00000000..ca49afc7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java @@ -0,0 +1,34 @@ +package cn.ysk.cashier.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/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java index b69c7560..0e38ad25 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java @@ -25,8 +25,6 @@ public class TbProductVo { private Integer id; - private String merchantId; - private String shopId; private String name; @@ -47,24 +45,19 @@ public class TbProductVo { private String shortTitle; - private BigDecimal lowMemberPrice; - private String shareImg; private JSONArray images; private Integer sort; - private Integer limitNumber; - private Integer status; - private String failMsg; - private Integer isHot; private Integer isOnSale; + private String type; private String typeEnum; private Integer isDel; @@ -79,19 +72,11 @@ public class TbProductVo { private Long updatedAt; - private Integer furnishMeal; - private Double realSalesNumber; private Double stockNumber; - private Integer furnishExpress; - - private Integer furnishDraw; - - private Integer furnishVir; - - private JSONArray groupSnap; + private Integer groupType; private String unitName; @@ -115,9 +100,28 @@ public class TbProductVo { private Integer warnLine = 0; + private String showType; + + private BigDecimal weight; + + private Integer isTempPrice = 0; + + private Integer dayLimit = 0; + + private Integer singleOrderLimit = 0; + + private Integer singlePeopleLimit = 0; + + private String days; + + private String startTime; + + private String endTime; + private List conInfos; private TbPurchaseNotice notices=new TbPurchaseNotice(); private List groupCategoryId = new ArrayList<>(); private List tags = new ArrayList<>(); + private List proGroupVo; } From 5c7388801f3228d95e7e6317b644f761f77c0d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 15:19:51 +0800 Subject: [PATCH 018/170] =?UTF-8?q?fix:=20=E5=85=88=E7=82=B9=E9=A4=90?= =?UTF-8?q?=E5=90=8E=E9=80=89=E6=8B=A9=E4=BC=9A=E5=91=98=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BB=B7=E4=B8=8D=E6=AD=A3=E5=B8=B8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index b8be293f..4e7cf663 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -580,9 +580,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); // tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); - if (tbCashierCart.getIsMember() == 1) { - tbCashierCart.setMemberPrice(productSku.getMemberPrice()); - } + tbCashierCart.setMemberPrice(productSku.getMemberPrice()); cashierCartRepository.save(tbCashierCart); } else { From ff5cebf20330a4c3956f38a3ede4e93c37c0fac7 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 17:07:57 +0800 Subject: [PATCH 019/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=A5=97=E9=A4=90=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/pojo/product/TbProduct.java | 5 ++++- .../impl/productimpl/TbProductServiceImpl.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 04598356..73a8fe2d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -17,6 +17,7 @@ package cn.ysk.cashier.pojo.product; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.ysk.cashier.vo.ProductGroupVo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -220,7 +221,9 @@ public class TbProduct implements Serializable { @Transient @TableField(exist = false) private List> specList; - + @Transient + @TableField(exist = false) + private List proGroupVo; public void copy(TbProduct source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index fe562882..3c05d239 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -3,6 +3,7 @@ package cn.ysk.cashier.service.impl.productimpl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.domain.ViewConSku; import cn.ysk.cashier.cons.repository.ViewConSkuRepository; @@ -14,7 +15,6 @@ import cn.ysk.cashier.dto.product.TbProductSortCriteria; import cn.ysk.cashier.dto.shop.TbCouponCategoryDto; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.product.TbProductMapper; -import cn.ysk.cashier.mapper.product.TbProductSkuMapper; import cn.ysk.cashier.mybatis.entity.TagProductDepts; import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper; import cn.ysk.cashier.mybatis.service.TagProductDeptsService; @@ -764,10 +764,14 @@ public class TbProductServiceImpl implements TbProductService { com.baomidou.mybatisplus.extension.plugins.pagination.Page page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("is_del", 0) - .in("type_enum", "sku", "normal") + .eq(false,"type", "coupon") .eq("shop_id", shopId) .eq("is_delete", 0) .eq("status", 1) + .eq("is_del", 0) + .like("days", DateUtil.dayOfWeekEnum(new Date()).getValue()) + .gt("end_time", System.currentTimeMillis()) + .lt("start_time", System.currentTimeMillis()) .eq("is_pause_sale", 0); // 查询skuResult @@ -783,6 +787,9 @@ public class TbProductServiceImpl implements TbProductService { com.baomidou.mybatisplus.extension.plugins.pagination.Page tbProductPage = productMapper.selectPage(page1, queryWrapper); tbProductPage.getRecords().forEach(item -> { + if("package".equals(item.getType())){ + item.setProGroupVo(JSONUtil.parseJSONStrTList(item.getGroupSnap(), ProductGroupVo.class)); + } TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null); List tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper().eq(TbProductSku::getIsDel, 0) .eq(TbProductSku::getIsPauseSale, 0) From 179e5d2d23e5283a751c44a265939dda9983c145 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 17:28:06 +0800 Subject: [PATCH 020/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../productimpl/TbProductServiceImpl.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 3c05d239..142e8798 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -40,6 +40,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.joda.time.LocalTime; import org.springframework.beans.BeanUtils; import org.springframework.data.domain.*; import org.springframework.stereotype.Service; @@ -473,6 +474,9 @@ public class TbProductServiceImpl implements TbProductService { } //保存到sku_result if ("sku".equals(resources.getTypeEnum())) { + if (StringUtils.isNotBlank(resources.getSkuSnap())) { + resources.setSkuSnap(resources.getSkuSnap().replace("label", "name")); + } TbProductSkuResult productSkuResult = new TbProductSkuResult(); productSkuResult.setCreatedAt(Instant.now().toEpochMilli()); productSkuResult.setUpdatedAt(Instant.now().toEpochMilli()); @@ -527,7 +531,7 @@ public class TbProductServiceImpl implements TbProductService { if (!"coupon".equals(product.getType())) { if (resources.getCategoryId() == null) throw new BadRequestException("商品分类不可为空"); product.setGroupSnap(null); - if (resources.getNotices() != null && resources.getNotices().getId() != null) { + if (resources.getNotices() != null && resources.getNotices().getId() != null && resources.getNotices().getId() > 0) { noticeRepository.deleteById(resources.getNotices().getId()); } } @@ -580,6 +584,9 @@ public class TbProductServiceImpl implements TbProductService { } //保存到sku_result if ("sku".equals(resources.getTypeEnum())) { + if (StringUtils.isNotBlank(resources.getSkuSnap())) { + resources.setSkuSnap(resources.getSkuSnap().replace("label", "name")); + } TbProductSkuResult productSkuResult = new TbProductSkuResult(); productSkuResult.setCreatedAt(Instant.now().toEpochMilli()); productSkuResult.setUpdatedAt(Instant.now().toEpochMilli()); @@ -766,12 +773,11 @@ public class TbProductServiceImpl implements TbProductService { queryWrapper.eq("is_del", 0) .eq(false,"type", "coupon") .eq("shop_id", shopId) - .eq("is_delete", 0) .eq("status", 1) .eq("is_del", 0) - .like("days", DateUtil.dayOfWeekEnum(new Date()).getValue()) - .gt("end_time", System.currentTimeMillis()) - .lt("start_time", System.currentTimeMillis()) + .like("days", "%"+DateUtil.dayOfWeekEnum(new Date()).name()+"%") + .gt("end_time", new LocalTime()) + .lt("start_time", new LocalTime()) .eq("is_pause_sale", 0); // 查询skuResult @@ -871,7 +877,4 @@ public class TbProductServiceImpl implements TbProductService { } } - public static void main(String[] args) { - - } } From 5bef6e19ec5d8b446faad52120e97f09ba264763 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 17:41:45 +0800 Subject: [PATCH 021/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 77ebc5c5..4f09da7d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -775,7 +775,7 @@ public class TbProductServiceImpl implements TbProductService { .eq("shop_id", shopId) .eq("status", 1) .eq("is_del", 0) - .like("days", "%"+DateUtil.dayOfWeekEnum(new Date()).name()+"%") + .like("days", DateUtil.dayOfWeekEnum(new Date()).name()) .gt("end_time", new LocalTime()) .lt("start_time", new LocalTime()) .eq("is_pause_sale", 0); From 8a0551d4907004f5e5e124455eabd7a21f3c3c7c Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 17:54:54 +0800 Subject: [PATCH 022/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/productimpl/TbProductServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 4f09da7d..22453f6d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -776,8 +776,8 @@ public class TbProductServiceImpl implements TbProductService { .eq("status", 1) .eq("is_del", 0) .like("days", DateUtil.dayOfWeekEnum(new Date()).name()) - .gt("end_time", new LocalTime()) - .lt("start_time", new LocalTime()) + .gt("end_time", DateUtil.formatTime(new Date())) + .lt("start_time", DateUtil.formatTime(new Date())) .eq("is_pause_sale", 0); // 查询skuResult From 5e4bb2e71b71559688c2ea68e3044aa17ed7ec6b Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 19 Nov 2024 17:56:16 +0800 Subject: [PATCH 023/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/productimpl/TbProductServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 142e8798..13cd958e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -775,9 +775,9 @@ public class TbProductServiceImpl implements TbProductService { .eq("shop_id", shopId) .eq("status", 1) .eq("is_del", 0) - .like("days", "%"+DateUtil.dayOfWeekEnum(new Date()).name()+"%") - .gt("end_time", new LocalTime()) - .lt("start_time", new LocalTime()) + .like("days", DateUtil.dayOfWeekEnum(new Date()).name()) + .gt("end_time", DateUtil.formatTime(new Date())) + .lt("start_time", DateUtil.formatTime(new Date())) .eq("is_pause_sale", 0); // 查询skuResult From e771493474437cda76750b4fbb432203c83e9b5f Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 10:47:00 +0800 Subject: [PATCH 024/170] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 73a8fe2d..5fef345e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -88,10 +88,6 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "短标题--促销语") private String shortTitle; - @Column(name = "`low_member_price`") - @ApiModelProperty(value = "lowMemberPrice") - private BigDecimal lowMemberPrice; - @Column(name = "`images`") @ApiModelProperty(value = "商品图片(第一张为缩略图,其他为详情)") private String images; From d8177bf3a47ffba17d5f8938b01a4bd0998f1489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 10:47:52 +0800 Subject: [PATCH 025/170] =?UTF-8?q?feat:=20=E5=8D=95=E5=93=81=E6=94=B9?= =?UTF-8?q?=E4=BB=B7=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java | 2 +- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java index 976ce91e..17580c4e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java @@ -49,7 +49,7 @@ public class MpOrderInfoServiceImpl extends ServiceImpl() .eq(TbOrderInfo::getId, orderId) .eq(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue()) - .apply("settlement_amount + {0} >= 0", subtract) + .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)) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 95a5c9c7..240257dc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2902,11 +2902,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("购物车商品不存在"); } - if (updatePriceDTO.getSaleAmount().compareTo(cashierCart.getSalePrice()) == 0) { + if (updatePriceDTO.getSaleAmount().compareTo(cashierCart.getDiscountSaleAmount()) == 0) { return cashierCart; } BigDecimal newTotalPrice = updatePriceDTO.getSaleAmount().multiply(cashierCart.getTotalNumber()).add(cashierCart.getPackFee()); + BigDecimal oldAmount = cashierCart.getTotalAmount(); cashierCart.setTotalAmount(newTotalPrice); cashierCart.setUpdatedAt(DateUtil.current()); cashierCart.setDiscountSaleNote(updatePriceDTO.getNote()); @@ -2916,7 +2917,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 更新订单和detail价格 if (cashierCart.getOrderId() != null) { mpOrderDetailService.updatePriceByCartId(cashierCart.getId(), updatePriceDTO.getSaleAmount(), newTotalPrice); - mpOrderInfoService.incrAmount(cashierCart.getOrderId(), newTotalPrice.subtract(cashierCart.getTotalAmount())); + mpOrderInfoService.incrAmount(cashierCart.getOrderId(), newTotalPrice.subtract(oldAmount)); } return cashierCart; } From af8934dcba66057926501bc7284d7a9a7eef16e4 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 14:20:33 +0800 Subject: [PATCH 026/170] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 22453f6d..9ac7908b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -219,7 +219,7 @@ public class TbProductServiceImpl implements TbProductService { tbProductVo.setRealSalesNumber(0.00); } else { for (Object[] o : objects) { - if (((Integer) o[1]).equals(product.getId())) { + if (o[1] != null && ((Integer) o[1]).equals(product.getId())) { if (o[0] != null) { BigDecimal bigDecimal = (BigDecimal) o[0]; tbProductVo.setRealSalesNumber(bigDecimal.doubleValue()); From 19b78079a447721cfeeefdda41e93e552618d9a7 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 14:46:55 +0800 Subject: [PATCH 027/170] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 9ac7908b..47fbed60 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -219,7 +219,7 @@ public class TbProductServiceImpl implements TbProductService { tbProductVo.setRealSalesNumber(0.00); } else { for (Object[] o : objects) { - if (o[1] != null && ((Integer) o[1]).equals(product.getId())) { + if (o[1] != null && (o[1]).equals(product.getId())) { if (o[0] != null) { BigDecimal bigDecimal = (BigDecimal) o[0]; tbProductVo.setRealSalesNumber(bigDecimal.doubleValue()); From 118404ecbea8c8002631db63bdfb4e283729a3b0 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 15:44:23 +0800 Subject: [PATCH 028/170] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java index 087f44d5..c3724166 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java @@ -4,6 +4,7 @@ import java.util.Date; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serializable; @@ -43,10 +44,11 @@ public class TbShopShareRecord extends Model { //0 非新用户 1 未领取 2 已领取 3 已使用 private Integer status; //生效时间/获得奖励的时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date rewardTime; - + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; - + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime; From 105671347ab023df6de3f8a15619f121b63e50b8 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 16:04:30 +0800 Subject: [PATCH 029/170] =?UTF-8?q?=E7=BB=91=E5=AE=9A=20=E5=BC=80=E7=A5=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/TbShopInfoController.java | 8 ++++- .../java/cn/ysk/cashier/dto/BindingDto.java | 9 +++++ .../cashier/pojo/shop/TbMerchantAccount.java | 4 +++ .../impl/shopimpl/TbShopInfoServiceImpl.java | 35 +++++++++++++++++++ .../service/shop/TbShopInfoService.java | 9 +++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index cf037124..38e1aec4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -4,6 +4,7 @@ import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.service.OnlineUserService; +import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.pojo.shop.TbShopInfo; @@ -36,7 +37,12 @@ public class TbShopInfoController { private final TbShopInfoService tbShopInfoService; private final OnlineUserService onlineUserService; private final TokenProvider tokenProvider; - + @PostMapping("binding") + @AnonymousPostMapping("binding") + @ApiOperation("绑定开票信息") + public ResponseEntity binding(@RequestBody BindingDto bindingDto){ + return new ResponseEntity<>(tbShopInfoService.binding(bindingDto), HttpStatus.OK); + } // @Log("导出数据") // @ApiOperation("导出数据") // @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java new file mode 100644 index 00000000..74d481b8 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java @@ -0,0 +1,9 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +@Data +public class BindingDto { + private Integer shopId; + private String account; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java index 83b4a4b5..e36d3dc4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java @@ -131,6 +131,10 @@ public class TbMerchantAccount implements Serializable { @ApiModelProperty(value = "操作密码") private String pwd; + @Column(name = "`bind_account`") + @ApiModelProperty(value = "开票系统账号") + private String bindAccount; + public void copy(TbMerchantAccount source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index d7277038..d9ad7880 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -3,8 +3,10 @@ package cn.ysk.cashier.service.impl.shopimpl; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; +import cn.hutool.http.HttpUtil; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.service.UserCacheManager; +import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; @@ -28,6 +30,7 @@ import cn.ysk.cashier.system.repository.UserRepository; import cn.ysk.cashier.system.service.ParamsService; import cn.ysk.cashier.system.service.UserService; import cn.ysk.cashier.utils.*; +import com.alibaba.fastjson.JSONObject; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; @@ -86,6 +89,38 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private final TbShopPayTypeRepository tbShopPayTypeRepository; private final WxService wxService; + @Override + public JSONObject binding(BindingDto bindingDto) { +// TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); +// TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount()); +// if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) { +// if (tbShopInfo != null) { +// if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) { +// bindingDto.setAccount(account.getBindAccount()); +// } else { +// return null; +// } +// } +// } + Map param = new HashMap<>(); + //超掌柜生活-用户端 + param.put("account", bindingDto.getAccount()); + String result = HttpUtil.post("http://test.invoice.sxczgkj.cn/api/cash/binding", param, 5000); + + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + JSONObject data = jsonObject.getJSONObject("data"); +// if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) { +// String bindAccount = data.getJSONObject("store").getString("account"); +// account.setBindAccount(bindAccount); +// merchantAccountRepository.save(account); +// } + return data; + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + @Override public Map queryAll(TbShopInfoQueryCriteria criteria){ Sort sort = Sort.by(Sort.Direction.DESC, "id"); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java index a45d6309..07a587a6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java @@ -15,9 +15,11 @@ */ package cn.ysk.cashier.service.shop; +import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; +import com.alibaba.fastjson.JSONObject; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; @@ -32,6 +34,13 @@ import javax.servlet.http.HttpServletResponse; **/ public interface TbShopInfoService { + /** + * 绑定开票信息 + * @param bindingDto + * @return + */ + JSONObject binding(BindingDto bindingDto); + /** * 查询数据分页 * @param criteria 条件 From f3cac2b5d53ffd0e038570120857f680ba0f3deb Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 16:19:46 +0800 Subject: [PATCH 030/170] =?UTF-8?q?=E7=BB=91=E5=AE=9A=20=E5=BC=80=E7=A5=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopShareController.java | 1 - .../impl/shopimpl/TbShopInfoServiceImpl.java | 32 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java index 40ffba36..e3d707e2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java @@ -36,7 +36,6 @@ public class TbShopShareController { private TbShopShareRecordService tbShopShareRecordService; @PostMapping("byShare") - @AnonymousPostMapping @ApiOperation("分页查询") public ResponseEntity selectAllByShare(@RequestBody TbShopShareRecordQueryCriteria criteria) { return new ResponseEntity<>(tbShopShareRecordService.selectAllByShare(criteria), HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index d9ad7880..ce0e2ce1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -91,17 +91,17 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override public JSONObject binding(BindingDto bindingDto) { -// TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); -// TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount()); -// if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) { -// if (tbShopInfo != null) { -// if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) { -// bindingDto.setAccount(account.getBindAccount()); -// } else { -// return null; -// } -// } -// } + TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); + TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount()); + if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) { + if (tbShopInfo != null) { + if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) { + bindingDto.setAccount(account.getBindAccount()); + } else { + return null; + } + } + } Map param = new HashMap<>(); //超掌柜生活-用户端 param.put("account", bindingDto.getAccount()); @@ -110,11 +110,11 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { JSONObject jsonObject = JSONObject.parseObject(result); if (jsonObject.getInteger("code").equals(1)) { JSONObject data = jsonObject.getJSONObject("data"); -// if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) { -// String bindAccount = data.getJSONObject("store").getString("account"); -// account.setBindAccount(bindAccount); -// merchantAccountRepository.save(account); -// } + if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) { + String bindAccount = data.getJSONObject("store").getString("account"); + account.setBindAccount(bindAccount); + merchantAccountRepository.save(account); + } return data; } else { throw new BadRequestException(jsonObject.getString("msg")); From 66af437db6506e44b0c7cddafe43c8990252afc6 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 20 Nov 2024 16:25:44 +0800 Subject: [PATCH 031/170] =?UTF-8?q?=E5=88=86=E4=BA=AB=20=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java index c3724166..40dc708b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java @@ -44,12 +44,9 @@ public class TbShopShareRecord extends Model { //0 非新用户 1 未领取 2 已领取 3 已使用 private Integer status; //生效时间/获得奖励的时间 - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date rewardTime; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date createTime; - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date updateTime; + private String rewardTime; + private String createTime; + private String updateTime; } From 6786006ed172208ec14dd6417dceb95e0faca64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 16:50:12 +0800 Subject: [PATCH 032/170] =?UTF-8?q?feat:=201.=E7=BE=8E=E5=9B=A2=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E5=88=B8=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=202.?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=94=AF=E6=8C=81=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E9=80=80=E6=AC=BE=EF=BC=8C=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThirdPartyCouponController.java | 31 +++++ .../cashier/dto/shoptable/UpdateCartDTO.java | 2 + .../ysk/cashier/pojo/order/TbCashierCart.java | 4 + .../ysk/cashier/pojo/order/TbOrderDetail.java | 5 +- .../cn/ysk/cashier/resp/PhpCommonResp.java | 11 ++ .../service/ThirdPartyCouponService.java | 9 ++ .../impl/ThirdPartyCouponServiceImpl.java | 38 ++++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 116 ++++++++++++++---- 8 files changed, 192 insertions(+), 24 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java new file mode 100644 index 00000000..a7579669 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java @@ -0,0 +1,31 @@ +package cn.ysk.cashier.controller; + +import cn.ysk.cashier.service.ThirdPartyCouponService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 三方团购券 + */ +@RestController +@RequestMapping("/api/thirdPartyCoupon") +public class ThirdPartyCouponController { + + private final ThirdPartyCouponService thirdPartyCouponService; + + public ThirdPartyCouponController(ThirdPartyCouponService thirdPartyCouponService) { + this.thirdPartyCouponService = thirdPartyCouponService; + } + + /** + * 获取美团绑定链接 + * @return 美团绑定链接 + */ + @GetMapping + public ResponseEntity getBindUrl() { + return ResponseEntity.ok(thirdPartyCouponService.getBindUrl()); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index 97b094c0..b7db4dfd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -22,5 +22,7 @@ public class UpdateCartDTO { private String note; private Boolean isPack; private Boolean isGift; + // 是否打印 + private Boolean isPrint; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 56264e2f..905e6d15 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -15,6 +15,7 @@ */ package cn.ysk.cashier.pojo.order; +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -173,6 +174,8 @@ public class TbCashierCart implements Serializable { private String unit; private BigDecimal discountSaleAmount; private String discountSaleNote; + private Boolean isPrint; + private String useCouponInfo; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); @@ -211,4 +214,5 @@ public class TbCashierCart implements Serializable { } } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index fa7c253c..dad7060d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -15,6 +15,7 @@ */ package cn.ysk.cashier.pojo.order; +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import cn.hutool.core.bean.BeanUtil; @@ -133,9 +134,11 @@ public class TbOrderDetail implements Serializable { private Integer isMember; private Integer isTemporary; private String discountSaleNote; - + private Boolean isPrint; + private String useCouponInfo; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java b/eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java new file mode 100644 index 00000000..afe66147 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java @@ -0,0 +1,11 @@ +package cn.ysk.cashier.resp; + +import lombok.Data; + +@Data +public class PhpCommonResp { + private String code; + private String msg; + private long time; + private T data; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java new file mode 100644 index 00000000..9fc82d46 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java @@ -0,0 +1,9 @@ +package cn.ysk.cashier.service; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +public interface ThirdPartyCouponService { + + String getBindUrl(); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java new file mode 100644 index 00000000..50f50a69 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java @@ -0,0 +1,38 @@ +package cn.ysk.cashier.service.impl; + +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.resp.PhpCommonResp; +import cn.ysk.cashier.service.ThirdPartyCouponService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService { + + @Value("${phpServer}") + private String phpServerUrl; + + public ThirdPartyCouponServiceImpl(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + private final RestTemplate restTemplate; + + private T getData(String url, Object data) { + PhpCommonResp resp = restTemplate.getForEntity(phpServerUrl + url, PhpCommonResp.class).getBody(); + if (resp == null) { + throw new BadRequestException("请求php服务器失败"); + } + + if (!"1".equals(resp.getCode())) { + throw new BadRequestException(resp.getMsg()); + } + + return (T) resp.getData(); + } + + @Override + public String getBindUrl() { + return getData("/meituan/getuisdkurl", null); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 632c3cc5..5bdc5a10 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.service.impl.shopimpl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.thread.ThreadUtil; @@ -454,6 +455,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setSalePrice(tbCashierCart.getSalePrice()); tbCashierCart.setTotalAmount(updateCartDTO.getNum().multiply(tbCashierCart.getSalePrice())); tbCashierCart.setNote(updateCartDTO.getNote()); + tbCashierCart.setIsPrint(updateCartDTO.getIsPrint()); if (updateCartDTO.getIsPack() != null) { if (!updateCartDTO.getIsPack()) { @@ -1308,13 +1310,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 创建结余购物车 balanceCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class); - BigDecimal num = balanceNum; balanceCart.setUserCouponId(null); balanceCart.setId(null); balanceCart.setNumber(balanceNum); balanceCart.setTotalNumber(balanceNum); - balanceCart.setPackFee(singlePackFee.multiply(num)); - balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum).add(singlePackFee.multiply(num))); + balanceCart.setPackFee(singlePackFee.multiply(balanceNum)); + balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum).add(singlePackFee.multiply(balanceNum))); balanceCartList.add(balanceCart); } else { currentUseNum =cashierCart.getNumber(); @@ -1334,6 +1335,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbActivateOutRecord.setCreateTime(DateUtil.date()); tbActivateOutRecord.setRefNum(0); outRecords.add(tbActivateOutRecord); + cashierCart.setUseCouponInfo(JSONObject.toJSONString(tbActivateOutRecord)); couponVo.setFinalDiscountAmount(discountAmount); // 优惠券未消耗完毕 @@ -1526,6 +1528,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } + /** * 根据商品优惠券 * @@ -1609,6 +1612,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setIsTemporary(cashierCart.getIsTemporary()); orderDetail.setOrderId(orderInfo == null ? null : orderInfo.getId()); orderDetail.setIsMember(cashierCart.getIsMember()); + orderDetail.setIsPrint(cashierCart.getIsPrint()); + orderDetail.setUseCouponInfo(cashierCart.getUseCouponInfo()); + priceDTO.getOrderDetailList().add(orderDetail); } return priceDTO; @@ -2138,6 +2144,34 @@ public class TbShopTableServiceImpl implements TbShopTableService { return orderInfo.getOrderAmount(); } + /** + * 根据折扣设置订单信息 + */ + private BigDecimal resetAmountByDiscount(PayDTO payDTO, TbOrderInfo orderInfo) { + List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); + List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); + BigDecimal discount = BigDecimal.valueOf(payDTO.getDiscount()); + cashierCarts.forEach(item -> { + item.setTotalAmount(item.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + }); + + detailList.forEach(item -> { + item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + }); + + mpCashierCartService.updateBatchById(cashierCarts); + mpOrderDetailService.updateBatchById(detailList); + BigDecimal oldAmount = orderInfo.getOrderAmount(); + BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + BigDecimal discountAmount = oldAmount.subtract(finalAmount); + orderInfo.setDiscountAmount(discountAmount); + orderInfo.setOrderAmount(finalAmount); + orderInfo.setAmount(finalAmount); + orderInfo.setSettlementAmount(finalAmount); + mpOrderInfoService.updateById(orderInfo); + return finalAmount; + } + @Override // @Transactional public Object pay(PayDTO payDTO) { @@ -2157,8 +2191,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { payDTO.setVipUserId(orderInfo.getMemberId() != null ? Integer.valueOf(orderInfo.getMemberId()) : null); } - - if (ObjectUtil.isEmpty(orderInfo)) { throw new BadRequestException("订单不存在"); } @@ -2172,17 +2204,20 @@ public class TbShopTableServiceImpl implements TbShopTableService { payDTO.setDiscount((double) 1); } - // 计算优惠券积分折扣信息 BigDecimal finalAmount = null; + // 计算订单折扣信息 + if (payDTO.getDiscount() != 1) { + finalAmount = resetAmountByDiscount(payDTO, orderInfo); + }else { + finalAmount = orderInfo.getOrderAmount(); + } + + // 计算优惠券积分折扣信息 if (payDTO.getVipUserId() != null) { // 计算商品券折扣 finalAmount = calcDiscountAndUpdateInfo(payDTO, orderInfo); } - if (finalAmount == null) { - finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); - } - boolean isOnline = false; switch (payDTO.getPayType()) { @@ -2671,15 +2706,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("订单明细数量不一致"); } + HashMap data = new HashMap<>(); BigDecimal returnAmount = BigDecimal.ZERO; BigDecimal packAMount = BigDecimal.ZERO; BigDecimal saleAmount = BigDecimal.ZERO; ArrayList remainOrderDetailList = new ArrayList<>(); for (TbOrderDetail orderDetail : detailList) { - if (orderDetail.getUserCouponId() != null) { - throw new BadRequestException("选择了优惠券抵扣商品,无法退款"); - } + // 退款数量 BigDecimal returnNum = returnNumMap.get(orderDetail.getId().toString()); + // 剩余数量 BigDecimal remainNum = orderDetail.getNum().subtract(returnNum); if (remainNum.compareTo(BigDecimal.ZERO) < 0) { throw new BadRequestException("{}最多可退数量为: {}", orderDetail.getProductName(), orderDetail.getNum()); @@ -2700,14 +2735,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { remainOrderDetailList.add(remainOrderDetail); } - returnAmount = returnAmount.add(orderDetail.getPriceAmount() - .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) - .multiply(returnNum)); - saleAmount = saleAmount.add(orderDetail.getPrice()); - packAMount = packAMount.add(orderDetail.getPackAmount() - .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) - .multiply(returnNum)); - BigDecimal returnPackFee = packFee.multiply(returnNum); orderDetail.setNum(returnNum); orderDetail.setPriceAmount(returnNum.multiply(orderDetail.getPrice()) @@ -2716,6 +2743,34 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setRefundNumber(returnNum); // orderDetail.setStatus(isOnline ? "refunding" : "refund"); orderDetail.setStatus("refund"); + // 优惠券抵扣商品直接退券 + 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)); + // 使用了满减或积分,获取普通付款商品计算退款比例,退部分现金 + }else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ + // 计算当前商品占比 + BigDecimal ratio = calcDetailRatio(orderDetail); + BigDecimal realAmount = orderDetail.getPriceAmount().multiply(ratio); + returnAmount = returnAmount.add(realAmount + .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) + .multiply(returnNum)); + saleAmount = saleAmount.add(orderDetail.getPrice()); + packAMount = packAMount.add(orderDetail.getPackAmount() + .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) + .multiply(returnNum)); + + }else { + returnAmount = returnAmount.add(orderDetail.getPriceAmount() + .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) + .multiply(returnNum)); + saleAmount = saleAmount.add(orderDetail.getPrice()); + packAMount = packAMount.add(orderDetail.getPackAmount() + .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) + .multiply(returnNum)); + } } if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) { @@ -2757,12 +2812,23 @@ public class TbShopTableServiceImpl implements TbShopTableService { updateStockAndRecord(detailList); mpOrderDetailService.updateBatchById(detailList); - HashMap data = new HashMap<>(); data.put("returnOrder", returnOrder); data.put("returnAmount", returnAmount); return data; } + private BigDecimal calcDetailRatio(TbOrderDetail orderDetail) { + List detailList = mpOrderDetailService.selectByOrderIdAndState(orderDetail.getId(), TableConstant.OrderInfo.Status.CLOSED); + BigDecimal totalAmount = BigDecimal.ZERO; + for (TbOrderDetail item : detailList) { + if (item.getUserCouponId() == null) { + totalAmount = totalAmount.add(item.getPriceAmount()); + } + } + + return orderDetail.getPriceAmount().divide(totalAmount, 2, RoundingMode.HALF_UP); + } + private void updateStockAndRecord(List orderDetailList) { // 更新商品库存 for (TbOrderDetail detail : orderDetailList) { @@ -2826,7 +2892,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { String shopId = orderInfo.getShopId(); // // 线上退款 - orderInfo.setRefundAmount(returnOrderInfo.getRefundAmount()); + orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(returnOrderInfo.getRefundAmount())); orderInfo.setRefundRemark(returnOrderDTO.getNote()); if ("scanCode".equals(payType) || "wx_lite".equals(payType)) { payService.returnOrder(Integer.valueOf(shopId), orderInfo, returnOrderInfo); @@ -2842,6 +2908,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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) { + returnCoupon(orderInfo); + } orderInfoMapper.updateById(orderInfo); // 打印退款小票 // producer.printMechine(newOrderInfo.getId().toString()); From 8b74c09559f70efff3aef58f1d7875e01d92b4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 16:53:30 +0800 Subject: [PATCH 033/170] =?UTF-8?q?feat:=201.=E7=BE=8E=E5=9B=A2=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E5=88=B8=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=202.?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=94=AF=E6=8C=81=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E9=80=80=E6=AC=BE=EF=BC=8C=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eladmin-system/src/main/resources/config/application.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index debc3e04..415edd2e 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -107,3 +107,6 @@ gateway: client: backUrl: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay + +# php服务器地址 +phpServer: https://czgdoumei.sxczgkj.com/index.php/api From 8a7c9d8e2e2c9848109154950d39969248d68083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 17:33:51 +0800 Subject: [PATCH 034/170] =?UTF-8?q?feat:=201.=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 5bdc5a10..6f98aac9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2736,41 +2736,46 @@ public class TbShopTableServiceImpl implements TbShopTableService { } BigDecimal returnPackFee = packFee.multiply(returnNum); - orderDetail.setNum(returnNum); - orderDetail.setPriceAmount(returnNum.multiply(orderDetail.getPrice()) - .add(returnPackFee)); - orderDetail.setPackAmount(returnPackFee); - orderDetail.setRefundNumber(returnNum); -// orderDetail.setStatus(isOnline ? "refunding" : "refund"); - orderDetail.setStatus("refund"); + 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); // 使用了满减或积分,获取普通付款商品计算退款比例,退部分现金 }else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ // 计算当前商品占比 BigDecimal ratio = calcDetailRatio(orderDetail); BigDecimal realAmount = orderDetail.getPriceAmount().multiply(ratio); - returnAmount = returnAmount.add(realAmount - .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) - .multiply(returnNum)); + currentDetailAMount = realAmount + .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) + .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); + returnAmount = returnAmount.add(currentDetailAMount); saleAmount = saleAmount.add(orderDetail.getPrice()); packAMount = packAMount.add(orderDetail.getPackAmount() - .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) - .multiply(returnNum)); + .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) + .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); }else { - returnAmount = returnAmount.add(orderDetail.getPriceAmount() - .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) - .multiply(returnNum)); + currentDetailAMount = orderDetail.getPriceAmount() + .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) + .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); + returnAmount = returnAmount.add(currentDetailAMount); saleAmount = saleAmount.add(orderDetail.getPrice()); packAMount = packAMount.add(orderDetail.getPackAmount() - .divide(orderDetail.getNum(), 2, RoundingMode.DOWN) - .multiply(returnNum)); + .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) + .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); } + + orderDetail.setNum(returnNum); + orderDetail.setPriceAmount(currentDetailAMount); + orderDetail.setPackAmount(returnPackFee); + orderDetail.setRefundNumber(returnNum); +// orderDetail.setStatus(isOnline ? "refunding" : "refund"); + orderDetail.setStatus("refund"); } if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) { From 8894d4797ef7b3f0f0b17b68377324833a026b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 17:40:37 +0800 Subject: [PATCH 035/170] =?UTF-8?q?feat:=201.=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java index 5f98c1ff..3ce0a45a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java @@ -182,7 +182,7 @@ public class PayServiceImpl implements PayService { //修改主单状态 orderInfo.setStatus("closed"); orderInfo.setPayOrderNo(payment.getTradeNumber()); - orderInfo.setPayAmount(orderInfo.getOrderAmount()); +// orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPaidTime(System.currentTimeMillis()); tbOrderInfoMapper.updateById(orderInfo); From f4f074f07572a1c49b4982ddeae697767b395ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 17:48:13 +0800 Subject: [PATCH 036/170] =?UTF-8?q?feat:=201.=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java index 3ce0a45a..6ee20bf1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/PayServiceImpl.java @@ -176,7 +176,7 @@ public class PayServiceImpl implements PayService { .eq(TbOrderDetail::getOrderId, orderInfo.getId()) .eq(TbOrderDetail::getUseType, orderInfo.getUseType()) .in(TbOrderDetail::getStatus, "unpaid") - .setSql(StrUtil.format("price_amount=price*num*{}", orderInfo.getDiscountRatio() == null ? 1 : orderInfo.getDiscountRatio())) +// .setSql(StrUtil.format("price_amount=price*num*{}", orderInfo.getDiscountRatio() == null ? 1 : orderInfo.getDiscountRatio())) .set(TbOrderDetail::getStatus, "closed")); //修改主单状态 From 0d81ab7f47435cca8abb212594227b445c2bff96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 17:53:36 +0800 Subject: [PATCH 037/170] =?UTF-8?q?feat:=201.=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 6f98aac9..d945816a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2727,8 +2727,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal remainPackFee = packFee.multiply(remainNum); TbOrderDetail remainOrderDetail = BeanUtil.copyProperties(orderDetail, TbOrderDetail.class); remainOrderDetail.setNum(remainNum); - remainOrderDetail.setPriceAmount(remainNum.multiply(orderDetail.getPrice()) - .add(remainPackFee)); + remainOrderDetail.setPriceAmount(remainNum.multiply(orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)) + .add(remainPackFee).setScale(2, RoundingMode.HALF_UP)); remainOrderDetail.setPackAmount(remainPackFee); remainOrderDetail.setReturnNum("0"); remainOrderDetail.setId(null); From 515759f05f3534c9d552a342a7a7295303ab7550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 20 Nov 2024 17:59:08 +0800 Subject: [PATCH 038/170] =?UTF-8?q?feat:=201.=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index d945816a..75d6fa31 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2153,10 +2153,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal discount = BigDecimal.valueOf(payDTO.getDiscount()); cashierCarts.forEach(item -> { item.setTotalAmount(item.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + }); detailList.forEach(item -> { item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + item.setPrice(item.getPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); }); mpCashierCartService.updateBatchById(cashierCarts); From a15eafdb5764e68a39efb84f7d1617d974fc1ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 09:17:09 +0800 Subject: [PATCH 039/170] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=86=E5=89=B2detail=E7=8A=B6=E6=80=81=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 75d6fa31..d0f7c11f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -581,12 +581,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); -// tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setMemberPrice(productSku.getMemberPrice()); cashierCartRepository.save(tbCashierCart); } else { - tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); + tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice())); @@ -1578,6 +1578,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (orderDetail == null) { orderDetail = new TbOrderDetail(); + orderDetail.setStatus(TableConstant.CashierCart.Status.RETURN.equalsVals(cashierCart.getStatus()) ? cashierCart.getStatus() : "unpaid"); priceDTO.setHasNewInfo(true); priceDTO.getNewOrderDetailList().add(orderDetail); } @@ -2706,7 +2707,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId()) .eq(TbOrderDetail::getStatus, "closed") .eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId()) - .in(TbOrderDetail::getId, detailIds)); + .in(TbOrderDetail::getId, detailIds) + .orderByDesc(TbOrderDetail::getUserCouponId)); if (detailList.size() != returnOrderDTO.getOrderDetails().size()) { throw new BadRequestException("订单明细数量不一致"); } From 425a3a3f37238a9c5872a67e55b958b9bc236faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 09:25:12 +0800 Subject: [PATCH 040/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index d0f7c11f..1426a4ed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2718,6 +2718,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal packAMount = BigDecimal.ZERO; BigDecimal saleAmount = BigDecimal.ZERO; ArrayList remainOrderDetailList = new ArrayList<>(); + boolean hasNormalReturn = false; for (TbOrderDetail orderDetail : detailList) { // 退款数量 BigDecimal returnNum = returnNumMap.get(orderDetail.getId().toString()); @@ -2754,6 +2755,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { .add(returnPackFee); // 使用了满减或积分,获取普通付款商品计算退款比例,退部分现金 }else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ + hasNormalReturn = true; // 计算当前商品占比 BigDecimal ratio = calcDetailRatio(orderDetail); BigDecimal realAmount = orderDetail.getPriceAmount().multiply(ratio); @@ -2767,6 +2769,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); }else { + hasNormalReturn = true; currentDetailAMount = orderDetail.getPriceAmount() .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); @@ -2785,7 +2788,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setStatus("refund"); } - if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) { + if (hasNormalReturn && returnAmount.compareTo(BigDecimal.ZERO) <= 0) { throw new BadRequestException("退款金额必须大于0"); } From 5364eec11c127a27058a8564f131af160e3ed77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 09:54:52 +0800 Subject: [PATCH 041/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/dto/OrderInfoCouponInfoDTO.java | 16 ++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 79 ++++++++++++++++--- .../ysk/cashier/vo/OrderInfoUserCouponVo.java | 10 +++ 3 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/OrderInfoCouponInfoDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/vo/OrderInfoUserCouponVo.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/OrderInfoCouponInfoDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/OrderInfoCouponInfoDTO.java new file mode 100644 index 00000000..264ff4bb --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/OrderInfoCouponInfoDTO.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.dto; + +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; +import cn.ysk.cashier.vo.OrderInfoUserCouponVo; +import cn.ysk.cashier.vo.TbUserCouponVo; +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/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 1426a4ed..7a6d097a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -13,6 +13,7 @@ import cn.ysk.cashier.cons.RedisConstant; import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.cons.rabbit.RabbitConstants; import cn.ysk.cashier.dto.CouponDto; +import cn.ysk.cashier.dto.OrderInfoCouponInfoDTO; import cn.ysk.cashier.dto.order.OrderCartInfoDTO; import cn.ysk.cashier.dto.order.OrderCouponInfoDTO; import cn.ysk.cashier.dto.order.OrderPriceDTO; @@ -47,6 +48,7 @@ import cn.ysk.cashier.service.order.TbOrderInfoService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.*; import cn.ysk.cashier.vo.ActivateInInfoVO; +import cn.ysk.cashier.vo.OrderInfoUserCouponVo; import cn.ysk.cashier.vo.PendingCountVO; import cn.ysk.cashier.vo.TbUserCouponVo; import com.alibaba.fastjson.JSONObject; @@ -1511,18 +1513,30 @@ public class TbShopTableServiceImpl implements TbShopTableService { } } - private void returnCoupon(TbOrderInfo orderInfo) { + private void returnCoupon(TbOrderInfo orderInfo, boolean resetInfo) { // 返还优惠券 if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) { - OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderCouponInfoDTO.class); + 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 -> { - item.setRefNum(item.getUseNum()); + if (!couponIds.contains(item.getGiveId())) { + item.setRefNum(item.getUseNum()); + finalReturnList.add(item); + } }); - shopCouponService.refund(couponInfoDTO.getOutRecordList()); - couponInfoDTO.setOutRecordList(new ArrayList<>()); - orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO)); + shopCouponService.refund(finalReturnList); + if (resetInfo) { + couponInfoDTO.setOutRecordList(new ArrayList<>()); + orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO)); + } } } @@ -2091,7 +2105,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { private BigDecimal calcDiscountAndUpdateInfo(PayDTO payDTO, TbOrderInfo orderInfo) { // 返还上次使用的券 - returnCoupon(orderInfo); + returnCoupon(orderInfo, true); + Set productIdSet = new HashSet<>(); List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); @@ -2133,11 +2148,21 @@ public class TbShopTableServiceImpl implements TbShopTableService { consumeCoupon(couponInfo.getOutRecordList(), payDTO.getVipUserId(), orderInfo); couponInfo.setProductCouponMap(BeanUtil.copyProperties(couponInfo.getProductCouponMap(), HashMap.class)); - HashMap map = new HashMap<>(); - map.put("outRecordList", couponInfo.getOutRecordList()); - map.put("fullReductionCoupon", couponInfo.getFullReductionCouponMap().values()); - map.put("productCoupon", couponInfo.getProductCouponMap().values()); - orderInfo.setCouponInfoList(JSONObject.toJSONString(map)); + OrderInfoCouponInfoDTO infoDTO = new OrderInfoCouponInfoDTO(); + infoDTO.setOutRecordList(couponInfo.getOutRecordList()); + + ArrayList productArr = new ArrayList<>(); + couponInfo.getProductCouponMap().values().forEach(item -> { + BeanUtil.copyProperties(item, OrderInfoUserCouponVo.class); + }); + infoDTO.setProductCoupon(productArr); + + ArrayList fullArr = new ArrayList<>(); + couponInfo.getFullReductionCouponMap().values().forEach(item -> { + BeanUtil.copyProperties(item, OrderInfoUserCouponVo.class); + }); + infoDTO.setFullReductionCoupon(fullArr); + orderInfo.setCouponInfoList(JSONObject.toJSONString(infoDTO)); // orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfo)); // 修改订单detail @@ -2697,6 +2722,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { } 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 -> { @@ -2753,6 +2783,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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()); + } + }); + // 使用了满减或积分,获取普通付款商品计算退款比例,退部分现金 }else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ hasNormalReturn = true; @@ -2792,6 +2829,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("退款金额必须大于0"); } + oldOrderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO)); + // 保存剩余未退款的订单详情 if (!remainOrderDetailList.isEmpty()) { mpOrderDetailService.saveBatch(remainOrderDetailList); @@ -2923,9 +2962,23 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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) { - returnCoupon(orderInfo); + String couponInfoList = orderInfo.getCouponInfoList(); + if (StrUtil.isNotBlank(couponInfoList)) { + OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class); + int remainNum = 0; + for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { + if (item.getFinalUseNum() > item.getReturnNum()) { + remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); + } + } + + if (remainNum == 0) { + returnCoupon(orderInfo, true); + } + } } orderInfoMapper.updateById(orderInfo); // 打印退款小票 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/OrderInfoUserCouponVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/OrderInfoUserCouponVo.java new file mode 100644 index 00000000..bc4c4c40 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/OrderInfoUserCouponVo.java @@ -0,0 +1,10 @@ +package cn.ysk.cashier.vo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class OrderInfoUserCouponVo extends TbUserCouponVo{ + private int returnNum = 0; +} From 610b0f327b2499fa167f7a01cf7d73f2731519d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 09:57:00 +0800 Subject: [PATCH 042/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 7a6d097a..427f4bc1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2977,6 +2977,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (remainNum == 0) { returnCoupon(orderInfo, true); + // 返还积分 + memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), + "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + } } } From 667151fefbf75cc7e87688e2ca57d07bdc11d793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 10:23:20 +0800 Subject: [PATCH 043/170] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 427f4bc1..bcaa957f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1488,6 +1488,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { ArrayList cartIdList = new ArrayList<>(); // 订单总价 for (TbCashierCart tbCashierCart : cartInfoDTO.getCashierCarts()) { + if (shopUser != null) { + tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : shopUser.getIsVip() == 1 ? 0 : 1); + } + tbCashierCart.resetTotalAmount(); + if (tbCashierCart.getOrderId() != null) { cartInfoDTO.setOrderId(tbCashierCart.getOrderId()); } @@ -1495,10 +1500,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (TableConstant.CashierCart.Status.CREATE.equalsVals(tbCashierCart.getStatus())) { cartInfoDTO.setNewAddTotalAmount(cartInfoDTO.getNewAddTotalAmount().add(tbCashierCart.getTotalAmount())); } - if (shopUser != null) { - tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && tbCashierCart.getMemberPrice() == null && shopUser.getIsVip() == 1 ? 0 : 1); - } - tbCashierCart.resetTotalAmount(); cartInfoDTO.setTotalAmount(cartInfoDTO.getTotalAmount().add(tbCashierCart.getTotalAmount())); } @@ -2433,8 +2434,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { .set(TbOrderInfo::getUserId, null) .set(TbOrderInfo::getMemberId, null)); } - if (dto != null) { + dto.setVipUserId(updateVipDTO.getVipUserId()); return createOrder(dto, true); } return "哈哈哈"; From 97e2b91364da87d3ae1532aeb66c078151bdc61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 10:34:15 +0800 Subject: [PATCH 044/170] =?UTF-8?q?fix:=20=E6=94=AF=E4=BB=98=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E4=BC=98=E6=83=A0=E5=88=B8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index bcaa957f..da2a29e6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2154,13 +2154,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { ArrayList productArr = new ArrayList<>(); couponInfo.getProductCouponMap().values().forEach(item -> { - BeanUtil.copyProperties(item, OrderInfoUserCouponVo.class); + productArr.add(BeanUtil.copyProperties(item, OrderInfoUserCouponVo.class)); }); infoDTO.setProductCoupon(productArr); ArrayList fullArr = new ArrayList<>(); couponInfo.getFullReductionCouponMap().values().forEach(item -> { - BeanUtil.copyProperties(item, OrderInfoUserCouponVo.class); + fullArr.add(BeanUtil.copyProperties(item, OrderInfoUserCouponVo.class)); }); infoDTO.setFullReductionCoupon(fullArr); orderInfo.setCouponInfoList(JSONObject.toJSONString(infoDTO)); From 2d36aa4d9b3e6b6abaf131cc9cfb3461e5e14060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 11:24:01 +0800 Subject: [PATCH 045/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=AF=94=E4=BE=8B=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/MpOrderDetailService.java | 2 +- .../impl/MpOrderDetailServiceImpl.java | 12 ++++++++---- .../impl/shopimpl/TbShopTableServiceImpl.java | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java index 6083494f..01baf902 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java @@ -47,7 +47,7 @@ public interface MpOrderDetailService extends IService { /** * 根据订单id和状态获取订单详情 */ - List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state); + List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... states); /** * 根据购物车id和订单id查询订单详情 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java index d6010748..0e49896a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; @@ -50,10 +51,13 @@ public class MpOrderDetailServiceImpl extends ServiceImpl selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state) { - return list(new LambdaQueryWrapper() - .eq(TbOrderDetail::getStatus, state.getValue()) - .eq(TbOrderDetail::getOrderId, orderId)); + public List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... statuses) { + LambdaQueryWrapper query = new LambdaQueryWrapper() + .eq(TbOrderDetail::getOrderId, orderId); + if (statuses.length != 0) { + query.in(TbOrderDetail::getStatus, CollUtil.newArrayList(statuses)); + } + return list(query); } @Override diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index da2a29e6..fc3bf24a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2795,12 +2795,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { }else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ hasNormalReturn = true; // 计算当前商品占比 - BigDecimal ratio = calcDetailRatio(orderDetail); - BigDecimal realAmount = orderDetail.getPriceAmount().multiply(ratio); - currentDetailAMount = realAmount - .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) + BigDecimal ratio = calcDetailRatio(orderDetail, returnNum); + currentDetailAMount = orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); - returnAmount = returnAmount.add(currentDetailAMount); + returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().multiply(ratio)); saleAmount = saleAmount.add(orderDetail.getPrice()); packAMount = packAMount.add(orderDetail.getPackAmount() .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) @@ -2869,11 +2867,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpOrderDetailService.updateBatchById(detailList); data.put("returnOrder", returnOrder); data.put("returnAmount", returnAmount); + data.put("hasNormalReturn", hasNormalReturn); return data; } - private BigDecimal calcDetailRatio(TbOrderDetail orderDetail) { - List detailList = mpOrderDetailService.selectByOrderIdAndState(orderDetail.getId(), TableConstant.OrderInfo.Status.CLOSED); + private BigDecimal calcDetailRatio(TbOrderDetail orderDetail, BigDecimal returnNum) { + List detailList = mpOrderDetailService.selectByOrderIdAndState(orderDetail.getOrderId(), TableConstant.OrderInfo.Status.CLOSED, TableConstant.OrderInfo.Status.REFUND); BigDecimal totalAmount = BigDecimal.ZERO; for (TbOrderDetail item : detailList) { if (item.getUserCouponId() == null) { @@ -2881,7 +2880,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { } } - return orderDetail.getPriceAmount().divide(totalAmount, 2, RoundingMode.HALF_UP); + return orderDetail.getPriceAmount().divide(totalAmount, 8, RoundingMode.HALF_UP) + .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP).multiply(returnNum).setScale(2, RoundingMode.HALF_UP); } private void updateStockAndRecord(List orderDetailList) { @@ -2944,12 +2944,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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 ("scanCode".equals(payType) || "wx_lite".equals(payType)) { + if (hasNormalReturn && ("scanCode".equals(payType) || "wx_lite".equals(payType))) { payService.returnOrder(Integer.valueOf(shopId), orderInfo, returnOrderInfo); returnOrderInfo.setStatus("refund"); mpOrderInfoService.updateById(returnOrderInfo); From 2ac38c77a8dc59c7f80086dc5b9ee9fc8906df35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 13:39:05 +0800 Subject: [PATCH 046/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E9=80=80=E6=AC=BE=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index fc3bf24a..8735c901 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2149,6 +2149,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { consumeCoupon(couponInfo.getOutRecordList(), payDTO.getVipUserId(), orderInfo); couponInfo.setProductCouponMap(BeanUtil.copyProperties(couponInfo.getProductCouponMap(), HashMap.class)); + OrderInfoCouponInfoDTO infoDTO = new OrderInfoCouponInfoDTO(); infoDTO.setOutRecordList(couponInfo.getOutRecordList()); @@ -2820,6 +2821,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setPriceAmount(currentDetailAMount); orderDetail.setPackAmount(returnPackFee); orderDetail.setRefundNumber(returnNum); + orderDetail.setReturnNum(returnNum.toPlainString()); // orderDetail.setStatus(isOnline ? "refunding" : "refund"); orderDetail.setStatus("refund"); } From b233f6ea215753e190b070f5e69dc3aac0406a45 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 21 Nov 2024 14:12:35 +0800 Subject: [PATCH 047/170] =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8/=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rest/AuthorizationController.java | 1 + .../security/security/TokenProvider.java | 10 ++++ .../security/service/OnlineUserService.java | 13 +++++ .../controller/shop/TbShopInfoController.java | 49 ++++++++++++++++--- .../ysk/cashier/dto/shop/TbShopInfoDto.java | 5 +- .../cn/ysk/cashier/pojo/shop/TbShopInfo.java | 10 +++- .../impl/shopimpl/TbShopInfoServiceImpl.java | 45 +++++++++++++++-- .../service/shop/TbShopInfoService.java | 3 +- 8 files changed, 121 insertions(+), 15 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java index 0865bed7..d9d1de1f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java @@ -137,6 +137,7 @@ public class AuthorizationController { put("user", jwtUserDto); if (byAccount != null) { put("shopId", byAccount.getId()); + put("mainId", byAccount.getId()); put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType())?authUser.getLoginType():"merchant"); put("shopName", byAccount.getShopName()); put("logo", byAccount.getLogo()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java index d66bd65c..a035a0e2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java @@ -73,6 +73,16 @@ public class TokenProvider implements InitializingBean { .compact(); } + public String createToken(String name,String shopId) { + return jwtBuilder + // 加入ID确保生成的 Token 都不一致 + .setId(IdUtil.simpleUUID()) + .claim(AUTHORITIES_KEY, name) + .claim("shopId",shopId) + .setSubject(name) + .compact(); + } + /** * 依据Token 获取鉴权信息 * diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java index 360d2df2..450968dc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java @@ -50,6 +50,19 @@ public class OnlineUserService { redisUtils.set(properties.getOnlineKey() + token, onlineUserDto, properties.getTokenValidityInSeconds()/1000); } + public void save(String username, String nickName, String token, HttpServletRequest request,Integer shopId){ + String ip = StringUtils.getIp(request); + String browser = StringUtils.getBrowser(request); + String address = StringUtils.getCityInfo(ip); + OnlineUserDto onlineUserDto = null; + try { + onlineUserDto = new OnlineUserDto(shopId,username, nickName, null, browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); + } catch (Exception e) { + log.error(e.getMessage(),e); + } + redisUtils.set(properties.getOnlineKey() + token, onlineUserDto, properties.getTokenValidityInSeconds()/1000); + } + /** * 查询全部数据 * @param filter / diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index cf037124..a910c753 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -1,11 +1,15 @@ package cn.ysk.cashier.controller.shop; import cn.ysk.cashier.annotation.Log; +import cn.ysk.cashier.annotation.rest.AnonymousGetMapping; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.config.security.config.bean.SecurityProperties; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.service.OnlineUserService; +import cn.ysk.cashier.config.security.service.dto.JwtUserDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.service.shop.TbShopInfoService; import io.swagger.annotations.Api; @@ -15,10 +19,15 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; import java.util.Map; /** @@ -36,14 +45,40 @@ public class TbShopInfoController { private final TbShopInfoService tbShopInfoService; private final OnlineUserService onlineUserService; private final TokenProvider tokenProvider; + private final SecurityProperties properties; -// @Log("导出数据") -// @ApiOperation("导出数据") -// @GetMapping(value = "/download") -// @PreAuthorize("@el.check('tbShopInfo:list')") -// public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException { -// tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response); -// } + @AnonymousPostMapping("changChildShop") + @PostMapping("changChildShop") + @ApiOperation("切换子店铺") + public ResponseEntity changChildShop(@RequestBody TbShopInfoQueryCriteria criteria, HttpServletRequest request) { + TbShopInfoDto shopInfo = tbShopInfoService.findById(criteria.getId()); + if (shopInfo != null) { + //生成token + String token = tokenProvider.createToken(shopInfo.getAccount(), criteria.getId().toString()); + Map authInfo = new HashMap(2) {{ + put("token", properties.getTokenStartWith() + token); + if (shopInfo != null) { + put("shopId", shopInfo.getId()); + put("mainId", shopInfo.getMainId()); + put("loginType", "merchant"); + put("shopName", shopInfo.getShopName()); + put("logo", shopInfo.getLogo()); + } + }}; + // 保存在线信息 + onlineUserService.save(shopInfo.getAccount(), shopInfo.getShopName(), token, request, shopInfo.getId()); + return ResponseEntity.ok(authInfo); + } else { + throw new BadRequestException("店铺信息不存在"); + } + } + + @AnonymousGetMapping("queryChildShop") + @GetMapping("queryChildShop") + @ApiOperation("查询子店铺") + public ResponseEntity queryChildShop(TbShopInfoQueryCriteria criteria){ + return new ResponseEntity<>(tbShopInfoService.queryChildShop(criteria),HttpStatus.OK); + } @GetMapping @ApiOperation("查询/shop/list") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java index 534f40af..1cd23a78 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java @@ -37,6 +37,7 @@ public class TbShopInfoDto implements Serializable { /** 自增id */ private Integer id; + private String mainId; /** 店铺帐号 */ @NotBlank(message = "店铺账号不能为空") @@ -101,6 +102,8 @@ public class TbShopInfoDto implements Serializable { /** 未用 */ private String mchId; + private Integer tubeType; + private String registerType; /** 是否独立的微信小程序 */ @@ -112,7 +115,7 @@ public class TbShopInfoDto implements Serializable { /** 类似于这种规则51.51.570 */ private String city; - /** 店铺类型 超市--MARKET---其它店SHOP */ + /** 店铺类型 单店--only 连锁店--chain--加盟店join*/ private String type; /** 行业 */ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java index 5720d7bd..e8302686 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java @@ -41,6 +41,10 @@ public class TbShopInfo implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; + @Column(name = "`main_id`") + @ApiModelProperty(value = "总店铺帐号") + private String mainId; + @Column(name = "`account`") @ApiModelProperty(value = "店铺帐号") private String account; @@ -138,9 +142,13 @@ public class TbShopInfo implements Serializable { private String city; @Column(name = "`type`") - @ApiModelProperty(value = "店铺类型 超市--MARKET---其它店SHOP") + @ApiModelProperty(value = "店铺类型 单店--only 连锁店--chain--加盟店join") private String type; + @Column(name = "`tube_type`") + @ApiModelProperty(value = "管理 0否 1是") + private Integer tubeType; + @Column(name = "`industry`") @ApiModelProperty(value = "行业") private String industry; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index d7277038..bd1925fa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -11,6 +11,7 @@ import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.EntityNotFoundException; import cn.ysk.cashier.mapper.shop.TbShopInfoMapper; import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; +import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbMerchantRegister; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; @@ -43,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.imageio.ImageIO; +import javax.persistence.criteria.Predicate; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -94,6 +96,28 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { return PageUtil.toPage(page); } + @Override + public List queryChildShop(TbShopInfoQueryCriteria criteria){ + List list = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> { + Predicate query1 = criteriaBuilder.equal(root.get("id"), criteria.getId()); + Predicate query2 = criteriaBuilder.and( + criteriaBuilder.equal(root.get("mainId"), criteria.getId()), + criteriaBuilder.notEqual(root.get("type"), "only"), + criteriaBuilder.equal(root.get("tubeType"), 1) + ); + + + // 再将两个子条件进行或运算组合成最终条件 + Predicate predicate = criteriaBuilder.or( + query1, + query2 + ); + + return predicate; + }); + return list; + } + // @Override // public List queryAll(TbShopInfoQueryCriteria criteria){ // return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); @@ -120,11 +144,6 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { return tbShopInfo; } - @Override - public TbShopInfoDto finByAccount(String account) { - return null; - } - @Override @Transactional(rollbackFor = Exception.class) public TbShopInfoDto create(TbShopInfoDto resources) { @@ -163,6 +182,15 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { //向redis中存入key redisUtils.set(CacheKey.ACT_CODE+resources.getAccount(),"1",tbShopInfo.getExpireAt()-Instant.now().toEpochMilli()); } + + if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){ + if(resources.getMainId() == null){ + throw new BadRequestException("连锁店或者扩展店 主店铺不能为空"); + } + }else { + tbShopInfo.setMainId(null); + } + //增加商户详情 TbShopInfo save = tbShopInfoRepository.save(tbShopInfo); if (resources.getRegisterCode() != null) { @@ -251,6 +279,13 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Transactional(rollbackFor = Exception.class) public void update(TbShopInfo resources) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new); + if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){ + if(resources.getMainId() == null){ + throw new BadRequestException("连锁店或者扩展店 主店铺不能为空"); + } + }else { + tbShopInfo.setMainId(null); + } if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) { shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString()); userRepository.updateNickName(resources.getAccount(),resources.getShopName()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java index a45d6309..b0167366 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java @@ -39,6 +39,8 @@ public interface TbShopInfoService { */ Map queryAll(TbShopInfoQueryCriteria criteria); + List queryChildShop(TbShopInfoQueryCriteria criteria); + /** * 查询所有数据不分页 * @param criteria 条件参数 @@ -54,7 +56,6 @@ public interface TbShopInfoService { TbShopInfoDto findById(Integer id); TbShopInfo findByIdInfo(Integer id); - TbShopInfoDto finByAccount(String account); /** * 创建 * @param resources / From bd820cbd4dc1df587fc3d9a6bbd125bd96c3b45d Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 21 Nov 2024 14:16:45 +0800 Subject: [PATCH 048/170] =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8/=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/TbShopInfoController.java | 7 ------- .../impl/shopimpl/TbShopInfoServiceImpl.java | 19 ++++--------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index c885de1b..7b45d0a8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -7,7 +7,6 @@ import cn.ysk.cashier.config.security.config.bean.SecurityProperties; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.service.OnlineUserService; import cn.ysk.cashier.dto.BindingDto; -import cn.ysk.cashier.config.security.service.dto.JwtUserDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; @@ -20,10 +19,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -55,7 +50,6 @@ public class TbShopInfoController { private final SecurityProperties properties; - @AnonymousPostMapping("changChildShop") @PostMapping("changChildShop") @ApiOperation("切换子店铺") public ResponseEntity changChildShop(@RequestBody TbShopInfoQueryCriteria criteria, HttpServletRequest request) { @@ -81,7 +75,6 @@ public class TbShopInfoController { } } - @AnonymousGetMapping("queryChildShop") @GetMapping("queryChildShop") @ApiOperation("查询子店铺") public ResponseEntity queryChildShop(TbShopInfoQueryCriteria criteria){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 340e192f..999d95ee 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -1,8 +1,5 @@ package cn.ysk.cashier.service.impl.shopimpl; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.qrcode.QrCodeUtil; -import cn.hutool.extra.qrcode.QrConfig; import cn.hutool.http.HttpUtil; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.service.UserCacheManager; @@ -12,14 +9,15 @@ import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.EntityNotFoundException; import cn.ysk.cashier.mapper.shop.TbShopInfoMapper; -import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; -import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbMerchantRegister; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.repository.TbShopPayTypeRepository; -import cn.ysk.cashier.repository.shop.*; +import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; +import cn.ysk.cashier.repository.shop.TbMerchantRegisterRepository; +import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; +import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.service.WxService; import cn.ysk.cashier.service.shop.TbShopInfoService; import cn.ysk.cashier.system.domain.Dept; @@ -32,11 +30,8 @@ import cn.ysk.cashier.system.service.ParamsService; import cn.ysk.cashier.system.service.UserService; import cn.ysk.cashier.utils.*; import com.alibaba.fastjson.JSONObject; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ResourceLoader; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -46,13 +41,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import javax.imageio.ImageIO; import javax.persistence.criteria.Predicate; import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; import java.time.Instant; import java.util.*; @@ -76,8 +67,6 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private final UserService userService; - private final UserCacheManager userCacheManager; - private final TokenProvider tokenProvider; private final ParamsService paramsService; private final TbMerchantRegisterRepository merchantRegisterRepository; From a563a41c23a7fd7217b615b14aa9132427100782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 14:17:40 +0800 Subject: [PATCH 049/170] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/MpOrderDetailService.java | 7 ++++ .../impl/MpOrderDetailServiceImpl.java | 7 ++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 35 +++++++++++-------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java index 01baf902..c1d059a3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java @@ -71,5 +71,12 @@ public interface MpOrderDetailService extends IService { * @param totalAmount 总价格 */ boolean updatePriceByCartId(Integer cartId, BigDecimal saleAmount, BigDecimal totalAmount); + + /** + * 根据会员id修改detail信息 + * @param orderId 订单id + * @param isMember 会员id + */ + boolean updateMemberByOrderId(Integer orderId, boolean isMember); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java index 0e49896a..ceef2831 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java @@ -81,5 +81,12 @@ public class MpOrderDetailServiceImpl extends ServiceImpl() + .eq(TbOrderDetail::getOrderId, orderId) + .set(TbOrderDetail::getIsMember, isMember ? 1 : 0)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 8735c901..56c1afbb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1210,9 +1210,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean byOrderId) { createOrderDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(createOrderDTO.getUseType()) ? null : createOrderDTO.getTableId()); return Utils.runFunAndCheckKey(() -> { - TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null); - if (shopInfo == null) throw new BadRequestException("店铺信息不存在"); - TbShopUser shopUser = null; if (createOrderDTO.getVipUserId() != null) { shopUser = tbShopUserMapper.selectById(createOrderDTO.getVipUserId()); @@ -1243,7 +1240,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { // } // 创建订单详情 - OrderPriceDTO detailPriceDTO = createOrderDetailWithCoupon(cartInfoDTO.getCashierCarts(), orderInfo, createOrderDTO.getShopId(), true, shopEatTypeInfoDTO); + OrderPriceDTO detailPriceDTO = createOrderDetailWithCoupon(cartInfoDTO.getCashierCarts(), orderInfo, + createOrderDTO.getShopId(), true, shopEatTypeInfoDTO); // 是否是第一次创建订单 orderInfo = createOrderWithAction(createOrderDTO, detailPriceDTO, shopEatTypeInfoDTO, @@ -2392,10 +2390,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Transactional public Object updateVip(UpdateVipDTO updateVipDTO) { Integer orderId = updateVipDTO.getOrderId(); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(updateVipDTO.getShopId(), updateVipDTO.getTableId()); if (orderId == null) { - ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(updateVipDTO.getShopId(), updateVipDTO.getTableId()); List tbCashierCarts = mpCashierCartService.selectByShopEatType(shopEatTypeInfoDTO, updateVipDTO.getMasterId()); for (TbCashierCart item : tbCashierCarts) { + item.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : updateVipDTO.getType() == 0 ? 1 : 0); if (item.getOrderId() != null) { orderId = item.getOrderId(); } @@ -2423,20 +2422,26 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("用户信息不存在"); } - orderInfoMapper.update(null, new LambdaUpdateWrapper() - .eq(TbOrderInfo::getId, orderId) - .set(TbOrderInfo::getUserId, shopUser.getUserId()) - .set(TbOrderInfo::getMemberId, updateVipDTO.getVipUserId())); + if (orderId != null) { + mpOrderDetailService.updateMemberByOrderId(orderId, shopEatTypeInfoDTO.isMemberPrice()); + orderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderId) + .set(TbOrderInfo::getUserId, shopUser.getUserId()) + .set(TbOrderInfo::getMemberId, updateVipDTO.getVipUserId())); + } } else { - mpCashierCartService.updateMemberAndAmountByOrderId(orderId, false); - orderInfoMapper.update(null, new LambdaUpdateWrapper() - .eq(TbOrderInfo::getId, orderId) - .set(TbOrderInfo::getUserId, null) - .set(TbOrderInfo::getMemberId, null)); + if (orderId != null) { + mpOrderDetailService.updateMemberByOrderId(orderId, false); + mpCashierCartService.updateMemberAndAmountByOrderId(orderId, false); + orderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderId) + .set(TbOrderInfo::getUserId, null) + .set(TbOrderInfo::getMemberId, null)); + } } if (dto != null) { - dto.setVipUserId(updateVipDTO.getVipUserId()); + dto.setVipUserId(updateVipDTO.getType() == 0 ? updateVipDTO.getVipUserId() : null); return createOrder(dto, true); } return "哈哈哈"; From dd7a3a9d46837198da71b3c1ab5eaf1f202a2946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 14:25:16 +0800 Subject: [PATCH 050/170] =?UTF-8?q?fix:=20=E6=89=93=E6=8A=98=E4=B8=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9detail=E5=8E=9F=E5=A7=8B=E5=94=AE=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 56c1afbb..ac661740 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2179,15 +2179,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal discount = BigDecimal.valueOf(payDTO.getDiscount()); cashierCarts.forEach(item -> { item.setTotalAmount(item.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); +// item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); +// item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); }); detailList.forEach(item -> { item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - item.setPrice(item.getPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); +// item.setPrice(item.getPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); +// item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); }); mpCashierCartService.updateBatchById(cashierCarts); From 00638d069c765edae7be8e1da3a5087ad04a3d5c Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Thu, 21 Nov 2024 14:30:28 +0800 Subject: [PATCH 051/170] =?UTF-8?q?=E5=91=98=E5=B7=A5=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shopimpl/TbPlussShopStaffServiceImpl.java | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java index 60b3cca6..89303ea2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java @@ -104,27 +104,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { @Override @Transactional(rollbackFor = Exception.class) public TbPlussShopStaffDto create(TbPlussShopStaff resources) { - if (org.apache.commons.lang3.StringUtils.isBlank(resources.getAccount())) { - throw new BadRequestException("员工账号为空"); - } - if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) { - throw new BadRequestException("员工账号已存在"); - } - if (!PhoneUtil.validator(resources.getPhone())){ - throw new BadRequestException("手机号格式有误"); - } + checkStaffParams(resources); - if (pattern.matcher(resources.getCode()).find()) { - throw new BadRequestException("员工编号不能包含中文"); - } - - if (resources.getRoleId()==null) { - throw new BadRequestException("请选择角色"); - } - - if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) { - throw new BadRequestException("最大优惠金额过大"); - } resources.setCreatedAt(Instant.now().toEpochMilli()); //添加收银系统后台账号 @@ -172,9 +153,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { resources.setPassword(null); } - if (pattern.matcher(resources.getCode()).find()) { - throw new BadRequestException("员工编号不能包含中文"); - } + checkStaffParams(resources); + TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new); User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount()); if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){ @@ -207,6 +187,33 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { Integer.valueOf(resources.getShopId()), resources.getId(), resources.getPermissions()); } + private void checkStaffParams(TbPlussShopStaff resources) { + if (StringUtils.isBlank(resources.getAccount())) { + throw new BadRequestException("员工账号为空"); + } + if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) { + throw new BadRequestException("员工账号已存在"); + } + if (!PhoneUtil.validator(resources.getPhone())){ + throw new BadRequestException("手机号格式有误"); + } + if (tbPlussShopStaffRepository.queryByAccount(resources.getAccount(),resources.getShopId()) != null) { + throw new BadRequestException("账号已存在"); + } + + if (pattern.matcher(resources.getCode()).find()) { + throw new BadRequestException("员工编号不能包含中文"); + } + + if (resources.getRoleId()==null) { + throw new BadRequestException("请选择角色"); + } + + if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) { + throw new BadRequestException("最大优惠金额过大"); + } + } + @Override @Transactional(rollbackFor = Exception.class) public void updateStatus(TbPlussShopStaff resources) { From 4c5c8ef02eaf9ee984a683eba73dcc49f5f8b476 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 21 Nov 2024 14:35:04 +0800 Subject: [PATCH 052/170] =?UTF-8?q?=E8=90=A5=E9=94=80=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/controller/AppCenterController.java | 8 ++++++-- .../service/impl/TbPlatformDictTypeServiceImpl.java | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java index 716887ea..8b2f4b8b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java @@ -4,10 +4,12 @@ import cn.ysk.cashier.service.TbPlatformDictService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.apache.ibatis.annotations.Param; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; 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 @RequiredArgsConstructor @@ -19,10 +21,12 @@ public class AppCenterController { @GetMapping @ApiOperation("获取应用中心列表") - public ResponseEntity queryBotButtonConfig(){ - return new ResponseEntity<>(tbPlatformDictService.queryByType("appCenter"), HttpStatus.OK); + public ResponseEntity queryBotButtonConfig(@RequestParam(required = false, defaultValue = "appCenter") String type){ + return new ResponseEntity<>(tbPlatformDictService.queryByType(type), HttpStatus.OK); } + + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java index cb4b64be..452d993d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java @@ -9,6 +9,7 @@ import cn.ysk.cashier.utils.ValidationUtil; import lombok.RequiredArgsConstructor; import cn.ysk.cashier.repository.TbPlatformDictTypeRepository; import cn.ysk.cashier.service.TbPlatformDictTypeService; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; @@ -31,6 +32,7 @@ public class TbPlatformDictTypeServiceImpl implements TbPlatformDictTypeService @Override public Map queryAll(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable){ + pageable = PageRequest.of(0,50); Page page = tbPlatformDictTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); return PageUtil.toPage(page.map(tbPlatformDictTypeMapper::toDto)); } From caac76dbd8c728b761f81bf8944c3d709278a66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 14:37:21 +0800 Subject: [PATCH 053/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index ac661740..5e0386fb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2831,7 +2831,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setStatus("refund"); } - if (hasNormalReturn && returnAmount.compareTo(BigDecimal.ZERO) <= 0) { + if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0.01")) <= 0) { throw new BadRequestException("退款金额必须大于0"); } @@ -2977,19 +2977,21 @@ public class TbShopTableServiceImpl implements TbShopTableService { String couponInfoList = orderInfo.getCouponInfoList(); if (StrUtil.isNotBlank(couponInfoList)) { OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class); - int remainNum = 0; - for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { - if (item.getFinalUseNum() > item.getReturnNum()) { - remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); + if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) { + int remainNum = 0; + for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { + if (item.getFinalUseNum() > item.getReturnNum()) { + remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); + } } - } - if (remainNum == 0) { - returnCoupon(orderInfo, true); - // 返还积分 - memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), - "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + if (remainNum == 0) { + returnCoupon(orderInfo, true); + // 返还积分 + memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), + "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + } } } } From 052e1a51a44fcb670d5712169eae5dda02c05f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 14:50:17 +0800 Subject: [PATCH 054/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E5=90=8C=E6=97=B6=E4=BD=BF=E7=94=A8detail?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E4=B8=8D=E5=87=86=E7=A1=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/pojo/order/TbCashierCart.java | 18 ++++++++++++++++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 2 ++ 2 files changed, 20 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 905e6d15..43775903 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -199,6 +199,24 @@ public class TbCashierCart implements Serializable { } } + /** + * 根据是否会员充值价格 + */ + public void resetTotalAmount(BigDecimal discountRadio) { + if ("false".equals(isPack)) { + packFee = BigDecimal.ZERO; + } + if ("true".equals(isGift)) { + totalAmount = packFee; + } else { + if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { + totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio); + } else { + totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio); + } + } + } + /** * 获取总价不包含打包费 * diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 5e0386fb..47c4d496 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1372,6 +1372,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { resetCouponList.add(cashierCart); cashierCart.setUserCouponId(null); } + cashierCart.resetTotalAmount(orderInfo.getDiscountRatio()); discountAmount = reduceProCoupon(couponMap, cashierCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId); } @@ -2196,6 +2197,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); BigDecimal discountAmount = oldAmount.subtract(finalAmount); orderInfo.setDiscountAmount(discountAmount); + orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount())); orderInfo.setOrderAmount(finalAmount); orderInfo.setAmount(finalAmount); orderInfo.setSettlementAmount(finalAmount); From 7c8d22f5ed630285dc77b0095f0ead6d1a3f424f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 15:03:32 +0800 Subject: [PATCH 055/170] =?UTF-8?q?fix:=20=E8=AE=A2=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E6=8A=98=E6=89=A3=E9=87=91=E9=A2=9D=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 47c4d496..73379fa9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1400,7 +1400,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { couponInfoDTO.setOutRecordList(outRecords); couponInfoDTO.setCouponMap(usedCouponMap); - return discountAmount; + return discountAmount.multiply(orderInfo.getDiscountRatio()); } private OrderCouponInfoDTO getCouponInfo(Integer memberId, Integer shopId, List userCouponInfoDTOList, BigDecimal orderAmount, Set productIds) { From 6bc9a2aaa6e6315bd7a052550f89ce9ff3d14ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 15:13:36 +0800 Subject: [PATCH 056/170] =?UTF-8?q?fix:=20=E8=AE=A2=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E6=8A=98=E6=89=A3=E9=87=91=E9=A2=9D=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 73379fa9..9755afca 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1457,7 +1457,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { OrderCartInfoDTO cartInfoDTO = new OrderCartInfoDTO(); List allCashierCarts; if (orderId != null) { - allCashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId, null); + allCashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId); }else { allCashierCarts = mpCashierCartService.selectByShopEatType(shopEatTypeInfoDTO, masterId); } @@ -2082,7 +2082,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private BigDecimal getCartCouponDiscount(TbOrderInfo orderInfo, PayDTO payDTO) { Set productIdSet = new HashSet<>(); - List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId(), null); + List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); ArrayList activateCartInfo = new ArrayList<>(); for (TbCashierCart cashierCart : cashierCarts) { productIdSet.add(cashierCart.getProductId()); From e6bd4af95cc42adf2a57b88d1cc3329cfa95303c Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 21 Nov 2024 15:31:27 +0800 Subject: [PATCH 057/170] =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=97=A8=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopInfoServiceImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index bd1925fa..d7ba32a5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -102,17 +102,14 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { Predicate query1 = criteriaBuilder.equal(root.get("id"), criteria.getId()); Predicate query2 = criteriaBuilder.and( criteriaBuilder.equal(root.get("mainId"), criteria.getId()), - criteriaBuilder.notEqual(root.get("type"), "only"), - criteriaBuilder.equal(root.get("tubeType"), 1) + criteriaBuilder.notEqual(root.get("type"), "only") ); - - // 再将两个子条件进行或运算组合成最终条件 Predicate predicate = criteriaBuilder.or( query1, query2 ); - + criteriaBuilder.desc(root.get("tubeType")); return predicate; }); return list; @@ -189,6 +186,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { } }else { tbShopInfo.setMainId(null); + tbShopInfo.setTubeType(1); } //增加商户详情 @@ -285,6 +283,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { } }else { tbShopInfo.setMainId(null); + tbShopInfo.setTubeType(1); } if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) { shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString()); From 1fc38f75baf02b50428780d858c83998bce6f50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 16:18:03 +0800 Subject: [PATCH 058/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 9755afca..8630f22c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2286,10 +2286,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderInfo.setPaidTime(DateUtil.current()); orderInfo.setPayAmount(finalAmount); orderInfo.setStatus("closed"); - if (payDTO.getDiscount() != null) { - orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount())); - orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(finalAmount)); - } if (StrUtil.isEmpty(orderInfo.getMemberId())) { orderInfo.setMemberId(Convert.toStr(payDTO.getVipUserId())); } From 01f43aacafe40b493ded9f08ed413247fa986b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 16:32:58 +0800 Subject: [PATCH 059/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/dto/shoptable/PayDTO.java | 12 +++++------- .../ysk/cashier/service/impl/TbPayServiceImpl.java | 4 ++-- .../impl/shopimpl/TbShopTableServiceImpl.java | 12 ++++++------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java index 74e34174..b54bfc51 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java @@ -4,10 +4,8 @@ import cn.ysk.cashier.dto.order.UserCouponInfoDTO; import lombok.Data; import javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.*; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -19,9 +17,9 @@ public class PayDTO { private Integer orderId; @NotEmpty private String payType; - @Min(0) - @Max(1) - private Double discount; + @DecimalMin("0") + @DecimalMax("1") + private BigDecimal discount; private Integer vipUserId; private String code; private String token; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java index f004ce74..56dace2c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java @@ -365,12 +365,12 @@ public class TbPayServiceImpl implements TbPayService { // return Result.fail(CodeEnum.PAYTYPENOEXIST); // } - BigDecimal payMount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + BigDecimal payMount = orderInfo.getOrderAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP); orderInfo.setPayAmount(payMount); orderInfo.setPayType("cash"); orderInfo.setStatus("closed"); orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo())); - orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount())); + orderInfo.setDiscountRatio(payDTO.getDiscount()); orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(payMount)); orderInfoMapper.updateById(orderInfo); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 8630f22c..06fba60d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2131,7 +2131,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 更新订单信息 ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(orderInfo.getShopId(), orderInfo.getTableId()); OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO); - BigDecimal finalAmount = priceDTO.getTotalAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + BigDecimal finalAmount = priceDTO.getTotalAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP); orderInfo.setUpdatedAt(System.currentTimeMillis()); orderInfo.setSettlementAmount(finalAmount); @@ -2177,7 +2177,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private BigDecimal resetAmountByDiscount(PayDTO payDTO, TbOrderInfo orderInfo) { List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); - BigDecimal discount = BigDecimal.valueOf(payDTO.getDiscount()); + BigDecimal discount = payDTO.getDiscount(); cashierCarts.forEach(item -> { item.setTotalAmount(item.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); @@ -2194,10 +2194,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpCashierCartService.updateBatchById(cashierCarts); mpOrderDetailService.updateBatchById(detailList); BigDecimal oldAmount = orderInfo.getOrderAmount(); - BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP); BigDecimal discountAmount = oldAmount.subtract(finalAmount); orderInfo.setDiscountAmount(discountAmount); - orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount())); + orderInfo.setDiscountRatio(payDTO.getDiscount()); orderInfo.setOrderAmount(finalAmount); orderInfo.setAmount(finalAmount); orderInfo.setSettlementAmount(finalAmount); @@ -2234,12 +2234,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { } if (payDTO.getDiscount() == null) { - payDTO.setDiscount((double) 1); + payDTO.setDiscount(new BigDecimal("1")); } BigDecimal finalAmount = null; // 计算订单折扣信息 - if (payDTO.getDiscount() != 1) { + if (payDTO.getDiscount().compareTo(new BigDecimal("1")) != 0) { finalAmount = resetAmountByDiscount(payDTO, orderInfo); }else { finalAmount = orderInfo.getOrderAmount(); From ecbf54604f2ec46fe0ef55b765215529aa232ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 16:41:18 +0800 Subject: [PATCH 060/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 06fba60d..54933f1d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1337,11 +1337,20 @@ public class TbShopTableServiceImpl implements TbShopTableService { outRecords.add(tbActivateOutRecord); cashierCart.setUseCouponInfo(JSONObject.toJSONString(tbActivateOutRecord)); - couponVo.setFinalDiscountAmount(discountAmount); // 优惠券未消耗完毕 if (balanceCart != null && getCanUseCoupon(couponMap, balanceCart.getProductId()) != null) { - discountAmount = reduceProCoupon(couponMap, balanceCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId); + // 递归调用并累加递归返回的折扣金额 + discountAmount = discountAmount.add(reduceProCoupon( + couponMap, + balanceCart, + usedCouponMap, + BigDecimal.ZERO, // 避免重复累加,递归时传入新的初始值 + balanceCartList, + outRecords, + memberId + )); } + couponVo.setFinalDiscountAmount(discountAmount); return discountAmount; } return discountAmount; From 6854619b71055085104f66c8aa4ce9eb5e822fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 17:14:47 +0800 Subject: [PATCH 061/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/pojo/order/TbCashierCart.java | 19 +++++++++++++------ .../impl/shopimpl/TbShopTableServiceImpl.java | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 43775903..b83a735e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -25,6 +25,7 @@ import javax.persistence.*; import javax.validation.constraints.*; import java.math.BigDecimal; import java.io.Serializable; +import java.math.RoundingMode; /** * @author lyf @@ -221,15 +222,21 @@ public class TbCashierCart implements Serializable { * 获取总价不包含打包费 * */ - public BigDecimal getTotalAmountByNum(BigDecimal num) { + public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) { + if (discountRadio == null) { + discountRadio = new BigDecimal("1"); + } + resetTotalAmount(discountRadio); if (num == null) { num = totalNumber; } - if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - return num.multiply(memberPrice); - } else { - return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice); - } + + return totalAmount.divide(totalNumber, 9, RoundingMode.HALF_UP).multiply(num).setScale(2, RoundingMode.HALF_UP); +// if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { +// return num.multiply(memberPrice); +// } else { +// return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice); +// } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 54933f1d..4929b533 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1287,7 +1287,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { TbCashierCart balanceCart = null; if (cashierCart.getNumber().compareTo(couponVo.getCurrentUseNum()) < 0) { cashierCart.setUserCouponId(couponVo.getId()); - discountAmount = discountAmount.add(cashierCart.getTotalAmountByNum(null)); + discountAmount = discountAmount.add(cashierCart.getTotalAmountByNum(null, null)); couponVo.setCurrentUseNum(couponVo.getCurrentUseNum().subtract(cashierCart.getNumber())); currentUseNum = cashierCart.getNumber(); // 优惠券数量小于购物车数量,分割购物车数据 @@ -1297,7 +1297,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal balanceNum = cashierCart.getTotalNumber().subtract(couponVo.getCurrentUseNum()); BigDecimal singlePackFee = cashierCart.getPackFee().divide(cartNum, RoundingMode.HALF_UP); cashierCart.setPackFee(singlePackFee.multiply(currentUseNum)); - BigDecimal totalAmountByNum = cashierCart.getTotalAmountByNum(couponVo.getCurrentUseNum()); + BigDecimal totalAmountByNum = cashierCart.getTotalAmountByNum(couponVo.getCurrentUseNum(), null); cashierCart.setTotalAmount(totalAmountByNum.add(singlePackFee.multiply(currentUseNum))); cashierCart.setNumber(couponVo.getCurrentUseNum()); cashierCart.setTotalNumber(couponVo.getCurrentUseNum()); @@ -1315,7 +1315,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { balanceCart.setNumber(balanceNum); balanceCart.setTotalNumber(balanceNum); balanceCart.setPackFee(singlePackFee.multiply(balanceNum)); - balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum).add(singlePackFee.multiply(balanceNum))); + balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum, null).add(singlePackFee.multiply(balanceNum))); balanceCartList.add(balanceCart); } else { currentUseNum =cashierCart.getNumber(); From ab3fa48f7aa38e61438e53f47458813d01d9376d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 17:59:06 +0800 Subject: [PATCH 062/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 4929b533..d11b2e77 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2314,7 +2314,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { .eq(TbOrderDetail::getOrderId, orderInfo.getId()) .eq(TbOrderDetail::getUseType, orderInfo.getUseType()) .eq(TbOrderDetail::getStatus, "unpaid") - .setSql(StrUtil.format("price_amount=price*num*{}", payDTO.getDiscount() == null ? 1 : payDTO.getDiscount())) .set(TbOrderDetail::getStatus, "closed")); JSONObject jsonObject = new JSONObject(); From b618db850a9660edcee7d76a84b1c1ccae41007e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 18:19:12 +0800 Subject: [PATCH 063/170] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java | 3 +++ .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index b83a735e..caef29d2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -204,6 +204,9 @@ public class TbCashierCart implements Serializable { * 根据是否会员充值价格 */ public void resetTotalAmount(BigDecimal discountRadio) { + if (discountRadio == null) { + discountRadio = BigDecimal.ONE; + } if ("false".equals(isPack)) { packFee = BigDecimal.ZERO; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index d11b2e77..d78f59fc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1582,7 +1582,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (orderInfo != null && shopEatTypeInfoDTO != null) { cashierCart.setIsMember(StrUtil.isBlank(orderInfo.getMemberId()) ? 0 : shopEatTypeInfoDTO.isMemberPrice() ? 1 : 0); } - cashierCart.resetTotalAmount(); + cashierCart.resetTotalAmount(orderInfo == null ? null : orderInfo.getDiscountRatio()); // 已经退款和使用优惠券的商品不进行统计金额 if (!"return".equals(cashierCart.getStatus()) && cashierCart.getUserCouponId() == null) { From 7e413ad469ef2d323d306d091074ecfc7cfb05a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 18:27:22 +0800 Subject: [PATCH 064/170] =?UTF-8?q?fix:=20=E7=BE=8E=E5=9B=A2=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThirdPartyCouponController.java | 9 +-- .../service/ThirdPartyCouponService.java | 2 +- .../impl/ThirdPartyCouponServiceImpl.java | 56 +++++++++++++++++-- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java index a7579669..0a69f072 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java @@ -2,10 +2,7 @@ package cn.ysk.cashier.controller; import cn.ysk.cashier.service.ThirdPartyCouponService; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * 三方团购券 @@ -25,7 +22,7 @@ public class ThirdPartyCouponController { * @return 美团绑定链接 */ @GetMapping - public ResponseEntity getBindUrl() { - return ResponseEntity.ok(thirdPartyCouponService.getBindUrl()); + public ResponseEntity getBindUrl(@RequestParam Integer shopId) { + return ResponseEntity.ok(thirdPartyCouponService.getBindUrl(shopId)); } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java index 9fc82d46..3da26911 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java @@ -5,5 +5,5 @@ import org.springframework.web.bind.annotation.RestController; public interface ThirdPartyCouponService { - String getBindUrl(); + String getBindUrl(Integer shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java index 50f50a69..5082747c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java @@ -1,38 +1,82 @@ package cn.ysk.cashier.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; +import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.resp.PhpCommonResp; import cn.ysk.cashier.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) { + public ThirdPartyCouponServiceImpl(RestTemplate restTemplate, MpShopInfoMapper mpShopInfoMapper) { this.restTemplate = restTemplate; + this.mpShopInfoMapper = mpShopInfoMapper; } private final RestTemplate restTemplate; - private T getData(String url, Object data) { - PhpCommonResp resp = restTemplate.getForEntity(phpServerUrl + url, PhpCommonResp.class).getBody(); + private T getData(String url, Integer shopId, Object data) { + // 获取店铺信息 + TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); + if (shopInfo == null) { + throw new BadRequestException("店铺信息不存在"); + } + + // 设置请求头 + HttpHeaders headers = new HttpHeaders(); + headers.set("account", shopId.toString()); + + // 构造请求实体,根据 data 是否为空设置请求体 + HttpEntity entity; + if (data != null) { + Map map = BeanUtil.beanToMap(data); + map.put("title", shopInfo.getShopName()); + entity = new HttpEntity<>(map, headers); + } else { + entity = new HttpEntity<>(new HashMap(){{ + put("title", shopInfo.getShopName()); + }},headers); + } + + // 发起请求 + ResponseEntity response = restTemplate.exchange( + phpServerUrl + url, + HttpMethod.POST, // 使用 POST 请求发送 body 数据 + entity, + PhpCommonResp.class + ); + + // 处理响应 + PhpCommonResp resp = response.getBody(); if (resp == null) { throw new BadRequestException("请求php服务器失败"); } - if (!"1".equals(resp.getCode())) { throw new BadRequestException(resp.getMsg()); } + // 返回数据 return (T) resp.getData(); } + @Override - public String getBindUrl() { - return getData("/meituan/getuisdkurl", null); + public String getBindUrl(Integer shopId) { + return getData("/meituan/getuisdkurl", shopId, null); } } From ba6af5e2cf62b9d35b936b48095a0f2816d04e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 18 Nov 2024 11:40:40 +0800 Subject: [PATCH 065/170] =?UTF-8?q?fix:=20=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=A1=BA=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index d78f59fc..dd334f6a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2187,12 +2187,16 @@ public class TbShopTableServiceImpl implements TbShopTableService { List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); BigDecimal discount = payDTO.getDiscount(); - cashierCarts.forEach(item -> { - item.setTotalAmount(item.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + BigDecimal totalAmount = BigDecimal.ZERO; + for (TbCashierCart cashierCart : cashierCarts) { + if (cashierCart.getUserCouponId() == null) { + cashierCart.setTotalAmount(cashierCart.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + totalAmount = cashierCart.getTotalAmount(); + } // item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - }); + } detailList.forEach(item -> { item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); @@ -2203,15 +2207,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpCashierCartService.updateBatchById(cashierCarts); mpOrderDetailService.updateBatchById(detailList); BigDecimal oldAmount = orderInfo.getOrderAmount(); - BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP); - BigDecimal discountAmount = oldAmount.subtract(finalAmount); +// BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP); + BigDecimal discountAmount = oldAmount.subtract(totalAmount); orderInfo.setDiscountAmount(discountAmount); orderInfo.setDiscountRatio(payDTO.getDiscount()); - orderInfo.setOrderAmount(finalAmount); - orderInfo.setAmount(finalAmount); - orderInfo.setSettlementAmount(finalAmount); + orderInfo.setOrderAmount(totalAmount); + orderInfo.setAmount(totalAmount); + orderInfo.setSettlementAmount(totalAmount); mpOrderInfoService.updateById(orderInfo); - return finalAmount; + return totalAmount; } @Override From b5f8419e822a23b46543cce7e9de733956a33971 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 22 Nov 2024 09:57:33 +0800 Subject: [PATCH 066/170] =?UTF-8?q?=E5=BC=80=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/utils/CacheKey.java | 2 + .../shop/ShopInvoiceController.java | 69 ++++++++++ .../controller/shop/TbShopInfoController.java | 7 -- .../java/cn/ysk/cashier/dto/BindingDto.java | 11 ++ .../cashier/pojo/shop/TbMerchantAccount.java | 12 ++ .../cn/ysk/cashier/service/BindService.java | 42 +++++++ .../cashier/service/impl/BindServiceImpl.java | 118 ++++++++++++++++++ .../impl/shopimpl/TbShopInfoServiceImpl.java | 31 +++-- 8 files changed, 268 insertions(+), 24 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java index 78a39675..7773b32f 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java @@ -76,4 +76,6 @@ public interface CacheKey { String SONG_URL = "song:"; String VIPCODE = "VIPCODE:"; + + String INVOICE_SD_TYPE = "invoice:sd_type:"; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java new file mode 100644 index 00000000..e9de5b82 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java @@ -0,0 +1,69 @@ +package cn.ysk.cashier.controller.shop; + +import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.dto.BindingDto; +import cn.ysk.cashier.service.BindService; +import cn.ysk.cashier.service.shop.TbShopInfoService; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @author Administrator + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/invoice") +public class ShopInvoiceController { + + @Resource + private TbShopInfoService shopInfoService; + @Resource + private BindService bindService; + + @PostMapping("binding") + @ApiOperation("绑定开票信息") + public ResponseEntity binding(@Validated @RequestBody BindingDto bindingDto){ + return new ResponseEntity<>(shopInfoService.binding(bindingDto), HttpStatus.OK); + } + + @PostMapping("subInvoicing") + @ApiOperation("提交开票") + public ResponseEntity subInvoicing(@RequestBody Map params){ + return new ResponseEntity<>(bindService.subInvoicing(params), HttpStatus.OK); + } + + @PostMapping("industry") + @ApiOperation("获取项目分类") + @AnonymousPostMapping("industry") + public ResponseEntity industry(@RequestBody BindingDto bindingDto){ + return new ResponseEntity<>(bindService.industry(bindingDto), HttpStatus.OK); + } + + @PostMapping("digitalInvoice") + @ApiOperation("数电发票类型") + @AnonymousPostMapping("digitalInvoice") + public ResponseEntity digitalInvoice(){ + return new ResponseEntity<>(bindService.digitalInvoice(), HttpStatus.OK); + } + + @PostMapping("storeSe") + @ApiOperation("计算税额") + @AnonymousPostMapping("storeSe") + public ResponseEntity storeSe(@RequestBody Map params){ + return new ResponseEntity<>(bindService.storeSe(params), HttpStatus.OK); + } + + + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index 7b45d0a8..9b0f57f3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -41,13 +41,6 @@ public class TbShopInfoController { private final TbShopInfoService tbShopInfoService; private final OnlineUserService onlineUserService; private final TokenProvider tokenProvider; - @PostMapping("binding") - @AnonymousPostMapping("binding") - @ApiOperation("绑定开票信息") - public ResponseEntity binding(@RequestBody BindingDto bindingDto){ - return new ResponseEntity<>(tbShopInfoService.binding(bindingDto), HttpStatus.OK); - } - private final SecurityProperties properties; @PostMapping("changChildShop") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java index 74d481b8..146293b9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java @@ -6,4 +6,15 @@ import lombok.Data; public class BindingDto { private Integer shopId; private String account; + + // 项目分类 + private String article; + + // 数电发票类型 + private String sdType; + + // 税率 + private String taxAmount; + + private Integer page = 1; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java index e36d3dc4..c7e8482a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java @@ -135,6 +135,18 @@ public class TbMerchantAccount implements Serializable { @ApiModelProperty(value = "开票系统账号") private String bindAccount; + @Column(name = "`article`") + @ApiModelProperty(value = "项目分类") + private String article; + + @Column(name = "`sd_type`") + @ApiModelProperty(value = "数电发票类型") + private String sdType; + + @Column(name = "`tax_amount`") + @ApiModelProperty(value = "税率") + private String taxAmount; + public void copy(TbMerchantAccount source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java new file mode 100644 index 00000000..e77e7493 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java @@ -0,0 +1,42 @@ +package cn.ysk.cashier.service; + +import cn.ysk.cashier.dto.BindingDto; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.Map; + +/** + * 开票服务员 + */ +public interface BindService { + + /** + * 绑定 + */ + JSONObject binding(Map params); + + /** + * 商家提交开票信息 + */ + JSONObject subInvoicing(Map params); + + /** + * 项目分类 + */ + JSONObject industry(BindingDto bindingDto); + + + /** + * 计算税额 + */ + JSONObject storeSe(Map params); + + /** + * 数电发票类型 + */ + JSONArray digitalInvoice(); + + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java new file mode 100644 index 00000000..a31826c9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java @@ -0,0 +1,118 @@ +package cn.ysk.cashier.service.impl; + +import cn.hutool.http.HttpUtil; +import cn.ysk.cashier.dto.BindingDto; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.pojo.shop.TbMerchantAccount; +import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; +import cn.ysk.cashier.repository.shop.TbShopInfoRepository; +import cn.ysk.cashier.service.BindService; +import cn.ysk.cashier.utils.CacheKey; +import cn.ysk.cashier.utils.RedisUtils; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@Service +public class BindServiceImpl implements BindService { + + @Autowired + private TbMerchantAccountRepository accountRepository; + @Autowired + private TbShopInfoRepository tbShopInfoRepository; + @Lazy + @Autowired + private RedisUtils redisUtils; + private final String url = "http://test.invoice.sxczgkj.cn/api/"; + + @Override + public JSONObject binding(Map params) { + String result = HttpUtil.post(url + "cash/binding", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + + @Override + public JSONObject subInvoicing(Map params) { + String result = HttpUtil.post(url + "cash/subinvoicing", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + if (params.get("shopId") != null) { + if (redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + params.get("shopId"))) { + Set articles = redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + params.get("shopId")); + if (!articles.contains(params.get("article"))) { + articles.add(params.get("article")); + redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + params.get("shopId"), articles); + } + } + } + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + + @Override + public JSONObject industry(BindingDto bindingDto) { + if (StringUtils.isNotBlank(bindingDto.getArticle())) { + Map params = new HashMap<>(); + params.put("name", bindingDto.getArticle()); + params.put("page", bindingDto.getPage() == null ? 1 : bindingDto.getPage()); + String result = HttpUtil.post(url + "store/industrylistsj", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } else { + Set set = new HashSet<>(); + JSONObject jsonObject = new JSONObject(); + if (!redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())) { + TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); + TbMerchantAccount account = accountRepository.findByAccount(tbShopInfo.getAccount()); + set.add(account.getArticle()); + redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId(), set); + jsonObject.put("articles", set); + } else { + jsonObject.put("list", redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())); + } + return jsonObject; + } + } + + @Override + public JSONObject storeSe(Map params) { + String result = HttpUtil.post(url + "store/se", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + + @Override + public JSONArray digitalInvoice() { + String result = HttpUtil.post(url + "store/digitalinvoice", "", 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONArray("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index afd10bf8..8b8f6599 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -1,8 +1,5 @@ package cn.ysk.cashier.service.impl.shopimpl; -import cn.hutool.http.HttpUtil; -import cn.ysk.cashier.config.security.security.TokenProvider; -import cn.ysk.cashier.config.security.service.UserCacheManager; import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; @@ -18,6 +15,7 @@ import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; import cn.ysk.cashier.repository.shop.TbMerchantRegisterRepository; import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository; +import cn.ysk.cashier.service.BindService; import cn.ysk.cashier.service.WxService; import cn.ysk.cashier.service.shop.TbShopInfoService; import cn.ysk.cashier.system.domain.Dept; @@ -78,6 +76,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private final RedisUtils redisUtils; private final TbShopPayTypeRepository tbShopPayTypeRepository; + private final BindService bindService; private final WxService wxService; @Override @@ -94,22 +93,20 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { } } Map param = new HashMap<>(); - //超掌柜生活-用户端 param.put("account", bindingDto.getAccount()); - String result = HttpUtil.post("http://test.invoice.sxczgkj.cn/api/cash/binding", param, 5000); - - JSONObject jsonObject = JSONObject.parseObject(result); - if (jsonObject.getInteger("code").equals(1)) { - JSONObject data = jsonObject.getJSONObject("data"); - if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) { - String bindAccount = data.getJSONObject("store").getString("account"); - account.setBindAccount(bindAccount); - merchantAccountRepository.save(account); - } - return data; - } else { - throw new BadRequestException(jsonObject.getString("msg")); + JSONObject data = bindService.binding(param); + if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) { + account.setBindAccount(bindingDto.getAccount()); + account.setArticle(bindingDto.getArticle()); + account.setTaxAmount(bindingDto.getTaxAmount()); + account.setSdType(bindingDto.getSdType()); + merchantAccountRepository.save(account); } + data.put("bindAccount", account.getBindAccount()); + data.put("article", account.getArticle()); + data.put("taxAmount", account.getTaxAmount()); + data.put("sdType", account.getSdType()); + return data; } @Override From 8a33d49c7c60e21180824cb9d1b9ce9bacc41406 Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Fri, 22 Nov 2024 10:10:52 +0800 Subject: [PATCH 067/170] =?UTF-8?q?=E5=91=98=E5=B7=A5=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbPlussShopStaffServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java index 89303ea2..ec00978e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java @@ -153,7 +153,9 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { resources.setPassword(null); } - checkStaffParams(resources); + if (pattern.matcher(resources.getCode()).find()) { + throw new BadRequestException("员工编号不能包含中文"); + } TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new); User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount()); From 04023c3f30993fb78a73c278d2ed2a27fa3eb543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 10:19:12 +0800 Subject: [PATCH 068/170] =?UTF-8?q?fix:=20=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=A1=BA=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/dto/order/OrderPriceDTO.java | 2 + .../ysk/cashier/pojo/order/TbCashierCart.java | 7 ++- .../impl/shopimpl/TbShopTableServiceImpl.java | 50 ++++++++++--------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java index b7b4249a..9f33b66d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java @@ -12,6 +12,8 @@ public class OrderPriceDTO { private BigDecimal originAmount = BigDecimal.ZERO; private BigDecimal totalAmount = BigDecimal.ZERO; private BigDecimal packAmount = BigDecimal.ZERO; + // 打折折扣金额 + private BigDecimal discountAmount = BigDecimal.ZERO; private boolean hasNewInfo = false; private List newOrderDetailList = new ArrayList<>(); private List removeOrderDetailList = new ArrayList<>(); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index caef29d2..35e4c816 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -229,12 +229,15 @@ public class TbCashierCart implements Serializable { if (discountRadio == null) { discountRadio = new BigDecimal("1"); } - resetTotalAmount(discountRadio); if (num == null) { num = totalNumber; } - return totalAmount.divide(totalNumber, 9, RoundingMode.HALF_UP).multiply(num).setScale(2, RoundingMode.HALF_UP); + if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { + return num.multiply(memberPrice).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP); + }else { + return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); + } // if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { // return num.multiply(memberPrice); // } else { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index dd334f6a..e7d41e52 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -583,12 +583,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); - tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setMemberPrice(productSku.getMemberPrice()); cashierCartRepository.save(tbCashierCart); } else { - tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice())); @@ -1277,7 +1277,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private BigDecimal reduceProCoupon(HashMap> couponMap, TbCashierCart cashierCart, HashMap> usedCouponMap, BigDecimal discountAmount, ArrayList balanceCartList, - ArrayList outRecords, Integer memberId) { + ArrayList outRecords, Integer memberId) { TbUserCouponVo couponVo = getCanUseCoupon(couponMap, cashierCart.getProductId()); if (couponVo != null && couponVo.getCurrentUseNum().compareTo(BigDecimal.ZERO) > 0) { BigDecimal currentUseNum; @@ -1291,7 +1291,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { couponVo.setCurrentUseNum(couponVo.getCurrentUseNum().subtract(cashierCart.getNumber())); currentUseNum = cashierCart.getNumber(); // 优惠券数量小于购物车数量,分割购物车数据 - }else if (cashierCart.getNumber().compareTo(couponVo.getCurrentUseNum()) > 0) { + } else if (cashierCart.getNumber().compareTo(couponVo.getCurrentUseNum()) > 0) { currentUseNum = couponVo.getCurrentUseNum(); BigDecimal cartNum = BigDecimal.valueOf(cashierCart.getNumber().intValue()); BigDecimal balanceNum = cashierCart.getTotalNumber().subtract(couponVo.getCurrentUseNum()); @@ -1307,7 +1307,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { currentUseNum = cashierCart.getNumber(); - // 创建结余购物车 balanceCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class); balanceCart.setUserCouponId(null); @@ -1318,7 +1317,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum, null).add(singlePackFee.multiply(balanceNum))); balanceCartList.add(balanceCart); } else { - currentUseNum =cashierCart.getNumber(); + currentUseNum = cashierCart.getNumber(); discountAmount = discountAmount.add(cashierCart.getTotalAmount()); cashierCart.setUserCouponId(couponVo.getId()); couponVo.setCurrentUseNum(couponVo.getCurrentUseNum().subtract(cashierCart.getNumber())); @@ -1369,7 +1368,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbUserCouponVos = new ArrayList<>(); tbUserCouponVos.add(item); couponMap.put(item.getProId().toString(), tbUserCouponVos); - }else { + } else { tbUserCouponVos.add(item); } }); @@ -1409,7 +1408,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { couponInfoDTO.setOutRecordList(outRecords); couponInfoDTO.setCouponMap(usedCouponMap); - return discountAmount.multiply(orderInfo.getDiscountRatio()); + return discountAmount; } private OrderCouponInfoDTO getCouponInfo(Integer memberId, Integer shopId, List userCouponInfoDTOList, BigDecimal orderAmount, Set productIds) { @@ -1467,7 +1466,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { List allCashierCarts; if (orderId != null) { allCashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId); - }else { + } else { allCashierCarts = mpCashierCartService.selectByShopEatType(shopEatTypeInfoDTO, masterId); } TbCashierCart seatCart = null; @@ -1586,11 +1585,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 已经退款和使用优惠券的商品不进行统计金额 if (!"return".equals(cashierCart.getStatus()) && cashierCart.getUserCouponId() == null) { + BigDecimal originalTotal = cashierCart.getTotalAmountByNum(cashierCart.getTotalNumber(), BigDecimal.ONE); + priceDTO.setDiscountAmount(priceDTO.getDiscountAmount().add(originalTotal.subtract(cashierCart.getTotalAmount()))); priceDTO.setTotalAmount(priceDTO.getTotalAmount().add(cashierCart.getTotalAmount())); priceDTO.setPackAmount(priceDTO.getPackAmount().add(cashierCart.getPackFee())); } - if(!"return".equals(cashierCart.getStatus())) { + if (!"return".equals(cashierCart.getStatus())) { priceDTO.setOriginAmount(priceDTO.getOriginAmount().add(cashierCart.getTotalAmount())); } @@ -2116,6 +2117,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 返还上次使用的券 returnCoupon(orderInfo, true); + // 设置折扣比例 + orderInfo.setDiscountRatio(payDTO.getDiscount()); Set productIdSet = new HashSet<>(); List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); @@ -2140,12 +2143,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 更新订单信息 ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(orderInfo.getShopId(), orderInfo.getTableId()); OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO); - BigDecimal finalAmount = priceDTO.getTotalAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP); + BigDecimal finalAmount = priceDTO.getTotalAmount().setScale(2, RoundingMode.HALF_UP); orderInfo.setUpdatedAt(System.currentTimeMillis()); orderInfo.setSettlementAmount(finalAmount); orderInfo.setAmount(finalAmount); orderInfo.setOrderAmount(finalAmount); + orderInfo.setDiscountAmount(priceDTO.getDiscountAmount()); // 计算订单优惠 TbActivateOutRecord outRecord = calcOrderInfoDiscount(payDTO, orderInfo, couponInfo); @@ -2251,17 +2255,17 @@ public class TbShopTableServiceImpl implements TbShopTableService { } BigDecimal finalAmount = null; - // 计算订单折扣信息 - if (payDTO.getDiscount().compareTo(new BigDecimal("1")) != 0) { - finalAmount = resetAmountByDiscount(payDTO, orderInfo); - }else { - finalAmount = orderInfo.getOrderAmount(); - } // 计算优惠券积分折扣信息 if (payDTO.getVipUserId() != null) { // 计算商品券折扣 finalAmount = calcDiscountAndUpdateInfo(payDTO, orderInfo); + } else { + if (payDTO.getDiscount().compareTo(new BigDecimal("1")) != 0) { + finalAmount = resetAmountByDiscount(payDTO, orderInfo); + } else { + finalAmount = orderInfo.getOrderAmount(); + } } boolean isOnline = false; @@ -2414,7 +2418,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { CreateOrderDTO dto = null; if (orderId != null) { TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId); - if(!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) { + if (!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) { throw new BadRequestException("订单状态异常"); } dto = new CreateOrderDTO(); @@ -2802,13 +2806,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { .add(returnPackFee); // 移除使用的券 couponInfoDTO.getProductCoupon().forEach(item -> { - if (Objects.equals(item.getId(), outRecord.getGiveId())) { - item.setReturnNum(item.getReturnNum() + outRecord.getRefNum()); - } + if (Objects.equals(item.getId(), outRecord.getGiveId())) { + item.setReturnNum(item.getReturnNum() + outRecord.getRefNum()); + } }); // 使用了满减或积分,获取普通付款商品计算退款比例,退部分现金 - }else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ + } else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0) { hasNormalReturn = true; // 计算当前商品占比 BigDecimal ratio = calcDetailRatio(orderDetail, returnNum); @@ -2820,7 +2824,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); - }else { + } else { hasNormalReturn = true; currentDetailAMount = orderDetail.getPriceAmount() .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) From 7b2cc558eb5287351fcc6c930539623a5936ccc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 14:22:54 +0800 Subject: [PATCH 069/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=AE=9E=E9=99=85=E9=80=80=E6=AC=BE=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 1 + 2 files changed, 2 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index dad7060d..98597ea9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -136,6 +136,7 @@ public class TbOrderDetail implements Serializable { private String discountSaleNote; private Boolean isPrint; private String useCouponInfo; + private BigDecimal returnAmount; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index e7d41e52..240d386e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2841,6 +2841,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setPackAmount(returnPackFee); orderDetail.setRefundNumber(returnNum); orderDetail.setReturnNum(returnNum.toPlainString()); + orderDetail.setReturnAmount(returnAmount); // orderDetail.setStatus(isOnline ? "refunding" : "refund"); orderDetail.setStatus("refund"); } From 3de6ed70809a3953462349d73ed923496945317f Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 22 Nov 2024 14:58:07 +0800 Subject: [PATCH 070/170] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=20=E5=92=8C?= =?UTF-8?q?=20=E6=A8=A1=E7=B3=8A=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java | 2 +- .../src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java | 2 +- .../cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java index 700b127c..4a7e0ba2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java @@ -35,7 +35,7 @@ public class TbShopInfoQueryCriteria{ private String account; /** 精确 */ - @Query(type = Query.Type.LEFT_LIKE) + @Query(type = Query.Type.INNER_LIKE) private String shopName; /** 精确 */ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java index e8302686..92017cf4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java @@ -274,7 +274,7 @@ public class TbShopInfo implements Serializable { @Column(name = "consume_colony") @ApiModelProperty(value = "积分群体 all-所有 vip-仅针对会员") - private String consumeColony; + private String consumeColony = "all"; @Column(name = "is_table_fee") @ApiModelProperty(value = "是否免除桌位费 0否1是") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 8b8f6599..64c840ee 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -186,6 +186,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); tbShopInfo.setOnSale(1); tbShopInfo.setIsOpenYhq(resources.getIsOpenYhq()); + tbShopInfo.setConsumeColony("all"); //激活码 TbMerchantRegister tbMerchantRegister = new TbMerchantRegister(); if (resources.getRegisterCode() != null){ From 31965da486974ca56b757afe7c3349d5b81a6fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 15:02:13 +0800 Subject: [PATCH 071/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 240d386e..29b74356 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2818,7 +2818,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal ratio = calcDetailRatio(orderDetail, returnNum); currentDetailAMount = orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); - returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().multiply(ratio)); + if (oldOrderInfo.getRefundAmount() == null) { + oldOrderInfo.setRefundAmount(BigDecimal.ZERO); + } + 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) @@ -2894,7 +2897,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } private BigDecimal calcDetailRatio(TbOrderDetail orderDetail, BigDecimal returnNum) { - List detailList = mpOrderDetailService.selectByOrderIdAndState(orderDetail.getOrderId(), TableConstant.OrderInfo.Status.CLOSED, TableConstant.OrderInfo.Status.REFUND); + List detailList = mpOrderDetailService.selectByOrderIdAndState(orderDetail.getOrderId(), TableConstant.OrderInfo.Status.CLOSED); BigDecimal totalAmount = BigDecimal.ZERO; for (TbOrderDetail item : detailList) { if (item.getUserCouponId() == null) { From 38dc6da10ce5dbbfcfadb7e35d9ad008141fbcd5 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 22 Nov 2024 15:05:33 +0800 Subject: [PATCH 072/170] =?UTF-8?q?=E5=BA=97=E9=93=BA=20=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java index 4a7e0ba2..f1488665 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java @@ -17,6 +17,7 @@ package cn.ysk.cashier.dto.shop; import lombok.Data; import cn.ysk.cashier.annotation.Query; +import org.apache.commons.lang3.StringUtils; /** * @website https://eladmin.vip @@ -71,4 +72,10 @@ public class TbShopInfoQueryCriteria{ private Integer size; private String sort; + + public void setShopName(String shopName) { + if(StringUtils.isNotBlank(shopName)){ + this.shopName = shopName; + } + } } \ No newline at end of file From a8ed1b945c226fe40904761db8b643ba3187fcb6 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 22 Nov 2024 15:13:24 +0800 Subject: [PATCH 073/170] =?UTF-8?q?=E5=BA=97=E9=93=BA=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java index f1488665..e4b64d48 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java @@ -39,6 +39,9 @@ public class TbShopInfoQueryCriteria{ @Query(type = Query.Type.INNER_LIKE) private String shopName; + @Query + private String type; + /** 精确 */ @Query private String phone; @@ -73,6 +76,12 @@ public class TbShopInfoQueryCriteria{ private String sort; + public void setType(String type) { + if(StringUtils.isNotBlank(type)){ + this.type = type; + } + } + public void setShopName(String shopName) { if(StringUtils.isNotBlank(shopName)){ this.shopName = shopName; From dd7bf372b557dc61b461b11e2f4e5eb4807d1076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 15:17:16 +0800 Subject: [PATCH 074/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 29b74356..8eeab0a7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2817,7 +2817,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 计算当前商品占比 BigDecimal ratio = calcDetailRatio(orderDetail, returnNum); currentDetailAMount = orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) - .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); + .multiply(returnNum).setScale(2, RoundingMode.DOWN); if (oldOrderInfo.getRefundAmount() == null) { oldOrderInfo.setRefundAmount(BigDecimal.ZERO); } @@ -2905,8 +2905,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { } } - return orderDetail.getPriceAmount().divide(totalAmount, 8, RoundingMode.HALF_UP) - .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP).multiply(returnNum).setScale(2, RoundingMode.HALF_UP); + return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.DOWN) + .divide(orderDetail.getNum(), 10, RoundingMode.DOWN).multiply(returnNum).setScale(2, RoundingMode.DOWN); } private void updateStockAndRecord(List orderDetailList) { From 1546b0ee605dd66a67caa9319aaa35e24d3d965e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 15:26:06 +0800 Subject: [PATCH 075/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 8eeab0a7..81ac385f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2821,7 +2821,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (oldOrderInfo.getRefundAmount() == null) { oldOrderInfo.setRefundAmount(BigDecimal.ZERO); } - returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount()).multiply(ratio)); + + 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) @@ -2838,6 +2843,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); } + returnAmount = returnAmount.setScale(2, RoundingMode.DOWN); orderDetail.setNum(returnNum); orderDetail.setPriceAmount(currentDetailAMount); @@ -2904,6 +2910,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { totalAmount = totalAmount.add(item.getPriceAmount()); } } + if (orderDetail.getPriceAmount().compareTo(totalAmount) == 0) { + return BigDecimal.ONE; + } return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.DOWN) .divide(orderDetail.getNum(), 10, RoundingMode.DOWN).multiply(returnNum).setScale(2, RoundingMode.DOWN); From e058072d966297ba340462dcffe37e4b6ee1a9e3 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 22 Nov 2024 15:26:34 +0800 Subject: [PATCH 076/170] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/TbShopInfoController.java | 3 ++- .../cn/ysk/cashier/pojo/shop/TbShopInfo.java | 20 +++++++++---------- .../impl/shopimpl/TbShopInfoServiceImpl.java | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index 9b0f57f3..495c92f8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -54,7 +55,7 @@ public class TbShopInfoController { put("token", properties.getTokenStartWith() + token); if (shopInfo != null) { put("shopId", shopInfo.getId()); - put("mainId", shopInfo.getMainId()); + put("mainId", StringUtils.isNotBlank(shopInfo.getMainId())?shopInfo.getId():shopInfo.getMainId()); put("loginType", "merchant"); put("shopName", shopInfo.getShopName()); put("logo", shopInfo.getLogo()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java index 92017cf4..f1b7e545 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java @@ -179,7 +179,7 @@ public class TbShopInfo implements Serializable { @Column(name = "`on_sale`") @ApiModelProperty(value = "0停业1,正常营业,网上售卖") - private Integer onSale; + private Integer onSale = 1; @Column(name = "`settle_type`") @ApiModelProperty(value = "0今日,1次日") @@ -252,25 +252,25 @@ public class TbShopInfo implements Serializable { @Column(name = "is_custom") @ApiModelProperty(value = "是否允许用户自定义金额") - private String isCustom; + private String isCustom = "0"; @Column(name = "is_return") - @ApiModelProperty(value = "是否允许用户自定义金额") - private String isReturn; + @ApiModelProperty(value = "是否开启退款密码 ") + private String isReturn = "0"; @Column(name = "is_member_in") - @ApiModelProperty(value = "是否允许用户自定义金额") - private String isMemberIn; + @ApiModelProperty(value = "是否开启会员充值密码 ") + private String isMemberIn = "0"; @Column(name = "is_member_return") - @ApiModelProperty(value = "是否允许用户自定义金额") - private String isMemberReturn; + @ApiModelProperty(value = "是否开启会员退款密码 ") + private String isMemberReturn = "0"; @Column(name = "is_member_price") @ApiModelProperty(value = "是否启用会员价 0否1是") - private Integer isMemberPrice; + private Integer isMemberPrice = 0; @Column(name = "consume_colony") @ApiModelProperty(value = "积分群体 all-所有 vip-仅针对会员") @@ -278,7 +278,7 @@ public class TbShopInfo implements Serializable { @Column(name = "is_table_fee") @ApiModelProperty(value = "是否免除桌位费 0否1是") - private Integer isTableFee; + private Integer isTableFee = 1; @Column(name = "table_fee") @ApiModelProperty(value = "桌位费") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 64c840ee..d6e52d54 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -1,5 +1,7 @@ package cn.ysk.cashier.service.impl.shopimpl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; @@ -181,12 +183,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { } TbShopInfo tbShopInfo = new TbShopInfo(); - BeanUtils.copyProperties(resources,tbShopInfo); + BeanUtil.copyProperties(resources,tbShopInfo, CopyOptions.create().setIgnoreNullValue(true)); tbShopInfo.setCreatedAt(Instant.now().toEpochMilli()); tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); - tbShopInfo.setOnSale(1); tbShopInfo.setIsOpenYhq(resources.getIsOpenYhq()); - tbShopInfo.setConsumeColony("all"); //激活码 TbMerchantRegister tbMerchantRegister = new TbMerchantRegister(); if (resources.getRegisterCode() != null){ From c63f439a08dcc7e977afd9523e96777b01c088ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 15:42:21 +0800 Subject: [PATCH 077/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 81ac385f..04249f8a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2771,6 +2771,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { 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()); // 剩余数量 @@ -2781,19 +2784,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 将未退款的剩余订单详情重新生成记录 BigDecimal packFee = orderDetail.getPackAmount().divide(orderDetail.getNum(), RoundingMode.HALF_UP); - if (remainNum.compareTo(BigDecimal.ZERO) > 0) { - // 单个打包费 - BigDecimal remainPackFee = packFee.multiply(remainNum); - TbOrderDetail remainOrderDetail = BeanUtil.copyProperties(orderDetail, TbOrderDetail.class); - remainOrderDetail.setNum(remainNum); - remainOrderDetail.setPriceAmount(remainNum.multiply(orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)) - .add(remainPackFee).setScale(2, RoundingMode.HALF_UP)); - remainOrderDetail.setPackAmount(remainPackFee); - remainOrderDetail.setReturnNum("0"); - remainOrderDetail.setId(null); - remainOrderDetailList.add(remainOrderDetail); - } - BigDecimal returnPackFee = packFee.multiply(returnNum); BigDecimal currentDetailAMount = BigDecimal.ZERO; // 优惠券抵扣商品直接退券 @@ -2834,17 +2824,33 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else { hasNormalReturn = true; - currentDetailAMount = orderDetail.getPriceAmount() - .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) - .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); - returnAmount = returnAmount.add(currentDetailAMount); saleAmount = saleAmount.add(orderDetail.getPrice()); - packAMount = packAMount.add(orderDetail.getPackAmount() - .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) - .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); + if (remainNum.compareTo(BigDecimal.ZERO) > 0) { + returnAmount = orderDetail.getPriceAmount(); + packAMount = orderDetail.getPackAmount(); + }else { + 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); + } } returnAmount = returnAmount.setScale(2, RoundingMode.DOWN); + if (remainNum.compareTo(BigDecimal.ZERO) > 0) { + // 单个打包费 + TbOrderDetail remainOrderDetail = BeanUtil.copyProperties(orderDetail, TbOrderDetail.class); + remainOrderDetail.setNum(remainNum); + remainOrderDetail.setPriceAmount(originalAmount.subtract(returnAmount)); + remainOrderDetail.setPackAmount(originalPackAmount.subtract(returnPackFee)); + remainOrderDetail.setReturnNum("0"); + remainOrderDetail.setId(null); + remainOrderDetailList.add(remainOrderDetail); + } + orderDetail.setNum(returnNum); orderDetail.setPriceAmount(currentDetailAMount); orderDetail.setPackAmount(returnPackFee); From 52b29f4179291720a1b37bbe1945034bebdcf279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 15:42:38 +0800 Subject: [PATCH 078/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 04249f8a..0aec8013 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2825,7 +2825,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else { hasNormalReturn = true; saleAmount = saleAmount.add(orderDetail.getPrice()); - if (remainNum.compareTo(BigDecimal.ZERO) > 0) { + if (remainNum.compareTo(BigDecimal.ZERO) <= 0) { returnAmount = orderDetail.getPriceAmount(); packAMount = orderDetail.getPackAmount(); }else { From 5a0e799e96ab0748531b8819be1e385bcb53cdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 16:29:44 +0800 Subject: [PATCH 079/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 0aec8013..90ff9673 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2118,7 +2118,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { returnCoupon(orderInfo, true); // 设置折扣比例 - orderInfo.setDiscountRatio(payDTO.getDiscount()); + orderInfo.setDiscountRatio(payDTO.getDiscount().setScale(4, RoundingMode.DOWN)); Set productIdSet = new HashSet<>(); List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); From a0ec9bbede03ce05380e1d0c450fd638f2c0b77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Fri, 22 Nov 2024 17:09:17 +0800 Subject: [PATCH 080/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=94=B5=E8=AF=9D=E6=9C=BA=E9=A2=84=E7=BA=A6=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booking/TbShopTableBookingController.java | 97 +++++++ .../credit/TbCreditBuyerController.java | 63 +++++ .../credit/TbCreditBuyerOrderController.java | 48 ++++ .../TbCreditPaymentRecordController.java | 37 +++ .../dto/booking/ShopTableBookingDTO.java | 16 ++ .../dto/shop/TbShopTableQueryCriteria.java | 17 +- .../cashier/mybatis/entity/TbCreditBuyer.java | 96 +++++++ .../mybatis/entity/TbCreditBuyerOrder.java | 61 ++++ .../mybatis/entity/TbCreditPaymentRecord.java | 57 ++++ .../mybatis/entity/TbShopTableBooking.java | 129 +++++++++ .../mybatis/mapper/TbCreditBuyerMapper.java | 16 ++ .../mapper/TbCreditBuyerOrderMapper.java | 16 ++ .../mapper/TbCreditPaymentRecordMapper.java | 16 ++ .../mapper/TbShopTableBookingMapper.java | 16 ++ .../service/TbCreditBuyerOrderService.java | 19 ++ .../mybatis/service/TbCreditBuyerService.java | 24 ++ .../service/TbCreditPaymentRecordService.java | 18 ++ .../service/TbShopTableBookingService.java | 39 +++ .../impl/TbCreditBuyerOrderServiceImpl.java | 37 +++ .../impl/TbCreditBuyerServiceImpl.java | 134 +++++++++ .../TbCreditPaymentRecordServiceImpl.java | 32 +++ .../impl/TbShopTableBookingServiceImpl.java | 265 ++++++++++++++++++ .../cn/ysk/cashier/pojo/shop/TbShopInfo.java | 12 +- .../impl/shopimpl/TbShopTableServiceImpl.java | 4 + 24 files changed, 1263 insertions(+), 6 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java new file mode 100644 index 00000000..7edc9167 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java @@ -0,0 +1,97 @@ +package cn.ysk.cashier.controller.booking; + +import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; +import cn.ysk.cashier.pojo.shop.TbShopArea; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@RestController +@RequestMapping("/api/booking/shop-table") +@Api(tags = "店铺台桌预订") +public class TbShopTableBookingController { + + @Resource + private TbShopTableBookingService tbShopTableBookingService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map data = tbShopTableBookingService.page(params); + return ResponseEntity.ok().body(data); + } + + @GetMapping("{id}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("id") Long id) { + TbShopTableBooking data = tbShopTableBookingService.getById(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("预订") + public ResponseEntity booking(@RequestBody TbShopTableBooking dto) { + String orderNo = tbShopTableBookingService.booking(dto); + Map data = new HashMap<>(2); + data.put("id", dto.getId()); + data.put("orderNo", orderNo); + return ResponseEntity.ok().body(data); + } + + @PutMapping + @ApiOperation("修改预订信息") + public ResponseEntity update(@RequestBody TbShopTableBooking dto) { + boolean ret = tbShopTableBookingService.update(dto); + return ResponseEntity.ok().body(ret); + } + + @PostMapping("mark-status") + @ApiOperation("修改预订状态") + public ResponseEntity markStatus(@RequestBody TbShopTableBooking dto) { + tbShopTableBookingService.markStatus(dto.getId(), dto.getStatus()); + return ResponseEntity.ok().build(); + } + + @DeleteMapping("/delete/{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") Long id) { + tbShopTableBookingService.delete(id); + return ResponseEntity.ok().build(); + } + + @GetMapping("sms/{id}") + @ApiOperation("获取待发送的短信内容") + public ResponseEntity sms(@PathVariable("id") Long id) { + String smsContent = tbShopTableBookingService.getBookingSms(id); + return ResponseEntity.ok().body(smsContent); + } + + @GetMapping("area") + @ApiOperation("获取区域列表") + public ResponseEntity areaList(@RequestParam Integer shopId) { + List list = tbShopTableBookingService.findShopAreaList(shopId); + return ResponseEntity.ok().body(list); + } + + @GetMapping("list") + @ApiOperation("获取台桌列表") + public ResponseEntity list(@RequestParam Map params) { + List list = tbShopTableBookingService.findShopTableList(params); + return ResponseEntity.ok().body(list); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java new file mode 100644 index 00000000..3f432be9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java @@ -0,0 +1,63 @@ +package cn.ysk.cashier.controller.credit; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; +import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + + +/** +* 挂账人 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@RestController +@RequestMapping("/api/credit/buyer") +@Tag(name = "挂账人") +public class TbCreditBuyerController { + + @Resource + private TbCreditBuyerService tbCreditBuyerService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params){ + Map page = tbCreditBuyerService.page(params); + return ResponseEntity.ok().body(page); + } + + + @GetMapping("{id}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("id") String id){ + TbCreditBuyer data = tbCreditBuyerService.getById(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("保存") + public ResponseEntity save(@RequestBody TbCreditBuyer entity){ + boolean ret = tbCreditBuyerService.save(entity); + return ResponseEntity.ok().body(ret); + } + + @PutMapping + @ApiOperation("修改") + public ResponseEntity update(@RequestBody TbCreditBuyer dto){ + boolean ret = tbCreditBuyerService.update(dto); + return ResponseEntity.ok().body(ret); + } + + @DeleteMapping("{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") String id){ + tbCreditBuyerService.delete(id); + return ResponseEntity.ok().build(); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java new file mode 100644 index 00000000..a96e23b5 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java @@ -0,0 +1,48 @@ +package cn.ysk.cashier.controller.credit; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + + +/** +* 挂账账单 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@RestController +@RequestMapping("/api/credit/buyer-order") +@Api(tags = "挂账账单") +public class TbCreditBuyerOrderController { + + @Resource + private TbCreditBuyerOrderService tbCreditBuyerOrderService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params){ + Map page = tbCreditBuyerOrderService.page(params); + return ResponseEntity.ok().body(page); + } + + @PostMapping("pay") + @ApiOperation("付款") + public ResponseEntity pay(@RequestBody TbCreditBuyerOrder dto){ + boolean ret = tbCreditBuyerOrderService.save(dto); + return ResponseEntity.ok().body(ret); + } + + @GetMapping("summary") + @ApiOperation("统计") + public ResponseEntity summary(@RequestParam Map params){ + Map data = tbCreditBuyerOrderService.summary(params); + return ResponseEntity.ok().body(data); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java new file mode 100644 index 00000000..ef5db472 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java @@ -0,0 +1,37 @@ +package cn.ysk.cashier.controller.credit; + +import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +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; + +import javax.annotation.Resource; +import java.util.Map; + + +/** +* 挂账账单付款记录 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@RestController +@RequestMapping("/api/credit/payment-record") +@Api(tags = "挂账账单付款记录") +public class TbCreditPaymentRecordController { + + @Resource + private TbCreditPaymentRecordService tbCreditPaymentRecordService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params){ + Map page = tbCreditPaymentRecordService.page(params); + return ResponseEntity.ok().body(page); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java new file mode 100644 index 00000000..1d673f4f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.dto.booking; + +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.pojo.shop.TbShopTable; +import lombok.Data; + +/** + * 店铺台桌及预订信息 + * + * @author tankaikai + * @since 2024-11-22 11:24 + */ +@Data +public class ShopTableBookingDTO extends TbShopTable { + private TbShopTableBooking bookingInfo; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java index 72099d7d..ef4b3645 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java @@ -15,9 +15,8 @@ */ package cn.ysk.cashier.dto.shop; -import cn.ysk.cashier.enums.TableStateEnum; -import lombok.Data; import cn.ysk.cashier.annotation.Query; +import lombok.Data; import javax.validation.constraints.NotNull; @@ -43,8 +42,22 @@ public class TbShopTableQueryCriteria{ @Query private Long qrcode; + + /** + * 是否接受网络预订 + */ + @Query + private Integer isPredate; private String state; private Integer page = 1; private Integer size = 99999; + + public Integer getIsPredate() { + return isPredate; + } + + public void setIsPredate(Integer isPredate) { + this.isPredate = isPredate; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java new file mode 100644 index 00000000..7ca67722 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java @@ -0,0 +1,96 @@ +package cn.ysk.cashier.mybatis.entity; + +import cn.hutool.core.util.NumberUtil; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +/** + * 挂账人 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_credit_buyer") +public class TbCreditBuyer { + private static final long serialVersionUID = 1L; + + /** + * 挂账编码 + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + /** + * 店铺id + */ + private Integer shopId; + /** + * 状态 1-启用 0-停用 + */ + private Integer status; + /** + * 挂账人 + */ + private String debtor; + /** + * 手机号 + */ + private String mobile; + /** + * 职务 + */ + private String position; + /** + * 挂账额度 + */ + private BigDecimal creditAmount; + /** + * 还款方式 total-按总金额还款 order-按订单还款 + */ + private String repaymentMethod; + /** + * 支付方式 + */ + private String paymentMethod; + /** + * 备注 + */ + private String remark; + /** + * 删除标志 0-正常 1-删除 + */ + private Integer delFlag; + + + /** + * 已挂账金额 + */ + @TableField(value = "(select sum(unpaid_amount) from view_credit_buyer_order where credit_buyer_id = id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private BigDecimal owedAmount; + + /** + * 剩余挂账额度 + */ + @TableField(exist = false) + private BigDecimal remainingAmount; + + /** + * 累计挂账金额 + */ + @TableField(value = "(select sum(pay_amount) from view_credit_buyer_order where credit_buyer_id = id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private BigDecimal accumulateAmount; + + /** + * 适用门店 + */ + @TableField(value = "(select shop_name from tb_shop_info where id = shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private String shopName; + + public BigDecimal getRemainingAmount() { + return NumberUtil.sub(creditAmount, NumberUtil.null2Zero(owedAmount)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java new file mode 100644 index 00000000..675c316e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java @@ -0,0 +1,61 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_credit_buyer_order") +public class TbCreditBuyerOrder { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 已付金额 + */ + private BigDecimal paidAmount; + /** + * 未付金额 + */ + private BigDecimal unpaidAmount; + /** + * 状态 unpaid-未付款 paid-已付款 + */ + private String status; + /** + * 最近一次付款时间 + */ + private Date lastPaymentTime; + /** + * 最近一次付款方式 + */ + private String lastPaymentMethod; + /** + * 备注 + */ + private String remark; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java new file mode 100644 index 00000000..0d161a39 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java @@ -0,0 +1,57 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 挂账账单付款记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_credit_payment_record") +public class TbCreditPaymentRecord { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 还款金额 + */ + private BigDecimal repaymentAmount; + /** + * 支付方式 + */ + private String paymentMethod; + /** + * 备注 + */ + private String remark; + /** + * 还款时间 + */ + private Date paymentTime; + /** + * 操作时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java new file mode 100644 index 00000000..d5e8b9a6 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java @@ -0,0 +1,129 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_shop_table_booking") +public class TbShopTableBooking { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺桌台id + */ + private Integer shopTableId; + /** + * 店铺id + */ + private Integer shopId; + /** + * 订单编号 + */ + private String orderNo; + /** + * 预约日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @JSONField(format = "yyyy-MM-dd") + private Date bookingDate; + /** + * 预约类型 lunch-午餐 dinner-晚餐 + */ + private String bookingType; + /** + * 用餐人数 + */ + private Integer dinerNum; + /** + * 电话号码 + */ + private String phoneNumber; + /** + * 订餐人 + */ + private String bookingPerson; + /** + * 性别/称呼 1-先生 2-女士 + */ + private Integer gender; + /** + * 预约时间 + */ + private Date bookingTime; + /** + * 用餐类型 普通用餐/宴会套餐/自助餐/...,由前端定义或者输入文本 + */ + private String diningType; + /** + * 重点关注 1-是 0-否 + */ + private Integer focus; + /** + * 接收营销短信 1-是 0-否 + */ + private Integer receiveMarketingSms; + /** + * 摆台桌数 + */ + private Integer bookingTableNum; + /** + * 餐标(单价) + */ + private BigDecimal diningStandardPrice; + /** + * 餐标(单位) table-元/桌 person-元/人 + */ + private String diningStandardUnit; + /** + * 预订状态 -1-已取消 10-已到店 20-待到店 999-已超时 + * 注:此处定义为数字是为了方便按状态排序 + */ + private Integer status; + /** + * 留座时间 + */ + private Integer timeoutMinute; + /** + * 操作时间 + */ + private Date createTime; + /** + * 操作人 + */ + private String createUserName; + /** + * 到店时间 + */ + @TableField(value = "arrived_time", updateStrategy = FieldStrategy.ALWAYS) + private Date arrivedTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 备注 + */ + private String remark; + /** + * 删除标志 1-是 0-否 + */ + private Integer delFlag; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java new file mode 100644 index 00000000..e4a8efc4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* 挂账人 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@Mapper +public interface TbCreditBuyerMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java new file mode 100644 index 00000000..ff9f0290 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* 挂账账单 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@Mapper +public interface TbCreditBuyerOrderMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java new file mode 100644 index 00000000..ad01d1d3 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* 挂账账单付款记录 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@Mapper +public interface TbCreditPaymentRecordMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java new file mode 100644 index 00000000..c7f465e4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* 店铺台桌预订 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-21 +*/ +@Mapper +public interface TbShopTableBookingMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java new file mode 100644 index 00000000..1ebcb706 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java @@ -0,0 +1,19 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +public interface TbCreditBuyerOrderService extends IService { + + Map page(Map params); + Map summary(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java new file mode 100644 index 00000000..d8842225 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java @@ -0,0 +1,24 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 挂账人 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +public interface TbCreditBuyerService extends IService { + + Map page(Map params); + + boolean save(TbCreditBuyer entity); + + boolean update(TbCreditBuyer dto); + + void delete(String id); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java new file mode 100644 index 00000000..fd9b5946 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 挂账账单付款记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +public interface TbCreditPaymentRecordService extends IService { + + Map page(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java new file mode 100644 index 00000000..03c2d7e8 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java @@ -0,0 +1,39 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.pojo.shop.TbShopArea; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; +import java.util.Map; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +public interface TbShopTableBookingService extends IService { + + Map page(Map params); + + String booking(TbShopTableBooking entity); + + boolean update(TbShopTableBooking dto); + + void markStatus(Long id, Integer status); + + void delete(Long id); + + /** + * 获取待发送的短信内容 + * @param id 预订id + */ + String getBookingSms(Long id); + + List findShopAreaList(Integer shopId); + + List findShopTableList(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java new file mode 100644 index 00000000..7f63f00c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -0,0 +1,37 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Service +public class TbCreditBuyerOrderServiceImpl extends ServiceImpl implements TbCreditBuyerOrderService { + + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + wrapper.orderByDesc("id"); + return wrapper; + } + + @Override + public Map page(Map params) { + return null; + } + + @Override + public Map summary(Map params) { + return null; + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java new file mode 100644 index 00000000..c2245f70 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -0,0 +1,134 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.lang.Validator; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +/** + * 挂账人 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Service +public class TbCreditBuyerServiceImpl extends ServiceImpl implements TbCreditBuyerService { + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String keywords = mapProxy.getStr("keywords"); + TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbCreditBuyer::getShopId, param.getShopId()); + wrapper.eq(StrUtil.isNotEmpty(param.getId()), TbCreditBuyer::getId, param.getId()); + wrapper.eq(param.getStatus() != null, TbCreditBuyer::getStatus, param.getStatus()); + if (StrUtil.isNotEmpty(keywords)) { + wrapper.nested(i -> i.like(TbCreditBuyer::getDebtor, keywords).or().like(TbCreditBuyer::getMobile, keywords)); + } + wrapper.eq(TbCreditBuyer::getDelFlag, 0); + wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName); + wrapper.orderByDesc(TbCreditBuyer::getStatus); + wrapper.orderByDesc(TbCreditBuyer::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + private void commonVerify(TbCreditBuyer entity) { + try { + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notNull(entity.getStatus(), "{}({})不能为空", "状态", "status"); + Assert.notEmpty(entity.getDebtor(), "{}({})不能为空", "挂账人", "debtor"); + Assert.notEmpty(entity.getMobile(), "{}({})不能为空", "手机号", "mobile"); + Assert.notNull(entity.getCreditAmount(), "{}({})不能为空", "挂账额度", "creditAmount"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + if (!Validator.isMobile(entity.getMobile())) { + throw new BadRequestException(StrUtil.format("{}({})不合法", "手机号", "mobile")); + } + if (NumberUtil.isLessOrEqual(entity.getCreditAmount(), BigDecimal.ZERO)) { + throw new BadRequestException(StrUtil.format("{}({})必须大于0", "挂账额度", "creditAmount")); + } + } + + @Override + public boolean save(TbCreditBuyer entity) { + commonVerify(entity); + try { + Assert.notEmpty(entity.getRepaymentMethod(), "{}({})不能为空", "还款方式", "repaymentMethod"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + if (!ArrayUtil.contains(new String[]{"total", "order"}, entity.getRepaymentMethod())) { + throw new BadRequestException(StrUtil.format("{}({})不合法", "还款方式", "repaymentMethod")); + } + return super.save(entity); + } + + @Override + public boolean update(TbCreditBuyer dto) { + try { + Assert.notEmpty(dto.getId(), "{}不能为空", "id"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + commonVerify(dto); + TbCreditBuyer entity = super.getById(dto.getId()); + if (entity == null) { + throw new BadRequestException("挂账人不存在"); + } + Map params = new HashMap<>(); + params.put("id", dto.getId()); + params.put("shopId", dto.getShopId()); + LambdaQueryWrapper wrapper = getWrapper(params); + entity = baseMapper.selectOne(wrapper); + + // 验证挂账额度是否小于已挂账金额 + boolean less = NumberUtil.isLess(dto.getCreditAmount(), NumberUtil.null2Zero(entity.getOwedAmount())); + if (less) { + throw new BadRequestException(StrUtil.format("{}({})不能小于已挂账金额({})", "挂账额度", "creditAmount", entity.getOwedAmount())); + } + BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false).setIgnoreProperties("repaymentMethod")); + return super.updateById(entity); + } + + @Override + public void delete(String id) { + try { + Assert.notEmpty(id, "{}不能为空", "id"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + super.update(Wrappers.lambdaUpdate().set(TbCreditBuyer::getDelFlag, 1).eq(TbCreditBuyer::getId, id)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java new file mode 100644 index 00000000..d42fac80 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java @@ -0,0 +1,32 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; +import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 挂账账单付款记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Service +public class TbCreditPaymentRecordServiceImpl extends ServiceImpl implements TbCreditPaymentRecordService { + + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + wrapper.orderByDesc("id"); + return wrapper; + } + + @Override + public Map page(Map params) { + return null; + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java new file mode 100644 index 00000000..5bcfb06c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -0,0 +1,265 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.mybatis.mapper.MpShopAreaMapper; +import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper; +import cn.ysk.cashier.mybatis.mapper.TbShopTableBookingMapper; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; +import cn.ysk.cashier.pojo.shop.TbShopArea; +import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.pojo.shop.TbShopTable; +import cn.ysk.cashier.repository.shop.TbShopInfoRepository; +import cn.ysk.cashier.utils.PageUtil; +import cn.ysk.cashier.utils.SecurityUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@Service +public class TbShopTableBookingServiceImpl extends ServiceImpl implements TbShopTableBookingService { + + private static final Map BOOKING_TYPE = MapUtil.builder("lunch", "午餐") + .put("dinner", "晚餐") + .build(); + + @Resource + private TbShopInfoRepository tbShopInfoRepository; + + @Resource + private MpShopTableMapper mpShopTableMapper; + + @Resource + private MpShopAreaMapper mpShopAreaMapper; + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String keywords = mapProxy.getStr("keywords"); + TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbShopTableBooking::getShopId, param.getShopId()); + wrapper.eq(param.getId() != null, TbShopTableBooking::getId, param.getId()); + wrapper.like(StrUtil.isNotEmpty(param.getOrderNo()), TbShopTableBooking::getOrderNo, param.getOrderNo()); + wrapper.eq(param.getBookingDate() != null, TbShopTableBooking::getBookingDate, param.getBookingDate()); + wrapper.eq(StrUtil.isNotEmpty(param.getBookingType()), TbShopTableBooking::getBookingType, param.getBookingType()); + wrapper.like(StrUtil.isNotEmpty(param.getDiningType()), TbShopTableBooking::getDiningType, param.getDiningType()); + wrapper.eq(param.getFocus() != null, TbShopTableBooking::getFocus, param.getFocus()); + wrapper.eq(param.getReceiveMarketingSms() != null, TbShopTableBooking::getReceiveMarketingSms, param.getReceiveMarketingSms()); + wrapper.eq(param.getReceiveMarketingSms() != null, TbShopTableBooking::getReceiveMarketingSms, param.getReceiveMarketingSms()); + wrapper.eq(param.getStatus() != null, TbShopTableBooking::getStatus, param.getStatus()); + if (StrUtil.isNotEmpty(keywords)) { + wrapper.nested(i -> i.like(TbShopTableBooking::getBookingPerson, keywords).or().like(TbShopTableBooking::getPhoneNumber, keywords)); + } + wrapper.eq(TbShopTableBooking::getDelFlag, 0); + wrapper.orderByDesc(TbShopTableBooking::getFocus); + wrapper.orderByDesc(TbShopTableBooking::getStatus); + wrapper.orderByAsc(TbShopTableBooking::getBookingTime); + wrapper.orderByDesc(TbShopTableBooking::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + private void commonVerify(TbShopTableBooking entity) { + try { + Assert.notNull(entity.getShopTableId(), "{}({})不能为空", "台桌id", "shopTableId"); + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notNull(entity.getBookingDate(), "{}({})不能为空", "预约日期", "bookingDate"); + Assert.notEmpty(entity.getBookingType(), "{}({})不能为空", "预订类型(午餐/晚餐)", "bookingType"); + Assert.notNull(entity.getDinerNum(), "{}({})不能为空", "用餐人数", "dinerNum"); + Assert.notEmpty(entity.getPhoneNumber(), "{}({})不能为空", "电话号码", "phoneNumber"); + Assert.notEmpty(entity.getBookingPerson(), "{}({})不能为空", "订餐人", "bookingPerson"); + Assert.notNull(entity.getGender(), "{}({})不能为空", "性别/称呼", "gender"); + Assert.notNull(entity.getBookingTime(), "{}({})不能为空", "约定时间", "bookingTime"); + Assert.notEmpty(entity.getDiningType(), "{}({})不能为空", "用餐类型", "diningType"); + Assert.notNull(entity.getFocus(), "{}({})不能为空", "重点关注", "focus"); + Assert.notNull(entity.getReceiveMarketingSms(), "{}({})不能为空", "接收营销短信", "receiveMarketingSms"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + } + + @Override + public String booking(TbShopTableBooking entity) { + commonVerify(entity); + if (DateUtil.compare(entity.getBookingTime(), new Date()) < 0) { + throw new BadRequestException("预订日期(bookingDate)不能小于今天"); + } + long existCount = baseMapper.selectCount(Wrappers.lambdaQuery() + .eq(TbShopTableBooking::getShopId, entity.getShopId()) + .eq(TbShopTableBooking::getShopTableId, entity.getShopTableId()) + .eq(TbShopTableBooking::getBookingDate, entity.getBookingDate()) + .eq(TbShopTableBooking::getBookingType, entity.getBookingType()) + .ne(TbShopTableBooking::getStatus, -1) + .eq(TbShopTableBooking::getDelFlag, 0) + ); + if (existCount > 0) { + throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate()))); + } + String randomStr = RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER, 4); + String orderNo = DateUtil.format(new Date(), "yyMMddHHmmss") + "-" + randomStr.toUpperCase(); + entity.setOrderNo("BK" + orderNo); + entity.setStatus(20); + entity.setCreateTime(new Date()); + entity.setCreateUserName(SecurityUtils.getCurrentUserNickName()); + entity.setDelFlag(0); + super.save(entity); + return entity.getOrderNo(); + } + + @Override + public boolean update(TbShopTableBooking dto) { + if (dto.getId() == null) { + throw new BadRequestException("id不能为空"); + } + commonVerify(dto); + TbShopTableBooking entity = super.getById(dto.getId()); + if (entity == null) { + throw new BadRequestException("预订信息不存在"); + } + if (DateUtil.compare(dto.getBookingTime(), new Date()) < 0) { + throw new BadRequestException("预订日期(bookingDate)不能小于今天"); + } + long existCount = baseMapper.selectCount(Wrappers.lambdaQuery() + .ne(TbShopTableBooking::getId, entity.getId()) + .eq(TbShopTableBooking::getShopId, dto.getShopId()) + .eq(TbShopTableBooking::getShopTableId, dto.getShopTableId()) + .eq(TbShopTableBooking::getBookingDate, dto.getBookingDate()) + .eq(TbShopTableBooking::getBookingType, dto.getBookingType()) + .ne(TbShopTableBooking::getStatus, -1) + .eq(TbShopTableBooking::getDelFlag, 0) + ); + if (existCount > 0) { + throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate()))); + } + BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(true).setIgnoreProperties("orderNo", "status", "createTime", "createUserName", "delFlag")); + entity.setUpdateTime(new Date()); + return super.updateById(entity); + } + + @Override + public void markStatus(Long id, Integer status) { + if (id == null) { + throw new BadRequestException("id不能为空"); + } + if (status == null) { + throw new BadRequestException("状态不能为空"); + } + TbShopTableBooking entity = super.getById(id); + if (entity == null) { + throw new BadRequestException("预订信息不存在"); + } + entity.setStatus(status); + entity.setUpdateTime(new Date()); + if (status == 10) { + entity.setArrivedTime(new Date()); + } else { + entity.setArrivedTime(null); + } + super.updateById(entity); + } + + @Override + public void delete(Long id) { + baseMapper.update(Wrappers.lambdaUpdate() + .set(TbShopTableBooking::getDelFlag, 1) + .eq(TbShopTableBooking::getId, id)); + } + + @Override + public String getBookingSms(Long id) { + if (id == null) { + throw new BadRequestException("id不能为空"); + } + TbShopTableBooking entity = super.getById(id); + if (entity == null) { + throw new BadRequestException("预订信息不存在"); + } + Integer shopId = entity.getShopId(); + TbShopInfo shop = tbShopInfoRepository.getById(shopId); + if (shop == null) { + throw new BadRequestException("店铺信息不存在"); + } + return shop.getBookingSms(); + } + + @Override + public List findShopAreaList(Integer shopId) { + List tableList = mpShopTableMapper.selectList(Wrappers.lambdaQuery().eq(TbShopTable::getShopId, shopId).eq(TbShopTable::getIsPredate, 1)); + if (CollUtil.isEmpty(tableList)) { + return new ArrayList<>(); + } + Set areaId = tableList.stream().map(TbShopTable::getAreaId).collect(Collectors.toSet()); + List areaList = mpShopAreaMapper.selectList(Wrappers.lambdaQuery().in(TbShopArea::getId, areaId)); + if (CollUtil.isEmpty(areaList)) { + return new ArrayList<>(); + } + return areaList; + } + + @Override + public List findShopTableList(Map params) { + MapProxy mapProxy = MapProxy.create(params); + Integer areaId = mapProxy.getInt("areaId"); + TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class); + List tableList = mpShopTableMapper.selectList( + Wrappers.lambdaQuery() + .eq(TbShopTable::getShopId, param.getShopId()) + .eq(TbShopTable::getIsPredate, 1) + .eq(areaId != null, TbShopTable::getAreaId, areaId) + .orderByAsc(TbShopTable::getName) + ); + if (CollUtil.isEmpty(tableList)) { + return new ArrayList<>(); + } + List result = BeanUtil.copyToList(tableList, ShopTableBookingDTO.class); + Date bookingDate = param.getBookingDate(); + String bookingType = param.getBookingType(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(bookingDate != null, TbShopTableBooking::getBookingDate, bookingDate); + wrapper.eq(StrUtil.isNotEmpty(bookingType), TbShopTableBooking::getBookingType, bookingType); + wrapper.ne(TbShopTableBooking::getStatus, -1); + wrapper.eq(TbShopTableBooking::getDelFlag, 0); + List list = super.list(wrapper); + if (CollUtil.isEmpty(list)) { + return result; + } + for (ShopTableBookingDTO dto : result) { + dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId())).findFirst().orElse(null)); + } + return result; + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java index f1b7e545..fcabc2ae 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java @@ -15,14 +15,14 @@ */ package cn.ysk.cashier.pojo.shop; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; import java.io.Serializable; +import java.math.BigDecimal; /** * @website https://eladmin.vip @@ -295,6 +295,10 @@ public class TbShopInfo implements Serializable { @ApiModelProperty(value = "店铺收款码") private String paymentQrcode; + @Column(name = "booking_sms") + @ApiModelProperty(value = "台桌预订短信") + private String bookingSms; + public void copy(TbShopInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 90ff9673..19e9876c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -261,6 +261,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { query.eq(TbShopTable::getStatus, criteria.getState()).isNotNull(TbShopTable::getQrcode).ne(TbShopTable::getQrcode, ""); } + if (criteria.getIsPredate() != null) { + query.eq(TbShopTable::getIsPredate, criteria.getIsPredate()); + } + com.baomidou.mybatisplus.extension.plugins.pagination.Page shopTablePage = mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query); List tbShopTableList = shopTablePage.getRecords(); From 8e040203fdaf2dfff33dd71153823096f072bf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 17:20:42 +0800 Subject: [PATCH 081/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 90ff9673..db38f350 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2190,7 +2190,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private BigDecimal resetAmountByDiscount(PayDTO payDTO, TbOrderInfo orderInfo) { List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); - BigDecimal discount = payDTO.getDiscount(); + BigDecimal discount = payDTO.getDiscount().setScale(4, RoundingMode.DOWN); BigDecimal totalAmount = BigDecimal.ZERO; for (TbCashierCart cashierCart : cashierCarts) { if (cashierCart.getUserCouponId() == null) { From 999a2a29a04a53e5d62ef4f3285b6b6844d6653e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 22 Nov 2024 17:21:12 +0800 Subject: [PATCH 082/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 35e4c816..eff0d41e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -214,9 +214,10 @@ public class TbCashierCart implements Serializable { totalAmount = packFee; } else { if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio); + totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } else { - totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio); + totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice) + .add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } } } From 764fd5289b4f3b7cb5a792d4a72a058c029a30f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 09:11:07 +0800 Subject: [PATCH 083/170] =?UTF-8?q?fix:=20=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=A0=B9=E6=8D=AE=E5=8F=AF=E9=80=80=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 4b4b54b1..fec306fa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2122,7 +2122,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { returnCoupon(orderInfo, true); // 设置折扣比例 - orderInfo.setDiscountRatio(payDTO.getDiscount().setScale(4, RoundingMode.DOWN)); + orderInfo.setDiscountRatio(payDTO.getDiscount().setScale(4, RoundingMode.HALF_DOWN)); Set productIdSet = new HashSet<>(); List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); @@ -2194,7 +2194,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private BigDecimal resetAmountByDiscount(PayDTO payDTO, TbOrderInfo orderInfo) { List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); - BigDecimal discount = payDTO.getDiscount().setScale(4, RoundingMode.DOWN); + BigDecimal discount = payDTO.getDiscount().setScale(4, RoundingMode.HALF_DOWN); BigDecimal totalAmount = BigDecimal.ZERO; for (TbCashierCart cashierCart : cashierCarts) { if (cashierCart.getUserCouponId() == null) { @@ -2811,7 +2811,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 计算当前商品占比 BigDecimal ratio = calcDetailRatio(orderDetail, returnNum); currentDetailAMount = orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) - .multiply(returnNum).setScale(2, RoundingMode.DOWN); + .multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); if (oldOrderInfo.getRefundAmount() == null) { oldOrderInfo.setRefundAmount(BigDecimal.ZERO); } @@ -2842,7 +2842,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { .multiply(returnNum)).setScale(2, RoundingMode.HALF_UP); } } - returnAmount = returnAmount.setScale(2, RoundingMode.DOWN); + returnAmount = returnAmount.setScale(2, RoundingMode.HALF_DOWN); if (remainNum.compareTo(BigDecimal.ZERO) > 0) { // 单个打包费 @@ -2924,8 +2924,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { return BigDecimal.ONE; } - return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.DOWN) - .divide(orderDetail.getNum(), 10, RoundingMode.DOWN).multiply(returnNum).setScale(2, RoundingMode.DOWN); + return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.HALF_DOWN) + .divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN).multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); } private void updateStockAndRecord(List orderDetailList) { From 0cd809b07fdc09185d64db29164f7b0a604443de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 09:31:22 +0800 Subject: [PATCH 084/170] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E9=9B=B6?= =?UTF-8?q?=E5=85=83=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index fec306fa..38ac2668 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2865,7 +2865,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setStatus("refund"); } - if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0.01")) <= 0) { + if (returnAmount.compareTo(BigDecimal.ZERO) < 0) { + throw new BadRequestException("退款金额为负数有误"); + } + + if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0.01")) <= 0 && oldOrderInfo.getPayAmount().compareTo(BigDecimal.ZERO) != 0) { throw new BadRequestException("退款金额必须大于0"); } From 042716e39fcee26312c231cec72e3d010bbed813 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Sat, 23 Nov 2024 09:41:17 +0800 Subject: [PATCH 085/170] =?UTF-8?q?=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopInfoServiceImpl.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index d6e52d54..574ee745 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -8,6 +8,7 @@ import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.EntityNotFoundException; import cn.ysk.cashier.mapper.shop.TbShopInfoMapper; +import cn.ysk.cashier.pojo.product.TbProductGroup; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbMerchantRegister; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; @@ -19,6 +20,7 @@ import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.service.BindService; import cn.ysk.cashier.service.WxService; +import cn.ysk.cashier.service.product.TbProductGroupService; import cn.ysk.cashier.service.shop.TbShopInfoService; import cn.ysk.cashier.system.domain.Dept; import cn.ysk.cashier.system.domain.Job; @@ -31,7 +33,6 @@ import cn.ysk.cashier.system.service.UserService; import cn.ysk.cashier.utils.*; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -62,7 +63,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private TbShopInfoMapper tbShopInfoMapper; private final TbMerchantAccountRepository merchantAccountRepository; - + private final TbProductGroupService tbProductGroupService; private final UserRepository userRepository; private final UserService userService; @@ -277,8 +278,14 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { if (integer<4){ throw new BadRequestException("请重试"); } - - return tbShopInfoMapper.toDto(new TbShopInfo()); + TbProductGroup tbProductGroup = new TbProductGroup(); + tbProductGroup.setName("热销"); + tbProductGroup.setShopId(save.getId()); + tbProductGroup.setProductIds("[]"); + tbProductGroup.setSortMode("0"); + tbProductGroup.setUseTime(0); + tbProductGroupService.create(tbProductGroup); + return tbShopInfoMapper.toDto(save); } @Override From 39ed73a388535b8b9c7e62ff43410cc3a9590afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 11:08:20 +0800 Subject: [PATCH 086/170] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E4=BB=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 38ac2668..ffd93e5b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1499,9 +1499,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { ArrayList cartIdList = new ArrayList<>(); // 订单总价 for (TbCashierCart tbCashierCart : cartInfoDTO.getCashierCarts()) { - if (shopUser != null) { - tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : shopUser.getIsVip() == 1 ? 0 : 1); - } + tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : shopUser == null ? 0 : 1); tbCashierCart.resetTotalAmount(); if (tbCashierCart.getOrderId() != null) { From 514533bfeda6bb165693e7f4aff9b1000c2ad333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 14:28:14 +0800 Subject: [PATCH 087/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=BF=94=E8=BF=98=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index ffd93e5b..76278c82 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2867,7 +2867,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("退款金额为负数有误"); } - if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0.01")) <= 0 && oldOrderInfo.getPayAmount().compareTo(BigDecimal.ZERO) != 0) { + if (hasNormalReturn && returnAmount.compareTo(new BigDecimal("0")) <= 0 && oldOrderInfo.getPayAmount().compareTo(BigDecimal.ZERO) != 0) { throw new BadRequestException("退款金额必须大于0"); } @@ -2922,12 +2922,17 @@ public class TbShopTableServiceImpl implements TbShopTableService { totalAmount = totalAmount.add(item.getPriceAmount()); } } - if (orderDetail.getPriceAmount().compareTo(totalAmount) == 0) { + if (orderDetail.getPriceAmount().compareTo(totalAmount) == 0 && orderDetail.getNum().compareTo(BigDecimal.ONE) == 0) { return BigDecimal.ONE; } + if (orderDetail.getNum().compareTo(returnNum) == 0) { + return orderDetail.getPriceAmount().divide(totalAmount, 2, RoundingMode.HALF_DOWN); + } + return orderDetail.getPriceAmount().divide(totalAmount, 10, RoundingMode.HALF_DOWN) - .divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN).multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); + .divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN) + .multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); } private void updateStockAndRecord(List orderDetailList) { @@ -3013,26 +3018,35 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 订单金额全退,退优惠券以及积分 if (orderInfo.getPayAmount().compareTo(orderInfo.getRefundAmount()) <= 0) { - String couponInfoList = orderInfo.getCouponInfoList(); - if (StrUtil.isNotBlank(couponInfoList)) { - OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class); - if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) { - int remainNum = 0; - for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { - if (item.getFinalUseNum() > item.getReturnNum()) { - remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); - } - } - - if (remainNum == 0) { - returnCoupon(orderInfo, true); - // 返还积分 - memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), - "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); - - } - } + 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())); } +// String couponInfoList = orderInfo.getCouponInfoList(); +// if (StrUtil.isNotBlank(couponInfoList)) { +// OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class); +// if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) { +// int remainNum = 0; +// for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { +// if (item.getFinalUseNum() > item.getReturnNum()) { +// remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); +// } +// } +// +// if (remainNum == 0) { +// returnCoupon(orderInfo, true); +// // 返还积分 +// memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), +// "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); +// +// } +// } +// } } orderInfoMapper.updateById(orderInfo); // 打印退款小票 From b33d7b0f317dac4cae80fcf51af916d2a1cb7834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 16:53:31 +0800 Subject: [PATCH 088/170] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8F=AF=E9=80=80=E6=AC=BE=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../impl/shopimpl/TbShopTableServiceImpl.java | 43 ++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 98597ea9..b7ebdb97 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -137,6 +137,7 @@ public class TbOrderDetail implements Serializable { private Boolean isPrint; private String useCouponInfo; private BigDecimal returnAmount; + private BigDecimal canReturnAmount; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 76278c82..bee1bf80 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2115,6 +2115,28 @@ public class TbShopTableServiceImpl implements TbShopTableService { return productDiscount; } + 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()); + } + } + } + private BigDecimal calcDiscountAndUpdateInfo(PayDTO payDTO, TbOrderInfo orderInfo) { // 返还上次使用的券 returnCoupon(orderInfo, true); @@ -2182,6 +2204,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfo)); // 修改订单detail + updateOrderDetailCanReturn(priceDTO.getOrderDetailList(), orderInfo); mpOrderDetailService.saveOrUpdateBatch(priceDTO.getOrderDetailList()); return orderInfo.getOrderAmount(); } @@ -2807,6 +2830,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else if (oldOrderInfo.getFullCouponDiscountAmount().compareTo(BigDecimal.ZERO) > 0 || oldOrderInfo.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0) { hasNormalReturn = true; // 计算当前商品占比 + returnAmount = calcDetailReturnAmount(orderDetail, returnNum); BigDecimal ratio = calcDetailRatio(orderDetail, returnNum); currentDetailAMount = orderDetail.getPriceAmount().divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); @@ -2814,11 +2838,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { oldOrderInfo.setRefundAmount(BigDecimal.ZERO); } - if (ratio.compareTo(BigDecimal.ONE) == 0) { - returnAmount = oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount()); - }else { - returnAmount = returnAmount.add(oldOrderInfo.getPayAmount().subtract(oldOrderInfo.getRefundAmount()).multiply(ratio)); - } +// 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) @@ -2850,7 +2874,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { remainOrderDetail.setPackAmount(originalPackAmount.subtract(returnPackFee)); remainOrderDetail.setReturnNum("0"); remainOrderDetail.setId(null); + remainOrderDetail.setCanReturnAmount(remainOrderDetail.getCanReturnAmount().subtract(returnAmount)); remainOrderDetailList.add(remainOrderDetail); + orderDetail.setCanReturnAmount(returnAmount); } orderDetail.setNum(returnNum); @@ -2935,6 +2961,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { .multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); } + private BigDecimal calcDetailReturnAmount(TbOrderDetail orderDetail, BigDecimal returnNum) { + if (orderDetail.getNum().compareTo(returnNum) == 0) { + return orderDetail.getCanReturnAmount(); + } + return orderDetail.getCanReturnAmount().divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN).multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); + } + private void updateStockAndRecord(List orderDetailList) { // 更新商品库存 for (TbOrderDetail detail : orderDetailList) { From d188906e81b1ca4906b3245ad5b26b56c0dd1f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Sat, 23 Nov 2024 17:31:15 +0800 Subject: [PATCH 089/170] =?UTF-8?q?fix:=200.01=E9=80=80=E6=AC=BE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index bee1bf80..acc7cdbc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2965,6 +2965,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (orderDetail.getNum().compareTo(returnNum) == 0) { return orderDetail.getCanReturnAmount(); } + if (returnNum.compareTo(BigDecimal.ONE) == 0 && + orderDetail.getNum().compareTo(BigDecimal.ONE) > 0 && + orderDetail.getCanReturnAmount().compareTo(new BigDecimal("0.01")) <= 0) { + throw new BadRequestException(orderDetail.getProductName() + "总金额为0.01,请选择全部商品数量退回"); + } return orderDetail.getCanReturnAmount().divide(orderDetail.getNum(), 10, RoundingMode.HALF_DOWN).multiply(returnNum).setScale(2, RoundingMode.HALF_DOWN); } From f451425a5cf77308fa86aa8cf5f06d61e374fbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Sat, 23 Nov 2024 18:07:42 +0800 Subject: [PATCH 090/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../credit/TbCreditBuyerController.java | 7 + .../credit/TbCreditBuyerOrderController.java | 22 +- .../dto/credit/CreditBuyerOrderDTO.java | 69 ++++++ .../cashier/mybatis/entity/TbCreditBuyer.java | 14 +- .../mybatis/entity/TbCreditBuyerOrder.java | 83 ++++--- .../mybatis/entity/TbCreditPaymentRecord.java | 6 + .../mapper/TbCreditBuyerOrderMapper.java | 15 +- .../service/TbCreditBuyerOrderService.java | 10 + .../mybatis/service/TbCreditBuyerService.java | 5 + .../impl/TbCreditBuyerOrderServiceImpl.java | 215 +++++++++++++++++- .../impl/TbCreditBuyerServiceImpl.java | 136 ++++++++++- .../TbCreditPaymentRecordServiceImpl.java | 28 ++- .../mapper/plus/TbCreditBuyerOrderMapper.xml | 66 ++++++ 13 files changed, 602 insertions(+), 74 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java create mode 100644 eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java index 3f432be9..3a8439c9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java @@ -60,4 +60,11 @@ public class TbCreditBuyerController { tbCreditBuyerService.delete(id); return ResponseEntity.ok().build(); } + + @PostMapping("repayment") + @ApiOperation("还款") + public ResponseEntity repayment(@RequestBody Map params) { + Map data = tbCreditBuyerService.repayment(params); + return ResponseEntity.ok().body(data); + } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java index a96e23b5..9ca18496 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java @@ -1,6 +1,6 @@ package cn.ysk.cashier.controller.credit; -import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -12,11 +12,11 @@ import java.util.Map; /** -* 挂账账单 -* -* @author Tankaikai tankaikai@aliyun.com -* @since 2.0 2024-11-20 -*/ + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ @RestController @RequestMapping("/api/credit/buyer-order") @Api(tags = "挂账账单") @@ -27,21 +27,21 @@ public class TbCreditBuyerOrderController { @GetMapping("page") @ApiOperation("分页") - public ResponseEntity page(@RequestParam Map params){ + public ResponseEntity page(@RequestParam Map params) { Map page = tbCreditBuyerOrderService.page(params); return ResponseEntity.ok().body(page); } @PostMapping("pay") @ApiOperation("付款") - public ResponseEntity pay(@RequestBody TbCreditBuyerOrder dto){ - boolean ret = tbCreditBuyerOrderService.save(dto); - return ResponseEntity.ok().body(ret); + public ResponseEntity pay(@RequestBody TbCreditPaymentRecord record) { + tbCreditBuyerOrderService.pay(record); + return ResponseEntity.ok().build(); } @GetMapping("summary") @ApiOperation("统计") - public ResponseEntity summary(@RequestParam Map params){ + public ResponseEntity summary(@RequestParam Map params) { Map data = tbCreditBuyerOrderService.summary(params); return ResponseEntity.ok().body(data); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java new file mode 100644 index 00000000..0ed9cf5b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java @@ -0,0 +1,69 @@ +package cn.ysk.cashier.dto.credit; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +public class CreditBuyerOrderDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 应付金额 + */ + private BigDecimal payAmount; + /** + * 已付金额 + */ + private BigDecimal paidAmount; + /** + * 未付金额 + */ + private BigDecimal unpaidAmount; + /** + * 状态 unpaid-未付款 partial-部分支付 paid-已付款 + */ + private String status; + /** + * 最近一次付款时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPaymentTime; + /** + * 最近一次付款方式 + */ + private String lastPaymentMethod; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java index 7ca67722..c4f151db 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java @@ -48,6 +48,10 @@ public class TbCreditBuyer { * 挂账额度 */ private BigDecimal creditAmount; + /** + * 账户余额 + */ + private BigDecimal accountBalance; /** * 还款方式 total-按总金额还款 order-按订单还款 */ @@ -56,6 +60,10 @@ public class TbCreditBuyer { * 支付方式 */ private String paymentMethod; + /** + * 责任人 + */ + private String responsiblePerson; /** * 备注 */ @@ -69,7 +77,7 @@ public class TbCreditBuyer { /** * 已挂账金额 */ - @TableField(value = "(select sum(unpaid_amount) from view_credit_buyer_order where credit_buyer_id = id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + @TableField(value = "(select ifnull(sum(unpaid_amount),0) from view_credit_buyer_order where credit_buyer_id = tb_credit_buyer.id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) private BigDecimal owedAmount; /** @@ -81,13 +89,13 @@ public class TbCreditBuyer { /** * 累计挂账金额 */ - @TableField(value = "(select sum(pay_amount) from view_credit_buyer_order where credit_buyer_id = id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + @TableField(value = "(select ifnull(sum(pay_amount),0) from view_credit_buyer_order where credit_buyer_id = tb_credit_buyer.id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) private BigDecimal accumulateAmount; /** * 适用门店 */ - @TableField(value = "(select shop_name from tb_shop_info where id = shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + @TableField(value = "(select shop_name from tb_shop_info where id = tb_credit_buyer.shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) private String shopName; public BigDecimal getRemainingAmount() { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java index 675c316e..93e6f038 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java @@ -1,8 +1,8 @@ package cn.ysk.cashier.mybatis.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,46 +16,45 @@ import java.util.Date; * @since 2.0 2024-11-20 */ @Data -@EqualsAndHashCode(callSuper=false) +@EqualsAndHashCode(callSuper = false) @TableName("tb_credit_buyer_order") public class TbCreditBuyerOrder { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * id - */ - @TableId(type = IdType.AUTO) - private Long id; - /** - * 订单id - */ - private Long orderId; - /** - * 挂账人编码 - */ - private String creditBuyerId; - /** - * 已付金额 - */ - private BigDecimal paidAmount; - /** - * 未付金额 - */ - private BigDecimal unpaidAmount; - /** - * 状态 unpaid-未付款 paid-已付款 - */ - private String status; - /** - * 最近一次付款时间 - */ - private Date lastPaymentTime; - /** - * 最近一次付款方式 - */ - private String lastPaymentMethod; - /** - * 备注 - */ - private String remark; + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 已付金额 + */ + private BigDecimal paidAmount; + /** + * 状态 unpaid-未付款 partial-部分支付 paid-已付款 + */ + private String status; + /** + * 最近一次付款时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPaymentTime; + /** + * 最近一次付款方式 + */ + private String lastPaymentMethod; + /** + * 备注 + */ + @TableField(value = "remark", updateStrategy = FieldStrategy.ALWAYS) + private String remark; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java index 0d161a39..e6c6c097 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java @@ -1,8 +1,10 @@ package cn.ysk.cashier.mybatis.entity; +import com.alibaba.fastjson.annotation.JSONField; 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; @@ -49,9 +51,13 @@ public class TbCreditPaymentRecord { /** * 还款时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date paymentTime; /** * 操作时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java index ff9f0290..1010a72c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java @@ -1,9 +1,14 @@ package cn.ysk.cashier.mybatis.mapper; +import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + /** * 挂账账单 * @@ -12,5 +17,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface TbCreditBuyerOrderMapper extends BaseMapper { - + + List getList(Map params); + long getCount(Map params); + + BigDecimal getSumPaidAmount(Map params); + BigDecimal getSumUnpaidAmount(Map params); + + CreditBuyerOrderDTO getOne(Map params); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java index 1ebcb706..5a96a86f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.mybatis.service; import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; import com.baomidou.mybatisplus.extension.service.IService; import java.util.Map; @@ -16,4 +17,13 @@ public interface TbCreditBuyerOrderService extends IService Map page(Map params); Map summary(Map params); + void pay(TbCreditPaymentRecord record); + + /** + * 保存挂账账单 + * @param creditBuyerId 挂账人id + * @param orderId 订单id + */ + boolean save(String creditBuyerId, Long orderId); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java index d8842225..32240ac1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java @@ -21,4 +21,9 @@ public interface TbCreditBuyerService extends IService { void delete(String id); + TbCreditBuyer getById(String id); + + Map repayment(Map params); + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 7f63f00c..1f0136a9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -1,12 +1,38 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; +import cn.ysk.cashier.dto.product.PadProductCategoryDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper; import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; +import cn.ysk.cashier.mybatis.service.MpOrderInfoService; import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -18,20 +44,197 @@ import java.util.Map; @Service public class TbCreditBuyerOrderServiceImpl extends ServiceImpl implements TbCreditBuyerOrderService { - public QueryWrapper getWrapper(Map params){ - QueryWrapper wrapper = new QueryWrapper<>(); + @Resource + private TbCreditBuyerService tbCreditBuyerService; + @Resource + private TbCreditBuyerMapper tbCreditBuyerMapper; + @Resource + private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper; + @Resource + private MpOrderInfoService mpOrderInfoService; - wrapper.orderByDesc("id"); + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String beginDate = mapProxy.getStr("beginDate"); + String endDate = mapProxy.getStr("endDate"); + TbCreditBuyerOrder param = BeanUtil.toBean(params, TbCreditBuyerOrder.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.orderByDesc(TbCreditBuyerOrder::getOrderId); return wrapper; } @Override public Map page(Map params) { - return null; + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + Page page = new Page<>(pageNum, pageSize); + page.addOrder(OrderItem.desc("order_id")); + params.put("page", page); + List list = baseMapper.getList(params); + return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal())); } @Override public Map summary(Map params) { - return null; + long count = baseMapper.getCount(params); + Map data = new HashMap<>(4); + // 总交易笔数 + data.put("count", count); + // 未支付 + params.put("status", "unpaid"); + long unpaidCount = baseMapper.getCount(params); + // 部分支付 + params.put("status", "partial"); + long partialCount = baseMapper.getCount(params); + // 待支付笔数 = 未支付笔数 + 部分支付笔数 + data.put("unpaidCount", unpaidCount + partialCount); + + BigDecimal paidAmount = baseMapper.getSumPaidAmount(params); + BigDecimal unpaidAmount = baseMapper.getSumUnpaidAmount(params); + data.put("paidAmountTotal", paidAmount); + data.put("unpaidAmountTotal", unpaidAmount); + return data; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void pay(TbCreditPaymentRecord record) { + try { + Assert.notNull(record.getCreditBuyerId(), "{}({})不能为空", "挂账人id", "creditBuyerId"); + Assert.notNull(record.getOrderId(), "{}({})不能为空", "订单id", "orderId"); + Assert.notNull(record.getRepaymentAmount(), "{}({})不能为空", "还款金额", "repaymentAmount"); + Assert.notEmpty(record.getPaymentMethod(), "{}({})不能为空", "支付方式", "paymentMethod"); + Assert.notNull(record.getPaymentTime(), "{}({})不能为空", "还款时间", "paymentTime"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + TbCreditBuyer creditBuyer = tbCreditBuyerMapper.selectById(record.getCreditBuyerId()); + if (creditBuyer == null) { + throw new BadRequestException("挂账人不存在"); + } + String repaymentMethod = creditBuyer.getRepaymentMethod(); + if (!"order".equals(repaymentMethod)) { + throw new BadRequestException("该挂账人不支持按订单付款"); + } + Map params = new HashMap<>(2); + params.put("creditBuyerId", record.getCreditBuyerId()); + params.put("orderId", record.getOrderId()); + CreditBuyerOrderDTO dto = baseMapper.getOne(params); + if (dto == null) { + throw new BadRequestException("挂账订单不存在"); + } + if ("paid".equals(dto.getStatus())) { + throw new BadRequestException("挂账订单已还清,无需还款"); + } + if (NumberUtil.isLess(record.getRepaymentAmount(), BigDecimal.ZERO)) { + throw new BadRequestException("还款金额不能小于0"); + } + if (NumberUtil.isGreater(record.getRepaymentAmount(), dto.getUnpaidAmount())) { + throw new BadRequestException("还款金额不能大于未支付金额"); + } + TbCreditBuyerOrder entity = BeanUtil.copyProperties(dto, TbCreditBuyerOrder.class); + if (NumberUtil.equals(record.getRepaymentAmount(), dto.getUnpaidAmount())) { + entity.setStatus("paid"); + } else { + entity.setStatus("partial"); + } + entity.setPaidAmount(NumberUtil.add(entity.getPaidAmount(), record.getRepaymentAmount())); + entity.setLastPaymentTime(new Date()); + entity.setLastPaymentMethod(record.getPaymentMethod()); + super.updateById(entity); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + } + + @Override + public boolean save(String creditBuyerId, Long orderId) { + if (StrUtil.isBlank(creditBuyerId)) { + throw new BadRequestException("挂账人id不能为空"); + } + TbCreditBuyer creditBuyer = tbCreditBuyerService.getById(creditBuyerId); + if (creditBuyer == null) { + throw new BadRequestException("挂账人不存在"); + } + Integer delFlag = creditBuyer.getDelFlag(); + if (delFlag != null && delFlag == 1) { + throw new BadRequestException("挂账人已删除"); + } + Integer status = creditBuyer.getStatus(); + if (status != null && status == 0) { + throw new BadRequestException("挂账人已被停用"); + } + TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId); + if (orderInfo == null) { + throw new BadRequestException("订单不存在"); + } + // 账户余额 + BigDecimal accountBalance = creditBuyer.getAccountBalance(); + // 如果有余额的话,从余额里面扣除,没有余额的话,从信用额度里面扣除,余额和信用额度都为0,则不允许挂账,余额+信用额度刚好够支付这笔订单的话需要同时减余额减信用额度 + if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getPayAmount())) { + // 减余额 + creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getPayAmount())); + tbCreditBuyerMapper.updateById(creditBuyer); + // 记录还款记录 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(creditBuyerId); + record.setOrderId(orderId); + record.setRepaymentAmount(orderInfo.getPayAmount()); + record.setPaymentMethod("余额支付"); + record.setPaymentTime(new Date()); + record.setRemark("挂账时余额充足,直接从余额扣除"); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + TbCreditBuyerOrder entity = new TbCreditBuyerOrder(); + entity.setCreditBuyerId(creditBuyerId); + entity.setOrderId(orderId); + entity.setPaidAmount(orderInfo.getPayAmount()); + entity.setStatus("paid"); + entity.setLastPaymentTime(new Date()); + entity.setLastPaymentMethod(record.getPaymentMethod()); + entity.setRemark(record.getRemark()); + return super.save(entity); + } + TbCreditBuyerOrder entity = null; + if (NumberUtil.isGreater(accountBalance, BigDecimal.ZERO)) { + // 减余额 + creditBuyer.setAccountBalance(BigDecimal.ZERO); + tbCreditBuyerMapper.updateById(creditBuyer); + // 记录还款记录 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(creditBuyerId); + record.setOrderId(orderId); + record.setRepaymentAmount(accountBalance); + record.setPaymentMethod("余额支付"); + record.setPaymentTime(new Date()); + record.setRemark("挂账时余额不足,先扣除现有余额,其他的从挂账额度中扣除"); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + entity = new TbCreditBuyerOrder(); + entity.setCreditBuyerId(creditBuyerId); + entity.setOrderId(orderId); + entity.setPaidAmount(accountBalance); + entity.setStatus("partial"); + entity.setLastPaymentTime(new Date()); + entity.setLastPaymentMethod(record.getPaymentMethod()); + entity.setRemark(record.getRemark()); + //super.save(entity); + orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getPayAmount(), accountBalance)); + } + // 剩余挂账额度 + BigDecimal remainingAmount = creditBuyer.getRemainingAmount(); + // 验证挂账金额是否大于剩余额度 + boolean greater = NumberUtil.isGreater(orderInfo.getPayAmount(), remainingAmount); + if (greater) { + throw new BadRequestException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getPayAmount(), remainingAmount)); + } + if (entity == null) { + entity = new TbCreditBuyerOrder(); + entity.setStatus("unpaid"); + entity.setPaidAmount(BigDecimal.ZERO); + entity.setCreditBuyerId(creditBuyerId); + entity.setOrderId(orderId); + } + return super.saveOrUpdate(entity); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index c2245f70..10c96535 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Validator; @@ -9,9 +10,12 @@ import cn.hutool.core.map.MapProxy; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper; import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; import cn.ysk.cashier.utils.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -19,10 +23,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * 挂账人 @@ -33,6 +39,9 @@ import java.util.Map; @Service public class TbCreditBuyerServiceImpl extends ServiceImpl implements TbCreditBuyerService { + @Resource + private TbCreditBuyerOrderMapper tbCreditBuyerOrderMapper; + private LambdaQueryWrapper getWrapper(Map params) { MapProxy mapProxy = MapProxy.create(params); String keywords = mapProxy.getStr("keywords"); @@ -41,12 +50,13 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl wrapper = Wrappers.lambdaQuery(); wrapper.eq(TbCreditBuyer::getShopId, param.getShopId()); wrapper.eq(StrUtil.isNotEmpty(param.getId()), TbCreditBuyer::getId, param.getId()); + wrapper.like(StrUtil.isNotEmpty(param.getResponsiblePerson()), TbCreditBuyer::getResponsiblePerson, param.getResponsiblePerson()); wrapper.eq(param.getStatus() != null, TbCreditBuyer::getStatus, param.getStatus()); if (StrUtil.isNotEmpty(keywords)) { wrapper.nested(i -> i.like(TbCreditBuyer::getDebtor, keywords).or().like(TbCreditBuyer::getMobile, keywords)); } wrapper.eq(TbCreditBuyer::getDelFlag, 0); - wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName); + wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance); wrapper.orderByDesc(TbCreditBuyer::getStatus); wrapper.orderByDesc(TbCreditBuyer::getId); return wrapper; @@ -58,7 +68,6 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl wrapper = getWrapper(params); - Page page = super.page(new Page<>(pageNum, pageSize), wrapper); return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); } @@ -92,6 +101,7 @@ public class TbCreditBuyerServiceImpl extends ServiceImpllambdaUpdate().set(TbCreditBuyer::getDelFlag, 1).eq(TbCreditBuyer::getId, id)); } + + @Override + public TbCreditBuyer getById(String id) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbCreditBuyer::getId, id); + wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance); + return baseMapper.selectOne(wrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Map repayment(Map params) { + MapProxy mapProxy = MapProxy.create(params); + // 还款金额 + BigDecimal repaymentAmount = mapProxy.getBigDecimal("repaymentAmount"); + TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class); + try { + Assert.notEmpty(param.getId(), "{}不能为空", "id"); + Assert.notNull(repaymentAmount, "{}({})不能为空", "还款金额", "repaymentAmount"); + Assert.notNull(param.getPaymentMethod(), "{}({})不能为空", "支付方式", "paymentMethod"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + TbCreditBuyer entity = getById(param.getId()); + if (entity == null) { + throw new BadRequestException("挂账人不存在"); + } + Integer delFlag = entity.getDelFlag(); + if (delFlag == 1) { + throw new BadRequestException("挂账人已删除"); + } + if (!"total".equals(entity.getRepaymentMethod())) { + throw new BadRequestException("此挂账人不能以【按总账户还款】进行还款"); + } + if (NumberUtil.isLess(repaymentAmount, BigDecimal.ZERO)) { + throw new BadRequestException("还款金额不能小于0"); + } + BigDecimal initRepaymentAmount = NumberUtil.add(repaymentAmount, BigDecimal.ZERO); + // 已挂账金额 + BigDecimal owedAmount = entity.getOwedAmount(); + if (NumberUtil.equals(owedAmount, BigDecimal.ZERO)) { + entity.setAccountBalance(NumberUtil.add(entity.getAccountBalance(), repaymentAmount)); + super.updateById(entity); + Map result = new HashMap<>(3); + result.put("repaymentCount", 0); + result.put("repaymentAmount", repaymentAmount); + result.put("repaymentMsg", StrUtil.format("账单无需还款,{}元已转储至余额。", repaymentAmount)); + return result; + } + BigDecimal rechargeAmount = BigDecimal.ZERO; + if (NumberUtil.isGreater(repaymentAmount, owedAmount)) { + rechargeAmount = NumberUtil.sub(repaymentAmount, owedAmount); + entity.setAccountBalance(NumberUtil.add(entity.getAccountBalance(), rechargeAmount)); + super.updateById(entity); + } + + // 校验完毕,可以批量还款 + Map where = new HashMap<>(); + where.put("creditBuyerId", param.getId()); + where.put("statusList", Arrays.asList("unpaid", "partial")); + List list = tbCreditBuyerOrderMapper.getList(where); + if (CollUtil.isEmpty(list)) { + throw new BadRequestException("没有需要还款的订单"); + } + int repaymentCount = 0; + List orderList = list.stream().sorted(Comparator.comparing(CreditBuyerOrderDTO::getOrderId)).collect(Collectors.toList()); + for (CreditBuyerOrderDTO dto : orderList) { + // 未付款金额 + BigDecimal unpaidAmount = dto.getUnpaidAmount(); + if (NumberUtil.isGreaterOrEqual(repaymentAmount, unpaidAmount)) { + // 还全额 + tbCreditBuyerOrderMapper.update(Wrappers.lambdaUpdate() + .eq(TbCreditBuyerOrder::getStatus, dto.getStatus()) + .eq(TbCreditBuyerOrder::getId, dto.getId()) + .eq(TbCreditBuyerOrder::getOrderId, dto.getOrderId()) + .eq(TbCreditBuyerOrder::getCreditBuyerId, dto.getCreditBuyerId()) + .eq(TbCreditBuyerOrder::getPaidAmount, dto.getPaidAmount()) + .set(TbCreditBuyerOrder::getStatus, "paid") + .set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.add(dto.getPaidAmount(), unpaidAmount)) + .set(TbCreditBuyerOrder::getRemark, param.getRemark()) + .set(TbCreditBuyerOrder::getLastPaymentMethod, param.getPaymentMethod()) + .set(TbCreditBuyerOrder::getLastPaymentTime, new Date()) + ); + repaymentAmount = NumberUtil.sub(repaymentAmount, unpaidAmount); + } else if (NumberUtil.isLess(repaymentAmount, unpaidAmount)) { + // 还部分 + tbCreditBuyerOrderMapper.update(Wrappers.lambdaUpdate() + .eq(TbCreditBuyerOrder::getStatus, dto.getStatus()) + .eq(TbCreditBuyerOrder::getId, dto.getId()) + .eq(TbCreditBuyerOrder::getOrderId, dto.getOrderId()) + .eq(TbCreditBuyerOrder::getCreditBuyerId, dto.getCreditBuyerId()) + .eq(TbCreditBuyerOrder::getPaidAmount, dto.getPaidAmount()) + .set(TbCreditBuyerOrder::getStatus, "partial") + .set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.add(dto.getPaidAmount(), repaymentAmount)) + .set(TbCreditBuyerOrder::getRemark, param.getRemark()) + .set(TbCreditBuyerOrder::getLastPaymentMethod, param.getPaymentMethod()) + .set(TbCreditBuyerOrder::getLastPaymentTime, new Date()) + ); + repaymentAmount = BigDecimal.ZERO; + } + repaymentCount++; + if (NumberUtil.equals(repaymentAmount, BigDecimal.ZERO)) { + break; + } + } + Map result = new HashMap<>(3); + BigDecimal payAmount = NumberUtil.sub(initRepaymentAmount, repaymentAmount); + result.put("repaymentCount", repaymentCount); + result.put("repaymentAmount", initRepaymentAmount); + result.put("payAmount", payAmount); + result.put("rechargeAmount", rechargeAmount); + result.put("repaymentMsg", StrUtil.format("共计还款{}笔,还款金额:{}元,支付欠款:{}元,转存余额:{}元,当前余额:{}元。", repaymentCount, initRepaymentAmount, payAmount, entity.getAccountBalance())); + return result; + } + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java index d42fac80..c30d30a0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java @@ -1,9 +1,16 @@ package cn.ysk.cashier.mybatis.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.StrUtil; import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -18,15 +25,24 @@ import java.util.Map; @Service public class TbCreditPaymentRecordServiceImpl extends ServiceImpl implements TbCreditPaymentRecordService { - public QueryWrapper getWrapper(Map params){ - QueryWrapper wrapper = new QueryWrapper<>(); - - wrapper.orderByDesc("id"); + private LambdaQueryWrapper getWrapper(Map params) { + TbCreditPaymentRecord param = BeanUtil.toBean(params, TbCreditPaymentRecord.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbCreditPaymentRecord::getCreditBuyerId, param.getCreditBuyerId()); + wrapper.eq(param.getOrderId() != null, TbCreditPaymentRecord::getOrderId, param.getOrderId()); + wrapper.like(StrUtil.isNotEmpty(param.getPaymentMethod()), TbCreditPaymentRecord::getPaymentMethod, param.getPaymentMethod()); + wrapper.orderByDesc(TbCreditPaymentRecord::getId); return wrapper; } @Override public Map page(Map params) { - return null; + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + wrapper.orderByDesc(TbCreditPaymentRecord::getId); + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); } } \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml new file mode 100644 index 00000000..d2dc56e4 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml @@ -0,0 +1,66 @@ + + + + + + + + and t1.credit_buyer_id = #{creditBuyerId} + + and t1.order_id = #{orderId} + + + and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s') + + + + + + and t1.status = #{status} + + + and t1.status in + + #{status} + + + + and t1.id = #{id} + + + + + + + + + + + + + + + \ No newline at end of file From 76d4495f458d573e31e8b28002d2742821db3287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 25 Nov 2024 10:03:35 +0800 Subject: [PATCH 091/170] =?UTF-8?q?fix:=20=E5=82=A8=E5=80=BC=E5=8D=A1?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=98=8E=E7=BB=86=E8=AE=B0=E5=BD=95=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 4e96acc2..b27dfb3a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -637,7 +637,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { flow.setBizName("会员储值卡退款"); flow.setType("+"); flow.setAmount(returnAmount); - flow.setBalance(user.getAmount()); + flow.setBalance(user.getAmount().add(returnAmount)); flow.setCreateTime(cn.hutool.core.date.DateUtil.date().toTimestamp()); flow.setIsReturn("0"); tbShopUserFlowMapper.insert(flow); From 6dc95d29a15276dbf613b7272641c902fb84e8fc Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Sat, 23 Nov 2024 09:41:17 +0800 Subject: [PATCH 092/170] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E7=BB=91=E5=AE=9A=20?= =?UTF-8?q?=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopInfoServiceImpl.java | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 574ee745..b6acf46b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -49,11 +49,11 @@ import java.time.Instant; import java.util.*; /** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2023-11-07 -**/ + * @author lyf + * @website https://eladmin.vip + * @description 服务实现 + * @date 2023-11-07 + **/ @Service @RequiredArgsConstructor public class TbShopInfoServiceImpl implements TbShopInfoService { @@ -86,9 +86,11 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { public JSONObject binding(BindingDto bindingDto) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount()); + boolean isNew = true; if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) { if (tbShopInfo != null) { if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) { + isNew = false; bindingDto.setAccount(account.getBindAccount()); } else { return null; @@ -98,7 +100,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { Map param = new HashMap<>(); param.put("account", bindingDto.getAccount()); JSONObject data = bindService.binding(param); - if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) { + if (isNew) { account.setBindAccount(bindingDto.getAccount()); account.setArticle(bindingDto.getArticle()); account.setTaxAmount(bindingDto.getTaxAmount()); @@ -113,15 +115,15 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { } @Override - public Map queryAll(TbShopInfoQueryCriteria criteria){ + public Map queryAll(TbShopInfoQueryCriteria criteria) { Sort sort = Sort.by(Sort.Direction.DESC, "id"); Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); - Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables); + Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageables); return PageUtil.toPage(page); } @Override - public List queryChildShop(TbShopInfoQueryCriteria criteria){ + public List queryChildShop(TbShopInfoQueryCriteria criteria) { List list = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> { Predicate query1 = criteriaBuilder.equal(root.get("id"), criteria.getId()); Predicate query2 = criteriaBuilder.and( @@ -148,14 +150,14 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Transactional public TbShopInfoDto findById(Integer id) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(id).orElseGet(TbShopInfo::new); - if(StringUtils.isBlank(tbShopInfo.getSmallQrcode())){ + if (StringUtils.isBlank(tbShopInfo.getSmallQrcode())) { String smallQrcode = wxService.getSmallQrcode(id.toString()); tbShopInfo.setSmallQrcode(smallQrcode); tbShopInfoRepository.save(tbShopInfo); } String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name()); - tbShopInfo.setPaymentQrcode(baseUrl+"?shopId="+id); - ValidationUtil.isNull(tbShopInfo.getId(),"TbShopInfo","id",id); + tbShopInfo.setPaymentQrcode(baseUrl + "?shopId=" + id); + ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", id); return tbShopInfoMapper.toDto(tbShopInfo); } @@ -168,46 +170,46 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override @Transactional(rollbackFor = Exception.class) public TbShopInfoDto create(TbShopInfoDto resources) { - if(StringUtils.isBlank(resources.getShopName())){ + if (StringUtils.isBlank(resources.getShopName())) { throw new BadRequestException("店铺名称不可为空"); } resources.setShopName(resources.getShopName().trim()); - if ("release".equals(resources.getProfiles())){ - if (resources.getRegisterCode() == null){ + if ("release".equals(resources.getProfiles())) { + if (resources.getRegisterCode() == null) { throw new BadRequestException("未绑定激活码"); } } TbShopInfo byAccount = tbShopInfoRepository.findByAccount(resources.getAccount()); User byUsername = userRepository.findByUsername(resources.getAccount()); - if (byAccount != null || byUsername != null){ + if (byAccount != null || byUsername != null) { throw new BadRequestException("登录名已注册"); } TbShopInfo tbShopInfo = new TbShopInfo(); - BeanUtil.copyProperties(resources,tbShopInfo, CopyOptions.create().setIgnoreNullValue(true)); + BeanUtil.copyProperties(resources, tbShopInfo, CopyOptions.create().setIgnoreNullValue(true)); tbShopInfo.setCreatedAt(Instant.now().toEpochMilli()); tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); tbShopInfo.setIsOpenYhq(resources.getIsOpenYhq()); //激活码 TbMerchantRegister tbMerchantRegister = new TbMerchantRegister(); - if (resources.getRegisterCode() != null){ + if (resources.getRegisterCode() != null) { tbMerchantRegister = merchantRegisterRepository.findByRegisterCode(resources.getRegisterCode()); - if(tbMerchantRegister == null){ + if (tbMerchantRegister == null) { throw new BadRequestException("激活码有误"); } - if (tbMerchantRegister.getStatus() == 1){ + if (tbMerchantRegister.getStatus() == 1) { throw new BadRequestException("激活码已激活,不能重复绑定"); } tbShopInfo.setExpireAt(DateUtil.addMonthsAndGetTimestamp(tbMerchantRegister.getPeriodYear())); //向redis中存入key - redisUtils.set(CacheKey.ACT_CODE+resources.getAccount(),"1",tbShopInfo.getExpireAt()-Instant.now().toEpochMilli()); + redisUtils.set(CacheKey.ACT_CODE + resources.getAccount(), "1", tbShopInfo.getExpireAt() - Instant.now().toEpochMilli()); } - if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){ - if(resources.getMainId() == null){ + if (org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())) { + if (resources.getMainId() == null) { throw new BadRequestException("连锁店或者扩展店 主店铺不能为空"); } - }else { + } else { tbShopInfo.setMainId(null); tbShopInfo.setTubeType(1); } @@ -275,7 +277,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { shopStaffRepository.save(tbPlussShopStaff); //增加默认支付方式 Integer integer = tbShopPayTypeRepository.creatPayType(save.getId().toString()); - if (integer<4){ + if (integer < 4) { throw new BadRequestException("请重试"); } TbProductGroup tbProductGroup = new TbProductGroup(); @@ -290,35 +292,35 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override @Transactional - public void upShopPass(String username,String password){ + public void upShopPass(String username, String password) { User user = userRepository.findByUsername(username); if (user == null) { throw new EntityNotFoundException(User.class, "username", username); } String encPass = MD5Utils.encrypt(password); - shopStaffRepository.updatePass(username,encPass,System.currentTimeMillis()); - merchantAccountRepository.updatePass(username,encPass,System.currentTimeMillis()); + shopStaffRepository.updatePass(username, encPass, System.currentTimeMillis()); + merchantAccountRepository.updatePass(username, encPass, System.currentTimeMillis()); // passwordEncoder.encode(passwordEncoder.encode(password)) - userService.updatePass(username,passwordEncoder.encode(password)); + userService.updatePass(username, passwordEncoder.encode(password)); } @Override @Transactional(rollbackFor = Exception.class) public void update(TbShopInfo resources) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new); - if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){ - if(resources.getMainId() == null){ + if (org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())) { + if (resources.getMainId() == null) { throw new BadRequestException("连锁店或者扩展店 主店铺不能为空"); } - }else { + } else { tbShopInfo.setMainId(null); tbShopInfo.setTubeType(1); } if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) { - shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString()); - userRepository.updateNickName(resources.getAccount(),resources.getShopName()); + shopStaffRepository.updateNameById(resources.getShopName(), resources.getId().toString()); + userRepository.updateNickName(resources.getAccount(), resources.getShopName()); } - ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId()); + ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", resources.getId()); tbShopInfo.copy(resources); tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); tbShopInfoRepository.save(tbShopInfo); @@ -327,7 +329,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override public void updateShopId(TbShopInfo resources) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new); - ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId()); + ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", resources.getId()); tbShopInfo.copy(resources); } @@ -348,7 +350,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { public void download(List all, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (TbShopInfoDto tbShopInfo : all) { - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put("店铺帐号", tbShopInfo.getAccount()); map.put("店铺代号,策略方式为city +店铺号(8位)", tbShopInfo.getShopCode()); map.put("店铺口号", tbShopInfo.getSubTitle()); @@ -369,7 +371,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { map.put("经纬度", tbShopInfo.getLat()); map.put("经纬度", tbShopInfo.getLng()); map.put("未用", tbShopInfo.getMchId()); - map.put(" registerType", tbShopInfo.getRegisterType()); + map.put(" registerType", tbShopInfo.getRegisterType()); map.put("是否独立的微信小程序", tbShopInfo.getIsWxMaIndependent()); map.put("详细地址", tbShopInfo.getAddress()); map.put("类似于这种规则51.51.570", tbShopInfo.getCity()); @@ -378,7 +380,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { map.put("行业名称", tbShopInfo.getIndustryName()); map.put("营业时间", tbShopInfo.getBusinessTime()); map.put("配送时间", tbShopInfo.getPostTime()); - map.put(" postAmountLine", tbShopInfo.getPostAmountLine()); + map.put(" postAmountLine", tbShopInfo.getPostAmountLine()); map.put("0停业1,正常营业,网上售卖", tbShopInfo.getOnSale()); map.put("0今日,1次日", tbShopInfo.getSettleType()); map.put("时间", tbShopInfo.getSettleTime()); @@ -389,9 +391,9 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { map.put("订单等待时间", tbShopInfo.getOrderWaitPayMinute()); map.put("支持登陆设备个数", tbShopInfo.getSupportDeviceNumber()); map.put("分销层级(1-下级分销 2-两下级分销)", tbShopInfo.getDistributeLevel()); - map.put(" createdAt", tbShopInfo.getCreatedAt()); - map.put(" updatedAt", tbShopInfo.getUpdatedAt()); - map.put(" proxyId", tbShopInfo.getProxyId()); + map.put(" createdAt", tbShopInfo.getCreatedAt()); + map.put(" updatedAt", tbShopInfo.getUpdatedAt()); + map.put(" proxyId", tbShopInfo.getProxyId()); list.add(map); } FileUtil.downloadExcel(list, response); From c6454d45ed79ca538b10f7ac35c3da8a543138db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Mon, 25 Nov 2024 11:01:56 +0800 Subject: [PATCH 093/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/mapper/TbCreditBuyerOrderMapper.java | 14 +++++++++----- .../impl/TbCreditBuyerOrderServiceImpl.java | 5 +++++ .../mapper/plus/TbCreditBuyerOrderMapper.xml | 6 ++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java index 1010a72c..a608b1f7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java @@ -10,18 +10,22 @@ import java.util.List; import java.util.Map; /** -* 挂账账单 -* -* @author Tankaikai tankaikai@aliyun.com -* @since 2.0 2024-11-20 -*/ + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ @Mapper public interface TbCreditBuyerOrderMapper extends BaseMapper { List getList(Map params); + long getCount(Map params); + BigDecimal getSumPayAmount(Map params); + BigDecimal getSumPaidAmount(Map params); + BigDecimal getSumUnpaidAmount(Map params); CreditBuyerOrderDTO getOne(Map params); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 1f0136a9..fdd4bc1b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -81,6 +81,11 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl data = new HashMap<>(4); // 总交易笔数 data.put("count", count); + + // 总交易金额 + BigDecimal payAmount = baseMapper.getSumPayAmount(params); + data.put("payAmountTotal", payAmount); + // 未支付 params.put("status", "unpaid"); long unpaidCount = baseMapper.getCount(params); diff --git a/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml index d2dc56e4..78d39762 100644 --- a/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml +++ b/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml @@ -51,6 +51,12 @@ order by t1.order_id desc + + + select + x.phone_number as phoneNumber, + count( case when x.`status` = 10 then 1 end) AS consumeOrders, + count( case when x.`status` = -1 or x.`status` = 999 then 1 end) AS cancelOrders + from tb_shop_table_booking x + where x.phone_number in + + #{phoneNumber, jdbcType=VARCHAR} + + GROUP BY x.phone_number + + \ No newline at end of file From 83242a5398bc23bcc67ba11dc303656943d80806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Mon, 25 Nov 2024 17:12:43 +0800 Subject: [PATCH 101/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbShopTableBookingServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index ca9b9870..63a08eb9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -273,7 +273,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl data = list.stream().filter(item -> phoneNo.equals(item.get("phoneNumber"))).findFirst().orElse(fillData); - result.put("Tel_"+phoneNo, data); + result.put(phoneNo, data); } return result; } From ee88ccc07dae244acc754020b53784e0645ea044 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 25 Nov 2024 17:16:28 +0800 Subject: [PATCH 102/170] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=8F=8F=E8=BF=B0=20=E8=BF=94=E5=9B=9E=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/service/impl/TbShopCouponServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java index 5d2d448c..904706e5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java @@ -196,7 +196,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl Date: Mon, 25 Nov 2024 17:54:41 +0800 Subject: [PATCH 103/170] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/BindServiceImpl.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java index 46c89573..c6978cbd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java @@ -52,15 +52,15 @@ public class BindServiceImpl implements BindService { String result = HttpUtil.post(url + "cash/subinvoicing", params, 5000); JSONObject jsonObject = JSONObject.parseObject(result); if (jsonObject.getInteger("code").equals(1)) { - if (StringUtils.isNotBlank(shopId)) { - if (redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + shopId)) { - Set articles = redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + shopId); - if (!articles.contains(params.get("article"))) { - articles.add(params.get("article")); - redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + shopId, articles); - } - } - } +// if (StringUtils.isNotBlank(shopId)) { +// if (redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + shopId)) { +// Set articles = redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + shopId); +// if (!articles.contains(params.get("article"))) { +// articles.add(params.get("article")); +// redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + shopId, articles); +// } +// } +// } return jsonObject.getJSONObject("data"); } else { throw new BadRequestException(jsonObject.getString("msg")); @@ -69,7 +69,7 @@ public class BindServiceImpl implements BindService { @Override public JSONObject industry(BindingDto bindingDto) { - if (StringUtils.isNotBlank(bindingDto.getArticle())) { +// if (StringUtils.isNotBlank(bindingDto.getArticle())) { Map params = new HashMap<>(); params.put("name", bindingDto.getArticle()); params.put("page", bindingDto.getPage() == null ? 1 : bindingDto.getPage()); @@ -80,20 +80,21 @@ public class BindServiceImpl implements BindService { } else { throw new BadRequestException(jsonObject.getString("msg")); } - } else { - Set set = new HashSet<>(); - JSONObject jsonObject = new JSONObject(); - if (!redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())) { - TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); - TbMerchantAccount account = accountRepository.findByAccount(tbShopInfo.getAccount()); - set.add(account.getArticle()); - redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId(), set); - jsonObject.put("articles", set); - } else { - jsonObject.put("list", redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())); - } - return jsonObject; - } +// } +// else { +// Set set = new HashSet<>(); +// JSONObject jsonObject = new JSONObject(); +// if (!redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())) { +// TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); +// TbMerchantAccount account = accountRepository.findByAccount(tbShopInfo.getAccount()); +// set.add(account.getArticle()); +// redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId(), set); +// jsonObject.put("articles", set); +// } else { +// jsonObject.put("list", redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())); +// } +// return jsonObject; +// } } @Override From 41e21bcd3b3ce39e4edb7a5dabb119ed7f8b369c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Tue, 26 Nov 2024 09:26:44 +0800 Subject: [PATCH 104/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TbCreditBuyerServiceImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index 10c96535..4858bbab 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -45,6 +45,7 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl getWrapper(Map params) { MapProxy mapProxy = MapProxy.create(params); String keywords = mapProxy.getStr("keywords"); + String repaymentStatus = mapProxy.getStr("repaymentStatus"); TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); @@ -55,6 +56,16 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl i.like(TbCreditBuyer::getDebtor, keywords).or().like(TbCreditBuyer::getMobile, keywords)); } + if (StrUtil.isNotEmpty(repaymentStatus)) { + if ("unpaid".equals(repaymentStatus)) { + wrapper.apply("0 < ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'unpaid'),0)"); + wrapper.apply("0 = ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)"); + }else if ("partial".equals(repaymentStatus)) { + wrapper.apply("0 < ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)"); + }else if ("paid".equals(repaymentStatus)) { + wrapper.apply("0 = ifnull((select sum(x.count) from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status in ('unpaid','partial')),0)"); + } + } wrapper.eq(TbCreditBuyer::getDelFlag, 0); wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance); wrapper.orderByDesc(TbCreditBuyer::getStatus); From 574fc1eb15389dbb559b06c52438630847295f24 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 26 Nov 2024 10:28:07 +0800 Subject: [PATCH 105/170] =?UTF-8?q?=E7=9B=98=E7=82=B9=20=E5=8F=96=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java index d4358b77..787520ea 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java @@ -113,8 +113,8 @@ public class TbConCheckServiceImpl implements TbConCheckService { conCheck.setPrice(consInfo.getPrice()); conCheck.setAcStockNumber(resources.getStockNumber()); conCheck.setStockNumber(resources.getStockNumber()); - conCheck.setLpNum(resources.getLpNum()); conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum())); + conCheck.setLpNum(resources.getLpNum().abs()); conCheck.setCreateTime(new Timestamp(System.currentTimeMillis())); conCheck.setRemark(resources.getRemark()); return tbConCheckMapper.toDto(tbConCheckRepository.save(conCheck)); From f8cc0c26d664a2a6ce72b02bba535eb0f6f0cf5e Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 26 Nov 2024 10:43:28 +0800 Subject: [PATCH 106/170] =?UTF-8?q?=E7=9B=98=E7=82=B9=20=E5=8F=96=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java index 787520ea..67fcd93e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java @@ -97,7 +97,7 @@ public class TbConCheckServiceImpl implements TbConCheckService { flow.setConsId(consInfo.getId()); flow.setShopId(consInfo.getShopId()); flow.setConName(consInfo.getConName()); - flow.setAmount(resources.getLpNum()); + flow.setAmount(resources.getLpNum().abs()); flow.setBalance(resources.getStockNumber()); flow.setOperator(SecurityUtils.getCurrentUserNickName()); flow.setCreateTime(new Timestamp(System.currentTimeMillis())); @@ -114,7 +114,7 @@ public class TbConCheckServiceImpl implements TbConCheckService { conCheck.setAcStockNumber(resources.getStockNumber()); conCheck.setStockNumber(resources.getStockNumber()); conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum())); - conCheck.setLpNum(resources.getLpNum().abs()); + conCheck.setLpNum(resources.getLpNum()); conCheck.setCreateTime(new Timestamp(System.currentTimeMillis())); conCheck.setRemark(resources.getRemark()); return tbConCheckMapper.toDto(tbConCheckRepository.save(conCheck)); From 97397d041ab99dec75e4c063a3962cd53123971e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 26 Nov 2024 15:01:24 +0800 Subject: [PATCH 107/170] =?UTF-8?q?fix:=20=E7=BE=8E=E5=9B=A2=E5=88=B8?= =?UTF-8?q?=E6=A0=B8=E9=94=80=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/cons/TableConstant.java | 27 +++++++ .../ThirdPartyCouponController.java | 51 ++++++++++++- .../controller/product/TbPlaceController.java | 10 +++ .../cn/ysk/cashier/dto/shoptable/PayDTO.java | 1 + .../dto/shoptable/ThirdCouponCheckDTO.java | 25 ++++++ .../cashier/dto/thirdcoupon/BaseQueryDTO.java | 11 +++ .../dto/thirdcoupon/CheckCouponDTO.java | 18 +++++ .../dto/thirdcoupon/GetActivateCouponDTO.java | 13 ++++ .../dto/thirdcoupon/RevokeCouponDTO.java | 13 ++++ .../entity/TbThirdPartyCouponRecord.java | 47 ++++++++++++ .../TbThirdPartyCouponRecordMapper.java | 18 +++++ .../mybatis/service/MpCashierCartService.java | 9 +++ .../mybatis/service/MpOrderDetailService.java | 4 + .../TbThirdPartyCouponRecordService.java | 13 ++++ .../impl/MpCashierCartServiceImpl.java | 12 +++ .../impl/MpOrderDetailServiceImpl.java | 13 +++- .../TbThirdPartyCouponRecordServiceImpl.java | 22 ++++++ .../ysk/cashier/pojo/order/TbCashierCart.java | 26 +++++-- .../ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../service/ThirdPartyCouponService.java | 13 ++++ .../impl/ThirdPartyCouponServiceImpl.java | 32 +++++++- .../impl/shopimpl/TbShopTableServiceImpl.java | 76 ++++++++++++++++++- .../service/shop/TbShopTableService.java | 4 + .../mapper/TbThirdPartyCouponRecordMapper.xml | 23 ++++++ 24 files changed, 467 insertions(+), 15 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java create mode 100644 eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java index 1244125a..956f3942 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java @@ -20,6 +20,18 @@ public interface TableConstant { } } + class ThirdPartyCoupon { + @Getter + public enum Plat { + MEI_TUAN("meituan"); + private final String value; + + Plat(String value) { + this.value = value; + } + } + } + class CashierCart { public static final String ID = "-999"; @@ -70,6 +82,21 @@ public interface TableConstant { } + @Getter + public enum OrderType { + COUPON("coupon"); + private final String value; + + OrderType(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + + } + @Getter public enum UseType { TAKEOUT("takeout"), diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java index 0a69f072..7714c0e8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java @@ -1,9 +1,13 @@ package cn.ysk.cashier.controller; +import cn.ysk.cashier.dto.thirdcoupon.BaseQueryDTO; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; import cn.ysk.cashier.service.ThirdPartyCouponService; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.Map; + /** * 三方团购券 */ @@ -17,12 +21,57 @@ public class ThirdPartyCouponController { this.thirdPartyCouponService = thirdPartyCouponService; } + /** + * 获取绑定状态 + * @return 绑定状态 + */ + @GetMapping("/state") + public ResponseEntity> getState(@RequestParam Integer shopId) { + return ResponseEntity.ok(thirdPartyCouponService.getState(shopId)); + } + /** * 获取美团绑定链接 * @return 美团绑定链接 */ - @GetMapping + @GetMapping("bindUrl") public ResponseEntity getBindUrl(@RequestParam Integer shopId) { return ResponseEntity.ok(thirdPartyCouponService.getBindUrl(shopId)); } + + /** + * 解绑美团商家 + * @return 美团解绑链接 + */ + @GetMapping("unBindUrl") + public ResponseEntity getUnBindUrl(@RequestParam Integer shopId) { + return ResponseEntity.ok(thirdPartyCouponService.getUnBindUrl(shopId)); + } + + /** + * 获取门店客核销券 + * @return 所有券 + */ + @GetMapping("list") + public ResponseEntity> getActivateCoupon(@RequestParam Integer shopId, @RequestParam String code) { + return ResponseEntity.ok(thirdPartyCouponService.getActivateCoupon(shopId, code)); + } + + /** + * 核销券 + */ + @PostMapping + public ResponseEntity> checkCoupon(@RequestBody CheckCouponDTO checkCouponDTO) { + return ResponseEntity.ok(thirdPartyCouponService.checkCoupon(checkCouponDTO)); + } + + /** + * 撤销券核销 + */ + @DeleteMapping("revoke") + public ResponseEntity> revokeCoupon(@RequestBody CheckCouponDTO checkCouponDTO) { + return ResponseEntity.ok(thirdPartyCouponService.revokeCoupon(checkCouponDTO)); + } + + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index f98f6329..259bea04 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -250,6 +250,16 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.printDishes(baseTableDTO)); } + /** + * 美团核销 + * @param checkDTO + * @return + */ + @PostMapping("checkCoupon") + public ResponseEntity checkCoupon(@Validated @RequestBody ThirdCouponCheckDTO checkDTO) { + return ResponseEntity.ok(tbShopTableService.checkCoupon(checkDTO)); + } + @AnonymousAccess @GetMapping("/test") public void test( diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java index b54bfc51..77b1a8b5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java @@ -22,6 +22,7 @@ public class PayDTO { private BigDecimal discount; private Integer vipUserId; private String code; + private Integer num; private String token; // 使用的优惠券 @Valid diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java new file mode 100644 index 00000000..d3b1a7d0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java @@ -0,0 +1,25 @@ +package cn.ysk.cashier.dto.shoptable; + +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/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java new file mode 100644 index 00000000..96c474c9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java @@ -0,0 +1,11 @@ +package cn.ysk.cashier.dto.thirdcoupon; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class BaseQueryDTO { + @NotNull + private Integer shopId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java new file mode 100644 index 00000000..53565f9f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.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; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java new file mode 100644 index 00000000..656cb586 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.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/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java new file mode 100644 index 00000000..34eb22c0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.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/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java new file mode 100644 index 00000000..babe4b71 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java @@ -0,0 +1,47 @@ +package cn.ysk.cashier.mybatis.entity; + +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import javax.validation.constraints.Size; +import java.time.Instant; +import java.util.List; + +@Getter +@Setter +@Entity +@Table(name = "tb_third_party_coupon_record") +public class TbThirdPartyCouponRecord { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "order_id") + private Integer orderId; + + @Column(name = "state") + private Byte state; + + @Size(max = 255) + @Column(name = "plat") + private String plat; + + @Size(max = 50) + @Column(name = "code", length = 50) + private String code; + + private Integer num; + + @Column(name = "create_time") + private Instant createTime; + + @Column(name = "check_time") + private Instant checkTime; + + @Column(name = "shop_id") + private Integer shopId; + private String cartIdList; + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java new file mode 100644 index 00000000..3ca58f49 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Administrator +* @description 针对表【tb_third_party_coupon_record】的数据库操作Mapper +* @createDate 2024-11-25 17:57:03 +* @Entity cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord +*/ +public interface TbThirdPartyCouponRecordMapper extends BaseMapper { + +} + + + + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java index 36009ac5..9c1ea12a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java @@ -90,5 +90,14 @@ public interface MpCashierCartService extends IService { * @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/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java index c1d059a3..bdf3c773 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java @@ -5,11 +5,13 @@ import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbFullOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderDetail; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.function.Supplier; /** * (TbShopPermission)表服务接口 @@ -78,5 +80,7 @@ public interface MpOrderDetailService extends IService { * @param isMember 会员id */ boolean updateMemberByOrderId(Integer orderId, boolean isMember); + + boolean updateFieldByCartId(SFunction field, Object val, List cartIds); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java new file mode 100644 index 00000000..5277b6d2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author Administrator +* @description 针对表【tb_third_party_coupon_record】的数据库操作Service +* @createDate 2024-11-25 17:57:03 +*/ +public interface TbThirdPartyCouponRecordService extends IService { + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java index 60fb0a4d..6eba9141 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java @@ -184,5 +184,17 @@ public class MpCashierCartServiceImpl extends ServiceImpl 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/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java index ceef2831..318090ba 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java @@ -2,19 +2,18 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.hutool.core.collection.CollUtil; import cn.ysk.cashier.cons.TableConstant; -import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper; import cn.ysk.cashier.mybatis.service.MpOrderDetailService; import cn.ysk.cashier.pojo.order.TbOrderDetail; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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 org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -88,5 +87,15 @@ public class MpOrderDetailServiceImpl extends ServiceImpl field, Object val, List cartIds) { + LambdaUpdateWrapper query = new LambdaUpdateWrapper() + .set(field, val); + if (!cartIds.isEmpty()) { + query.in(TbOrderDetail::getCartId, cartIds); + } + return update(query); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java new file mode 100644 index 00000000..2c8b293b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; +import cn.ysk.cashier.mybatis.service.TbThirdPartyCouponRecordService; +import cn.ysk.cashier.mybatis.mapper.TbThirdPartyCouponRecordMapper; +import org.springframework.stereotype.Service; + +/** +* @author Administrator +* @description 针对表【tb_third_party_coupon_record】的数据库操作Service实现 +* @createDate 2024-11-25 17:57:03 +*/ +@Service +public class TbThirdPartyCouponRecordServiceImpl extends ServiceImpl + implements TbThirdPartyCouponRecordService{ + +} + + + + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index fd8eb268..92d30c9a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -177,6 +177,8 @@ public class TbCashierCart implements Serializable { private String discountSaleNote; private Boolean isPrint; private String useCouponInfo; + // 是否团购券商品 + private Integer isThirdCoupon; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); @@ -186,6 +188,10 @@ public class TbCashierCart implements Serializable { * 根据是否会员充值价格 */ public void resetTotalAmount() { + if (isThirdCoupon != null && isThirdCoupon == 1) { + totalAmount = BigDecimal.ZERO; + return; + } if ("false".equals(isPack)) { packFee = BigDecimal.ZERO; } @@ -207,6 +213,10 @@ public class TbCashierCart implements Serializable { * 根据是否会员充值价格 */ public void resetTotalAmount(BigDecimal discountRadio) { + if (isThirdCoupon != null && isThirdCoupon == 1) { + totalAmount = BigDecimal.ZERO; + return; + } if (discountRadio == null) { discountRadio = BigDecimal.ONE; } @@ -216,10 +226,14 @@ public class TbCashierCart implements Serializable { 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) { - totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); + subtract = memberPrice.subtract(discountSaleAmount); + totalAmount = totalNumber.multiply(subtract).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } else { - totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice) + subtract = salePrice.subtract(discountSaleAmount); + totalAmount = totalNumber.multiply(subtract) .add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } } @@ -230,6 +244,9 @@ public class TbCashierCart implements Serializable { * */ public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) { + if (isThirdCoupon != null && isThirdCoupon == 1) { + return BigDecimal.ZERO; + } if (discountRadio == null) { discountRadio = new BigDecimal("1"); } @@ -250,10 +267,5 @@ public class TbCashierCart implements Serializable { } - public void resetDiscountSaleAmount() { - BigDecimal finalAmount = BigDecimal.ZERO; - if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - } - } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index b7ebdb97..5dd2ca24 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -138,6 +138,7 @@ public class TbOrderDetail implements Serializable { private String useCouponInfo; private BigDecimal returnAmount; private BigDecimal canReturnAmount; + private Integer isThirdCoupon; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java index 3da26911..14af68f4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java @@ -1,9 +1,22 @@ package cn.ysk.cashier.service; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +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/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java index 5082747c..5160deed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; import cn.ysk.cashier.pojo.shop.TbShopInfo; @@ -30,7 +31,7 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService { } private final RestTemplate restTemplate; - private T getData(String url, Integer shopId, Object data) { + private T exec(String url, Integer shopId, Object data) { // 获取店铺信息 TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); if (shopInfo == null) { @@ -77,6 +78,33 @@ public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService { @Override public String getBindUrl(Integer shopId) { - return getData("/meituan/getuisdkurl", shopId, null); + return exec("/meituan/getuisdkurl", shopId, null); + } + + @Override + public String getUnBindUrl(Integer shopId) { + return exec("/meituan/getuisdkuniurl", shopId, null); + } + + @Override + public Map getActivateCoupon(Integer shopId, String code) { + return exec("/meituan/fulfilmentcertificateprepare", shopId, new HashMap(){{ + put("code", code); + }}); + } + + @Override + public Map checkCoupon(CheckCouponDTO checkCouponDTO) { + return exec("/meituan/certificateprepare", checkCouponDTO.getShopId(), checkCouponDTO); + } + + @Override + public Map revokeCoupon(CheckCouponDTO checkCouponDTO) { + return exec("/meituan/fulfilmentcertificatecancel", checkCouponDTO.getShopId(), checkCouponDTO); + } + + @Override + public Map getState(Integer shopId) { + return exec("/meituan/searchstorestatus", shopId, null); } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 8901b8f9..e7edd592 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -22,11 +22,13 @@ import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO; import cn.ysk.cashier.dto.shop.TbShopTableDto; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; import cn.ysk.cashier.dto.shoptable.*; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; import cn.ysk.cashier.enums.*; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.shop.TbShopTableMapper; import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; import cn.ysk.cashier.mybatis.entity.TbShopCoupon; +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; import cn.ysk.cashier.mybatis.mapper.*; import cn.ysk.cashier.mybatis.service.*; import cn.ysk.cashier.pojo.TbShopPayType; @@ -43,6 +45,7 @@ import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.repository.shop.TbShopTableRepository; import cn.ysk.cashier.service.PayService; +import cn.ysk.cashier.service.ThirdPartyCouponService; import cn.ysk.cashier.service.impl.TbPayServiceImpl; import cn.ysk.cashier.service.order.TbOrderInfoService; import cn.ysk.cashier.service.shop.TbShopTableService; @@ -125,12 +128,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final MpShopInfoMapper mpShopInfoMapper; private final MpOrderDetailService mpOrderDetailService; private final MpCashierCartService mpCashierCartService; - private final MpMerchantThirdApplyMapper mpMerchantThirdApplyMapper; private final PayService payService; private final TbOrderInfoService orderInfoService; private final MpOrderInfoService mpOrderInfoService; private final TbShopUserMapper tbShopUserMapper; - private final TbActivateInRecordService activateInRecordService; + private final ThirdPartyCouponService thirdPartyCouponService; + private final TbThirdPartyCouponRecordService thirdPartyCouponRecordService; private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) { // 获取当前台桌最新订单,先付款模式不获取 @@ -2279,7 +2282,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { payDTO.setDiscount(new BigDecimal("1")); } - BigDecimal finalAmount = null; + BigDecimal finalAmount; // 计算优惠券积分折扣信息 if (payDTO.getVipUserId() != null) { @@ -2320,6 +2323,28 @@ public class TbShopTableServiceImpl implements TbShopTableService { case "deposit": orderInfo = tbPayServiceImpl.memberAccountPay("", String.valueOf(payDTO.getShopId()), payDTO.getCode(), orderInfo, finalAmount); break; + // 团购券支付 + case "partyCoupon": + if (payDTO.getNum() == null || payDTO.getNum() < 1) { + throw new BadRequestException("团购券核销数量有误"); + } + CheckCouponDTO dto = new CheckCouponDTO(); + dto.setNum(1); + dto.setShopId(payDTO.getShopId()); + dto.setCouponCode(payDTO.getCode()); + thirdPartyCouponService.checkCoupon(dto); + orderInfo.setOrderType(TableConstant.OrderInfo.OrderType.COUPON.getValue()); + TbThirdPartyCouponRecord record = new TbThirdPartyCouponRecord(); + record.setOrderId(orderInfo.getId()); + record.setCode(payDTO.getCode()); + record.setNum(1); + record.setState((byte) 1); + record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue()); + record.setCreateTime(DateUtil.date().toInstant()); + record.setCheckTime(DateUtil.date().toInstant()); + record.setShopId(payDTO.getShopId()); + thirdPartyCouponRecordService.save(record); + break; default: throw new BadRequestException("未知支付方式"); } @@ -3171,4 +3196,49 @@ public class TbShopTableServiceImpl implements TbShopTableService { } return cashierCart; } + + @Override + public Object checkCoupon(ThirdCouponCheckDTO checkDTO) { + TbOrderInfo orderInfo = mpOrderInfoService.getById(checkDTO.getOrderId()); + if (orderInfo == null) { + throw new BadRequestException("订单信息不存在"); + } + + if (!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) { + throw new BadRequestException("订单不为待支付状态"); + } + + List cashierCarts = mpCashierCartService.selectByIds(checkDTO.getShopId(), checkDTO.getOrderId(), checkDTO.getCartId()); + if (cashierCarts.size() != checkDTO.getCartId().size()) { + throw new BadRequestException("含有不存在购物车"); + } + + 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((byte) 1); + record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue()); + record.setCreateTime(DateUtil.date().toInstant()); + record.setCheckTime(DateUtil.date().toInstant()); + record.setShopId(checkDTO.getShopId()); + record.setCartIdList(JSONObject.toJSONString(checkDTO.getCartId())); + thirdPartyCouponRecordService.save(record); + return true; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 6c32f853..1f89c770 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -163,4 +163,8 @@ public interface TbShopTableService { */ TbCashierCart updatePrice(UpdatePriceDTO updatePriceDTO); + /** + * 团购券核销 + */ + Object checkCoupon(ThirdCouponCheckDTO checkDTO); } diff --git a/eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml b/eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml new file mode 100644 index 00000000..539e2604 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,order_id,state, + plat,code,create_time, + check_time,shop_id + + From a4e98bada8f933417ce493180f602372430acab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Tue, 26 Nov 2024 15:29:34 +0800 Subject: [PATCH 108/170] =?UTF-8?q?fix:=20=E4=B8=B4=E6=97=B6=E8=8F=9C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 2 - .../impl/shopimpl/TbShopTableServiceImpl.java | 82 ++++++++----------- 2 files changed, 32 insertions(+), 52 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index 259bea04..3a2a99bc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -252,8 +252,6 @@ public class TbPlaceController { /** * 美团核销 - * @param checkDTO - * @return */ @PostMapping("checkCoupon") public ResponseEntity checkCoupon(@Validated @RequestBody ThirdCouponCheckDTO checkDTO) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index e7edd592..cd72bdbc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -636,51 +636,33 @@ public class TbShopTableServiceImpl implements TbShopTableService { public TbCashierCart addTemporaryDishes(AddTemporaryDishesDTO temporaryDishesDTO) { temporaryDishesDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(temporaryDishesDTO.getUseType()) ? null : temporaryDishesDTO.getTableId()); ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(temporaryDishesDTO.getShopId(), temporaryDishesDTO.getTableId(), temporaryDishesDTO.getUseType()); - - TbCashierCart tbCashierCart = mpCashierCartService.selectOneCartByShopEatType(shopEatTypeInfoDTO, temporaryDishesDTO.getMasterId(), null, null, false, true); - // 首次加入 - if (tbCashierCart == null) { - tbCashierCart = new TbCashierCart(); - tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); - tbCashierCart.setCreatedAt(System.currentTimeMillis()); - tbCashierCart.setIsSku("0"); - if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { - tbCashierCart.setTableId(shopEatTypeInfoDTO.getTableId()); - } - tbCashierCart.setName(temporaryDishesDTO.getName()); - tbCashierCart.setSalePrice(temporaryDishesDTO.getPrice()); - tbCashierCart.setMasterId(temporaryDishesDTO.getMasterId()); - tbCashierCart.setShopId(String.valueOf(temporaryDishesDTO.getShopId())); - tbCashierCart.setTradeDay(DateUtils.getDay()); - tbCashierCart.setStatus("create"); - tbCashierCart.setIsPack("false"); - tbCashierCart.setIsGift("false"); - tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); - tbCashierCart.setPackFee(BigDecimal.ZERO); - tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum()); - tbCashierCart.setNumber(temporaryDishesDTO.getNum()); - tbCashierCart.setCategoryId(String.valueOf(temporaryDishesDTO.getCategoryId())); - tbCashierCart.setNote(temporaryDishesDTO.getNote()); - tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); - tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && temporaryDishesDTO.getVipUserId() != null ? 1 : 0); - tbCashierCart.setIsTemporary(1); - tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); - cashierCartRepository.save(tbCashierCart); - - } else { - tbCashierCart.setIsMember(temporaryDishesDTO.getVipUserId() == null ? 0 : 1); - tbCashierCart.setNote(temporaryDishesDTO.getNote()); - tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); - tbCashierCart.setPackFee(BigDecimal.ZERO); - tbCashierCart.setIsPack("false"); - tbCashierCart.setIsGift("false"); - tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum()); - tbCashierCart.setNumber(temporaryDishesDTO.getNum()); - tbCashierCart.setUpdatedAt(DateUtil.current()); - tbCashierCart.setIsTemporary(1); - tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); - cashierCartMapper.updateById(tbCashierCart); +// + 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.setIsTemporary(1); + tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); + cashierCartRepository.save(tbCashierCart); if (StrUtil.isNotBlank(temporaryDishesDTO.getTableId())) { setRedisTableCartInfo(temporaryDishesDTO.getTableId(), temporaryDishesDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true); @@ -2118,14 +2100,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { return productDiscount; } - private void updateOrderDetailCanReturn(List orderDetailList, TbOrderInfo 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()); + totalAmount = totalAmount.add(orderDetail.getPriceAmount()); } for (TbOrderDetail item : orderDetailList) { if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) || orderInfo.getPointsNum() != null) { @@ -2134,7 +2116,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { lastReturnAmount = canReturnAmount; lastAmount = item.getPriceAmount(); item.setCanReturnAmount(canReturnAmount); - }else { + } else { item.setCanReturnAmount(item.getPriceAmount()); } } @@ -2323,7 +2305,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { case "deposit": orderInfo = tbPayServiceImpl.memberAccountPay("", String.valueOf(payDTO.getShopId()), payDTO.getCode(), orderInfo, finalAmount); break; - // 团购券支付 + // 团购券支付 case "partyCoupon": if (payDTO.getNum() == null || payDTO.getNum() < 1) { throw new BadRequestException("团购券核销数量有误"); @@ -2879,7 +2861,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (remainNum.compareTo(BigDecimal.ZERO) <= 0) { returnAmount = orderDetail.getPriceAmount(); packAMount = orderDetail.getPackAmount(); - }else { + } else { currentDetailAMount = orderDetail.getPriceAmount() .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); @@ -3175,7 +3157,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (cashierCart.getSalePrice().subtract(updatePriceDTO.getSaleAmount()).compareTo(BigDecimal.ZERO) < 0) { throw new BadRequestException("折扣金额不能超过单价"); } - }else { + } else { if (cashierCart.getMemberPrice().subtract(updatePriceDTO.getSaleAmount()).compareTo(BigDecimal.ZERO) < 0) { throw new BadRequestException("折扣金额不能超过单价"); } From 2d5a147bf7f92b4c65ee112a067bf96d04b6650c Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 26 Nov 2024 15:34:17 +0800 Subject: [PATCH 109/170] =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cons/repository/TbConsInfoRepository.java | 12 + .../cons/repository/TbConsTypeRepository.java | 10 + .../repository/TbProskuConRepository.java | 7 + .../controller/TbShopSyncInfoController.java | 68 +++ .../dto/TbShopSyncInfoQueryCriteria.java | 22 + .../mybatis/entity/TbShopSyncInfo.java | 56 +++ .../mybatis/mapper/TbShopSyncInfoMapper.java | 17 + .../service/TbShopSyncInfoService.java | 22 + .../impl/TbShopSyncInfoServiceImpl.java | 474 ++++++++++++++++++ .../product/TbProductGroupRepository.java | 10 + .../product/TbProductRepository.java | 29 +- .../product/TbProductSkuRepository.java | 6 + .../product/TbProductSkuResultRepository.java | 15 - .../product/TbProductSpecRepository.java | 51 +- .../product/TbShopCategoryRepository.java | 7 + .../repository/shop/TbShopUnitRepository.java | 23 +- 16 files changed, 769 insertions(+), 60 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java index 5b7c1a93..fc9ea24c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import java.util.List; @@ -34,4 +35,15 @@ public interface TbConsInfoRepository extends JpaRepository " where conPro.con_info_id = :conInfoId " + " group by conPro.product_id ",nativeQuery = true) List> queryAllAndPro(@Param("shopId") Integer shopId, @Param("conInfoId")Integer conInfoId); + + @Query(value = + "SELECT *" + + " FROM" + + " tb_prosku_con conPro" + + " where conPro.shop_id = :shopId ",nativeQuery = true) + List searchConsInfoByShopId(Integer shopId); + + @Modifying + @Query(value = "delete FROM tb_prosku_con conPro where conPro.shop_id = :shopId ",nativeQuery = true) + void clearShopCons(Integer shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java index 25b7904d..37084fa0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java @@ -3,8 +3,11 @@ package cn.ysk.cashier.cons.repository; import cn.ysk.cashier.cons.domain.TbConsType; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import java.util.List; + /** * @website https://eladmin.vip * @author admin @@ -16,6 +19,13 @@ public interface TbConsTypeRepository extends JpaRepository TbConsType findByConTypeCode(String conTypeCode); + @Query("SELECT c FROM TbProskuCon c WHERE c.shopId = :shopId") + List searchConsTypeByShopId(Integer shopId); + + @Modifying + @Query("delete FROM TbProskuCon c WHERE c.shopId = :shopId") + void clearShopConType(Integer shopId); + @Query("SELECT count(*) FROM TbProskuCon c LEFT JOIN TbConsInfo i ON c.conInfoId = i.id WHERE i.conTypeId = :id") int countProByTypeId(Integer id); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java index e16d6305..b677992e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java @@ -30,4 +30,11 @@ public interface TbProskuConRepository extends JpaRepository searchAllByProductId(Integer productId); + @Query(value = "select * from tb_prosku_con where shop_id=?1 ",nativeQuery = true) + List searchConsProByShopId(Integer shopId); + + @Modifying + @Query(value = "delete from tb_prosku_con where shop_id=?1 ",nativeQuery = true) + void clearShopConPro(Integer shopId); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java new file mode 100644 index 00000000..780980e0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java @@ -0,0 +1,68 @@ +package cn.ysk.cashier.controller; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.dto.TbShopSyncInfoQueryCriteria; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import cn.ysk.cashier.mybatis.mapper.TbShopSyncInfoMapper; +import cn.ysk.cashier.mybatis.service.TbShopSyncInfoService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Date; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表控制层 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@RestController +@RequestMapping("/api/tbShopSyncInfo") +public class TbShopSyncInfoController { + + @Resource + private TbShopSyncInfoService tbShopSyncInfoService; + + @Autowired + private TbShopSyncInfoMapper tbShopSyncInfomapper; + + @GetMapping + @ApiOperation("查询同步数据情况") + public ResponseEntity selectAll(TbShopSyncInfoQueryCriteria criteria) { + return new ResponseEntity<>(tbShopSyncInfoService.queryByShopId(criteria), HttpStatus.OK); + } + + @PostMapping("/sync") + @ApiOperation("同步") + public ResponseEntity sync(@RequestBody TbShopSyncInfo tbShopSyncInfo){ + tbShopSyncInfo.setSyncTime(new Date()); + tbShopSyncInfo.setStatus(1); + tbShopSyncInfomapper.insert(tbShopSyncInfo); + tbShopSyncInfoService.sync(tbShopSyncInfo); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @AnonymousPostMapping("/clear") + @ApiOperation("一键清除店铺数据") + public ResponseEntity clear(@RequestBody TbShopSyncInfo tbShopSyncInfo){ + TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria(); + criteria.setPointShopId(tbShopSyncInfo.getPointShopId()); + TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria); + long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR); + if(between > 24){ + throw new RuntimeException("数据同步已超过一天 无法清除"); + } + tbShopSyncInfoService.clear(tbShopSyncInfo); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java new file mode 100644 index 00000000..feff2e2d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表查询类 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Data +public class TbShopSyncInfoQueryCriteria { + + //目的shop + private Integer pointShopId; + //1-正在 2-完成 + private Integer status; + + private long page = 1; + private long size = 10; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java new file mode 100644 index 00000000..e25648ff --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java @@ -0,0 +1,56 @@ +package cn.ysk.cashier.mybatis.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; + +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import java.io.Serializable; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表实体类 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Data +@SuppressWarnings("serial") +public class TbShopSyncInfo extends Model { + + @GeneratedValue(strategy = GenerationType.IDENTITY) + @TableId(type = IdType.AUTO) + private Integer id; + //源shop + private Integer sourceShopId; + //目的shop + private Integer pointShopId; + //分组同步数量 + private Integer proGroup; + //规格同步数量 + private Integer proSpec; + //单位同步数量 + private Integer proUnit; + //分类同步数量 + private Integer proCategory; + //商品同步数量 + private Integer product; + //规格同步数量 + private Integer proSku; + //商品同步数量 + private Integer proSkuResult; + //耗材类型同步数量 + private Integer consType; + //耗材信息同步数量 + private Integer consInfo; + //商品耗材关联同步数量 + private Integer consPro; + //1-正在 2-完成 + private Integer status; + //同步时间 + private Date syncTime; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java new file mode 100644 index 00000000..5f535b7e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java @@ -0,0 +1,17 @@ +package cn.ysk.cashier.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import org.apache.ibatis.annotations.Mapper; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表数据库访问层 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Mapper +public interface TbShopSyncInfoMapper extends BaseMapper { + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java new file mode 100644 index 00000000..a6573378 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import cn.ysk.cashier.dto.TbShopSyncInfoQueryCriteria; + +import java.util.Map; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表服务接口 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +public interface TbShopSyncInfoService extends IService { + + TbShopSyncInfo queryByShopId(TbShopSyncInfoQueryCriteria criteria); + void sync(TbShopSyncInfo tbShopSyncInfo); + void clear(TbShopSyncInfo tbShopSyncInfo); + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java new file mode 100644 index 00000000..18e7dca8 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -0,0 +1,474 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateTime; +import cn.ysk.cashier.cons.domain.TbConsInfo; +import cn.ysk.cashier.cons.domain.TbConsType; +import cn.ysk.cashier.cons.repository.TbConsInfoRepository; +import cn.ysk.cashier.cons.repository.TbConsTypeRepository; +import cn.ysk.cashier.cons.repository.TbProskuConRepository; +import cn.ysk.cashier.dto.TbShopSyncInfoQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import cn.ysk.cashier.mybatis.mapper.TbShopSyncInfoMapper; +import cn.ysk.cashier.mybatis.service.TbShopSyncInfoService; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.pojo.product.*; +import cn.ysk.cashier.pojo.shop.TbShopUnit; +import cn.ysk.cashier.repository.product.*; +import cn.ysk.cashier.repository.shop.TbShopUnitRepository; +import cn.ysk.cashier.utils.JSONUtil; +import cn.ysk.cashier.utils.ListUtil; +import cn.ysk.cashier.utils.PageUtil; +import cn.ysk.cashier.utils.QueryHelp; +import cn.ysk.cashier.vo.ProductGroupVo; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.gson.JsonObject; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.Predicate; +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表服务实现类 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Slf4j +@Service +public class TbShopSyncInfoServiceImpl extends ServiceImpl implements TbShopSyncInfoService { + + + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private TbShopSyncInfoMapper tbShopSyncInfomapper; + //单位 + @Autowired + private TbShopUnitRepository unitRepository; + //规格 + @Autowired + private TbProductSpecRepository specRepository; + //分组 + @Autowired + private TbProductGroupRepository groupRepository; + //分类 + @Autowired + private TbShopCategoryRepository categoryRepository; + //商品 + @Autowired + private TbProductRepository productRepository; + @Autowired + private TbProductSkuRepository skuRepository; + @Autowired + private TbProductSkuResultRepository skuResultRepository; + + //耗材 + @Autowired + private TbConsInfoRepository consRepository; + @Autowired + private TbConsTypeRepository consTypeRepository; + @Autowired + private TbProskuConRepository proSkuConRepository; + + + @Override + public TbShopSyncInfo queryByShopId(TbShopSyncInfoQueryCriteria criteria) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("point_shop_id", criteria.getPointShopId()); + wrapper.orderByDesc("sync_time"); + TbShopSyncInfo tbShopSyncInfo = tbShopSyncInfomapper.selectOne(wrapper); + return tbShopSyncInfo; + } + + @Async + @Override + public void sync(TbShopSyncInfo tbShopSyncInfo) { + Map units; + Map specs; + Map cateGorys; + Map groups; + Map pros = new HashMap<>(); + Map skus = new HashMap<>(); + Map conTypes; + Map consInfos = new HashMap<>(); + Map consPros = new HashMap<>(); + Integer skuResults = 0; + TbShopSyncInfoServiceImpl self = applicationContext.getBean(TbShopSyncInfoServiceImpl.class); + + try { + List> futures = new ArrayList<>(); + List> futures2 = new ArrayList<>(); + if (tbShopSyncInfo.getProduct() != null && tbShopSyncInfo.getProduct() > 0) { + CompletableFuture> futureUnit = self.syncUnit(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + CompletableFuture> futureSpec = self.syncSpec(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + CompletableFuture> futureCate = self.syncCategory(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + futures.add(futureUnit); + futures.add(futureSpec); + futures.add(futureCate); + + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + + units = futureUnit.get(); + tbShopSyncInfo.setProUnit(units.size()); + + specs = futureSpec.get(); + tbShopSyncInfo.setProSpec(specs.size()); + + cateGorys = futureCate.get(); + tbShopSyncInfo.setProCategory(cateGorys.size()); + + CompletableFuture> futurePros = self.syncProduct(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), units, specs, cateGorys); + pros = futurePros.get(); + tbShopSyncInfo.setProduct(pros.size()); + + self.syncGroupPackage(tbShopSyncInfo.getPointShopId(), pros, skus); + CompletableFuture> futureGroup = self.syncGroup(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), pros); + CompletableFuture> futureSkus = self.syncSku(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), pros); + CompletableFuture futureSkuResults = self.syncSkuResult(pros); + futures2.add(futureGroup); + futures2.add(futureSkus); + futures2.add(futureSkuResults); + + CompletableFuture.allOf(futures2.toArray(new CompletableFuture[0])).join(); + + groups = futureGroup.get(); + tbShopSyncInfo.setProGroup(groups.size()); + + skus = futureSkus.get(); + tbShopSyncInfo.setProSku(skus.size()); + + skuResults = futureSkuResults.get(); + tbShopSyncInfo.setProSkuResult(skuResults); + } else { + if (tbShopSyncInfo.getProUnit() != null && tbShopSyncInfo.getProUnit() > 0) { + CompletableFuture> futureUnit = self.syncUnit(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + units = futureUnit.get(); + tbShopSyncInfo.setProUnit(units.size()); + } + if (tbShopSyncInfo.getProCategory() != null && tbShopSyncInfo.getProCategory() > 0) { + CompletableFuture> futureCate = self.syncCategory(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + cateGorys = futureCate.get(); + tbShopSyncInfo.setProCategory(cateGorys.size()); + } + if (tbShopSyncInfo.getProSpec() != null && tbShopSyncInfo.getProSpec() > 0) { + CompletableFuture> futureSpec = self.syncSpec(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + specs = futureSpec.get(); + tbShopSyncInfo.setProSpec(specs.size()); + } + } + + if (tbShopSyncInfo.getConsInfo() != null && tbShopSyncInfo.getConsInfo() > 0) { + CompletableFuture> futureConTypes = self.syncConsType(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + conTypes = futureConTypes.get(); + tbShopSyncInfo.setConsType(conTypes.size()); + + CompletableFuture> futureConsInfos = self.syncCons(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), conTypes); + consInfos = futureConsInfos.get(); + tbShopSyncInfo.setConsInfo(consInfos.size()); + } else if (tbShopSyncInfo.getConsType() != null && tbShopSyncInfo.getConsType() > 0) { + CompletableFuture> futureConTypes = self.syncConsType(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + conTypes = futureConTypes.get(); + tbShopSyncInfo.setConsType(conTypes.size()); + } + + if (tbShopSyncInfo.getConsPro() != null && tbShopSyncInfo.getConsPro() > 0 + && tbShopSyncInfo.getConsInfo() != null && tbShopSyncInfo.getConsInfo() > 0 + && tbShopSyncInfo.getProduct() != null && tbShopSyncInfo.getProduct() > 0) { + CompletableFuture> mapCompletableFuture = self.syncConsPro(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), consInfos, pros, skus); + consPros = mapCompletableFuture.get(); + tbShopSyncInfo.setConsPro(consPros.size()); + } + tbShopSyncInfo.setSyncTime(new Date()); + tbShopSyncInfo.setStatus(2); + tbShopSyncInfomapper.updateById(tbShopSyncInfo); + } catch (Exception e) { + tbShopSyncInfo.setSyncTime(new Date()); + tbShopSyncInfo.setStatus(0); + tbShopSyncInfomapper.updateById(tbShopSyncInfo); + log.error("数据同步失败", e); + } + } + + @Override + public void clear(TbShopSyncInfo tbShopSyncInfo) { + unitRepository.clearShopUnit(tbShopSyncInfo.getPointShopId().toString()); + specRepository.clearShopSpec(tbShopSyncInfo.getPointShopId().toString()); + groupRepository.clearShopGroup(tbShopSyncInfo.getPointShopId()); + categoryRepository.clearShopCategory(tbShopSyncInfo.getPointShopId().toString()); + List products = productRepository.selectByShopId(tbShopSyncInfo.getPointShopId().toString()); + products.stream().map(TbProduct::getId).collect(Collectors.toList()).forEach(id -> skuResultRepository.deleteById(id)); + productRepository.clearShopPro(tbShopSyncInfo.getPointShopId().toString()); + skuRepository.clearShopSku(tbShopSyncInfo.getPointShopId().toString()); + consRepository.clearShopCons(tbShopSyncInfo.getPointShopId()); + consTypeRepository.clearShopConType(tbShopSyncInfo.getPointShopId()); + proSkuConRepository.clearShopConPro(tbShopSyncInfo.getPointShopId()); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("point_shop_id", tbShopSyncInfo.getPointShopId()); + tbShopSyncInfomapper.delete(wrapper); + } + + //单位 + @Async + public CompletableFuture> syncUnit(Integer sourceShopId, Integer pointShopId) { + CompletableFuture> future = new CompletableFuture<>(); + Map unitMap = new HashMap<>(); + unitRepository.searchUnitByShopId(sourceShopId.toString()).forEach(tbShopUnit -> { + Integer sourceUnitId = tbShopUnit.getId(); + tbShopUnit.setId(null); + tbShopUnit.setShopId(pointShopId.toString()); + unitRepository.save(tbShopUnit); + unitMap.put(sourceUnitId, tbShopUnit.getId()); + }); + future.complete(unitMap); + return future; + } + + //规格 + @Async + public CompletableFuture> syncSpec(Integer sourceShopId, Integer pointShopId) { + CompletableFuture> future = new CompletableFuture<>(); + Map specMap = new HashMap<>(); + specRepository.searchSpecByShopId(sourceShopId.toString()).forEach(tbProductSpec -> { + Integer sourceSpecId = tbProductSpec.getId(); + tbProductSpec.setId(null); + tbProductSpec.setShopId(pointShopId.toString()); + specRepository.save(tbProductSpec); + specMap.put(sourceSpecId, tbProductSpec.getId()); + }); + future.complete(specMap); + return future; + } + + // 分类 + @Async + public CompletableFuture> syncCategory(Integer sourceShopId, Integer pointShopId) { + CompletableFuture> future = new CompletableFuture<>(); + Map categoryMap = new HashMap<>(); + List tbShopCategories = categoryRepository.searchCategoryByShopId(sourceShopId.toString()); + List treeIds = new ArrayList<>(); + for (TbShopCategory tbShopCategory : tbShopCategories) { + treeIds.add(tbShopCategory.getId()); + + Integer sourceCategoryId = tbShopCategory.getId(); + tbShopCategory.setId(null); + tbShopCategory.setShopId(pointShopId.toString()); + tbShopCategory.setTree(null); + tbShopCategory.setPid(""); + categoryRepository.save(tbShopCategory); + categoryMap.put(sourceCategoryId, tbShopCategory.getId()); + } + if (CollectionUtil.isNotEmpty(treeIds)) { + List children = categoryRepository.findChildren(treeIds); + for (TbShopCategory child : children) { + Integer sourceCategoryId = child.getId(); + child.setId(null); + child.setShopId(pointShopId.toString()); + child.setTree(categoryMap.get(child.getTree())); + child.setPid(StringUtils.isNotBlank(child.getPid()) ? categoryMap.get(Integer.valueOf(child.getPid())).toString() : ""); + categoryRepository.save(child); + categoryMap.put(sourceCategoryId, child.getId()); + } + } + future.complete(categoryMap); + return future; + } + + @Async + public CompletableFuture> syncProduct(Integer sourceShopId, Integer pointShopId, Map units, + Map specs, Map cateGorys) { + CompletableFuture> future = new CompletableFuture<>(); + Map proMap = new HashMap<>(); + productRepository.findByShopId(sourceShopId.toString()).forEach(tbProduct -> { + Integer sourceSpecId = tbProduct.getId(); + tbProduct.setId(null); + tbProduct.setShopId(pointShopId.toString()); + tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : ""); + tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null); + tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null); + tbProduct.setStockNumber(0); + + productRepository.save(tbProduct); + proMap.put(sourceSpecId, tbProduct.getId()); + }); + future.complete(proMap); + return future; + } + + @Async + public CompletableFuture> syncGroup(Integer sourceShopId, Integer pointShopId, Map pros) { + CompletableFuture> future = new CompletableFuture<>(); + Map groupMap = new HashMap<>(); + groupRepository.searchGroupByShopId(sourceShopId).forEach(tbProductGroup -> { + Integer groupId = tbProductGroup.getId(); + tbProductGroup.setId(null); + tbProductGroup.setShopId(pointShopId); + tbProductGroup.setUseTime(0); + tbProductGroup.setProductIds(replaceProIds(tbProductGroup.getProductIds(), pros)); + groupRepository.save(tbProductGroup); + groupMap.put(groupId, tbProductGroup.getId()); + }); + future.complete(groupMap); + return future; + } + + //分组 + @Async + public void syncGroupPackage(Integer shopId, Map pros, Map skus) { + productRepository.findPackageByShopId(shopId.toString()).forEach(tbProduct -> { + tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); + tbProduct.getProGroupVo().forEach(proGroupVo -> { + proGroupVo.getGoods().forEach(goods -> { + if (pros.containsKey(goods.getProId())) { + if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) { + goods.setProId(pros.get(goods.getProId())); + goods.setSkuId(skus.get(goods.getSkuId())); + } else { + goods.setProId(pros.get(goods.getProId())); + } + } + }); + proGroupVo.setCount(proGroupVo.getGoods().size()); + if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) { + if (proGroupVo.getNumber() > proGroupVo.getCount()) { + proGroupVo.setNumber(proGroupVo.getCount()); + } + } + }); + tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo())); + productRepository.save(tbProduct); + }); + } + + //分组 + @Async + public CompletableFuture> syncSku(Integer sourceShopId, Integer pointShopId, Map pros) { + CompletableFuture> future = new CompletableFuture<>(); + Map skuMap = new HashMap<>(); + skuRepository.searchSkuByShopId(sourceShopId.toString()).forEach(tbProductSku -> { + Integer productId = Integer.valueOf(tbProductSku.getProductId()); + if (pros.containsKey(productId)) { + Integer sourceSkuId = tbProductSku.getId(); + tbProductSku.setId(null); + tbProductSku.setShopId(pointShopId.toString()); + tbProductSku.setProductId(pros.get(productId).toString()); + skuRepository.save(tbProductSku); + skuMap.put(sourceSkuId, tbProductSku.getId()); + } + }); + future.complete(skuMap); + return future; + } + + @Async + public CompletableFuture syncSkuResult(Map pros) { + CompletableFuture future = new CompletableFuture<>(); + List skuResults = skuResultRepository.findAll((root, criteriaQuery, criteriaBuilder) -> { + Predicate predicate = root.get("id").in(pros.keySet()); + return predicate; + }); + skuResults.forEach(tbProductSkuResult -> { + tbProductSkuResult.setId(pros.get(tbProductSkuResult.getId())); + skuResultRepository.save(tbProductSkuResult); + }); + future.complete(skuResults.size()); + return future; + } + + @Async + public CompletableFuture> syncConsType(Integer sourceShopId, Integer pointShopId) { + CompletableFuture> future = new CompletableFuture<>(); + Map consTypeMap = new HashMap<>(); + + List tbConsTypes = consTypeRepository.searchConsTypeByShopId(sourceShopId); + for (TbConsType tbConsType : tbConsTypes) { + Integer sourceConsTypeId = tbConsType.getId(); + tbConsType.setId(null); + tbConsType.setShopId(pointShopId); + consTypeRepository.save(tbConsType); + consTypeMap.put(sourceConsTypeId, tbConsType.getId()); + } + + future.complete(consTypeMap); + return future; + } + + // 耗材 + @Async + public CompletableFuture> syncCons(Integer sourceShopId, Integer pointShopId, Map conTypes) { + CompletableFuture> future = new CompletableFuture<>(); + Map consMap = new HashMap<>(); + List tbConsInfos = consRepository.searchConsInfoByShopId(sourceShopId); + for (TbConsInfo tbConsInfo : tbConsInfos) { + Integer sourceConsId = tbConsInfo.getId(); + + tbConsInfo.setId(null); + tbConsInfo.setShopId(pointShopId); + tbConsInfo.setConTypeId(conTypes.get(tbConsInfo.getConTypeId())); + tbConsInfo.setStockNumber(BigDecimal.ZERO); + tbConsInfo.setStockConsume(BigDecimal.ZERO); + consRepository.save(tbConsInfo); + consMap.put(sourceConsId, tbConsInfo.getId()); + } + future.complete(consMap); + return future; + } + + @Async + public CompletableFuture> syncConsPro(Integer sourceShopId, Integer pointShopId, Map consMap, Map proMap, Map skuMap) { + CompletableFuture> future = new CompletableFuture<>(); + Map proSkuConMap = new HashMap<>(); + proSkuConRepository.searchConsProByShopId(sourceShopId).forEach(tbConsPro -> { + if (consMap.containsKey(tbConsPro.getConInfoId()) && proMap.containsKey(tbConsPro.getProductId()) && skuMap.containsKey(tbConsPro.getProductSkuId())) { + Integer sourceConsProId = tbConsPro.getId(); + tbConsPro.setId(null); + tbConsPro.setShopId(pointShopId); + tbConsPro.setConInfoId(consMap.get(tbConsPro.getConInfoId())); + tbConsPro.setProductId(proMap.get(tbConsPro.getProductId())); + if (tbConsPro.getProductSkuId() > 0) { + tbConsPro.setProductSkuId(skuMap.get(tbConsPro.getProductSkuId())); + } + proSkuConRepository.save(tbConsPro); + proSkuConMap.put(sourceConsProId, tbConsPro.getId()); + } + }); + future.complete(proSkuConMap); + return future; + } + + /** + * 分组关联商品 重组 如果绑定的商品Id 不存在 则抛弃 + */ + public static String replaceProIds(String proStr, Map pros) { + if (StringUtils.isNotBlank(proStr) && !"[]".equals(proStr)) { + proStr = proStr.substring(1, proStr.length() - 1); + String[] numbersStr = proStr.split(","); + String result = Stream.of(numbersStr) + .map(Integer::parseInt) + .filter(number -> pros.containsKey(number)) + .map(pros::get) + .map(Object::toString) + .collect(Collectors.joining(",", "[", "]")); + return result; + } + return "[]"; + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java index 063d4e3e..e04741e4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.repository.product; import cn.ysk.cashier.pojo.product.TbProductGroup; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -23,4 +24,13 @@ public interface TbProductGroupRepository extends JpaRepository findByIds(List productIds); + + @Query("SELECT groups from TbProductGroup groups where groups.shopId = :shopId") + List searchGroupByShopId(@Param("shopId") Integer shopId); + + @Modifying + @Query("delete from TbProductGroup groups where groups.shopId = :shopId") + void clearShopGroup(@Param("shopId") Integer shopId); + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index f2c9ce26..e5cdad6b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -14,23 +14,34 @@ import java.math.BigDecimal; import java.util.List; /** -* @website https://eladmin.vip -* @author lyf -* @date 2023-12-11 -**/ + * @author lyf + * @website https://eladmin.vip + * @date 2023-12-11 + **/ public interface TbProductRepository extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT product from TbProduct product where product.id in :productIds order by product.sort") List findByIds(List productIds); - @Query(value = "update tb_product set status = -1 and is_del = 1 where id in :productIds",nativeQuery = true) + @Query("SELECT product from TbProduct product where product.shopId = :shopId and product.status=1 and product.isDel=0 and product.type in ('coupon','package') ") + List findPackageByShopId(@Param("shopId") String shopId); + + + @Query("SELECT product from TbProduct product where product.shopId = :shopId and product.status=1 and product.isDel=0") + List findByShopId(@Param("shopId") String shopId); + + @Modifying + @Query("delete FROM TbProduct product where product.shopId = :shopId") + void clearShopPro(@Param("shopId") String shopId); + + @Query(value = "update tb_product set status = -1 and is_del = 1 where id in :productIds", nativeQuery = true) @Modifying void updateByStatus(List productIds); @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=:stockNumber WHERE pro.id =:productId") - void updateProductStockNumber(@Param("productId") Integer productId,@Param("stockNumber") Integer stockNumber); + void updateProductStockNumber(@Param("productId") Integer productId, @Param("stockNumber") Integer stockNumber); @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=pro.stockNumber+:number WHERE pro.id =:productId") @@ -39,8 +50,8 @@ public interface TbProductRepository extends JpaRepository, @Transactional @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=:stocktakinNum where pro.id=:id and pro.stockNumber=:stockNumber") - Integer updateStock(@Param("id") Integer id,@Param("stockNumber") Integer stockNumber, - @Param("stocktakinNum") Integer stocktakinNum); + Integer updateStock(@Param("id") Integer id, @Param("stockNumber") Integer stockNumber, + @Param("stocktakinNum") Integer stocktakinNum); @Modifying @Query("update TbProduct set stockNumber=stockNumber+:num where id=:id") @@ -64,6 +75,6 @@ public interface TbProductRepository extends JpaRepository, @Transactional @Modifying @Query("UPDATE TbProduct p SET p.warnLine = :warnLine WHERE p.shopId = :shopId") - Integer updateWarnLineByShopId(@Param("warnLine")Integer warnLine, @Param("shopId")String shopId); + Integer updateWarnLineByShopId(@Param("warnLine") Integer warnLine, @Param("shopId") String shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java index c04d9045..598b5a01 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java @@ -22,6 +22,12 @@ public interface TbProductSkuRepository extends JpaRepository searchSku(@Param("productId")String productId); + @Query("SELECT sku FROM TbProductSku sku WHERE sku.shopId = :shopId and sku.isDel=0") + List searchSkuByShopId(@Param("shopId")String shopId); + + @Modifying + @Query("delete FROM TbProductSku sku WHERE sku.shopId = :shopId ") + void clearShopSku(@Param("shopId")String shopId); @Transactional @Modifying diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java index 0f818a00..a78d774a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java @@ -1,18 +1,3 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ package cn.ysk.cashier.repository.product; import cn.ysk.cashier.pojo.product.TbProductSkuResult; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java index b801a505..7be7e20b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java @@ -1,41 +1,50 @@ /* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cn.ysk.cashier.repository.product; import cn.ysk.cashier.pojo.product.TbProductSpec; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.util.List; /** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-03 -**/ + * @author lyf + * @website https://eladmin.vip + * @date 2024-01-03 + **/ public interface TbProductSpecRepository extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT spec FROM TbProductSpec spec WHERE spec.id IN :ids") - List searchSpec(@Param("ids")List ids); + List searchSpec(@Param("ids") List ids); @Query("SELECT spec FROM TbProductSpec spec WHERE spec.id = :ids") - TbProductSpec searchSpec(@Param("ids")Integer ids); + TbProductSpec searchSpec(@Param("ids") Integer ids); @Query("SELECT spec FROM TbProductSpec spec WHERE spec.shopId = :shopId and spec.name = :name") - TbProductSpec findAllByName(@Param("shopId")String shopId, @Param("name")String name); + TbProductSpec findAllByName(@Param("shopId") String shopId, @Param("name") String name); + + + @Query("SELECT spec FROM TbProductSpec spec WHERE spec.shopId = :shopId") + List searchSpecByShopId(@Param("shopId") String shopId); + + @Modifying + @Query("delete FROM TbProductSpec spec WHERE spec.shopId = :shopId") + void clearShopSpec(@Param("shopId") String shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java index 5e29938e..a74e1e88 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java @@ -20,6 +20,7 @@ import org.apache.ibatis.annotations.Param; import org.springframework.data.domain.Page; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.domain.Pageable; @@ -44,4 +45,10 @@ public interface TbShopCategoryRepository extends JpaRepository searchCategory(@Param("ids")List ids); + @Query("SELECT category FROM TbShopCategory category where category.shopId = :shopId and (category.pid is null or category.pid = '')") + List searchCategoryByShopId(@Param("shopId") String shopId); + + @Modifying + @Query("delete FROM TbShopCategory category where category.shopId = :shopId") + void clearShopCategory(@Param("shopId") String shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java index 06ff650c..2e791e25 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java @@ -1,23 +1,9 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ package cn.ysk.cashier.repository.shop; import cn.ysk.cashier.pojo.shop.TbShopUnit; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -37,4 +23,11 @@ public interface TbShopUnitRepository extends JpaRepository @Query("SELECT unit from TbShopUnit unit where unit.name = :name and unit.shopId = :shopId") TbShopUnit findName(@Param("name")String name,@Param("shopId")String shopId); + + @Query("SELECT unit FROM TbShopUnit unit WHERE unit.shopId = :shopId") + List searchUnitByShopId(@Param("shopId")String shopId); + + @Modifying + @Query("delete FROM TbShopUnit unit WHERE unit.shopId = :shopId") + void clearShopUnit(@Param("shopId")String shopId); } \ No newline at end of file From 11a089a5352a2ce219bfeff1ce44c5450f3fc507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Tue, 26 Nov 2024 16:05:04 +0800 Subject: [PATCH 110/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TbCreditBuyerServiceImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index 4858bbab..bc0e6628 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -14,8 +14,10 @@ import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper; import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; import cn.ysk.cashier.utils.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -41,6 +43,7 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl getWrapper(Map params) { MapProxy mapProxy = MapProxy.create(params); @@ -221,6 +224,8 @@ public class TbCreditBuyerServiceImpl extends ServiceImpllambdaUpdate() @@ -235,6 +240,7 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl Date: Tue, 26 Nov 2024 17:45:49 +0800 Subject: [PATCH 111/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index bc0e6628..b2819e82 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -43,6 +43,8 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl getWrapper(Map params) { From 81172f56f69106cc22193a815ffa3fd3bd7f838d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Tue, 26 Nov 2024 17:50:41 +0800 Subject: [PATCH 112/170] =?UTF-8?q?fix=E9=85=8D=E7=BD=AEpad=E7=AB=AF?= =?UTF-8?q?=E8=8F=9C=E5=93=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbCreditBuyerServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index b2819e82..de4064df 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -65,9 +65,9 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl Date: Tue, 26 Nov 2024 18:17:47 +0800 Subject: [PATCH 113/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index de4064df..9660aefa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -274,7 +274,7 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl result = new HashMap<>(3); + Map result = new HashMap<>(5); BigDecimal payAmount = NumberUtil.sub(initRepaymentAmount, repaymentAmount); result.put("repaymentCount", repaymentCount); result.put("repaymentAmount", initRepaymentAmount); From e82ba915517473bee9f0b0a9eea4f9d4f01d75fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 10:24:53 +0800 Subject: [PATCH 114/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=94=B5=E8=AF=9D=E6=9C=BA=E9=A2=84=E7=BA=A6=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booking/TbShopTableBookingController.java | 2 +- .../impl/TbShopTableBookingServiceImpl.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java index 24f7f493..d4f05012 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java @@ -95,7 +95,7 @@ public class TbShopTableBookingController { return ResponseEntity.ok().body(list); } - @GetMapping("summary") + @PostMapping("summary") @ApiOperation("根据电话号码统计历史预订信息") public ResponseEntity summary(@RequestBody String[] phoneNos) { Map data = tbShopTableBookingService.summary(phoneNos); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 63a08eb9..84ef70f9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -8,7 +8,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.map.MapProxy; import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; import cn.ysk.cashier.exception.BadRequestException; @@ -129,8 +129,9 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl 0) { throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate()))); } - String randomStr = RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER, 4); - String orderNo = DateUtil.format(new Date(), "yyMMddHHmmss") + "-" + randomStr.toUpperCase(); + String nextId = IdUtil.getSnowflakeNextIdStr(); + String seq = StrUtil.sub(nextId, -5, nextId.length()); + String orderNo = DateUtil.format(new Date(), "yyMMddHHmmss") + seq; entity.setOrderNo("BK" + orderNo); entity.setStatus(20); entity.setCreateTime(new Date()); @@ -277,4 +278,15 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl Date: Wed, 27 Nov 2024 10:40:19 +0800 Subject: [PATCH 115/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=94=B5=E8=AF=9D=E6=9C=BA=E9=A2=84=E7=BA=A6=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booking/TbShopTableBookingController.java | 10 ++++++++-- .../mybatis/mapper/TbShopTableBookingMapper.java | 14 +++++++------- .../mybatis/service/TbShopTableBookingService.java | 2 +- .../impl/TbShopTableBookingServiceImpl.java | 4 ++-- .../mapper/plus/TbShopTableBookingMapper.xml | 3 ++- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java index d4f05012..e0f433b1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java @@ -1,5 +1,8 @@ package cn.ysk.cashier.controller.booking; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.map.MapUtil; import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; @@ -97,8 +100,11 @@ public class TbShopTableBookingController { @PostMapping("summary") @ApiOperation("根据电话号码统计历史预订信息") - public ResponseEntity summary(@RequestBody String[] phoneNos) { - Map data = tbShopTableBookingService.summary(phoneNos); + public ResponseEntity summary(@RequestBody Map params) { + MapProxy proxy = MapUtil.createProxy(params); + Integer shopId = proxy.getInt("shopId"); + String[] phoneNos = Convert.toStrArray(proxy.get("phoneNos")); + Map data = tbShopTableBookingService.summary(shopId, phoneNos); return ResponseEntity.ok().body(data); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java index 835e5d96..7e98808d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java @@ -9,14 +9,14 @@ import java.util.List; import java.util.Map; /** -* 店铺台桌预订 -* -* @author Tankaikai tankaikai@aliyun.com -* @since 2.0 2024-11-21 -*/ + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ @Mapper public interface TbShopTableBookingMapper extends BaseMapper { - List> summaryByPhoneNos(@Param("phoneNoList") List phoneNoList); - + List> summaryByPhoneNos(@Param("shopId") Integer shopId, @Param("phoneNoList") List phoneNoList); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java index 762757bb..ea7bcbbd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java @@ -36,6 +36,6 @@ public interface TbShopTableBookingService extends IService List findShopTableList(Map params); - Map summary(String[] phoneNos); + Map summary(Integer shopId,String[] phoneNos); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 84ef70f9..0da669ed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -265,8 +265,8 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl summary(String[] phoneNos) { - List> list = baseMapper.summaryByPhoneNos(Arrays.asList(phoneNos)); + public Map summary(Integer shopId, String[] phoneNos) { + List> list = baseMapper.summaryByPhoneNos(shopId, Arrays.asList(phoneNos)); Map result = new HashMap<>(phoneNos.length); Map fillData = new HashMap<>(2); fillData.put("consumeOrders", 0); diff --git a/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml index 6a94f86e..d12a883c 100644 --- a/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml +++ b/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml @@ -9,7 +9,8 @@ count( case when x.`status` = 10 then 1 end) AS consumeOrders, count( case when x.`status` = -1 or x.`status` = 999 then 1 end) AS cancelOrders from tb_shop_table_booking x - where x.phone_number in + where x.shopId = #{shopId} + and x.phone_number in #{phoneNumber, jdbcType=VARCHAR} From 223703dc48bc8fe88cbaa83d69d9dc169e9b75ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 11:02:32 +0800 Subject: [PATCH 116/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=94=B5=E8=AF=9D=E6=9C=BA=E9=A2=84=E7=BA=A6=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../booking/TbShopTableBookingController.java | 6 +++--- .../mybatis/service/TbShopTableBookingService.java | 4 ++-- .../service/impl/TbShopTableBookingServiceImpl.java | 11 +++-------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java index e0f433b1..ed245d21 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java @@ -77,10 +77,10 @@ public class TbShopTableBookingController { return ResponseEntity.ok().build(); } - @GetMapping("sms/{id}") + @GetMapping("sms") @ApiOperation("获取待发送的短信内容") - public ResponseEntity sms(@PathVariable("id") Long id) { - String smsContent = tbShopTableBookingService.getBookingSms(id); + public ResponseEntity sms(@RequestParam("shopId") Integer shopId) { + String smsContent = tbShopTableBookingService.getBookingSms(shopId); return ResponseEntity.ok().body(smsContent); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java index ea7bcbbd..1af95615 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java @@ -28,9 +28,9 @@ public interface TbShopTableBookingService extends IService /** * 获取待发送的短信内容 - * @param id 预订id + * @param shopId 店铺id */ - String getBookingSms(Long id); + String getBookingSms(Integer shopId); List findShopAreaList(Integer shopId); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 0da669ed..2cc36e56 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -201,15 +201,10 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl Date: Wed, 27 Nov 2024 11:19:53 +0800 Subject: [PATCH 117/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=94=B5=E8=AF=9D=E6=9C=BA=E9=A2=84=E7=BA=A6=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/plus/TbShopTableBookingMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml index d12a883c..d898e886 100644 --- a/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml +++ b/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml @@ -9,7 +9,7 @@ count( case when x.`status` = 10 then 1 end) AS consumeOrders, count( case when x.`status` = -1 or x.`status` = 999 then 1 end) AS cancelOrders from tb_shop_table_booking x - where x.shopId = #{shopId} + where x.shop_id = #{shopId} and x.phone_number in #{phoneNumber, jdbcType=VARCHAR} From 7fa8119674aa98ab3f8e9200a8ba4f259824fa04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 11:30:21 +0800 Subject: [PATCH 118/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E7=94=B5=E8=AF=9D=E6=9C=BA=E9=A2=84=E7=BA=A6=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbShopTableBookingServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 2cc36e56..34af88e8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -263,10 +263,10 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl summary(Integer shopId, String[] phoneNos) { List> list = baseMapper.summaryByPhoneNos(shopId, Arrays.asList(phoneNos)); Map result = new HashMap<>(phoneNos.length); - Map fillData = new HashMap<>(2); - fillData.put("consumeOrders", 0); - fillData.put("cancelOrders", 0); for (String phoneNo : phoneNos) { + Map fillData = new HashMap<>(2); + fillData.put("consumeOrders", 0); + fillData.put("cancelOrders", 0); fillData.put("phoneNumber", phoneNo); Map data = list.stream().filter(item -> phoneNo.equals(item.get("phoneNumber"))).findFirst().orElse(fillData); result.put(phoneNo, data); From 98444ca0fb388d2217b290f4064da4c603bb8397 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 27 Nov 2024 13:31:41 +0800 Subject: [PATCH 119/170] =?UTF-8?q?=E8=80=97=E6=9D=90=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E5=87=BA=E5=85=A5=E5=BA=93=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E8=BD=AC=E5=87=BA=E5=BA=93=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/cons/domain/SuppFlow.java | 1 + .../service/impl/TbConsInfoServiceImpl.java | 99 ++++++++----------- .../pojo/shop/TbShopPurveyorTransact.java | 25 ++--- .../TbShopPurveyorTransactServiceImpl.java | 17 +++- 4 files changed, 70 insertions(+), 72 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java index 3baa92e7..dbd4aa54 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java @@ -30,6 +30,7 @@ public class SuppFlow implements Serializable { @Data public static class ConInfos{ private Integer conInfoId; + private String name; private String unit; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 476203f3..2dc9dea0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -67,7 +67,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { private final TbProductStockOperateRepository tbProductStockOperateRepository; - @Override public Map queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable) { Page page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); @@ -77,7 +76,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { @Override public Map queryAllAndPro(TbConsInfoQueryCriteria criteria) { Sort sort = Sort.by(Sort.Direction.DESC, "id"); - if(StringUtils.isNotBlank(criteria.getSort())){ + if (StringUtils.isNotBlank(criteria.getSort())) { String[] sortParams = criteria.getSort().split(","); String sortField = sortParams[0]; Sort.Direction sortDirection = Sort.Direction.fromString(sortParams[1]); @@ -112,7 +111,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { @Override @Transactional(rollbackFor = Exception.class) - public TbConsInfoDto create(List resources){ + public TbConsInfoDto create(List resources) { for (TbConsInfo resource : resources) { @@ -125,8 +124,8 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { // if (count > 0) { // throw new Exception("耗材代码不允许重复"); // } - if(StringUtils.isBlank(resource.getConUnit())){ - throw new BadRequestException(resource.getConName()+ "的单位不允许为空"); + if (StringUtils.isBlank(resource.getConUnit())) { + throw new BadRequestException(resource.getConName() + "的单位不允许为空"); } resource.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER)); resource.setConTypeName(tbConsType.getConTypeName()); @@ -150,7 +149,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { if (Objects.isNull(tbConsInfo)) { throw new Exception("耗材信息不存在"); } - BeanUtil.copyProperties(resource,tbConsInfo, CopyOptions.create().setIgnoreNullValue(true)); + BeanUtil.copyProperties(resource, tbConsInfo, CopyOptions.create().setIgnoreNullValue(true)); tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis())); tbConsInfoRepository.save(tbConsInfo); } @@ -220,7 +219,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { JSONArray array = new JSONArray(); - for (SuppFlow.ConInfos conInfos : resources.getList()) { JSONObject object = new JSONObject(); @@ -229,10 +227,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { log.info("耗材信息不存在"); continue; } + conInfos.setName(info.getConName()); BigDecimal changeStock = conInfos.getStockNumber(); //副单位的实际修改值 if (StringUtils.isNotBlank(conInfos.getUnit())) { info.setDefaultUnit(conInfos.getUnit()); + conInfos.setUnit(conInfos.getUnit()); if (conInfos.getUnit().equals(info.getConUnitTwo())) { changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); } @@ -240,23 +240,13 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { && StringUtils.isNotBlank(info.getDefaultUnit()) && info.getConUnitTwo().equals(info.getDefaultUnit())) { info.setDefaultUnit(info.getConUnitTwo()); + conInfos.setUnit(info.getConUnitTwo()); changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); } - - TbConsSuppFlow suppFlow = new TbConsSuppFlow(); TbConsInfoFlow flow = new TbConsInfoFlow(); - - TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact(); - purveyorTransact.setShopId(tbShopInfo.getId().toString()); - purveyorTransact.setPurveyorName(Objects.isNull(purveyor) ? "" : purveyor.getPurveyorName()); - purveyorTransact.setPurveyorId(Objects.isNull(purveyor) ? "" : purveyor.getId().toString()); - purveyorTransact.setRemark(resources.getRemark()); - purveyorTransact.setCreatedAt(System.currentTimeMillis()); - purveyorTransact.setUpdatedAt(System.currentTimeMillis()); - suppFlow.setConInfoId(info.getConTypeId()); suppFlow.setShopId(resources.getShopId()); suppFlow.setSupplierId(Objects.isNull(resources.getSupplierId()) ? 0 : resources.getSupplierId()); @@ -265,27 +255,17 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { //实际库存 BigDecimal amount = info.getStockNumber().subtract(info.getStockConsume()); - if ("in".equals(resources.getType())) { stockOperate.setSubType(1); info.setStockNumber(info.getStockNumber().add(changeStock)); info.setLasterInStock(changeStock); - suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).add(changeStock)); - - flow.setBizCode("stockIn"); flow.setBizName("耗材入库"); flow.setBizType("+"); - purveyorTransact.setTotalAmount(resources.getAccountsPayable()); - purveyorTransact.setPaidAmount(resources.getActualPayment()); - purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment()))); - purveyorTransact.setType("cons_in"); - object.put("number", changeStock); - } - else if ("out".equals(resources.getType())) { + } else if ("out".equals(resources.getType())) { stockOperate.setSubType(-1); if (changeStock.compareTo(amount) > 0) { @@ -293,23 +273,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { } info.setStockNumber(info.getStockNumber().subtract(changeStock)); - - suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(changeStock)); - - flow.setBizCode("stockout"); flow.setBizName("耗材出库"); flow.setBizType("-"); - - purveyorTransact.setPaidAmount(resources.getActualPayment()); - purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate()); - - purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate()); - purveyorTransact.setType("cons_out"); object.put("number", changeStock); - } - else { + } else { throw new BadRequestException("错误操作类型"); } @@ -326,21 +295,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { suppFlow.setActualPayment(resources.getActualPayment()); suppFlow.setCreateTime(new Timestamp(System.currentTimeMillis())); - - if (resources.getAccountsPayable().compareTo(resources.getActualPayment()) <= 0) { - purveyorTransact.setStatus(1); - } else { - purveyorTransact.setStatus(0); - } - - purveyorTransact.setPaidAt(System.currentTimeMillis()); - //供应商 - purveyorTransactRepository.save(purveyorTransact); - if (resources.getSupplierId() != null) { - tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString()); - } - - tbConsInfoRepository.save(info); tbConsSuppFlowRepository.save(suppFlow); @@ -359,6 +313,39 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { stockOperate.setBatchNumber(""); stockOperate.setStockSnap(array.toJSONString()); tbProductStockOperateRepository.save(stockOperate); + + if (resources.getSupplierId() != null) { + TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact(); + purveyorTransact.setShopId(tbShopInfo.getId().toString()); + purveyorTransact.setPurveyorName(Objects.isNull(purveyor) ? "" : purveyor.getPurveyorName()); + purveyorTransact.setPurveyorId(Objects.isNull(purveyor) ? "" : purveyor.getId().toString()); + purveyorTransact.setRemark(resources.getRemark()); + purveyorTransact.setCreatedAt(System.currentTimeMillis()); + purveyorTransact.setUpdatedAt(System.currentTimeMillis()); + purveyorTransact.setPaidAt(System.currentTimeMillis()); + purveyorTransact.setConInfos(JSONUtil.toJSONString(resources.getList())); + if ("in".equals(resources.getType())) { + purveyorTransact.setTotalAmount(resources.getAccountsPayable()); + purveyorTransact.setPaidAmount(resources.getActualPayment()); + purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment()))); + purveyorTransact.setType("cons_in"); + } else if ("out".equals(resources.getType())) { + purveyorTransact.setPaidAmount(resources.getActualPayment()); + purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate()); + + purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate()); + purveyorTransact.setType("cons_out"); + } + + if (resources.getAccountsPayable().compareTo(resources.getActualPayment()) <= 0) { + purveyorTransact.setStatus(1); + } else { + purveyorTransact.setStatus(0); + } + //供应商 + purveyorTransactRepository.save(purveyorTransact); + tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString()); + } } @Override diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java index 93095600..cdfce3c8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java @@ -1,20 +1,7 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ package cn.ysk.cashier.pojo.shop; +import cn.ysk.cashier.cons.domain.SuppFlow; +import cn.ysk.cashier.cons.domain.TbConsInfo; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -23,6 +10,7 @@ import javax.persistence.*; import javax.validation.constraints.*; import java.math.BigDecimal; import java.io.Serializable; +import java.util.List; /** * @website https://eladmin.vip @@ -94,7 +82,14 @@ public class TbShopPurveyorTransact implements Serializable { @ApiModelProperty(value = "type") private String type; + @Column(name = "`con_infos`") + private String conInfos; + @Transient + private List conFlows; + + @Transient + private List cons; public void copy(TbShopPurveyorTransact source){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java index b9cb0253..3c9dfb2f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java @@ -1,5 +1,8 @@ package cn.ysk.cashier.service.impl.shopimpl; +import cn.ysk.cashier.cons.domain.SuppFlow; +import cn.ysk.cashier.cons.domain.TbConsInfo; +import cn.ysk.cashier.cons.repository.TbConsInfoRepository; import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto; import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; @@ -11,10 +14,12 @@ import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository; import cn.ysk.cashier.repository.shop.TbShopPurveyorTransactRepository; import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService; import cn.ysk.cashier.utils.FileUtil; +import cn.ysk.cashier.utils.JSONUtil; import cn.ysk.cashier.utils.QueryHelp; import cn.ysk.cashier.utils.ValidationUtil; import cn.ysk.cashier.vo.PurveyorTransactVO; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -26,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * @author lyf @@ -39,6 +45,7 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact private final TbShopPurveyorTransactRepository tbShopPurveyorTransactRepository; private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper; + private final TbConsInfoRepository tbConsInfoRepository; private final TbShopPurveyorRepository tbShopPurveyorRepository; private final TbShopPurveyorTransactPayService transactPayService; @@ -47,7 +54,15 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact Sort sort = Sort.by(Sort.Direction.DESC, "id"); Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); Page pageShopPurveyor = tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); - + for (TbShopPurveyorTransact tbShopPurveyorTransact : pageShopPurveyor.getContent()) { + if (StringUtils.isNotBlank(tbShopPurveyorTransact.getConInfos())) { + List conInfos = JSONUtil.parseJSONStrTList(tbShopPurveyorTransact.getConInfos(), SuppFlow.ConInfos.class); + tbShopPurveyorTransact.setConFlows(conInfos); + List collect = conInfos.stream().map(SuppFlow.ConInfos::getConInfoId).collect(Collectors.toList()); + List cons = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.in(root.get("id")).value(collect)); + tbShopPurveyorTransact.setCons(cons); + } + } Map map = new HashMap<>(); map.put("content", pageShopPurveyor.getContent()); map.put("totalElements", pageShopPurveyor.getTotalElements()); From 284a9f8ce21f6ddc35194156c0981e4796a2467c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 13:47:25 +0800 Subject: [PATCH 120/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TbCreditBuyerServiceImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java index 9660aefa..d051bfbf 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -200,6 +200,14 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl result = new HashMap<>(3); result.put("repaymentCount", 0); result.put("repaymentAmount", repaymentAmount); @@ -212,6 +220,14 @@ public class TbCreditBuyerServiceImpl extends ServiceImpl Date: Wed, 27 Nov 2024 14:08:43 +0800 Subject: [PATCH 121/170] =?UTF-8?q?=E8=80=97=E6=9D=90=E5=85=A5=E5=BA=93=20?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=A1=AB=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 2dc9dea0..33c5d66f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -242,6 +242,9 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { info.setDefaultUnit(info.getConUnitTwo()); conInfos.setUnit(info.getConUnitTwo()); changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); + }else { + info.setDefaultUnit(info.getConUnit()); + conInfos.setUnit(info.getConUnit()); } TbConsSuppFlow suppFlow = new TbConsSuppFlow(); From f90b4ec109ffd2713a292d75f3ff79213818a0da Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 27 Nov 2024 14:18:11 +0800 Subject: [PATCH 122/170] =?UTF-8?q?=E8=80=97=E6=9D=90=E5=85=A5=E5=BA=93=20?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=A1=AB=E5=85=852?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cons/service/impl/TbConsInfoServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 33c5d66f..423171c7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -236,13 +236,13 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { if (conInfos.getUnit().equals(info.getConUnitTwo())) { changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); } - } else if (StringUtils.isNotBlank(info.getConUnitTwo()) - && StringUtils.isNotBlank(info.getDefaultUnit()) - && info.getConUnitTwo().equals(info.getDefaultUnit())) { - info.setDefaultUnit(info.getConUnitTwo()); - conInfos.setUnit(info.getConUnitTwo()); - changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); - }else { + } else if(StringUtils.isNotBlank(info.getDefaultUnit())){ + info.setDefaultUnit(info.getDefaultUnit()); + conInfos.setUnit(info.getDefaultUnit()); + if(StringUtils.isNotBlank(info.getConUnitTwo())&& info.getConUnitTwo().equals(info.getDefaultUnit())){ + changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); + } + } else { info.setDefaultUnit(info.getConUnit()); conInfos.setUnit(info.getConUnit()); } From 7b1e719f4b2704108f1621753ad0546df66c9d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 14:21:22 +0800 Subject: [PATCH 123/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TbCreditBuyerOrderServiceImpl.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 5afc8338..4ba73e44 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -30,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 挂账账单 @@ -86,16 +83,14 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl Date: Wed, 27 Nov 2024 14:31:15 +0800 Subject: [PATCH 124/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 4ba73e44..ccbf72ff 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -75,19 +75,16 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl summary(Map params) { long count = baseMapper.getCount(params); - Map data = new HashMap<>(4); + Map data = new HashMap<>(5); // 总交易笔数 data.put("count", count); - // 总交易金额 BigDecimal payAmount = baseMapper.getSumPayAmount(params); data.put("payAmountTotal", payAmount); - // 待支付笔数 params.put("statusList", Arrays.asList("unpaid","partial")); long unpaidCount = baseMapper.getCount(params); data.put("unpaidCount", unpaidCount); - params.put("statusList", Arrays.asList("paid", "partial")); BigDecimal paidAmount = baseMapper.getSumPaidAmount(params); params.put("statusList", Arrays.asList("unpaid", "partial")); From 1915c27b9b8ff92abb4b9b76e5d5f098332d79e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 14:33:55 +0800 Subject: [PATCH 125/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=821?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index ccbf72ff..16215bbb 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -81,6 +81,7 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl Date: Wed, 27 Nov 2024 15:12:21 +0800 Subject: [PATCH 126/170] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=82?= =?UTF-8?q?=E5=8D=95=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/cons/TableConstant.java | 11 +++++++++++ .../java/cn/ysk/cashier/dto/shoptable/PayDTO.java | 1 + .../service/impl/shopimpl/TbShopTableServiceImpl.java | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java index 956f3942..3225bba7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java @@ -97,6 +97,17 @@ public interface TableConstant { } + @Getter + public enum PayType { + CREDIT_BUYER("creditBuyer"); + private final String value; + + PayType(String value) { + this.value = value; + } + } + + @Getter public enum UseType { TAKEOUT("takeout"), diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java index 77b1a8b5..44f82220 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java @@ -31,5 +31,6 @@ public class PayDTO { private Integer pointsNum; private Integer staffId; private String loginName; + private String creditBuyerId; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index cd72bdbc..8d95cb21 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -134,6 +134,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final TbShopUserMapper tbShopUserMapper; private final ThirdPartyCouponService thirdPartyCouponService; private final TbThirdPartyCouponRecordService thirdPartyCouponRecordService; + private final TbCreditBuyerOrderService creditBuyerOrderService; private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) { // 获取当前台桌最新订单,先付款模式不获取 @@ -2281,6 +2282,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { boolean isOnline = false; switch (payDTO.getPayType()) { + case "creditBuyer": + if (payDTO.getCreditBuyerId() == null) { + throw new BadRequestException("挂单人不为空"); + } + creditBuyerOrderService.save(payDTO.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); + orderInfo.setPayType(TableConstant.OrderInfo.PayType.CREDIT_BUYER.getValue()); case "vipPay": if (payDTO.getVipUserId() != null) { orderInfo.setUserId(String.valueOf(payDTO.getVipUserId())); From a7349f806b2f0550c01ae56eb9a678d61e449df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 27 Nov 2024 15:36:36 +0800 Subject: [PATCH 127/170] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=82?= =?UTF-8?q?=E5=8D=95=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 8d95cb21..514a1d11 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2142,7 +2142,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 获取优惠券信息 OrderCouponInfoDTO couponInfo = new OrderCouponInfoDTO(); - if (!payDTO.getUserCouponInfos().isEmpty()) { + if (payDTO.getUserCouponInfos() != null && !payDTO.getUserCouponInfos().isEmpty()) { couponInfo = getCouponInfo(payDTO.getVipUserId(), payDTO.getShopId(), payDTO.getUserCouponInfos(), orderInfo.getOrderAmount(), productIdSet); } From cfc17d9533350890906e45f197f6dbc5afbe85b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 27 Nov 2024 15:38:44 +0800 Subject: [PATCH 128/170] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=82?= =?UTF-8?q?=E5=8D=95=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TbCreditBuyerOrderServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 16215bbb..31c2eb68 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -171,15 +171,15 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl Date: Wed, 27 Nov 2024 15:41:16 +0800 Subject: [PATCH 129/170] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=82?= =?UTF-8?q?=E5=8D=95=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 514a1d11..dfad8710 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2288,6 +2288,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } creditBuyerOrderService.save(payDTO.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); orderInfo.setPayType(TableConstant.OrderInfo.PayType.CREDIT_BUYER.getValue()); + break; case "vipPay": if (payDTO.getVipUserId() != null) { orderInfo.setUserId(String.valueOf(payDTO.getVipUserId())); From 4f7004736a970a17d807e939b531c3455a749600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 16:04:30 +0800 Subject: [PATCH 130/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TbShopTableBookingService.java | 3 +++ .../impl/TbShopTableBookingServiceImpl.java | 27 ++++++++++++------- .../cn/ysk/cashier/quartz/task/TestTask.java | 6 +++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java index 1af95615..28d95c8d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java @@ -38,4 +38,7 @@ public interface TbShopTableBookingService extends IService Map summary(Integer shopId,String[] phoneNos); + void batchTimeout(); + + void autoCancel(); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 34af88e8..a5980aba 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -254,7 +254,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl item.getShopTableId().equals(dto.getId())).findFirst().orElse(null)); + dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId()) && item.getStatus() != -1).findFirst().orElse(null)); } return result; } @@ -274,14 +274,21 @@ public class TbShopTableBookingServiceImpl extends ServiceImpllambdaUpdate() + .set(TbShopTableBooking::getStatus, 999) + .eq(TbShopTableBooking::getStatus, 20) + .last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute")); } + + @Override + public void autoCancel() { + // 15分钟后自动取消 + baseMapper.update(Wrappers.lambdaUpdate() + .set(TbShopTableBooking::getStatus, -1) + .eq(TbShopTableBooking::getStatus, 999) + .last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute+15")); + } + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java index 1e36b4d9..10459180 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.quartz.task; import cn.ysk.cashier.dto.product.StockCountDTO; import cn.ysk.cashier.mybatis.service.TbPointsExchangeRecordService; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.product.TbProductStockDetail; import cn.ysk.cashier.repository.order.StockCountRepository; @@ -46,6 +47,7 @@ public class TestTask { private EntityManager entityManager; @Autowired private TbPointsExchangeRecordService tbPointsExchangeRecordService; + private TbShopTableBookingService tbShopTableBookingService; private final TbCashierCartService tbCashierCartService; private final TbOrderInfoService orderInfoService; @@ -103,6 +105,10 @@ public class TestTask { public void cancelPointsExchangeOrder(){ log.info("积分商品订单取消定时任务执行"); tbPointsExchangeRecordService.authCancel(); + log.info("预定订单超时定时任务执行"); + tbShopTableBookingService.batchTimeout(); + log.info("预定订单取消定时任务执行"); + tbShopTableBookingService.autoCancel(); } @Transactional(rollbackFor = Exception.class) From ed4c1fb034df8dbdd59575ad6571bdd0600a37ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 27 Nov 2024 17:13:25 +0800 Subject: [PATCH 131/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/quartz/task/TestTask.java | 1 + 1 file changed, 1 insertion(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java index 10459180..09172c35 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java @@ -47,6 +47,7 @@ public class TestTask { private EntityManager entityManager; @Autowired private TbPointsExchangeRecordService tbPointsExchangeRecordService; + @Autowired private TbShopTableBookingService tbShopTableBookingService; private final TbCashierCartService tbCashierCartService; private final TbOrderInfoService orderInfoService; From 78a9e5b8ad83667d2daa01e35843bd2f7a669d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Thu, 28 Nov 2024 09:37:57 +0800 Subject: [PATCH 132/170] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=82=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TbPointsExchangeRecordServiceImpl.java | 2 +- .../impl/TbShopTableBookingServiceImpl.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java index 00071ce7..ccb65cda 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java @@ -250,7 +250,7 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl= 5")); + .last("and TIMESTAMPDIFF(MINUTE, NOW(), create_time) >= 5")); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index a5980aba..281c63cd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -261,10 +261,16 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl summary(Integer shopId, String[] phoneNos) { - List> list = baseMapper.summaryByPhoneNos(shopId, Arrays.asList(phoneNos)); - Map result = new HashMap<>(phoneNos.length); + List phoneNoList = Arrays.asList(phoneNos).stream().distinct().collect(Collectors.toList()); + List> splits = CollUtil.split(phoneNoList, 10); + List> list = new ArrayList<>(); + for (List split : splits) { + List> subList = baseMapper.summaryByPhoneNos(shopId, split); + list.addAll(subList); + } + Map result = new HashMap<>(phoneNoList.size()); for (String phoneNo : phoneNos) { - Map fillData = new HashMap<>(2); + Map fillData = new HashMap<>(3); fillData.put("consumeOrders", 0); fillData.put("cancelOrders", 0); fillData.put("phoneNumber", phoneNo); @@ -279,7 +285,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpllambdaUpdate() .set(TbShopTableBooking::getStatus, 999) .eq(TbShopTableBooking::getStatus, 20) - .last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute")); + .last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute")); } @Override @@ -288,7 +294,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpllambdaUpdate() .set(TbShopTableBooking::getStatus, -1) .eq(TbShopTableBooking::getStatus, 999) - .last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute+15")); + .last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute+15")); } } \ No newline at end of file From 15d2e28921be568b82eaa95125997d7b2dcfb004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Thu, 28 Nov 2024 11:30:57 +0800 Subject: [PATCH 133/170] =?UTF-8?q?fix=E9=85=8D=E7=BD=AEpad=E7=AB=AF?= =?UTF-8?q?=E8=8F=9C=E5=93=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/entity/TbCreditBuyer.java | 3 ++ .../service/TbCreditBuyerOrderService.java | 8 +++ .../impl/TbCreditBuyerOrderServiceImpl.java | 54 ++++++++++++++++++- .../impl/TbShopTableBookingServiceImpl.java | 2 + 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java index c4f151db..fa478af3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java @@ -98,6 +98,9 @@ public class TbCreditBuyer { @TableField(value = "(select shop_name from tb_shop_info where id = tb_credit_buyer.shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) private String shopName; + /** + * 剩余挂账额度 + */ public BigDecimal getRemainingAmount() { return NumberUtil.sub(creditAmount, NumberUtil.null2Zero(owedAmount)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java index 5a96a86f..01b0c8ab 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java @@ -26,4 +26,12 @@ public interface TbCreditBuyerOrderService extends IService */ boolean save(String creditBuyerId, Long orderId); + /** + * 挂账人退款 + * @param creditBuyerId 挂账人id + * @param orderId 订单id + * @return + */ + boolean refund(String creditBuyerId, Long orderId); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 31c2eb68..4ad17285 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -83,7 +83,7 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl params = new HashMap<>(2); + params.put("creditBuyerId", creditBuyerId); + params.put("orderId", orderId); + CreditBuyerOrderDTO dto = baseMapper.getOne(params); + if (dto == null) { + throw new BadRequestException("挂账订单不存在"); + } + // 1.只挂账未还款的情况,直接删除挂账订单 + if ("unpaid".equals(dto.getStatus())) { + baseMapper.deleteById(dto.getId()); + return true; + } + // 2.部分还款/已还款,删除挂账订单+红冲还款记录,并把已还款金额退回余额或挂账额度 + if ("partial".equals(dto.getStatus()) || "paid".equals(dto.getStatus())) { + // 已还款金额 + BigDecimal paidAmount = dto.getPaidAmount(); + // 已还款金额进行红冲 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(creditBuyerId); + record.setOrderId(orderId); + record.setRepaymentAmount(NumberUtil.sub(BigDecimal.ZERO, paidAmount)); + record.setPaymentMethod("余额支付"); + record.setPaymentTime(new Date()); + record.setRemark(StrUtil.format("挂账订单:{}退款,已还款金额退回余额或挂账额度", orderInfo.getOrderNo())); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + // 删除挂账订单,恢复挂账额度 + baseMapper.deleteById(dto.getId()); + // 退回余额 + creditBuyer.setAccountBalance(NumberUtil.add(creditBuyer.getAccountBalance(), paidAmount)); + tbCreditBuyerService.updateById(creditBuyer); + return true; + } + return false; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java index 281c63cd..f0344229 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -284,6 +284,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpllambdaUpdate() .set(TbShopTableBooking::getStatus, 999) + .set(TbShopTableBooking::getUpdateTime, new Date()) .eq(TbShopTableBooking::getStatus, 20) .last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute")); } @@ -293,6 +294,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpllambdaUpdate() .set(TbShopTableBooking::getStatus, -1) + .set(TbShopTableBooking::getUpdateTime, new Date()) .eq(TbShopTableBooking::getStatus, 999) .last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute+15")); } From 769385012723991d2def5cddd7eda8078a479fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 28 Nov 2024 14:07:14 +0800 Subject: [PATCH 134/170] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=82?= =?UTF-8?q?=E8=B4=A6=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/cons/TableConstant.java | 3 + .../cashier/dto/shoptable/CreateOrderDTO.java | 1 + .../cashier/dto/shoptable/UpdateCartDTO.java | 2 + .../ysk/cashier/pojo/order/TbCashierCart.java | 2 + .../ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../ysk/cashier/pojo/order/TbOrderInfo.java | 3 + .../impl/shopimpl/TbShopTableServiceImpl.java | 70 ++++++++++--------- 7 files changed, 49 insertions(+), 33 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java index 3225bba7..b0d6b858 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java @@ -105,6 +105,9 @@ public interface TableConstant { PayType(String value) { this.value = value; } + public boolean equalsVals(String value) { + return this.value.equals(value); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java index 558fd8b8..d755fe95 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java @@ -29,5 +29,6 @@ public class CreateOrderDTO { private List userCouponInfos = new ArrayList<>(); // 使用的积分抵扣数量 private Integer pointsNum; + private Integer isWaitCall; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index b7db4dfd..a63650ae 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -24,5 +24,7 @@ public class UpdateCartDTO { private Boolean isGift; // 是否打印 private Boolean isPrint; + // 是否等叫 + private Integer isWaitCall; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 92d30c9a..249de2a8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -179,6 +179,8 @@ public class TbCashierCart implements Serializable { private String useCouponInfo; // 是否团购券商品 private Integer isThirdCoupon; + // 是否等叫 + private Integer isWaitCall; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 5dd2ca24..52eb2a9c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -139,6 +139,7 @@ public class TbOrderDetail implements Serializable { private BigDecimal returnAmount; private BigDecimal canReturnAmount; private Integer isThirdCoupon; + private Integer isWaitCall; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java index 260e82cd..5b81e87c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java @@ -252,8 +252,11 @@ public class TbOrderInfo implements Serializable { // 满减抵扣金额 private BigDecimal fullCouponDiscountAmount; private Integer isPostpaid; + private Integer isWaitCall; + private String creditBuyerId; public void copy(TbOrderInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index dfad8710..a07e0536 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -466,6 +466,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setTotalAmount(updateCartDTO.getNum().multiply(tbCashierCart.getSalePrice())); tbCashierCart.setNote(updateCartDTO.getNote()); tbCashierCart.setIsPrint(updateCartDTO.getIsPrint()); + tbCashierCart.setIsWaitCall(updateCartDTO.getIsWaitCall()); if (updateCartDTO.getIsPack() != null) { if (!updateCartDTO.getIsPack()) { @@ -493,6 +494,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (tbCashierCart.getOrderId() != null && StrUtil.isNotBlank(updateCartDTO.getNote())) { orderDetailMapper.update(null, new LambdaUpdateWrapper() .eq(TbOrderDetail::getCartId, tbCashierCart.getId()) + .set(TbOrderDetail::getIsWaitCall, updateCartDTO.getIsWaitCall()) .set(TbOrderDetail::getNote, updateCartDTO.getNote())); } @@ -1231,11 +1233,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 创建订单详情 OrderPriceDTO detailPriceDTO = createOrderDetailWithCoupon(cartInfoDTO.getCashierCarts(), orderInfo, - createOrderDTO.getShopId(), true, shopEatTypeInfoDTO); + createOrderDTO.getShopId(), true, shopEatTypeInfoDTO, createOrderDTO.getIsWaitCall()); // 是否是第一次创建订单 orderInfo = createOrderWithAction(createOrderDTO, detailPriceDTO, shopEatTypeInfoDTO, - orderInfo, cartInfoDTO.getSeatCart(), shopUser, shopTable); + orderInfo, cartInfoDTO.getSeatCart(), shopUser, shopTable, createOrderDTO.getIsWaitCall()); // 修改订单详情并打票 updateDetailAndPrint(orderInfo, detailPriceDTO, shopEatTypeInfoDTO); @@ -1548,7 +1550,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { * @param updateState * @return */ - private OrderPriceDTO createOrderDetailWithCoupon(List fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { + private OrderPriceDTO createOrderDetailWithCoupon(List fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, + boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer isWaitCall) { OrderPriceDTO priceDTO = new OrderPriceDTO(); List cartIds = fullCashierCarts.stream().map(TbCashierCart::getId).collect(Collectors.toList()); @@ -1566,6 +1569,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { }); for (TbCashierCart cashierCart : fullCashierCarts) { + cashierCart.setIsWaitCall(isWaitCall); if (orderInfo != null && shopEatTypeInfoDTO != null) { cashierCart.setIsMember(StrUtil.isBlank(orderInfo.getMemberId()) ? 0 : shopEatTypeInfoDTO.isMemberPrice() ? 1 : 0); } @@ -1605,6 +1609,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); } + orderDetail.setIsWaitCall(cashierCart.getIsWaitCall()); orderDetail.setUserCouponId(cashierCart.getUserCouponId()); orderDetail.setMemberPrice(cashierCart.getMemberPrice()); orderDetail.setNote(cashierCart.getNote()); @@ -1634,7 +1639,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } private TbOrderInfo createOrderWithAction(CreateOrderDTO createOrderDTO, OrderPriceDTO priceDTO, ShopEatTypeInfoDTO eatTypeInfoDTO, - TbOrderInfo orderInfo, TbCashierCart seatCart, TbShopUser shopUser, TbShopTable shopTable) { + TbOrderInfo orderInfo, TbCashierCart seatCart, TbShopUser shopUser, TbShopTable shopTable, Integer isWaitCall) { int placeNum = getCurrentPlaceNum(eatTypeInfoDTO); boolean isFirst = false; // 修改订单信息 @@ -1660,6 +1665,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderInfo.setMerchantId(merchantAccount.getId().toString()); orderInfo.setIsPostpaid(eatTypeInfoDTO.isDineInAfter() ? 1 : 0); } + orderInfo.setIsWaitCall(isWaitCall); // 更新取餐号 orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString()); orderInfo.setUpdatedAt(System.currentTimeMillis()); @@ -2152,7 +2158,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 更新订单信息 ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(orderInfo.getShopId(), orderInfo.getTableId()); - OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO); + OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO, null); BigDecimal finalAmount = priceDTO.getTotalAmount().setScale(2, RoundingMode.HALF_UP); orderInfo.setUpdatedAt(System.currentTimeMillis()); @@ -2288,6 +2294,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } creditBuyerOrderService.save(payDTO.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); orderInfo.setPayType(TableConstant.OrderInfo.PayType.CREDIT_BUYER.getValue()); + orderInfo.setCreditBuyerId(payDTO.getCreditBuyerId()); break; case "vipPay": if (payDTO.getVipUserId() != null) { @@ -2794,16 +2801,31 @@ public class TbShopTableServiceImpl implements TbShopTableService { detailIds.add(item.getId()); returnNumMap.put(item.getId().toString(), item.getNum()); }); - List detailList = orderDetailMapper.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 BadRequestException("订单明细数量不一致"); + + List detailList = null; + if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(oldOrderInfo.getPayType())) { + detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() + .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId()) + .eq(TbOrderDetail::getStatus, "closed") + .eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId()) + .orderByDesc(TbOrderDetail::getUserCouponId)); + + if (detailList.size() != returnOrderDTO.getOrderDetails().size()) { + throw new BadRequestException("挂账退款必须全退"); + } + }else { + detailList = orderDetailMapper.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 BadRequestException("订单明细数量不一致"); + } } + HashMap data = new HashMap<>(); BigDecimal returnAmount = BigDecimal.ZERO; BigDecimal packAMount = BigDecimal.ZERO; @@ -3066,6 +3088,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else if ("cash".equals(payType)) { mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND, returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList())); + }else if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(payType)) { + creditBuyerOrderService.refund(orderInfo.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); } orderInfo.setStatus(TableConstant.OrderInfo.Status.CLOSED.getValue()); @@ -3080,26 +3104,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); } -// String couponInfoList = orderInfo.getCouponInfoList(); -// if (StrUtil.isNotBlank(couponInfoList)) { -// OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class); -// if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) { -// int remainNum = 0; -// for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { -// if (item.getFinalUseNum() > item.getReturnNum()) { -// remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); -// } -// } -// -// if (remainNum == 0) { -// returnCoupon(orderInfo, true); -// // 返还积分 -// memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), -// "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); -// -// } -// } -// } } orderInfoMapper.updateById(orderInfo); // 打印退款小票 From f82b521b00f1b4473ec150a8e18eeef4d8f705ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 28 Nov 2024 15:23:19 +0800 Subject: [PATCH 135/170] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=AD=89?= =?UTF-8?q?=E5=8F=AB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 5 ++ .../cashier/dto/shoptable/WaitCallDTO.java | 20 ++++++++ .../mybatis/service/MpCashierCartService.java | 7 +++ .../mybatis/service/MpOrderInfoService.java | 6 +++ .../impl/MpCashierCartServiceImpl.java | 47 ++++++++++++++++++- .../service/impl/MpOrderInfoServiceImpl.java | 9 ++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 30 +++++++++++- .../service/shop/TbShopTableService.java | 2 + 8 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index 3a2a99bc..b0f3a3d3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -206,6 +206,11 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.pay(payDTO)); } + @PutMapping("/waitCall") + public ResponseEntity waitCall(@Valid @RequestBody WaitCallDTO waitCallDTO) { + return ResponseEntity.ok(tbShopTableService.waitCall(waitCallDTO)); + } + @PostMapping("/returnOrder") public ResponseEntity returnOrder(@RequestBody ReturnOrderDTO returnOrderDTO) { return ResponseEntity.ok(tbShopTableService.returnOrder(returnOrderDTO)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java new file mode 100644 index 00000000..d2e9de3c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java @@ -0,0 +1,20 @@ +package cn.ysk.cashier.dto.shoptable; + +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; + @NotBlank + private String masterId; + @NotBlank + private String useType; + private String tableId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java index 9c1ea12a..1c0d33fa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java @@ -4,8 +4,10 @@ import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbCashierCart; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.ArrayList; import java.util.List; /** @@ -66,6 +68,9 @@ public interface MpCashierCartService extends IService { */ List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses); + + List selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses); + /** * 根据订单id和状态获取购物车数据 * @param orderId 订单id @@ -99,5 +104,7 @@ public interface MpCashierCartService extends IService { * @param statuses 状态 */ List selectByIds(Integer shopId, Integer orderId, List ids, TableConstant.OrderInfo.Status... statuses); + + boolean updateFieldValByIds(Integer shopId, ArrayList cartIds, SFunction column, Object val); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java index 6dda692a..5630aa6a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java @@ -4,6 +4,7 @@ import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderInfo; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; import java.math.BigDecimal; @@ -42,5 +43,10 @@ public interface MpOrderInfoService extends IService { TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status); boolean incrAmount(Integer orderId, BigDecimal subtract); + + + boolean updateFieldVal(Integer shopId, Integer orderId, SFunction column, Object val); + + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java index 6eba9141..7bc07258 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java @@ -17,6 +17,7 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.pojo.shop.TbShopTable; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -118,7 +119,7 @@ public class MpCashierCartServiceImpl extends ServiceImpl selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId()) + .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); + + if (statuses.length == 0) { + queryWrapper.in(TbCashierCart::getStatus, "create", "return"); + } else { + queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses)); + } + + if (orderId != null) { + queryWrapper.and(q -> q.eq(TbCashierCart::getOrderId, orderId) + .or().isNull(TbCashierCart::getOrderId)); + } + + // 非堂食校验台桌状态 + if (shopEatTypeInfoDTO.isTakeout()) { + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) + .in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue()); + } else { + if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId()); + } else { + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")); + } + + } + return list(queryWrapper); + } + @Override public List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status) { LambdaQueryChainWrapper queryChainWrapper = lambdaQuery().eq(TbCashierCart::getOrderId, orderId); @@ -158,7 +193,7 @@ public class MpCashierCartServiceImpl extends ServiceImpl q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); if (isTemp) { query.isNull(TbCashierCart::getProductId).isNull(TbCashierCart::getSkuId).eq(TbCashierCart::getIsTemporary, 1); - }else { + } else { query.eq(TbCashierCart::getProductId, productId) .eq(TbCashierCart::getSkuId, skuId); } @@ -196,5 +231,13 @@ public class MpCashierCartServiceImpl extends ServiceImpl cartIds, SFunction column, Object val) { + return update(new LambdaUpdateWrapper() + .eq(TbCashierCart::getShopId, shopId) + .in(TbCashierCart::getId, cartIds) + .set(column, val)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java index 17580c4e..c66b5717 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java @@ -10,6 +10,7 @@ import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.order.TbOrderInfo; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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 org.springframework.stereotype.Service; @@ -56,5 +57,13 @@ public class MpOrderInfoServiceImpl extends ServiceImpl column, Object val) { + return update(new LambdaUpdateWrapper() + .eq(TbOrderInfo::getShopId, shopId) + .eq(TbOrderInfo::getId, orderId) + .set(column, val)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index a07e0536..3af7259a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -595,7 +595,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setMemberPrice(productSku.getMemberPrice()); - cashierCartRepository.save(tbCashierCart); + mpCashierCartService.save(tbCashierCart); } else { tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); @@ -1569,7 +1569,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { }); for (TbCashierCart cashierCart : fullCashierCarts) { - cashierCart.setIsWaitCall(isWaitCall); + if (isWaitCall != null) { + cashierCart.setIsWaitCall(isWaitCall); + } if (orderInfo != null && shopEatTypeInfoDTO != null) { cashierCart.setIsMember(StrUtil.isBlank(orderInfo.getMemberId()) ? 0 : shopEatTypeInfoDTO.isMemberPrice() ? 1 : 0); } @@ -3235,4 +3237,28 @@ public class TbShopTableServiceImpl implements TbShopTableService { thirdPartyCouponRecordService.save(record); return true; } + + + @Override + public Object waitCall(WaitCallDTO waitCallDTO) { + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(waitCallDTO.getShopId(), waitCallDTO.getTableId(), waitCallDTO.getUseType()); + List cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO, + waitCallDTO.getMasterId(), waitCallDTO.getOrderId(), TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN, TableConstant.OrderInfo.Status.CLOSED); + if (cashierCarts.isEmpty()) { + throw new BadRequestException("购物车为空"); + } + ArrayList cartIds = new ArrayList<>(); + cashierCarts.forEach(item -> { + if (waitCallDTO.getOrderId() != null && item.getOrderId() != null && !item.getOrderId().equals(waitCallDTO.getOrderId())) { + throw new BadRequestException("订单id有误"); + } + cartIds.add(item.getId()); + }); + if (waitCallDTO.getOrderId() != null) { + mpOrderInfoService.updateFieldVal(waitCallDTO.getShopId(), waitCallDTO.getOrderId(), TbOrderInfo::getIsWaitCall, waitCallDTO.getIsWaitCall()); + } + + mpCashierCartService.updateFieldValByIds(waitCallDTO.getShopId(), cartIds, TbCashierCart::getIsWaitCall, waitCallDTO.getIsWaitCall()); + return mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsWaitCall, waitCallDTO.getIsWaitCall(), cartIds); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 1f89c770..c94ebc33 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -167,4 +167,6 @@ public interface TbShopTableService { * 团购券核销 */ Object checkCoupon(ThirdCouponCheckDTO checkDTO); + + Object waitCall(WaitCallDTO waitCallDTO); } From 80be3657ef5ee8bca886e005f6fb7ebc10eb8e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 28 Nov 2024 15:29:36 +0800 Subject: [PATCH 136/170] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=93=81=E6=94=B9=E4=BB=B7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 1 + 2 files changed, 2 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 52eb2a9c..db192934 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -134,6 +134,7 @@ public class TbOrderDetail implements Serializable { private Integer isMember; private Integer isTemporary; private String discountSaleNote; + private BigDecimal discountSaleAmount; private Boolean isPrint; private String useCouponInfo; private BigDecimal returnAmount; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 3af7259a..4d048b54 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -1611,6 +1611,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); } + orderDetail.setDiscountSaleAmount(cashierCart.getDiscountSaleAmount()); orderDetail.setIsWaitCall(cashierCart.getIsWaitCall()); orderDetail.setUserCouponId(cashierCart.getUserCouponId()); orderDetail.setMemberPrice(cashierCart.getMemberPrice()); From f3fd3a4a7133c28f535ec542e84e167e447997f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Thu, 28 Nov 2024 18:23:34 +0800 Subject: [PATCH 137/170] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E8=8F=9C=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 4d048b54..fd82673d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -906,8 +906,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { AtomicReference mealCashierCart = new AtomicReference<>(); + List skuList = new ArrayList<>(); if (!skuIds.isEmpty()) { - List skuList = productSkuRepository.findAllById(skuIds); + skuList = productSkuRepository.findAllById(skuIds); + } HashMap skuMap = new HashMap<>(); skuList.forEach(item -> skuMap.put(item.getId().toString(), item)); @@ -941,9 +943,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { Map map = BeanUtil.beanToMap(copyPage, false, false); map.put("seatFee", mealCashierCart); return map; - } - return BeanUtil.beanToMap(cartPage); +// return BeanUtil.beanToMap(cartPage); } @Override From 6888cedbd58ec0f733c5f7f8c6a6671bf21bb1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 29 Nov 2024 10:28:48 +0800 Subject: [PATCH 138/170] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BD=93=E5=89=8D=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rest/AuthorizationController.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java index d9d1de1f..11d70671 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java @@ -5,11 +5,19 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.config.security.config.bean.LoginCodeEnum; import cn.ysk.cashier.config.security.security.TokenProvider; +import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; +import cn.ysk.cashier.mybatis.mapper.TbMerchantAccountMapper; +import cn.ysk.cashier.mybatis.service.MpShopUserService; +import cn.ysk.cashier.pojo.TbToken; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; +import cn.ysk.cashier.repository.TbTokenRepository; import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; import cn.ysk.cashier.utils.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.wf.captcha.base.Captcha; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -43,6 +51,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -66,6 +75,11 @@ public class AuthorizationController { private final TbShopInfoRepository tbShopInfoRepository; private final TbPlussShopStaffRepository staffRepository; private final TbMerchantAccountRepository tbMerchantAccountRepository; + private final TbMerchantAccountMapper tbMerchantAccountMapper; + private final TbTokenRepository tbTokenRepository; + private final MpShopUserService shopUserService; + private final MpShopInfoMapper shopInfoMapper; + @Resource private LoginProperties loginProperties; @@ -154,6 +168,33 @@ public class AuthorizationController { return ResponseEntity.ok(authInfo); } + + @GetMapping("/userInfo") + public ResponseEntity getUserInfo(HttpServletRequest request) { + String token = tokenProvider.getToken(request); + JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-" + token))); + String userName = userInfo.getString("userName"); + String shopId = userInfo.getString("shopId"); + TbShopInfo shopInfo = shopInfoMapper.selectById(shopId); + TbPlussShopStaff shopStaff; + if (userName.contains("@")) { + shopStaff = staffRepository.queryMasterAccount(shopId); + } else { + shopStaff = staffRepository.queryByAccount(userName, shopId); + } +// TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.lambdaQuery() +// .eq(TbMerchantAccount::getAccount, shopStaff.getAccount())); +// Integer accountId = merchantAccount.getId(); +// Integer staffId = shopStaff.getId(); +// List onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId); + shopStaff.setPassword(null); + return ResponseEntity.ok(new HashMap(){{ + put("shopInfo", shopInfo); + put("shopStaff", shopStaff); + }}); + } + + /** * 小程序登录 * From aadecccbe2a106f65a8800219259c79f530fd21b Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 10:49:52 +0800 Subject: [PATCH 139/170] =?UTF-8?q?=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java index 18e7dca8..52b65288 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -35,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.persistence.criteria.Predicate; import java.math.BigDecimal; @@ -207,6 +208,7 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl Date: Fri, 29 Nov 2024 11:07:55 +0800 Subject: [PATCH 140/170] =?UTF-8?q?=E5=88=A0=E9=99=A4=20skuResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbShopSyncInfoServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java index 52b65288..08493270 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -216,7 +216,8 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl products = productRepository.selectByShopId(tbShopSyncInfo.getPointShopId().toString()); - products.stream().map(TbProduct::getId).collect(Collectors.toList()).forEach(id -> skuResultRepository.deleteById(id)); + List collect = products.stream().map(TbProduct::getId).collect(Collectors.toList()); + skuResultRepository.deleteAllByIdInBatch(collect); productRepository.clearShopPro(tbShopSyncInfo.getPointShopId().toString()); skuRepository.clearShopSku(tbShopSyncInfo.getPointShopId().toString()); consRepository.clearShopCons(tbShopSyncInfo.getPointShopId()); From ec275389f77bb5ed0872233c2ebf78d292755c08 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 11:18:43 +0800 Subject: [PATCH 141/170] =?UTF-8?q?=E5=88=A0=E9=99=A4=20proSku?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/cons/repository/TbProskuConRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java index b677992e..ec971ecc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java @@ -34,7 +34,7 @@ public interface TbProskuConRepository extends JpaRepository searchConsProByShopId(Integer shopId); @Modifying - @Query(value = "delete from tb_prosku_con where shop_id=?1 ",nativeQuery = true) + @Query("delete from TbProskuCon con where con.shopId=:shopId") void clearShopConPro(Integer shopId); } \ No newline at end of file From 3e4fc28d9b948c743ece5f82d7788cef05c10551 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 14:39:56 +0800 Subject: [PATCH 142/170] =?UTF-8?q?=E5=90=8C=E6=AD=A5=20=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/controller/TbShopSyncInfoController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java index 780980e0..8e309d01 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java @@ -41,7 +41,13 @@ public class TbShopSyncInfoController { @PostMapping("/sync") @ApiOperation("同步") - public ResponseEntity sync(@RequestBody TbShopSyncInfo tbShopSyncInfo){ + public ResponseEntity sync(@RequestBody TbShopSyncInfo tbShopSyncInfo) { + TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria(); + criteria.setPointShopId(tbShopSyncInfo.getPointShopId()); + TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria); + if (tbShopSyncInfo1 != null) { + throw new RuntimeException("已同步 请勿重复操作"); + } tbShopSyncInfo.setSyncTime(new Date()); tbShopSyncInfo.setStatus(1); tbShopSyncInfomapper.insert(tbShopSyncInfo); From b6c5180a399a2180b847cce2b5f57036046c8776 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 14:47:30 +0800 Subject: [PATCH 143/170] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=B8=BB=E5=BA=97Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/config/security/rest/AuthorizationController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java index 11d70671..43d1eb96 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java @@ -151,7 +151,7 @@ public class AuthorizationController { put("user", jwtUserDto); if (byAccount != null) { put("shopId", byAccount.getId()); - put("mainId", byAccount.getId()); + put("mainId", org.apache.commons.lang3.StringUtils.isNotBlank(byAccount.getMainId())?byAccount.getMainId():byAccount.getId()); put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType())?authUser.getLoginType():"merchant"); put("shopName", byAccount.getShopName()); put("logo", byAccount.getLogo()); From b1ba27aa1e03841c068af0d93a660ccaea721ca0 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 14:54:06 +0800 Subject: [PATCH 144/170] =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TbShopSyncInfoServiceImpl.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java index 08493270..ccf3444e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -337,26 +337,28 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl pros, Map skus) { productRepository.findPackageByShopId(shopId.toString()).forEach(tbProduct -> { tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); - tbProduct.getProGroupVo().forEach(proGroupVo -> { - proGroupVo.getGoods().forEach(goods -> { - if (pros.containsKey(goods.getProId())) { - if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) { - goods.setProId(pros.get(goods.getProId())); - goods.setSkuId(skus.get(goods.getSkuId())); - } else { - goods.setProId(pros.get(goods.getProId())); + if (tbProduct.getProGroupVo() != null) { + tbProduct.getProGroupVo().forEach(proGroupVo -> { + proGroupVo.getGoods().forEach(goods -> { + if (pros.containsKey(goods.getProId())) { + if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) { + goods.setProId(pros.get(goods.getProId())); + goods.setSkuId(skus.get(goods.getSkuId())); + } else { + goods.setProId(pros.get(goods.getProId())); + } + } + }); + proGroupVo.setCount(proGroupVo.getGoods().size()); + if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) { + if (proGroupVo.getNumber() > proGroupVo.getCount()) { + proGroupVo.setNumber(proGroupVo.getCount()); } } }); - proGroupVo.setCount(proGroupVo.getGoods().size()); - if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) { - if (proGroupVo.getNumber() > proGroupVo.getCount()) { - proGroupVo.setNumber(proGroupVo.getCount()); - } - } - }); - tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo())); - productRepository.save(tbProduct); + tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo())); + productRepository.save(tbProduct); + } }); } From 2830d1d94860fc77faf2b9997a46120f87c51b9f Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 15:09:24 +0800 Subject: [PATCH 145/170] =?UTF-8?q?=E5=95=86=E5=93=81=E7=9A=84=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopSyncInfoController.java | 12 +++++---- .../impl/TbShopSyncInfoServiceImpl.java | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java index 8e309d01..403538e6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java @@ -61,12 +61,14 @@ public class TbShopSyncInfoController { TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria(); criteria.setPointShopId(tbShopSyncInfo.getPointShopId()); TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria); - long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR); - if(between > 24){ - throw new RuntimeException("数据同步已超过一天 无法清除"); + if(tbShopSyncInfo1 != null){ + long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR); + if(between > 24){ + throw new RuntimeException("数据同步已超过一天 无法清除"); + } + tbShopSyncInfoService.clear(tbShopSyncInfo); } - tbShopSyncInfoService.clear(tbShopSyncInfo); - return new ResponseEntity<>(HttpStatus.CREATED); + return new ResponseEntity<>(HttpStatus.OK); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java index ccf3444e..38614709 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -299,18 +299,21 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl specs, Map cateGorys) { CompletableFuture> future = new CompletableFuture<>(); Map proMap = new HashMap<>(); - productRepository.findByShopId(sourceShopId.toString()).forEach(tbProduct -> { - Integer sourceSpecId = tbProduct.getId(); - tbProduct.setId(null); - tbProduct.setShopId(pointShopId.toString()); - tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : ""); - tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null); - tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null); - tbProduct.setStockNumber(0); + List products = productRepository.findByShopId(sourceShopId.toString()); + if(CollectionUtil.isNotEmpty(products)){ + products.forEach(tbProduct -> { + Integer sourceSpecId = tbProduct.getId(); + tbProduct.setId(null); + tbProduct.setShopId(pointShopId.toString()); + tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : ""); + tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null); + tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null); + tbProduct.setStockNumber(0); - productRepository.save(tbProduct); - proMap.put(sourceSpecId, tbProduct.getId()); - }); + productRepository.save(tbProduct); + proMap.put(sourceSpecId, tbProduct.getId()); + }); + } future.complete(proMap); return future; } From 217a6ed82a529aeaf113e92615cea3a498749aac Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 29 Nov 2024 15:51:56 +0800 Subject: [PATCH 146/170] =?UTF-8?q?=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TbShopSyncInfoServiceImpl.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java index 38614709..a146a47e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -53,6 +53,7 @@ import java.util.stream.Stream; */ @Slf4j @Service +@Transactional public class TbShopSyncInfoServiceImpl extends ServiceImpl implements TbShopSyncInfoService { @@ -208,7 +209,6 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl> syncProduct(Integer sourceShopId, Integer pointShopId, Map units, Map specs, Map cateGorys) { CompletableFuture> future = new CompletableFuture<>(); + String cateGory = ""; + if(CollectionUtil.isNotEmpty(cateGorys)){ + cateGory = cateGorys.get(cateGorys.keySet().stream().findFirst()).toString(); + } + Map proMap = new HashMap<>(); List products = productRepository.findByShopId(sourceShopId.toString()); if(CollectionUtil.isNotEmpty(products)){ - products.forEach(tbProduct -> { + for (TbProduct tbProduct : products) { Integer sourceSpecId = tbProduct.getId(); tbProduct.setId(null); tbProduct.setShopId(pointShopId.toString()); - tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : ""); + if(cateGorys.containsKey(Integer.valueOf(tbProduct.getCategoryId()))){ + tbProduct.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : ""); + }else { + tbProduct.setCategoryId(cateGory); + } + tbProduct.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null); tbProduct.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null); tbProduct.setStockNumber(0); productRepository.save(tbProduct); proMap.put(sourceSpecId, tbProduct.getId()); - }); + } } future.complete(proMap); return future; From 0bc8095e7c54cfa8ad61348e0b904d948aa64eed Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Dec 2024 11:07:27 +0800 Subject: [PATCH 147/170] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20over!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cons/repository/TbConsInfoRepository.java | 2 +- .../cons/repository/TbConsTypeRepository.java | 2 +- .../repository/TbProskuConRepository.java | 2 +- .../impl/TbShopSyncInfoServiceImpl.java | 215 +++++++++++------- 4 files changed, 132 insertions(+), 89 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java index fc9ea24c..bf9c29f5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java @@ -39,7 +39,7 @@ public interface TbConsInfoRepository extends JpaRepository @Query(value = "SELECT *" + " FROM" + - " tb_prosku_con conPro" + + " tb_cons_info conPro" + " where conPro.shop_id = :shopId ",nativeQuery = true) List searchConsInfoByShopId(Integer shopId); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java index 37084fa0..754358a1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java @@ -19,7 +19,7 @@ public interface TbConsTypeRepository extends JpaRepository TbConsType findByConTypeCode(String conTypeCode); - @Query("SELECT c FROM TbProskuCon c WHERE c.shopId = :shopId") + @Query("SELECT c FROM TbConsType c WHERE c.shopId = :shopId") List searchConsTypeByShopId(Integer shopId); @Modifying diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java index ec971ecc..0b020ef9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java @@ -34,7 +34,7 @@ public interface TbProskuConRepository extends JpaRepository searchConsProByShopId(Integer shopId); @Modifying - @Query("delete from TbProskuCon con where con.shopId=:shopId") + @Query(value = "delete from tb_prosku_con where shop_id = :shopId",nativeQuery = true) void clearShopConPro(Integer shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java index a146a47e..13305a4d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateTime; import cn.ysk.cashier.cons.domain.TbConsInfo; import cn.ysk.cashier.cons.domain.TbConsType; +import cn.ysk.cashier.cons.domain.TbProskuCon; import cn.ysk.cashier.cons.repository.TbConsInfoRepository; import cn.ysk.cashier.cons.repository.TbConsTypeRepository; import cn.ysk.cashier.cons.repository.TbProskuConRepository; @@ -17,10 +18,7 @@ import cn.ysk.cashier.pojo.product.*; import cn.ysk.cashier.pojo.shop.TbShopUnit; import cn.ysk.cashier.repository.product.*; import cn.ysk.cashier.repository.shop.TbShopUnitRepository; -import cn.ysk.cashier.utils.JSONUtil; -import cn.ysk.cashier.utils.ListUtil; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; +import cn.ysk.cashier.utils.*; import cn.ysk.cashier.vo.ProductGroupVo; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -45,6 +43,8 @@ import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; import java.util.stream.Stream; +import static cn.ysk.cashier.utils.StringCodeUtil.TYPE.LETTER_CAPITAL_NUMBER; + /** * 店铺信息同步记录表(TbShopSyncInfo)表服务实现类 * @@ -125,7 +125,6 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl tbProskuCons = proSkuConRepository.searchConsProByShopId(tbShopSyncInfo.getPointShopId()); + List proCons = tbProskuCons.stream().map(TbProskuCon::getId).collect(Collectors.toList()); + proSkuConRepository.deleteAllByIdInBatch(proCons); + proSkuConRepository.clearShopConPro(tbShopSyncInfo.getPointShopId()); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("point_shop_id", tbShopSyncInfo.getPointShopId()); @@ -235,10 +250,12 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl unitMap = new HashMap<>(); unitRepository.searchUnitByShopId(sourceShopId.toString()).forEach(tbShopUnit -> { Integer sourceUnitId = tbShopUnit.getId(); - tbShopUnit.setId(null); - tbShopUnit.setShopId(pointShopId.toString()); - unitRepository.save(tbShopUnit); - unitMap.put(sourceUnitId, tbShopUnit.getId()); + TbShopUnit unitNew = new TbShopUnit(); + unitNew.copy(tbShopUnit); + unitNew.setId(null); + unitNew.setShopId(pointShopId.toString()); + unitRepository.save(unitNew); + unitMap.put(sourceUnitId, unitNew.getId()); }); future.complete(unitMap); return future; @@ -247,13 +264,16 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl> syncSpec(Integer sourceShopId, Integer pointShopId) { + log.info("规格同步 "+System.currentTimeMillis()); CompletableFuture> future = new CompletableFuture<>(); Map specMap = new HashMap<>(); specRepository.searchSpecByShopId(sourceShopId.toString()).forEach(tbProductSpec -> { Integer sourceSpecId = tbProductSpec.getId(); - tbProductSpec.setId(null); - tbProductSpec.setShopId(pointShopId.toString()); - specRepository.save(tbProductSpec); + TbProductSpec tbProductSpecNew = new TbProductSpec(); + tbProductSpecNew.copy(tbProductSpec); + tbProductSpecNew.setId(null); + tbProductSpecNew.setShopId(pointShopId.toString()); + specRepository.save(tbProductSpecNew); specMap.put(sourceSpecId, tbProductSpec.getId()); }); future.complete(specMap); @@ -263,6 +283,7 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl> syncCategory(Integer sourceShopId, Integer pointShopId) { + log.info("分类同步 "+System.currentTimeMillis()); CompletableFuture> future = new CompletableFuture<>(); Map categoryMap = new HashMap<>(); List tbShopCategories = categoryRepository.searchCategoryByShopId(sourceShopId.toString()); @@ -271,23 +292,28 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl children = categoryRepository.findChildren(treeIds); for (TbShopCategory child : children) { Integer sourceCategoryId = child.getId(); - child.setId(null); - child.setShopId(pointShopId.toString()); - child.setTree(categoryMap.get(child.getTree())); - child.setPid(StringUtils.isNotBlank(child.getPid()) ? categoryMap.get(Integer.valueOf(child.getPid())).toString() : ""); - categoryRepository.save(child); - categoryMap.put(sourceCategoryId, child.getId()); + TbShopCategory tbShopCategoryNew = new TbShopCategory(); + tbShopCategoryNew.copy(child); + tbShopCategoryNew.setId(null); + tbShopCategoryNew.setShopId(pointShopId.toString()); + tbShopCategoryNew.setTree(categoryMap.get(child.getTree())); + tbShopCategoryNew.setPid(StringUtils.isNotBlank(child.getPid()) ? categoryMap.get(Integer.valueOf(child.getPid())).toString() : ""); + categoryRepository.save(tbShopCategoryNew); + categoryMap.put(sourceCategoryId, tbShopCategoryNew.getId()); } } future.complete(categoryMap); @@ -300,7 +326,7 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl> future = new CompletableFuture<>(); String cateGory = ""; if(CollectionUtil.isNotEmpty(cateGorys)){ - cateGory = cateGorys.get(cateGorys.keySet().stream().findFirst()).toString(); + cateGory = cateGorys.keySet().stream().findFirst().get().toString(); } Map proMap = new HashMap<>(); @@ -308,20 +334,23 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl groupMap = new HashMap<>(); groupRepository.searchGroupByShopId(sourceShopId).forEach(tbProductGroup -> { Integer groupId = tbProductGroup.getId(); - tbProductGroup.setId(null); - tbProductGroup.setShopId(pointShopId); - tbProductGroup.setUseTime(0); - tbProductGroup.setProductIds(replaceProIds(tbProductGroup.getProductIds(), pros)); - groupRepository.save(tbProductGroup); - groupMap.put(groupId, tbProductGroup.getId()); + TbProductGroup tbProductGroupNew = new TbProductGroup(); + tbProductGroupNew.copy(tbProductGroup); + tbProductGroupNew.setId(null); + tbProductGroupNew.setShopId(pointShopId); + tbProductGroupNew.setUseTime(0); + tbProductGroupNew.setProductIds(replaceProIds(tbProductGroup.getProductIds(), pros)); + groupRepository.save(tbProductGroupNew); + groupMap.put(groupId, tbProductGroupNew.getId()); }); future.complete(groupMap); return future; @@ -349,28 +380,30 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl pros, Map skus) { productRepository.findPackageByShopId(shopId.toString()).forEach(tbProduct -> { - tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); - if (tbProduct.getProGroupVo() != null) { - tbProduct.getProGroupVo().forEach(proGroupVo -> { - proGroupVo.getGoods().forEach(goods -> { - if (pros.containsKey(goods.getProId())) { - if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) { - goods.setProId(pros.get(goods.getProId())); - goods.setSkuId(skus.get(goods.getSkuId())); - } else { - goods.setProId(pros.get(goods.getProId())); + if(StringUtils.isNotBlank(tbProduct.getGroupSnap())){ + tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); + if (tbProduct.getProGroupVo() != null) { + tbProduct.getProGroupVo().forEach(proGroupVo -> { + proGroupVo.getGoods().forEach(goods -> { + if (pros.containsKey(goods.getProId())) { + if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) { + goods.setProId(pros.get(goods.getProId())); + goods.setSkuId(skus.get(goods.getSkuId())); + } else { + goods.setProId(pros.get(goods.getProId())); + } + } + }); + proGroupVo.setCount(proGroupVo.getGoods().size()); + if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) { + if (proGroupVo.getNumber() > proGroupVo.getCount()) { + proGroupVo.setNumber(proGroupVo.getCount()); } } }); - proGroupVo.setCount(proGroupVo.getGoods().size()); - if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) { - if (proGroupVo.getNumber() > proGroupVo.getCount()) { - proGroupVo.setNumber(proGroupVo.getCount()); - } - } - }); - tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo())); - productRepository.save(tbProduct); + tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo())); + productRepository.save(tbProduct); + } } }); } @@ -384,11 +417,13 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl { - tbProductSkuResult.setId(pros.get(tbProductSkuResult.getId())); - skuResultRepository.save(tbProductSkuResult); + TbProductSkuResult tbProductSkuResultNew = new TbProductSkuResult(); + tbProductSkuResultNew.copy(tbProductSkuResult); + tbProductSkuResultNew.setId(pros.get(tbProductSkuResult.getId())); + skuResultRepository.save(tbProductSkuResultNew); }); future.complete(skuResults.size()); return future; @@ -418,10 +455,12 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl tbConsTypes = consTypeRepository.searchConsTypeByShopId(sourceShopId); for (TbConsType tbConsType : tbConsTypes) { Integer sourceConsTypeId = tbConsType.getId(); - tbConsType.setId(null); - tbConsType.setShopId(pointShopId); - consTypeRepository.save(tbConsType); - consTypeMap.put(sourceConsTypeId, tbConsType.getId()); + TbConsType tbConsTypeNew = new TbConsType(); + tbConsTypeNew.copy(tbConsType); + tbConsTypeNew.setId(null); + tbConsTypeNew.setShopId(pointShopId); + consTypeRepository.save(tbConsTypeNew); + consTypeMap.put(sourceConsTypeId, tbConsTypeNew.getId()); } future.complete(consTypeMap); @@ -436,14 +475,16 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl tbConsInfos = consRepository.searchConsInfoByShopId(sourceShopId); for (TbConsInfo tbConsInfo : tbConsInfos) { Integer sourceConsId = tbConsInfo.getId(); - - tbConsInfo.setId(null); - tbConsInfo.setShopId(pointShopId); - tbConsInfo.setConTypeId(conTypes.get(tbConsInfo.getConTypeId())); - tbConsInfo.setStockNumber(BigDecimal.ZERO); - tbConsInfo.setStockConsume(BigDecimal.ZERO); - consRepository.save(tbConsInfo); - consMap.put(sourceConsId, tbConsInfo.getId()); + TbConsInfo tbConsInfoNew = new TbConsInfo(); + tbConsInfoNew.copy(tbConsInfo); + tbConsInfoNew.setId(null); + tbConsInfoNew.setShopId(pointShopId); + tbConsInfoNew.setConTypeId(conTypes.get(tbConsInfo.getConTypeId())); + tbConsInfoNew.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER)); + tbConsInfoNew.setStockNumber(BigDecimal.ZERO); + tbConsInfoNew.setStockConsume(BigDecimal.ZERO); + consRepository.save(tbConsInfoNew); + consMap.put(sourceConsId, tbConsInfoNew.getId()); } future.complete(consMap); return future; @@ -456,15 +497,17 @@ public class TbShopSyncInfoServiceImpl extends ServiceImpl { if (consMap.containsKey(tbConsPro.getConInfoId()) && proMap.containsKey(tbConsPro.getProductId()) && skuMap.containsKey(tbConsPro.getProductSkuId())) { Integer sourceConsProId = tbConsPro.getId(); - tbConsPro.setId(null); - tbConsPro.setShopId(pointShopId); - tbConsPro.setConInfoId(consMap.get(tbConsPro.getConInfoId())); - tbConsPro.setProductId(proMap.get(tbConsPro.getProductId())); + TbProskuCon tbConsProNew = new TbProskuCon(); + tbConsProNew.copy(tbConsPro); + tbConsProNew.setId(null); + tbConsProNew.setShopId(pointShopId); + tbConsProNew.setConInfoId(consMap.get(tbConsPro.getConInfoId())); + tbConsProNew.setProductId(proMap.get(tbConsPro.getProductId())); if (tbConsPro.getProductSkuId() > 0) { - tbConsPro.setProductSkuId(skuMap.get(tbConsPro.getProductSkuId())); + tbConsProNew.setProductSkuId(skuMap.get(tbConsPro.getProductSkuId())); } - proSkuConRepository.save(tbConsPro); - proSkuConMap.put(sourceConsProId, tbConsPro.getId()); + proSkuConRepository.save(tbConsProNew); + proSkuConMap.put(sourceConsProId, tbConsProNew.getId()); } }); future.complete(proSkuConMap); From 0e41e455ba1b2d4d3a8f3f47e5cbfdacaea06d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Mon, 2 Dec 2024 14:19:35 +0800 Subject: [PATCH 148/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=80=80=E6=AC=BEbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index fd82673d..ea3751e3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -910,39 +910,39 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (!skuIds.isEmpty()) { skuList = productSkuRepository.findAllById(skuIds); } - HashMap skuMap = new HashMap<>(); - skuList.forEach(item -> skuMap.put(item.getId().toString(), item)); + HashMap skuMap = new HashMap<>(); + skuList.forEach(item -> skuMap.put(item.getId().toString(), item)); - ArrayList> infos = new ArrayList<>(); - records.forEach(item -> { - if (item.getProductId() != null && item.getProductId().equals("-999")) { - mealCashierCart.set(item); - return; - } - Map map = BeanUtil.beanToMap(item, false, false); - TbProductSku tbProductSku = skuMap.get(item.getSkuId()); - map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null); - map.put("placeNum", item.getPlaceNum() == null ? 0 : item.getPlaceNum()); - infos.add(map); - }); + ArrayList> infos = new ArrayList<>(); + records.forEach(item -> { + if (item.getProductId() != null && item.getProductId().equals("-999")) { + mealCashierCart.set(item); + return; + } + Map map = BeanUtil.beanToMap(item, false, false); + TbProductSku tbProductSku = skuMap.get(item.getSkuId()); + map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null); + map.put("placeNum", item.getPlaceNum() == null ? 0 : item.getPlaceNum()); + infos.add(map); + }); - com.baomidou.mybatisplus.extension.plugins.pagination.Page copyPage = BeanUtil.copyProperties(cartPage, com.baomidou.mybatisplus.extension.plugins.pagination.Page.class); + com.baomidou.mybatisplus.extension.plugins.pagination.Page copyPage = BeanUtil.copyProperties(cartPage, com.baomidou.mybatisplus.extension.plugins.pagination.Page.class); - // 根据placeNum进行分组 - Map>> groupedByPlaceNum = infos.stream() - .collect(Collectors.groupingBy(info -> info.get("placeNum"))); + // 根据placeNum进行分组 + Map>> groupedByPlaceNum = infos.stream() + .collect(Collectors.groupingBy(info -> info.get("placeNum"))); - ArrayList> list = new ArrayList<>(); - groupedByPlaceNum.forEach((k, v) -> { - HashMap item = new HashMap<>(); - item.put("placeNum", k); - item.put("info", v); - list.add(item); - }); - copyPage.setRecords(list); - Map map = BeanUtil.beanToMap(copyPage, false, false); - map.put("seatFee", mealCashierCart); - return map; + ArrayList> list = new ArrayList<>(); + groupedByPlaceNum.forEach((k, v) -> { + HashMap item = new HashMap<>(); + item.put("placeNum", k); + item.put("info", v); + list.add(item); + }); + copyPage.setRecords(list); + Map map = BeanUtil.beanToMap(copyPage, false, false); + map.put("seatFee", mealCashierCart); + return map; // return BeanUtil.beanToMap(cartPage); } @@ -1514,7 +1514,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private void returnCoupon(TbOrderInfo orderInfo, boolean resetInfo) { // 返还优惠券 - if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) { + if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) && !"null".equals(orderInfo.getCouponInfoList())) { OrderInfoCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderInfoCouponInfoDTO.class); ArrayList couponIds = new ArrayList<>(); couponInfoDTO.getProductCoupon().forEach(item -> { @@ -2817,7 +2817,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (detailList.size() != returnOrderDTO.getOrderDetails().size()) { throw new BadRequestException("挂账退款必须全退"); } - }else { + } else { detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId()) .eq(TbOrderDetail::getStatus, "closed") @@ -3092,7 +3092,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else if ("cash".equals(payType)) { mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND, returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList())); - }else if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(payType)) { + } else if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(payType)) { creditBuyerOrderService.refund(orderInfo.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); } orderInfo.setStatus(TableConstant.OrderInfo.Status.CLOSED.getValue()); @@ -3104,9 +3104,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { .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())); + if (orderInfo.getMemberId() != null && orderInfo.getPointsNum() != null) { + // 返还积分 + memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), + "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + } } } orderInfoMapper.updateById(orderInfo); From 1bbf8a8822dc9f02028e8ba995af62506e0c6623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Mon, 2 Dec 2024 14:31:54 +0800 Subject: [PATCH 149/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=80=80=E6=AC=BEbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index ea3751e3..1bc612d8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -3109,6 +3109,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); } + // 返还挂账额度 + creditBuyerOrderService.refund(orderInfo.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); } } orderInfoMapper.updateById(orderInfo); From 2ee1b8a0e8143a45082eb7ff9848e3e8238a14c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Mon, 2 Dec 2024 14:51:43 +0800 Subject: [PATCH 150/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=80=80=E6=AC=BEbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 1bc612d8..ea3751e3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -3109,8 +3109,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); } - // 返还挂账额度 - creditBuyerOrderService.refund(orderInfo.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); } } orderInfoMapper.updateById(orderInfo); From c7633ec87590f9fe3d2d7d1daea9fab8c270a83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Mon, 2 Dec 2024 14:58:31 +0800 Subject: [PATCH 151/170] =?UTF-8?q?=E6=8C=82=E8=B4=A6=E9=80=80=E6=AC=BEbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java index 4ad17285..2f6fa687 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -275,9 +275,9 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl Date: Mon, 2 Dec 2024 15:43:37 +0800 Subject: [PATCH 152/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/pojo/product/TbProduct.java | 4 +++ .../productimpl/TbProductServiceImpl.java | 19 ++++++++----- .../cn/ysk/cashier/vo/TbProductNewVo.java | 27 +++++++++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 5fef345e..3620eb27 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -72,6 +72,10 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "单位Id") private Integer unitId; + @Transient + @TableField(exist = false) + private String unitName; + @Column(name = "`cover_img`") @ApiModelProperty(value = "商品封面图") private String coverImg; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 47fbed60..cc574cfc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -321,7 +321,7 @@ public class TbProductServiceImpl implements TbProductService { BeanUtils.copyProperties(tbProduct, tbProductVo); //套餐 - if(tbProduct.getType().equals("package")){ + if (tbProduct.getType().equals("package")) { if (tbProduct.getGroupSnap() == null) { tbProductVo.setProGroupVo(null); } else { @@ -448,7 +448,7 @@ public class TbProductServiceImpl implements TbProductService { } } } - if("package".equals(resources.getType())){ + if ("package".equals(resources.getType())) { //套餐内容 if (!resources.getProGroupVo().isEmpty()) { product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); @@ -563,7 +563,7 @@ public class TbProductServiceImpl implements TbProductService { } else { product.setCategoryId(resources.getCategoryId().toString()); } - if("package".equals(resources.getType())){ + if ("package".equals(resources.getType())) { //套餐内容 if (CollectionUtil.isNotEmpty(resources.getProGroupVo())) { product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); @@ -771,7 +771,7 @@ public class TbProductServiceImpl implements TbProductService { com.baomidou.mybatisplus.extension.plugins.pagination.Page page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("is_del", 0) - .eq(false,"type", "coupon") + .eq(false, "type", "coupon") .eq("shop_id", shopId) .eq("status", 1) .eq("is_del", 0) @@ -790,12 +790,19 @@ public class TbProductServiceImpl implements TbProductService { if (productId != null) { queryWrapper.eq("id", productId); } - + Map unitMap = new HashMap<>(); com.baomidou.mybatisplus.extension.plugins.pagination.Page tbProductPage = productMapper.selectPage(page1, queryWrapper); tbProductPage.getRecords().forEach(item -> { - if("package".equals(item.getType())){ + if ("package".equals(item.getType())) { item.setProGroupVo(JSONUtil.parseJSONStrTList(item.getGroupSnap(), ProductGroupVo.class)); } + if (item.getUnitId() != null) { + if (!unitMap.containsKey(item.getUnitId())) { + TbShopUnit tbShopUnit = tbShopUnitRepository.searchUnit(item.getUnitId()); + unitMap.put(item.getId(), tbShopUnit.getName()); + } + item.setUnitName(unitMap.get(item.getUnitId())); + } TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null); List tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper().eq(TbProductSku::getIsDel, 0) .eq(TbProductSku::getIsPauseSale, 0) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java index 34e15dcf..a83ae2fe 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java @@ -28,6 +28,7 @@ public class TbProductNewVo { private String name; //售价 private String lowPrice; + private String type; //类型 单规格/多规格 private String typeEnum; //库存 @@ -53,26 +54,30 @@ public class TbProductNewVo { private Integer sort; public void setTypeEnum(String typeEnum) { - switch (typeEnum) { + switch (this.type) { case "normal": - this.typeEnum = "单规格"; - break; - case "sku": - this.typeEnum = "多规格"; - break; - case "weight": + this.typeEnum = "普通商品"; + case "weigh": this.typeEnum = "称重商品"; break; - case "currentPrice": - this.typeEnum = "时价商品"; + case "coupon": + this.typeEnum = "优惠券"; break; - case "group": - this.typeEnum = "套餐商品/团购卷"; + case "package": + this.typeEnum = "套餐商品"; break; default: this.typeEnum = typeEnum; break; } + switch (typeEnum) { + case "normal": + this.typeEnum = this.typeEnum + ":单规格"; + break; + case "sku": + this.typeEnum = this.typeEnum + "多规格"; + break; + } } @Data From 6e5ed249adab4fc39610181813aa1b5e7b59bb8c Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Dec 2024 15:48:25 +0800 Subject: [PATCH 153/170] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java index a83ae2fe..851d2ae9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java @@ -57,18 +57,19 @@ public class TbProductNewVo { switch (this.type) { case "normal": this.typeEnum = "普通商品"; + break; case "weigh": this.typeEnum = "称重商品"; - break; + return; case "coupon": this.typeEnum = "优惠券"; - break; + return; case "package": this.typeEnum = "套餐商品"; - break; + return; default: this.typeEnum = typeEnum; - break; + return; } switch (typeEnum) { case "normal": From edcd85933eb46e4c32601f98b411a3cae0f1aa85 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Dec 2024 15:52:54 +0800 Subject: [PATCH 154/170] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java index 851d2ae9..cf704a98 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java @@ -76,7 +76,7 @@ public class TbProductNewVo { this.typeEnum = this.typeEnum + ":单规格"; break; case "sku": - this.typeEnum = this.typeEnum + "多规格"; + this.typeEnum = this.typeEnum + ":多规格"; break; } } From 0a37e4d7c53eb76efa3a63774fd4dbdf9e3ecd53 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Dec 2024 16:02:58 +0800 Subject: [PATCH 155/170] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index cc574cfc..149fc7f2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -799,7 +799,7 @@ public class TbProductServiceImpl implements TbProductService { if (item.getUnitId() != null) { if (!unitMap.containsKey(item.getUnitId())) { TbShopUnit tbShopUnit = tbShopUnitRepository.searchUnit(item.getUnitId()); - unitMap.put(item.getId(), tbShopUnit.getName()); + unitMap.put(tbShopUnit.getId(), tbShopUnit.getName()); } item.setUnitName(unitMap.get(item.getUnitId())); } From c8abded1fbdf8bd26cfd1fbf951436f0b36cd54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 09:39:00 +0800 Subject: [PATCH 156/170] =?UTF-8?q?fix:=20=E4=B8=B4=E6=97=B6=E8=8F=9C?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=87=AA=E5=8F=96=E6=8A=A5=E9=94=99=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/shopimpl/TbShopTableServiceImpl.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index ea3751e3..de29036c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2744,34 +2744,41 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (OrderUseTypeEnum.TAKEOUT.getValue().equals(choseModelDTO.getUseType())) { ArrayList productIds = new ArrayList<>(); cashierCarts.forEach(item -> { - productIds.add(Integer.valueOf(item.getProductId())); + if (item.getProductId() != null) { + productIds.add(Integer.valueOf(item.getProductId())); + } }); - List productList = productMapper.selectBatchIds(productIds); - Map productMap = productList.stream() - .collect(Collectors.toMap(product -> String.valueOf(product.getId()), product -> product)); - cashierCarts.forEach(item -> { - TbProduct product = productMap.get(item.getProductId()); + + Map productMap = new HashMap<>(); + if (!productIds.isEmpty()) { + List productList = productMapper.selectBatchIds(productIds); + productMap = productList.stream() + .collect(Collectors.toMap(product -> String.valueOf(product.getId()), product -> product)); + } + for (TbCashierCart cashierCart : cashierCarts) { + TbProduct product = productMap.get(cashierCart.getProductId()); + // 设置打包费 mpCashierCartService.update(new LambdaUpdateWrapper() - .eq(TbCashierCart::getId, item.getId()) - .set(TbCashierCart::getPackFee, product.getPackFee() != null ? - product.getPackFee().multiply(item.getNumber()) : BigDecimal.ZERO) + .eq(TbCashierCart::getId, cashierCart.getId()) + .set(TbCashierCart::getPackFee, product != null && product.getPackFee() != null ? + product.getPackFee().multiply(cashierCart.getNumber()) : BigDecimal.ZERO) .set(TbCashierCart::getTableId, null) .set(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue()) .set(TbCashierCart::getIsPack, "true")); - }); + } List detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() .in(TbOrderDetail::getCartId, choseModelDTO.getCartIds()) .eq(TbOrderDetail::getShopId, choseModelDTO.getShopId())); - detailList.forEach(item -> { + for (TbOrderDetail item : detailList) { item.setUseType(OrderUseTypeEnum.TAKEOUT.getValue()); TbProduct product = productMap.get(item.getProductId().toString()); // 设置打包费 - item.setPackAmount(product.getPackFee() != null ? + item.setPackAmount(product != null && product.getPackFee() != null ? product.getPackFee().multiply(item.getNum()) : BigDecimal.ZERO); - }); + } if (!detailList.isEmpty()) { mpOrderDetailService.updateBatchById(detailList); From 467f6e94341c6bf31c9343e5b125a2227b259cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 09:46:57 +0800 Subject: [PATCH 157/170] =?UTF-8?q?fix:=20=E6=94=B9=E4=BB=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java index 120d93e9..78404fed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java @@ -14,7 +14,7 @@ public class UpdatePriceDTO { private Integer shopId; @NotNull private Integer cartId; - @DecimalMin("0.01") + @DecimalMin(value = "0.01", message = "改价不能低于0.01元") @NotNull private BigDecimal saleAmount; @NotBlank(message = "折扣原因不能为空") From 2e46f9ab0fb3f3cd9a825399f63e0386b3821a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 10:56:19 +0800 Subject: [PATCH 158/170] =?UTF-8?q?feat:=20=E4=BB=A3=E5=AE=A2=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E6=94=AF=E6=8C=81=E5=A5=97=E9=A4=90=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/cons/TableConstant.java | 17 ++++++ .../ysk/cashier/dto/shoptable/AddCartDTO.java | 4 ++ .../cashier/dto/shoptable/UpdateCartDTO.java | 4 ++ .../ysk/cashier/pojo/order/TbCashierCart.java | 2 + .../ysk/cashier/pojo/order/TbOrderDetail.java | 1 + .../impl/shopimpl/TbShopTableServiceImpl.java | 61 +++++++++++++++++-- 6 files changed, 85 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java index b0d6b858..af3557f0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/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 ThirdPartyCoupon { @Getter public enum Plat { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java index 44335aaf..4738ec56 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java @@ -4,6 +4,7 @@ import lombok.Data; import javax.validation.constraints.*; import java.math.BigDecimal; +import java.util.List; @Data public class AddCartDTO { @@ -24,6 +25,9 @@ public class AddCartDTO { private Integer cartId; private String note; + // 套餐商品选择的id信息 + private List groupProductIdList; + // 用餐类型 @NotBlank private String useType; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index a63650ae..456c3092 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -7,6 +7,7 @@ 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 UpdateCartDTO { @@ -27,4 +28,7 @@ public class UpdateCartDTO { // 是否等叫 private Integer isWaitCall; + // 套餐商品选择的id信息 + private List groupProductIdList; + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 249de2a8..23d579ad 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -181,6 +181,8 @@ public class TbCashierCart implements Serializable { private Integer isThirdCoupon; // 是否等叫 private Integer isWaitCall; + // 套餐商品,选择的商品信息 + private String proGroupInfo; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index db192934..893a5049 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -141,6 +141,7 @@ public class TbOrderDetail implements Serializable { private BigDecimal canReturnAmount; private Integer isThirdCoupon; private Integer isWaitCall; + private String proGroupInfo; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index de29036c..e46e57b8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -50,10 +50,7 @@ import cn.ysk.cashier.service.impl.TbPayServiceImpl; import cn.ysk.cashier.service.order.TbOrderInfoService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.*; -import cn.ysk.cashier.vo.ActivateInInfoVO; -import cn.ysk.cashier.vo.OrderInfoUserCouponVo; -import cn.ysk.cashier.vo.PendingCountVO; -import cn.ysk.cashier.vo.TbUserCouponVo; +import cn.ysk.cashier.vo.*; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -449,6 +446,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("商品不存在或已下架, id: " + updateCartDTO.getSkuId()); } + resetGroupProductCart(updateCartDTO.getGroupProductIdList(), product, tbCashierCart); tbCashierCart.setCoverImg(product.getCoverImg()); tbCashierCart.setIsSku(product.getTypeEnum()); tbCashierCart.setName(product.getName()); @@ -494,6 +492,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (tbCashierCart.getOrderId() != null && StrUtil.isNotBlank(updateCartDTO.getNote())) { orderDetailMapper.update(null, new LambdaUpdateWrapper() .eq(TbOrderDetail::getCartId, tbCashierCart.getId()) + .set(TbOrderDetail::getProGroupInfo, tbCashierCart.getProGroupInfo()) .set(TbOrderDetail::getIsWaitCall, updateCartDTO.getIsWaitCall()) .set(TbOrderDetail::getNote, updateCartDTO.getNote())); } @@ -512,6 +511,51 @@ public class TbShopTableServiceImpl implements TbShopTableService { return orderInfo == null ? 1 : orderInfo.getPlaceNum() + 1; } + /** + * 重置购物车套餐商品信息 + */ + 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 BadRequestException("存在无效套餐商品"); + } + foods.add(food); + }); + + 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 -> { + groupVoHashMap.put(goods.getProId().toString(), goods); + }); + }); + + cashierCart.setProGroupInfo(JSONObject.toJSONString(groupVoHashMap.values())); + } + } + } + @Override public TbCashierCart addCartForUser(AddCartDTO addCartDTO) { addCartDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(addCartDTO.getUseType()) ? null : addCartDTO.getTableId()); @@ -528,6 +572,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException(product.getName() + "商品库存不足"); } + boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1; + if (isChoseGroup && (addCartDTO.getGroupProductIdList() == null || addCartDTO.getGroupProductIdList().isEmpty())) { + throw new BadRequestException("可选套餐,清先选择套餐商品"); + } + LambdaQueryWrapper query = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, addCartDTO.getShopId()) .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) @@ -555,6 +604,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 首次加入 if (tbCashierCart == null) { tbCashierCart = new TbCashierCart(); + resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart); + tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); tbCashierCart.setCoverImg(product.getCoverImg()); tbCashierCart.setCreatedAt(System.currentTimeMillis()); @@ -598,6 +649,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpCashierCartService.save(tbCashierCart); } else { + resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart); tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice())); @@ -1612,6 +1664,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); } + orderDetail.setProGroupInfo(cashierCart.getProGroupInfo()); orderDetail.setDiscountSaleAmount(cashierCart.getDiscountSaleAmount()); orderDetail.setIsWaitCall(cashierCart.getIsWaitCall()); orderDetail.setUserCouponId(cashierCart.getUserCouponId()); From ad27d30d4e33db2969c2a68fee3af895259a18fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 11:08:27 +0800 Subject: [PATCH 159/170] =?UTF-8?q?fix:=20=E8=B5=A0=E9=80=81=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E6=94=B9=E4=BB=B7=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index e46e57b8..7a15b760 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -483,6 +483,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (updateCartDTO.getIsGift() != null) { tbCashierCart.setTotalAmount(updateCartDTO.getIsGift() ? tbCashierCart.getPackFee() : tbCashierCart.getTotalAmount()); tbCashierCart.setIsGift(updateCartDTO.getIsGift() ? "true" : "false"); + tbCashierCart.setDiscountSaleAmount(BigDecimal.ZERO); + if (updateCartDTO.getIsGift()) { + tbCashierCart.setDiscountSaleNote(""); + tbCashierCart.resetTotalAmount(); + } } tbCashierCart.setTotalNumber(updateCartDTO.getNum()); From cddbe8d1953275de6ed08dae15787fcfb8ea5c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 14:22:07 +0800 Subject: [PATCH 160/170] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java | 2 ++ .../service/impl/shopimpl/TbShopTableServiceImpl.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 23d579ad..50c9bb49 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -183,6 +183,8 @@ public class TbCashierCart implements Serializable { private Integer isWaitCall; // 套餐商品,选择的商品信息 private String proGroupInfo; + // 商品类型 + private String typeEnum; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 7a15b760..1b162722 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -610,7 +610,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (tbCashierCart == null) { tbCashierCart = new TbCashierCart(); resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart); - + TbShopUnit tbShopUnit = mpShopUnitMapper.selectById(product.getId()); + if (tbShopUnit != null) { + tbCashierCart.setUnit(tbShopUnit.getName()); + } + tbCashierCart.setTypeEnum(product.getTypeEnum()); tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); tbCashierCart.setCoverImg(product.getCoverImg()); tbCashierCart.setCreatedAt(System.currentTimeMillis()); From feceb08a3e97a6c2a6314a39ba21658b5441ac17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 4 Dec 2024 16:25:11 +0800 Subject: [PATCH 161/170] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 1b162722..442c8cea 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -610,7 +610,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (tbCashierCart == null) { tbCashierCart = new TbCashierCart(); resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart); - TbShopUnit tbShopUnit = mpShopUnitMapper.selectById(product.getId()); + TbShopUnit tbShopUnit = mpShopUnitMapper.selectById(product.getUnitId()); if (tbShopUnit != null) { tbCashierCart.setUnit(tbShopUnit.getName()); } From 25a67350260d1c1666609d5325d37ac64e27c4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 4 Dec 2024 17:07:24 +0800 Subject: [PATCH 162/170] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E5=AE=A2?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=A4=9A=E4=B8=AA=E5=95=86=E5=93=81=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=80=BB=E9=87=91=E9=A2=9D=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 442c8cea..81a7f4f3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.config.security.security.TokenProvider; @@ -544,7 +545,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { cashierCart.setProGroupInfo(JSONObject.toJSONString(foods)); } - }else if (isFixGroup) { + } else if (isFixGroup) { String groupSnap = product.getGroupSnap(); if (StrUtil.isNotBlank(groupSnap)) { ArrayList foods = new ArrayList<>(); @@ -2278,7 +2279,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { for (TbCashierCart cashierCart : cashierCarts) { if (cashierCart.getUserCouponId() == null) { cashierCart.setTotalAmount(cashierCart.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - totalAmount = cashierCart.getTotalAmount(); + totalAmount = NumberUtil.add(totalAmount, cashierCart.getTotalAmount()); } // item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); From df088286736a58a930f42b61a5dfcec23c520355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Wed, 4 Dec 2024 17:53:47 +0800 Subject: [PATCH 163/170] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E5=AE=A2?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=A4=9A=E4=B8=AA=E5=95=86=E5=93=81=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=80=BB=E9=87=91=E9=A2=9D=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/shopimpl/TbShopTableServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 81a7f4f3..3c9376e9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2275,11 +2275,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); BigDecimal discount = payDTO.getDiscount().setScale(4, RoundingMode.HALF_DOWN); - BigDecimal totalAmount = BigDecimal.ZERO; + BigDecimal sumTotalAmount = cashierCarts.stream().map(TbCashierCart::getTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalAmount = NumberUtil.mul(sumTotalAmount, discount).setScale(2, RoundingMode.HALF_UP); for (TbCashierCart cashierCart : cashierCarts) { if (cashierCart.getUserCouponId() == null) { - cashierCart.setTotalAmount(cashierCart.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - totalAmount = NumberUtil.add(totalAmount, cashierCart.getTotalAmount()); + cashierCart.setTotalAmount(cashierCart.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_EVEN)); } // item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); @@ -2287,7 +2287,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } detailList.forEach(item -> { - item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_EVEN)); // item.setPrice(item.getPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); }); From 11fd24f8136846a4e91182dadf51a68bf03f672e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Thu, 5 Dec 2024 13:59:29 +0800 Subject: [PATCH 164/170] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E5=AE=A2?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=A4=9A=E4=B8=AA=E5=95=86=E5=93=81=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=80=BB=E9=87=91=E9=A2=9D=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/pojo/order/TbCashierCart.java | 12 ++++++------ .../impl/shopimpl/TbShopTableServiceImpl.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index 50c9bb49..a761734b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -15,16 +15,16 @@ */ package cn.ysk.cashier.pojo.order; -import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.util.NumberUtil; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.math.BigDecimal; import java.math.RoundingMode; /** @@ -261,7 +261,7 @@ public class TbCashierCart implements Serializable { } if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - return num.multiply(memberPrice).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP); + return num.multiply(memberPrice.subtract(NumberUtil.null2Zero(discountSaleAmount))).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP); }else { return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 3c9376e9..698fe84c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -580,7 +580,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1; if (isChoseGroup && (addCartDTO.getGroupProductIdList() == null || addCartDTO.getGroupProductIdList().isEmpty())) { - throw new BadRequestException("可选套餐,清先选择套餐商品"); + throw new BadRequestException("可选套餐,请先选择套餐商品"); } LambdaQueryWrapper query = new LambdaQueryWrapper() From 09eb3ccfadc6685c4533969fa654899ba8809607 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 6 Dec 2024 09:23:16 +0800 Subject: [PATCH 165/170] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=9C=AA=E5=A1=AB=E5=86=99=20=E6=A0=A1=E9=AA=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 149fc7f2..b8a01b9d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -417,7 +417,7 @@ public class TbProductServiceImpl implements TbProductService { } if (!"coupon".equals(resources.getType())) { if (resources.getCategoryId() == null) { - throw new BadRequestException("必填内容未填写"); + throw new BadRequestException("商品分类未填写"); } product.setCategoryId(String.valueOf(resources.getCategoryId())); } From 1c585acfd147ab4f26d4912ee189eb2616c0c34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 6 Dec 2024 10:08:48 +0800 Subject: [PATCH 166/170] =?UTF-8?q?fix:=20=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=95=B0=E9=87=8F=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/shopimpl/TbShopTableServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 3c9376e9..6bbca5cf 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -2089,6 +2089,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { TbActivateOutRecord tbActivateOutRecord = null; if (!couponInfo.getFullReductionCouponMap().isEmpty()) { TbUserCouponVo couponVo = couponInfo.getFullReductionCouponMap().values().stream().findFirst().orElse(null); + couponVo.setCurrentUseNum(BigDecimal.ONE); finalAmount = finalAmount.subtract(couponVo.getDiscountAmount()); orderInfo.setFullCouponDiscountAmount(couponVo.getDiscountAmount()); From 99c86e0175cb2dcbe6bcc0a6f64fe05db63dbde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 6 Dec 2024 13:38:30 +0800 Subject: [PATCH 167/170] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java index 4738ec56..f8abd013 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java @@ -18,7 +18,7 @@ public class AddCartDTO { private Integer shopId; private String tableId; @NotNull - @DecimalMin("0.01") + @DecimalMin(value = "0.01", message = "数量最小为0.01") private BigDecimal num; private boolean isPack; private boolean isGift; From 4229c500ad7bc9dee3180bcc4c07797614315a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 6 Dec 2024 13:54:41 +0800 Subject: [PATCH 168/170] =?UTF-8?q?fix:=E5=88=9B=E5=BB=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=A2=9E=E5=8A=A0=E8=8A=82=E6=B5=81=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 5 ++- .../main/java/cn/ysk/cashier/utils/Utils.java | 45 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index b0f3a3d3..3caed88d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -3,6 +3,7 @@ package cn.ysk.cashier.controller.product; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.annotation.AnonymousAccess; +import cn.ysk.cashier.annotation.Limit; import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.dto.shoptable.*; @@ -18,6 +19,7 @@ import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.RabbitMsgUtils; import cn.ysk.cashier.utils.RedisUtils; +import cn.ysk.cashier.utils.Utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -156,7 +158,8 @@ public class TbPlaceController { @PostMapping("/order") @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity createOrder(@RequestBody CreateOrderDTO createOrderDTO) { + public ResponseEntity createOrder(HttpServletRequest request, @RequestBody CreateOrderDTO createOrderDTO) { + Utils.checkLimit(tokenProvider.getToken(request), 1, 400); return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, false)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java index fbcc0f13..75fa6d9d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -12,10 +13,16 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +@Component public class Utils { public static int retryCount = 5; + private static StringRedisTemplate redisTemplate; private static final Logger log = LoggerFactory.getLogger(Utils.class); + public Utils(StringRedisTemplate redisTemplate) { + Utils.redisTemplate = redisTemplate; + } + public static void catchErrNoReturn(Supplier supplier) { try { supplier.get(); @@ -116,4 +123,42 @@ public class Utils { } return result; } + + public static void checkLimit(String key, int maxRequests, long timeWindow) { + // 获取当前时间戳 + long now = System.currentTimeMillis(); + + // 获取之前的时间戳和计数从 Redis + String prevTimestamp = redisTemplate.opsForValue().get(key + ":timestamp"); + String prevCount = redisTemplate.opsForValue().get(key + ":count"); + + // 如果这是第一次请求,设置初始值 + if (prevTimestamp == null || prevCount == null) { + redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + redisTemplate.opsForValue().set(key + ":count", "1"); + return; + } + + // 计算自上一次请求以来经过的时间 + long elapsed = now - Long.parseLong(prevTimestamp); + + // 如果时间窗口已经过去,重置计数 + if (elapsed > timeWindow) { + redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + redisTemplate.opsForValue().set(key + ":count", "1"); + return; + } + + // 增加计数 + int count = Integer.parseInt(prevCount) + 1; + + // 如果计数超过最大值,返回 false + if (count > maxRequests) { + throw new BadRequestException("操作太快啦,请稍后再试"); + } + + // 更新计数和时间戳 + redisTemplate.opsForValue().set(key + ":count", String.valueOf(count)); + redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + } } From c51d8325c29bce32cc4efcce746cdb563fbe102c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 6 Dec 2024 13:57:51 +0800 Subject: [PATCH 169/170] =?UTF-8?q?fix:=E5=88=9B=E5=BB=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=A2=9E=E5=8A=A0=E8=8A=82=E6=B5=81=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/utils/Utils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java index 75fa6d9d..7a3ae219 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java @@ -136,6 +136,8 @@ public class Utils { if (prevTimestamp == null || prevCount == null) { redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); redisTemplate.opsForValue().set(key + ":count", "1"); + redisTemplate.expire(key + ":timestamp", 5, TimeUnit.SECONDS); + redisTemplate.expire(key + ":count", 5, TimeUnit.SECONDS); return; } @@ -146,6 +148,8 @@ public class Utils { if (elapsed > timeWindow) { redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); redisTemplate.opsForValue().set(key + ":count", "1"); + redisTemplate.expire(key + ":timestamp", 5, TimeUnit.SECONDS); + redisTemplate.expire(key + ":count", 5, TimeUnit.SECONDS); return; } @@ -160,5 +164,7 @@ public class Utils { // 更新计数和时间戳 redisTemplate.opsForValue().set(key + ":count", String.valueOf(count)); redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + redisTemplate.expire(key + ":timestamp", 5, TimeUnit.SECONDS); + redisTemplate.expire(key + ":count", 5, TimeUnit.SECONDS); } } From c82dcd34966f53543b48caedc70583495a453336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 6 Dec 2024 14:23:25 +0800 Subject: [PATCH 170/170] =?UTF-8?q?fix:=20=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8sku=E4=BF=A1=E6=81=AF=E8=BF=94=E5=9B=9E=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashier/service/impl/productimpl/TbProductServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index b8a01b9d..98b622a3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -181,7 +181,8 @@ public class TbProductServiceImpl implements TbProductService { skuList.add(tbProductSku); } tbProductVo.setStockNumber(stockNumber); - tbProductVo.setSkuList(skuList); +// tbProductVo.setSkuList(skuList); + tbProductVo.setSkuList(tbProductSkus); //单位 if (tbShopUnits.isEmpty()) { tbProductVo.setUnitName("");