diff --git a/db/800pjcloudx_hardware.sql b/db/800pjcloudx_hardware.sql index 61b118a7d..440019f40 100644 --- a/db/800pjcloudx_hardware.sql +++ b/db/800pjcloudx_hardware.sql @@ -92,6 +92,7 @@ CREATE TABLE hard_parent_car id bigint NOT NULL COMMENT '标号', user_id bigint NOT NULL COMMENT '用户id', merchant_id bigint NOT NULL COMMENT '商户id', + hard_type char(10) NOT NULL COMMENT '设备类型', order_status char(10) NOT NULL COMMENT '订单状态', create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', create_time datetime DEFAULT NULL COMMENT '创建时间', diff --git a/db/800pjcloudx_wallet.sql b/db/800pjcloudx_wallet.sql index 308b06571..094f0b09b 100644 --- a/db/800pjcloudx_wallet.sql +++ b/db/800pjcloudx_wallet.sql @@ -47,7 +47,7 @@ CREATE TABLE wallet_manage freeze_price int DEFAULT 0 NOT NULL COMMENT '冻结金额,单位分', is_freeze tinyint DEFAULT '0' NOT NULL COMMENT '是否冻结饭卡', active_bind_time timestamp COMMENT '绑定饭卡时间', - active_bind_status tinyint COMMENT '饭卡绑定状态', + active_bind_status char(10) COMMENT '饭卡绑定状态', create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', create_time datetime DEFAULT NULL COMMENT '创建时间', update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人', @@ -139,6 +139,8 @@ CREATE TABLE wallet_transaction ( id bigint NOT NULL COMMENT '编号', wallet_id bigint NOT NULL COMMENT '会员钱包 id', + user_id bigint NOT NULL COMMENT '用户id', + dept_id bigint NOT NULL COMMENT '部门id', biz_type tinytext NOT NULL COMMENT '关联类型', biz_id varchar(64) NOT NULL COMMENT '关联业务编号', title varchar(128) NOT NULL COMMENT '流水标题', diff --git a/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java index 8d6157d26..80dad6595 100644 --- a/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java +++ b/pjcloud-common/pjcloud-common-core/src/main/java/com/bsd/pjcloud/common/core/constant/ServiceNameConstants.java @@ -81,4 +81,9 @@ public interface ServiceNameConstants { * 钱包模块 */ String WALLET_SERVICE = "pjcloud-wallet-biz"; + + /** + * 硬件模块 + */ + String HARDWARE_SERVICE = "pjcloud-hardware-biz"; } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/HardTypeEnum.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/HardTypeEnum.java index fdcafcba8..2b9bc77bd 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/HardTypeEnum.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/HardTypeEnum.java @@ -5,6 +5,8 @@ import lombok.AllArgsConstructor; import lombok.Getter; import java.util.Arrays; +import java.util.List; +import java.util.Map; /** * 硬件设备类型 @@ -21,6 +23,13 @@ public enum HardTypeEnum { private final String type; private final String description; + // 是否能预定 + private static final List isReserveList = List.of(SUPERMARKET, CANTEEN); + + public static Boolean isReserve(HardTypeEnum type) { + return isReserveList.contains(type); + } + public static HardTypeEnum valueOfByType(String type) { if (ObjectUtil.isEmpty(type)) return null; return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get(); diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/refund/HardRefundStatusEnum.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/refund/HardRefundStatusEnum.java index 582c0fb52..58f246606 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/refund/HardRefundStatusEnum.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/refund/HardRefundStatusEnum.java @@ -3,6 +3,9 @@ package com.bsd.pjcloud.hard.api.constant.refund; import lombok.Getter; import lombok.RequiredArgsConstructor; +/** + * 订单退款类型 + */ @RequiredArgsConstructor @Getter public enum HardRefundStatusEnum { diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/app/HardCarSaveOrUpdateDto.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/app/HardCarSaveOrUpdateDto.java index 8c58a4620..7157b6b71 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/app/HardCarSaveOrUpdateDto.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/app/HardCarSaveOrUpdateDto.java @@ -1,6 +1,6 @@ package com.bsd.pjcloud.hard.api.dto.app; -import com.bsd.pjcloud.hard.api.dto.order.HardCarDto; +import com.bsd.pjcloud.hard.api.constant.HardTypeEnum; import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; @@ -29,6 +29,9 @@ public class HardCarSaveOrUpdateDto { @Schema(description = "用户id") private Long userId; + @Schema(description = "硬件设备类型") + private HardTypeEnum hardType; + @Schema(description = "订单类型") private String orderType; diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardAfterSaleDto.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardAfterSaleDto.java index ee2a87e84..a2eff7d4b 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardAfterSaleDto.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardAfterSaleDto.java @@ -3,6 +3,15 @@ package com.bsd.pjcloud.hard.api.dto.order; import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity; import lombok.Data; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + @Data public class HardAfterSaleDto extends HardAfterSaleEntity { + + private List userIds; + + private LocalDate[] createTimeList; + } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderDto.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderDto.java index 975b823c0..349918d36 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderDto.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/HardOrderDto.java @@ -3,6 +3,8 @@ package com.bsd.pjcloud.hard.api.dto.order; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; import lombok.Data; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; @Data @@ -13,6 +15,16 @@ public class HardOrderDto extends HardOrderEntity { */ private List userIds; + private List orderIds; + + private List hardIds; + + private List mchIds; + + private LocalDate[] createTimeList; + + private LocalDate[] payTimeList; + /** * 是否查询购物车列表 */ diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/app/HardAppCreateOrderDto.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/app/HardAppCreateOrderDto.java index 3b9d7fff3..0666aef21 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/app/HardAppCreateOrderDto.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/dto/order/app/HardAppCreateOrderDto.java @@ -1,5 +1,6 @@ package com.bsd.pjcloud.hard.api.dto.order.app; +import com.bsd.pjcloud.hard.api.constant.HardTypeEnum; import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum; import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum; import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; @@ -30,6 +31,9 @@ public class HardAppCreateOrderDto { @NotNull(message = "支付类型不能为空") private HardPayTypeEnum payType; + @NotNull(message = "硬件设备类型不能为空") + private HardTypeEnum hardType; + private Long orderSourceTypeId; } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/entity/order/HardParentCarEntity.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/entity/order/HardParentCarEntity.java index 79cd3419c..00ee26a2d 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/entity/order/HardParentCarEntity.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/entity/order/HardParentCarEntity.java @@ -43,6 +43,13 @@ public class HardParentCarEntity extends Model { @Schema(description="商户id") private Long merchantId; + /** + * 硬件设备类型 + */ + @Schema(description="硬件设备类型") + private String hardType; + + /** * 订单状态 */ diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/feign/RemoteHardOrderService.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/feign/RemoteHardOrderService.java new file mode 100644 index 000000000..bedfe4a19 --- /dev/null +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/feign/RemoteHardOrderService.java @@ -0,0 +1,20 @@ +package com.bsd.pjcloud.hard.api.feign; + +import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.feign.annotation.NoToken; +import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +@FeignClient(contextId = "remoteHardOrderService", value = ServiceNameConstants.HARDWARE_SERVICE) +public interface RemoteHardOrderService { + + @NoToken + @GetMapping("/hard-order/get-by-ids") + R> getByIds(@RequestParam List ids); + +} diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/feign/packge-info.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/feign/packge-info.java deleted file mode 100644 index 292a39910..000000000 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/feign/packge-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/* - @author pigx archetype - *

- * feign client 存放目录,注意 @EnablePigxFeignClients 的扫描范围 - */ -package com.bsd.pjcloud.hard.api.feign; \ No newline at end of file diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/utils/HardUtil.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/utils/HardUtil.java index 081635638..55a33e790 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/utils/HardUtil.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/utils/HardUtil.java @@ -4,11 +4,19 @@ import cn.hutool.core.codec.Base64; import cn.hutool.core.lang.Pair; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; +import com.bsd.pjcloud.admin.api.entity.SysDept; +import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface; +import com.bsd.pjcloud.common.core.util.CollectionUtils; import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto; +import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; +import com.bsd.pjcloud.hard.api.vo.base.BaseOrderInterface; +import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo; import lombok.experimental.UtilityClass; import org.apache.commons.lang3.tuple.ImmutablePair; import javax.xml.stream.events.StartDocument; +import java.util.List; +import java.util.Map; @UtilityClass public class HardUtil { @@ -44,4 +52,22 @@ public class HardUtil { return ImmutablePair.of(fileName, coeContent); } + public List convertOrderList(List list, Map map) { + return CollectionUtils.convertList(list, v -> convertOrder(v, map.get(v.getOrderId()))); + } + + public T convertOrder(T v, HardOrderEntity order) { + if (ObjectUtil.isEmpty(order)) return v; + v.setOrderHardId(order.getHardId()); + v.setOrderId(order.getId()); + v.setOrderDeptId(order.getDeptId()); + v.setOrderWalletId(order.getWalletId()); + v.setOrderParentCarId(order.getParentCarId()); + v.setOrderTotalPrice(order.getTotalPrice()); + v.setOrderExtraPrice(order.getExtraPrice()); + v.setOrderPayPrice(order.getPayPrice()); + v.setOrderPayTime(order.getPayTime()); + return v; + } + } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/base/BaseOrderInterface.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/base/BaseOrderInterface.java new file mode 100644 index 000000000..43fafa8e4 --- /dev/null +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/base/BaseOrderInterface.java @@ -0,0 +1,42 @@ +package com.bsd.pjcloud.hard.api.vo.base; + +import java.time.LocalDateTime; + +public interface BaseOrderInterface { + + Long getOrderHardId(); + + void setOrderHardId(Long orderHardId); + + Long getOrderId(); + + void setOrderId(Long orderId); + + Long getOrderDeptId(); + + void setOrderDeptId(Long orderDeptId); + + Long getOrderWalletId(); + + void setOrderWalletId(Long orderWalletId); + + Long getOrderParentCarId(); + + void setOrderParentCarId(Long orderParentCarId); + + Integer getOrderTotalPrice(); + + void setOrderTotalPrice(Integer orderTotalPrice); + + Integer getOrderExtraPrice(); + + void setOrderExtraPrice(Integer orderExtraPrice); + + Integer getOrderPayPrice(); + + void setOrderPayPrice(Integer orderPayPrice); + + LocalDateTime getOrderPayTime(); + + void setOrderPayTime(LocalDateTime orderPayTime); +} diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardAfterSaleVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardAfterSaleVo.java index 2e0a6528d..46f71a4ce 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardAfterSaleVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardAfterSaleVo.java @@ -3,10 +3,13 @@ package com.bsd.pjcloud.hard.api.vo.order; import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface; import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface; import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity; +import com.bsd.pjcloud.hard.api.vo.base.BaseOrderInterface; import lombok.Data; +import java.time.LocalDateTime; + @Data -public class HardAfterSaleVo extends HardAfterSaleEntity implements BaseUserInterface, BaseDeptInterface { +public class HardAfterSaleVo extends HardAfterSaleEntity implements BaseUserInterface, BaseDeptInterface, BaseOrderInterface { /** * 用户相关 */ @@ -22,4 +25,25 @@ public class HardAfterSaleVo extends HardAfterSaleEntity implements BaseUserInte private Long deptId; private String deptName; + + /** + * 订单相关 + */ + private Long orderHardId; + + private Long orderId; + + private Long orderDeptId; + + private Long orderWalletId; + + private Long orderParentCarId; + + private Integer orderTotalPrice; + + private Integer orderExtraPrice; + + private Integer orderPayPrice; + + private LocalDateTime orderPayTime; } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardCarVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardCarVo.java index 5b58c50bc..cd43c8aac 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardCarVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardCarVo.java @@ -5,4 +5,8 @@ import lombok.Data; @Data public class HardCarVo extends HardCarEntity { + + // 商品id【超市的商品存的是 sku id】 + private Long supId; + } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderVo.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderVo.java index 8d3767a09..388b68601 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderVo.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/vo/order/HardOrderVo.java @@ -3,6 +3,7 @@ package com.bsd.pjcloud.hard.api.vo.order; import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface; import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; +import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity; import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface; import lombok.Data; @@ -42,4 +43,9 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B * 购物车 */ private List carList; + + /** + * 预约二维码信息 + */ + private String reserveCode; } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports b/pjcloud-hardware/pjcloud-hardware-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports new file mode 100644 index 000000000..315c2612d --- /dev/null +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports @@ -0,0 +1 @@ +com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService \ No newline at end of file diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardAfterSaleController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardAfterSaleController.java index edc1a7cbd..71d0cb36d 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardAfterSaleController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardAfterSaleController.java @@ -99,7 +99,7 @@ public class HardAfterSaleController { return R.ok(hardAfterSaleService.agreeAfterSale(user.getId(), id)); } - @PutMapping("/disagree") + @PostMapping("/disagree") @Operation(summary = "拒绝售后") @Idempotent(expireTime = 10, info = "正在处理中,请勿重复操作") public R disagreeRefund(@RequestBody HardDisagreeDto dto) { diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java index c0f009ad8..bd55aa4d4 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java @@ -10,16 +10,15 @@ import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.common.security.service.PjcloudUser; import com.bsd.pjcloud.common.security.util.SecurityUtils; +import com.bsd.pjcloud.hard.api.constant.HardTypeEnum; import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum; import com.bsd.pjcloud.hard.api.dto.app.HardCarSaveOrUpdateDto; import com.bsd.pjcloud.hard.api.dto.order.HardCarDto; import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; -import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity; import com.bsd.pjcloud.hard.api.vo.order.HardCarVo; import com.bsd.pjcloud.hard.service.HardCarService; import com.bsd.pjcloud.hard.service.HardOrderService; -import com.bsd.pjcloud.hard.service.HardParentCarService; import org.springframework.security.access.prepost.PreAuthorize; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -51,9 +50,9 @@ public class HardCarController { /* ************************************* start app start ************************************* */ @GetMapping("/app/mch-detail") @Operation(summary = "根据商户id查询当前用户购物车") - public R> appMchDetail(@RequestParam Long merchantId) { + public R> appMchDetail(@RequestParam Long merchantId, @RequestParam HardTypeEnum hardType) { PjcloudUser user = SecurityUtils.getUser(); - return R.ok(hardCarService.mchDetail(merchantId, user.getId())); + return R.ok(hardCarService.mchDetail(merchantId, user.getId(), hardType)); } @GetMapping("/app/order-id") @@ -68,6 +67,9 @@ public class HardCarController { PjcloudUser user = SecurityUtils.getUser(); dto.setUserId(user.getId()); dto.setOrderType(HardOrderTypeEnum.RESERVE.getType()); + if (ObjectUtil.isEmpty(dto.getHardType())) { + dto.setHardType(HardTypeEnum.SUPERMARKET); + } hardCarService.saveOrUpload(dto); return R.ok(true); } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderController.java index c4d4bfac2..cdc7de273 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderController.java @@ -8,13 +8,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.idempotent.annotation.Idempotent; import com.bsd.pjcloud.common.log.annotation.SysLog; +import com.bsd.pjcloud.common.security.annotation.Inner; import com.bsd.pjcloud.common.security.service.PjcloudUser; import com.bsd.pjcloud.common.security.util.SecurityUtils; +import com.bsd.pjcloud.hard.api.constant.HardTypeEnum; import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum; import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum; import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto; import com.bsd.pjcloud.hard.api.dto.order.app.HardAppCreateOrderDto; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; +import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper; import com.bsd.pjcloud.hard.service.HardOrderService; import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; import org.springframework.security.access.prepost.PreAuthorize; @@ -44,6 +47,19 @@ public class HardOrderController { private final HardOrderService hardwareOrderService; + private final HardOrderMapper hardOrderMapper; + + /* ************************************* start 远程调用 start ************************************* */ + @Inner + @Operation(summary = "app查询订单列表", description = "app查询订单列表") + @GetMapping("/get-by-ids") + public R> getByIds(@RequestParam List ids) { + HardOrderDto dto = new HardOrderDto(); + dto.setOrderIds(ids); + return R.ok(hardOrderMapper.list(dto)); + } + /* ************************************* end 远程调用 ************************************* */ + /* ************************************* start app start ************************************* */ @Operation(summary = "app查询订单列表", description = "app查询订单列表") @GetMapping("/app/page-join") @@ -63,9 +79,9 @@ public class HardOrderController { @Operation(summary = "app创建订单", description = "app创建订单") @GetMapping("/app/create-order") @Idempotent(expireTime = 10, info = "正在创建订单中,请勿重复操作") - public R appCreateOrder(@RequestParam Long carParentId) { + public R appCreateOrder(@RequestParam Long carParentId, @RequestParam HardTypeEnum hardType) { PjcloudUser user = SecurityUtils.getUser(); - HardAppCreateOrderDto dto = HardAppCreateOrderDto.builder().carParentId(carParentId).walletType(WalletTypeEnum.EAT).userId(user.getId()).orderType(HardOrderTypeEnum.RESERVE).payType(HardPayTypeEnum.WALLET_DEFAULT).build(); + HardAppCreateOrderDto dto = HardAppCreateOrderDto.builder().carParentId(carParentId).walletType(WalletTypeEnum.EAT).hardType(hardType).userId(user.getId()).orderType(HardOrderTypeEnum.RESERVE).payType(HardPayTypeEnum.WALLET_DEFAULT).build(); return R.ok(hardwareOrderService.appCreateOrder(dto)); } /* ************************************* end app end ************************************* */ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardAfterSaleMapper.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardAfterSaleMapper.java index 9e84ccc09..78fc3e428 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardAfterSaleMapper.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardAfterSaleMapper.java @@ -1,6 +1,10 @@ package com.bsd.pjcloud.hard.mapper.order; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.util.BeanUtils; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleDto; import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity; @@ -17,6 +21,21 @@ public interface HardAfterSaleMapper extends PjcloudBaseMapper scopePageList(Page page, HardAfterSaleDto dto) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .eq(ObjectUtil.isNotEmpty(dto.getStatus()), HardAfterSaleEntity::getStatus, dto.getStatus()) + .in(ObjectUtil.isNotEmpty(dto.getUserIds()), HardAfterSaleEntity::getUserId, dto.getUserIds()) + .between( + ObjectUtil.isNotEmpty(dto.getCreateTimeList()), + HardAfterSaleEntity::getCreateTime, + ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null, + ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null + ); + Page list = selectPageByScope(page, wrapper, DataScope.of()); + list.setRecords(BeanUtils.toBean(list.getRecords(), HardAfterSaleVo.class)); + return list; + } + default HardAfterSaleVo join(HardAfterSaleDto dto) { MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .selectAll(HardAfterSaleEntity.class) diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java index 3c8880a30..cf0569432 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/mapper/order/HardOrderMapper.java @@ -1,18 +1,50 @@ package com.bsd.pjcloud.hard.mapper.order; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.util.BeanUtils; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto; import com.bsd.pjcloud.hard.api.entity.HardManagerEntity; +import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo; -import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface HardOrderMapper extends PjcloudBaseMapper { + + default Page scopePageList(Page page, HardOrderDto dto) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .eq(ObjectUtil.isNotEmpty(dto.getOrderType()), HardOrderEntity::getOrderType, dto.getOrderType()) + .eq(ObjectUtil.isNotEmpty(dto.getPayType()), HardOrderEntity::getPayType, dto.getPayType()) + .eq(ObjectUtil.isNotEmpty(dto.getOrderStatus()), HardOrderEntity::getOrderStatus, dto.getOrderStatus()) + .in(ObjectUtil.isNotEmpty(dto.getOrderIds()), HardOrderEntity::getId, dto.getOrderIds()) + .in(ObjectUtil.isNotEmpty(dto.getUserIds()), HardOrderEntity::getUserId, dto.getUserIds()) + .in(ObjectUtil.isNotEmpty(dto.getHardIds()), HardOrderEntity::getHardId, dto.getHardIds()) + .in(ObjectUtil.isNotEmpty(dto.getMchIds()), HardOrderEntity::getMerchantId, dto.getMchIds()) + .between( + ObjectUtil.isNotEmpty(dto.getCreateTimeList()), + HardOrderEntity::getCreateTime, + ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null, + ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null + ) + .between( + ObjectUtil.isNotEmpty(dto.getPayTimeList()), + HardOrderEntity::getPayType, + ObjectUtil.isNotEmpty(dto.getPayTimeList()) ? dto.getPayTimeList()[0] : null, + ObjectUtil.isNotEmpty(dto.getPayTimeList()) ? dto.getPayTimeList()[1] : null + ); + Page list = selectPageByScope(page, wrapper, DataScope.of()); + list.setRecords(BeanUtils.toBean(list.getRecords(), HardOrderVo.class)); + return list; + } + default Page pageJoin(Page page, HardOrderDto dto) { MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .selectAll(HardOrderEntity.class) @@ -35,4 +67,10 @@ public interface HardOrderMapper extends PjcloudBaseMapper { .eqIfExists(HardOrderEntity::getId, dto.getId()); return selectJoinOne(HardOrderVo.class, wrapper); } + + default List list(HardOrderDto dto) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .in(ObjectUtil.isNotEmpty(dto.getOrderIds()), HardOrderEntity::getId, dto.getOrderIds()); + return selectListByScope(wrapper, DataScope.of()); + } } \ No newline at end of file diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardAfterSaleService.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardAfterSaleService.java index ebed93271..513303c13 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardAfterSaleService.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardAfterSaleService.java @@ -49,7 +49,7 @@ public interface HardAfterSaleService extends IService { * 同意售后 * * @param userId 用户id - * @param id + * @param id 售后id */ Boolean agreeAfterSale(Long userId, Long id); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardCarService.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardCarService.java index 725276eaa..c677b4ae4 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardCarService.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardCarService.java @@ -22,7 +22,7 @@ public interface HardCarService extends IService { List getByParentCarId(Long parentCarId); - List mchDetail(Long merchantId, Long userId); + List mchDetail(Long merchantId, Long userId,HardTypeEnum hardType); Integer computerCarTotalPrice(@NotNull HardTypeEnum sysType, @NotEmpty List list); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderService.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderService.java index 35a13598e..e41cf81cb 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderService.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/HardOrderService.java @@ -47,6 +47,11 @@ public interface HardOrderService extends IService { */ void cancelCode(HardOrderEntity order); + /** + * 生成二维码 + */ + void generateCode(HardOrderEntity order); + /** * 扣件库存 */ diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardManagerServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardManagerServiceImpl.java index c0fdffdb1..f2ee29b02 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardManagerServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/HardManagerServiceImpl.java @@ -19,7 +19,7 @@ import com.bsd.pjcloud.hard.service.HardManagerService; import com.bsd.pjcloud.hard.common.config.MqttConfig; import com.bsd.pjcloud.hard.utils.MqTopicUtil; import com.bsd.pjcloud.wallet.api.feign.RemoteMchService; -import com.bsd.pjcloud.wallet.api.utils.MchDataUtil; +import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil; import com.bsd.pjcloud.wallet.api.vo.MchManageVo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -61,7 +61,7 @@ public class HardManagerServiceImpl extends ServiceImpl mchIds = list.getRecords().stream().map(HardManagerVo::getMerchantId).distinct().toList(); R> mchList = mchService.getByIds(mchIds); if (ObjectUtil.isNotEmpty(mchList.getData())) { - MchDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId)); + WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId)); } } return list; diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java index f4d511fd1..6e3d6c38f 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java @@ -23,13 +23,16 @@ import com.bsd.pjcloud.hard.api.constant.refund.HardSaleStatusEnum; import com.bsd.pjcloud.hard.api.constant.refund.HardSaleTypeEnum; import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleDto; import com.bsd.pjcloud.hard.api.dto.order.HardDisagreeDto; +import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto; import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity; import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleLogEntity; import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity; +import com.bsd.pjcloud.hard.api.utils.HardUtil; import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleVo; import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo; import com.bsd.pjcloud.hard.mapper.order.HardAfterSaleLogMapper; import com.bsd.pjcloud.hard.mapper.order.HardAfterSaleMapper; +import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper; import com.bsd.pjcloud.hard.service.HardAfterSaleService; import com.bsd.pjcloud.hard.service.HardOrderService; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeRefundDto; @@ -63,6 +66,8 @@ public class HardAfterSaleServiceImpl extends ServiceImpl pageJoin(Page page, HardAfterSaleDto dto) { - Page list = baseMapper.pageJoin(page, dto); + Page list = baseMapper.scopePageList(page, dto); if (ObjectUtil.isNotEmpty(list.getRecords())) { // 用户 - List userIds = list.getRecords().stream().map(HardAfterSaleVo::getUserId).distinct().toList(); - R> userList = userService.getUserById(new ArrayList<>(userIds)); - if (ObjectUtil.isNotEmpty(userList.getData())) { - DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId)); + List userIds = list.getRecords().stream().map(HardAfterSaleVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList(); + if (ObjectUtil.isNotEmpty(userIds)) { + R> userList = userService.getUserById(new ArrayList<>(userIds)); + if (ObjectUtil.isNotEmpty(userList.getData())) { + DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId)); + } } // 部门 - List deptIds = list.getRecords().stream().map(HardAfterSaleVo::getDeptId).distinct().toList(); - R> deptList = deptService.getDeptByDeptIds(deptIds); - if (ObjectUtil.isNotEmpty(deptList.getData())) { - DataUtil.convertDeptList(list.getRecords(), deptList.getData()); + List deptIds = list.getRecords().stream().map(HardAfterSaleVo::getDeptId).filter(ObjectUtil::isNotEmpty).distinct().toList(); + if (ObjectUtil.isNotEmpty(deptIds)) { + R> deptList = deptService.getDeptByDeptIds(deptIds); + if (ObjectUtil.isNotEmpty(deptList.getData())) { + DataUtil.convertDeptList(list.getRecords(), deptList.getData()); + } + } + // 订单 + List orderIds = list.getRecords().stream().map(HardAfterSaleVo::getOrderId).filter(ObjectUtil::isNotEmpty).distinct().toList(); + if (ObjectUtil.isNotEmpty(orderIds)) { + HardOrderDto hardOrderDto = new HardOrderDto(); + hardOrderDto.setOrderIds(orderIds); + List orderList = hardOrderMapper.list(hardOrderDto); + HardUtil.convertOrderList(list.getRecords(), CollectionUtils.convertMap(orderList, HardOrderEntity::getId)); } } return list; @@ -129,7 +146,12 @@ public class HardAfterSaleServiceImpl extends ServiceImpl list = baseMapper.selectList(new LambdaQueryWrapper() + .eq(HardAfterSaleEntity::getOrderId, dto.getOrderId()) + .orderByDesc(HardAfterSaleEntity::getId) + ); + if (ObjectUtil.isEmpty(list)) return null; + HardAfterSaleVo detail = BeanUtils.toBean(list.stream().findFirst().get(), HardAfterSaleVo.class); if (ObjectUtil.isNotEmpty(detail)) { // 用户 if (ObjectUtil.isNotEmpty(detail.getUserId())) { @@ -157,7 +179,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl walletRefundResult = walletRechargeService.refund(hardRefundDto); WalletRechargeVo walletRefund = Optional.of(walletRefundResult).map(R::getData).orElseThrow(() -> new RuntimeException("钱包退款错误")); HardOrderEntity updateObj = HardOrderEntity.builder() @@ -182,6 +204,8 @@ public class HardAfterSaleServiceImpl extends ServiceImpl mchDetail(Long merchantId, Long userId) { - HardParentCarEntity parentCarDO = getParentCar(merchantId, userId); + public List mchDetail(Long merchantId, Long userId, HardTypeEnum hardTypeEnum) { + HardParentCarEntity parentCarDO = getParentCar(merchantId, userId, hardTypeEnum); if (ObjectUtil.isEmpty(parentCarDO)) return null; - return getByParentCarId(parentCarDO.getId()); + List carList = getByParentCarId(parentCarDO.getId()); + if (ObjectUtil.isEmpty(carList)) return null; + List resultList = BeanUtils.toBean(carList, HardCarVo.class); + List productIds = resultList.stream().map(HardCarEntity::getProductId).distinct().filter(ObjectUtil::isNotEmpty).toList(); + if (ObjectUtil.isNotEmpty(productIds)) { + if (ObjectUtil.equals(HardTypeEnum.CANTEEN, hardTypeEnum)) { + + } + if (ObjectUtil.equals(HardTypeEnum.SUPERMARKET, hardTypeEnum)) { + List supList = supermarketUnitSkuService.getSupermarketUnits(productIds).getData(); + for (HardCarVo v : resultList) { + supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + v.setSupId(spu.getSpuId()); + }); + } + } + } + return resultList; } @Override @@ -89,7 +105,7 @@ public class HardCarServiceImpl extends ServiceImpl carList = dto.getList().stream().filter(v -> v.getProductCount() > 0).toList(); - HardParentCarEntity parentCar = getParentCar(dto.getMerchantId(), dto.getUserId()); + HardParentCarEntity parentCar = getParentCar(dto.getMerchantId(), dto.getUserId(), dto.getHardType()); if (ObjectUtil.isNotEmpty(parentCar)) { baseMapper.delete(new LambdaQueryWrapper().eq(HardCarEntity::getParentCarId, parentCar.getId())); // 添加购物车 @@ -97,7 +113,7 @@ public class HardCarServiceImpl extends ServiceImpl { - int supermarketTotalPrice = 0; + // 查询超市商品 + AtomicInteger supermarketTotalPrice = new AtomicInteger(); + List supList = supermarketUnitSkuService.getSupermarketUnits(productIds).getData(); for (HardCreateCarDto v : list) { - + supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + int itemTotalPrice = v.getProductCount() * spu.getRetailPrice(); + supermarketTotalPrice.addAndGet(itemTotalPrice); + }); } - yield supermarketTotalPrice; + yield supermarketTotalPrice.get(); } default -> null; }; @@ -134,7 +155,7 @@ public class HardCarServiceImpl extends ServiceImpl list) { // 创建父订单 - HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(userId).merchantId(merchantId).orderStatus(HardOrderStatusEnum.PAY.getType()).build(); + HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(userId).merchantId(merchantId).hardType(sysType.getType()).orderStatus(HardOrderStatusEnum.PAY.getType()).build(); hardParentCarMapper.insert(parentCarObj); getSelf().appCreateCard(parentCarObj.getId(), sysType, list); return parentCarObj.getId(); @@ -209,11 +230,12 @@ public class HardCarServiceImpl extends ServiceImpl() .eq(HardParentCarEntity::getUserId, userId) .eq(HardParentCarEntity::getMerchantId, merchantId) + .eq(HardParentCarEntity::getHardType, hardTypeEnum.getType()) .eq(HardParentCarEntity::getOrderStatus, HardOrderStatusEnum.CREATE.getType()) ); } diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardwareOrderServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardwareOrderServiceImpl.java index 6b710c4f9..6111bff14 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardwareOrderServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardwareOrderServiceImpl.java @@ -34,12 +34,14 @@ import com.bsd.pjcloud.hard.service.HardCarService; import com.bsd.pjcloud.hard.service.HardManagerService; import com.bsd.pjcloud.hard.service.HardOrderService; import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum; +import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum; import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto; +import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity; import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity; import com.bsd.pjcloud.wallet.api.feign.*; -import com.bsd.pjcloud.wallet.api.utils.MchDataUtil; +import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil; import com.bsd.pjcloud.wallet.api.vo.MchManageVo; import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo; import jakarta.validation.Valid; @@ -86,7 +88,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl pageJoin(Page page, HardOrderDto dto) { - Page list = baseMapper.pageJoin(page, dto); + Page list = baseMapper.scopePageList(page, dto); if (ObjectUtil.isNotEmpty(list.getRecords())) { // 用户 List userIds = list.getRecords().stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList(); @@ -109,7 +111,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl> mchList = remoteMchService.getByIds(mchIds); if (ObjectUtil.isNotEmpty(mchList.getData())) { - MchDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId)); + WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId)); } } // 购物车 @@ -148,7 +150,14 @@ public class HardwareOrderServiceImpl extends ServiceImpl mch = remoteMchService.getById(detail.getMerchantId()); if (ObjectUtil.isNotEmpty(mch.getData())) { - MchDataUtil.convertMch(detail, mch.getData()); + WalletDataUtil.convertMch(detail, mch.getData()); + } + } + // 二维码 + if (isHaveCode(detail)) { + WalletCodeUseEntity codeDetail = remoteCodeUseService.getByBizId(detail.getId()).getData(); + if (ObjectUtil.isNotEmpty(codeDetail)) { + detail.setReserveCode(codeDetail.getCode()); } } } @@ -158,7 +167,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl { - } - // 线上订餐 - case RESERVE -> { - - } - // 外来人员 | 跨单位 - case FOREIGN_TICKET, STRIDE_DEPT -> remoteCodeUseService.cancelCode(id); + // 外来人员 | 跨单位 | 线上订餐 + case FOREIGN_TICKET, STRIDE_DEPT, RESERVE -> remoteCodeUseService.cancelCode(id); } } @Override + @GlobalTransactional + @Transactional(rollbackFor = Exception.class) + public void generateCode(HardOrderEntity order) { + HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(order.getSysType()); + HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType()); + if (!ObjectUtil.isAllNotEmpty(hardTypeEnum, orderTypeEnum)) return; + WalletCodeBizEnum codeType = null; + // 食堂预定核销 + if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.CANTEEN) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) { + codeType = WalletCodeBizEnum.CANTEEN_RESERVE; + } + // 超市预定核销 + if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.SUPERMARKET) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) { + codeType = WalletCodeBizEnum.SUPERMARKET_RESERVE; + } + if (ObjectUtil.isEmpty(codeType)) return; + remoteCodeUseService.generateCode(order.getId(), order.getUserId(), codeType, 1); + } + + @Override + @GlobalTransactional + @Transactional(rollbackFor = Exception.class) public void fastenerInventory(HardOrderEntity order) { HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(order.getSysType()); HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType()); if (!ObjectUtil.isAllNotEmpty(hardTypeEnum, orderTypeEnum)) return; - // 食堂预定核销 + // 食堂扣件库存 if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.CANTEEN) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) { return; } - // 超市预定核销 + // 超市扣家库存 if (ObjectUtil.equals(hardTypeEnum, HardTypeEnum.SUPERMARKET) && ObjectUtil.equals(orderTypeEnum, HardOrderTypeEnum.RESERVE)) { return; @@ -402,6 +435,18 @@ public class HardwareOrderServiceImpl extends ServiceImpl userIds; + private List walletIds; + } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionDto.java index 235f642d4..88449bb48 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionDto.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTransactionDto.java @@ -4,6 +4,7 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.time.LocalDate; import java.util.List; @Data @@ -32,4 +33,11 @@ public class WalletTransactionDto extends WalletTransactionEntity { private List bizTypes; + private LocalDate[] createTimeList; + + /** + * 是否查询order + */ + private Boolean isFindOrder = false; + } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTypeDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTypeDto.java new file mode 100644 index 000000000..8e1d098e3 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletTypeDto.java @@ -0,0 +1,13 @@ +package com.bsd.pjcloud.wallet.api.dto; + +import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class WalletTypeDto extends WalletTypeEntity { + + private List walletTypeIds; + +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletManageEntity.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletManageEntity.java index 53a98032b..4c2232d2a 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletManageEntity.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletManageEntity.java @@ -94,7 +94,7 @@ public class WalletManageEntity extends Model { * 饭卡绑定状态 */ @Schema(description = "饭卡绑定状态") - private Integer activeBindStatus; + private String activeBindStatus; /** * 创建人 diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletTransactionEntity.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletTransactionEntity.java index 2db7e1761..a6baae84b 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletTransactionEntity.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletTransactionEntity.java @@ -21,88 +21,100 @@ import java.time.LocalDateTime; public class WalletTransactionEntity extends Model { - /** - * 编号 - */ + /** + * 编号 + */ @TableId(type = IdType.ASSIGN_ID) - @Schema(description="编号") + @Schema(description = "编号") private Long id; - /** - * 会员钱包 id - */ - @Schema(description="会员钱包 id") + /** + * 用户 id + */ + @Schema(description = "用户 id") + private Long userId; + + /** + * 部门 id + */ + @Schema(description = "部门 id") + private Long deptId; + + /** + * 会员钱包 id + */ + @Schema(description = "会员钱包 id") private Long walletId; - /** - * 关联类型 - */ - @Schema(description="关联类型") + /** + * 关联类型 + */ + @Schema(description = "关联类型") private String bizType; - /** - * 关联业务编号 - */ - @Schema(description="关联业务编号") + /** + * 关联业务编号 + */ + @Schema(description = "关联业务编号") private String bizId; - /** - * 流水标题 - */ - @Schema(description="流水标题") + /** + * 流水标题 + */ + @Schema(description = "流水标题") private String title; - /** - * 交易金额, 单位分 - */ - @Schema(description="交易金额, 单位分") + /** + * 交易金额, 单位分 + */ + @Schema(description = "交易金额, 单位分") private Integer price; - /** - * 余额, 单位分 - */ - @Schema(description="余额, 单位分") + /** + * 余额, 单位分 + */ + @Schema(description = "余额, 单位分") private Integer balance; - /** - * 创建人 - */ - @TableField(fill = FieldFill.INSERT) - @Schema(description="创建人") - private String createBy; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建人") + private String createBy; - /** - * 创建时间 - */ - @TableField(fill = FieldFill.INSERT) - @Schema(description="创建时间") - private LocalDateTime createTime; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") + private LocalDateTime createTime; - /** - * 修改人 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - @Schema(description="修改人") - private String updateBy; + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "修改人") + private String updateBy; - /** - * 修改时间 - */ - @TableField(fill = FieldFill.INSERT_UPDATE) - @Schema(description="修改时间") - private LocalDateTime updateTime; + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "修改时间") + private LocalDateTime updateTime; - /** - * 删除标记 - */ - @TableLogic - @TableField(fill = FieldFill.INSERT) - @Schema(description="删除标记") - private String delFlag; + /** + * 删除标记 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description = "删除标记") + private String delFlag; - /** - * 租户ID - */ - @Schema(description="租户ID") - private Long tenantId; + /** + * 租户ID + */ + @Schema(description = "租户ID") + private Long tenantId; } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteCodeUseService.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteCodeUseService.java index bb0715dba..92c8f9cca 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteCodeUseService.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteCodeUseService.java @@ -3,12 +3,26 @@ package com.bsd.pjcloud.wallet.api.feign; import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.feign.annotation.NoToken; +import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum; +import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + @FeignClient(contextId = "remoteCodeUseService", value = ServiceNameConstants.WALLET_SERVICE) public interface RemoteCodeUseService { + + @NoToken + @GetMapping("/wallet-code-use/get-by-biz-ids") + R> getByBizIds(@RequestParam List ids); + + @NoToken + @GetMapping("/wallet-code-use/get-by-biz-id") + R getByBizId(@RequestParam Long id); + + /** * 核销二维码 * @@ -28,4 +42,17 @@ public interface RemoteCodeUseService { @NoToken @GetMapping("/wallet-code-use/is-cancel-code") R isCancelCode(@RequestParam Long id); + + /** + * 生成二维码 + * + * @param id + * @param userId + * @param walletCodeBiz + * @param count + * @return + */ + @NoToken + @GetMapping("/wallet-code-use/generate-code") + R generateCode(@RequestParam Long id, @RequestParam Long userId, @RequestParam WalletCodeBizEnum walletCodeBiz, @RequestParam Integer count); } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteWalletService.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteWalletService.java index b996fd43a..e789a3548 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteWalletService.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/feign/RemoteWalletService.java @@ -3,6 +3,7 @@ package com.bsd.pjcloud.wallet.api.feign; import com.bsd.pjcloud.common.core.constant.ServiceNameConstants; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.feign.annotation.NoToken; +import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum; import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; import org.springframework.cloud.openfeign.FeignClient; diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/utils/MchDataUtil.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/utils/MchDataUtil.java deleted file mode 100644 index b00c76e0b..000000000 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/utils/MchDataUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.bsd.pjcloud.wallet.api.utils; - -import cn.hutool.core.util.ObjectUtil; -import com.bsd.pjcloud.admin.api.entity.SysUser; -import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface; -import com.bsd.pjcloud.common.core.util.CollectionUtils; -import com.bsd.pjcloud.wallet.api.vo.MchManageVo; -import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface; -import lombok.experimental.UtilityClass; - -import java.util.List; -import java.util.Map; - -@UtilityClass -public class MchDataUtil { - - public List convertMchList(List list, Map map) { - return CollectionUtils.convertList(list, v -> convertMch(v, map.get(v.getMerchantId()))); - } - - public T convertMch(T v, MchManageVo vo) { - if (ObjectUtil.isEmpty(vo)) return v; - v.setMerchantName(vo.getName()); - v.setLogoPic(vo.getLogoPic()); - return v; - } - -} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/utils/WalletDataUtil.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/utils/WalletDataUtil.java new file mode 100644 index 000000000..a5b3b904b --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/utils/WalletDataUtil.java @@ -0,0 +1,62 @@ +package com.bsd.pjcloud.wallet.api.utils; + +import cn.hutool.core.util.ObjectUtil; +import com.bsd.pjcloud.common.core.util.CollectionUtils; +import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; +import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; +import com.bsd.pjcloud.wallet.api.vo.MchManageVo; +import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface; +import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletInterface; +import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface; +import lombok.experimental.UtilityClass; + +import java.util.List; +import java.util.Map; + +@UtilityClass +public class WalletDataUtil { + + public List convertMchList(List list, Map map) { + return CollectionUtils.convertList(list, v -> convertMch(v, map.get(v.getMerchantId()))); + } + + public T convertMch(T v, MchManageVo vo) { + if (ObjectUtil.isEmpty(vo)) return v; + v.setMerchantName(vo.getName()); + v.setLogoPic(vo.getLogoPic()); + return v; + } + + public List convertWalletTYpeList(List list, Map map) { + return CollectionUtils.convertList(list, v -> convertWalletType(v, map.get(v.getWalletTypeId()))); + } + + public T convertWalletType(T v, WalletTypeEntity vo) { + if (ObjectUtil.isEmpty(vo)) return v; + v.setWalletTypeId(vo.getId()); + v.setWalletTypeName(vo.getName()); + v.setWalletTypeUniqueCode(vo.getUniqueCode()); + v.setWalletTypeIcon(vo.getIcon()); + return v; + } + + public List convertWalletList(List list, Map map) { + return CollectionUtils.convertList(list, v -> convertWallet(v, map.get(v.getWalletId()))); + } + + public T convertWallet(T v, WalletManageEntity vo) { + if (ObjectUtil.isEmpty(vo)) return v; + v.setWalletId(vo.getId()); + v.setWalletTypeId(vo.getWalletTypeId()); + v.setWalletCardNumber(vo.getCardNumber()); + v.setWalletBalance(vo.getBalance()); + v.setWalletTotalExpense(vo.getTotalExpense()); + v.setWalletTotalRecharge(vo.getTotalRecharge()); + v.setWalletFreezePrice(vo.getFreezePrice()); + v.setWalletIsFreeze(vo.getIsFreeze()); + v.setWalletActiveBindTime(vo.getActiveBindTime()); + v.setWalletActiveBindStatus(vo.getActiveBindStatus()); + return v; + } + +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/WalletTransactionVo.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/WalletTransactionVo.java index f5865739f..ab475bdbf 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/WalletTransactionVo.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/WalletTransactionVo.java @@ -3,10 +3,14 @@ package com.bsd.pjcloud.wallet.api.vo; import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface; import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface; import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity; +import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletInterface; +import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface; import lombok.Data; +import java.time.LocalDateTime; + @Data -public class WalletTransactionVo extends WalletTransactionEntity implements BaseUserInterface, BaseDeptInterface { +public class WalletTransactionVo extends WalletTransactionEntity implements BaseUserInterface, BaseDeptInterface, BaseWalletTypeInterface, BaseWalletInterface { /** * 用户相关 @@ -28,11 +32,59 @@ public class WalletTransactionVo extends WalletTransactionEntity implements Base private String deptName; + /** + * 钱包相关 + */ + + private Long walletId; + + private String walletCardNumber; + + private Integer walletBalance; + + private Integer walletTotalExpense; + + private Integer walletTotalRecharge; + + private Integer walletFreezePrice; + + private Boolean walletIsFreeze; + + private LocalDateTime walletActiveBindTime; + + private String walletActiveBindStatus; + + /** * 钱包类型相关 */ + private Long walletTypeId; + private String walletTypeName; private String walletTypeUniqueCode; + private String walletTypeIcon; + + /** + * 订单相关 + */ + private Long orderHardId; + + private Long orderId; + + private Long orderDeptId; + + private Long orderWalletId; + + private Long orderParentCarId; + + private Integer orderTotalPrice; + + private Integer orderExtraPrice; + + private Integer orderPayPrice; + + private LocalDateTime orderPayTime; + } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/base/BaseWalletInterface.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/base/BaseWalletInterface.java new file mode 100644 index 000000000..19acede62 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/base/BaseWalletInterface.java @@ -0,0 +1,47 @@ +package com.bsd.pjcloud.wallet.api.vo.base; + +import java.time.LocalDateTime; + +public interface BaseWalletInterface { + + Long getWalletId(); + + void setWalletId(Long walletId); + + Long getWalletTypeId(); + + void setWalletTypeId(Long walletTypeId); + + String getWalletCardNumber(); + + void setWalletCardNumber(String walletCardNumber); + + Integer getWalletBalance(); + + void setWalletBalance(Integer walletBalance); + + Integer getWalletTotalExpense(); + + void setWalletTotalExpense(Integer walletTotalExpense); + + Integer getWalletTotalRecharge(); + + void setWalletTotalRecharge(Integer walletTotalRecharge); + + Integer getWalletFreezePrice(); + + void setWalletFreezePrice(Integer walletFreezePrice); + + Boolean getWalletIsFreeze(); + + void setWalletIsFreeze(Boolean walletIsFreeze); + + LocalDateTime getWalletActiveBindTime(); + + void setWalletActiveBindTime(LocalDateTime walletActiveBindTime); + + String getWalletActiveBindStatus(); + + void setWalletActiveBindStatus(String walletActiveBindStatus); + +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/base/BaseWalletTypeInterface.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/base/BaseWalletTypeInterface.java new file mode 100644 index 000000000..8c2ff646b --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/base/BaseWalletTypeInterface.java @@ -0,0 +1,20 @@ +package com.bsd.pjcloud.wallet.api.vo.base; + +public interface BaseWalletTypeInterface { + + Long getWalletTypeId(); + + void setWalletTypeId(Long walletTypeId); + + String getWalletTypeName(); + + void setWalletTypeName(String walletTypeName); + + String getWalletTypeUniqueCode(); + + void setWalletTypeUniqueCode(String walletTypeUniqueCode); + + String getWalletTypeIcon(); + + void setWalletTypeIcon(String walletTypeIcon); +} diff --git a/pjcloud-wallet/pjcloud-wallet-biz/pom.xml b/pjcloud-wallet/pjcloud-wallet-biz/pom.xml index f63a6c1ff..a260b4a19 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/pom.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/pom.xml @@ -107,12 +107,6 @@ com.bsd pjcloud-flow-task-api - - com.bsd - pjcloud-hardware-api - 5.7.0 - compile - diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletCodeUseController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletCodeUseController.java index 921a8a606..51a8f4f6f 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletCodeUseController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletCodeUseController.java @@ -1,10 +1,13 @@ package com.bsd.pjcloud.wallet.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.security.annotation.Inner; import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum; import com.bsd.pjcloud.wallet.api.dto.WalletCodeUseDto; +import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity; +import com.bsd.pjcloud.wallet.api.vo.WalletCodeUseVo; import com.bsd.pjcloud.wallet.service.WalletCodeUseService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -17,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @RestController @RequiredArgsConstructor @@ -39,6 +44,31 @@ public class WalletCodeUseController { public R isCancelCode(@RequestParam Long id) { return R.ok(walletCodeUseService.isCancelCode(id)); } + + @Inner + @GetMapping("/generate-code") + public R generateCode(@RequestParam Long id, @RequestParam Long userId, @RequestParam WalletCodeBizEnum walletCodeBiz, @RequestParam Integer count) { + walletCodeUseService.generate(id, userId, walletCodeBiz, count); + return R.ok(true); + } + + @Inner + @GetMapping("/get-by-biz-ids") + public R> getByBizIds(@RequestParam List ids) { + List list = walletCodeUseService.list(new LambdaQueryWrapper() + .in(WalletCodeUseEntity::getBizId, ids) + ); + return R.ok(list); + } + + @Inner + @GetMapping("/get-by-biz-id") + public R getByBizId(@RequestParam Long id) { + WalletCodeUseEntity detail = walletCodeUseService.getOne(new LambdaQueryWrapper() + .eq(WalletCodeUseEntity::getBizId, id) + ); + return R.ok(detail); + } /* ************************************* end 远程调用 end ************************************* */ /* ************************************* start app start ************************************* */ diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletManageController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletManageController.java index 5a6fb29e5..a762aef8c 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletManageController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletManageController.java @@ -14,6 +14,7 @@ import com.bsd.pjcloud.common.security.util.SecurityUtils; import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; import com.bsd.pjcloud.wallet.api.dto.WalletManageDto; import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; +import com.bsd.pjcloud.wallet.service.WalletCodeUseService; import com.bsd.pjcloud.wallet.service.WalletManageService; import org.springframework.security.access.prepost.PreAuthorize; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; @@ -26,7 +27,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; /** * 钱包管理 @@ -43,6 +43,8 @@ public class WalletManageController { private final WalletManageService walletManageService; + private final WalletCodeUseService walletCodeUseService; + /* ************************************* start 远程调用 start ************************************* */ @Inner @GetMapping("/get-or-create-wallet") @@ -82,6 +84,7 @@ public class WalletManageController { public R addPrice(@RequestParam("userIds") List userIds) { return R.ok(walletManageService.delWalletByUserIds(userIds)); } + /* ************************************* end 远程调用 end ************************************* */ diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java index 87af060c3..359a256e2 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java @@ -89,6 +89,7 @@ public class WalletTransactionController { @GetMapping("/page-xf") public R pageXf(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) { dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode())); + dto.setIsFindOrder(true); return R.ok(walletTransactionService.pageJoin(page, dto)); } @@ -96,6 +97,7 @@ public class WalletTransactionController { @GetMapping("/page-tk") public R pageTk(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) { dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode())); + dto.setIsFindOrder(true); return R.ok(walletTransactionService.pageJoin(page, dto)); } diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java index d47840b53..8857ffd2f 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletManageMapper.java @@ -12,6 +12,8 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + @Mapper public interface WalletManageMapper extends PjcloudBaseMapper { /** @@ -69,6 +71,16 @@ public interface WalletManageMapper extends PjcloudBaseMapper list(WalletManageDto dto) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper() + .eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletManageEntity::getUserId, dto.getUserId()) + .eq(ObjectUtil.isNotEmpty(dto.getWalletTypeId()), WalletManageEntity::getWalletTypeId, dto.getWalletTypeId()) + .eq(ObjectUtil.isNotEmpty(dto.getIsFreeze()), WalletManageEntity::getIsFreeze, dto.getIsFreeze()) + .in(ObjectUtil.isNotEmpty(dto.getWalletIds()), WalletManageEntity::getId, dto.getWalletIds()) + .in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds()); + return selectList(wrapper); + } + default WalletManageVo join(Long id) { MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .selectAll(WalletManageEntity.class) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java index 58821ce05..a3ce839e7 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java @@ -1,15 +1,15 @@ package com.bsd.pjcloud.wallet.mapper; import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.util.BeanUtils; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto; import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity; import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; -import com.bsd.pjcloud.wallet.api.vo.WalletManageVo; import com.bsd.pjcloud.wallet.api.vo.WalletTransactionVo; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.apache.ibatis.annotations.Mapper; @@ -38,7 +38,23 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper scopePageList(Page page, WalletTransactionDto dto) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId()) + .eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType()) + .in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletTransactionEntity::getUserId, dto.getUserIds()) + .in(ObjectUtil.isNotEmpty(dto.getBizTypes()), WalletTransactionEntity::getBizType, dto.getBizTypes()) + .between( + ObjectUtil.isNotEmpty(dto.getCreateTimeList()), + WalletTransactionEntity::getCreateTime, + ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null, + ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null + ); + Page list = selectPageByScope(page, wrapper, DataScope.of()); + list.setRecords(BeanUtils.toBean(list.getRecords(), WalletTransactionVo.class)); + return list; + } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTypeMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTypeMapper.java index 42daadf83..82803fb2d 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTypeMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTypeMapper.java @@ -1,11 +1,19 @@ package com.bsd.pjcloud.wallet.mapper; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto; import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface WalletTypeMapper extends PjcloudBaseMapper { - - + default List list(WalletTypeDto dto) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper() + .in(ObjectUtil.isNotEmpty(dto.getWalletTypeIds()), WalletTypeEntity::getId, dto.getWalletTypeIds()); + return selectList(wrapper); + } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletCodeUseService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletCodeUseService.java index 61b6477a8..e9bc1e8de 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletCodeUseService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletCodeUseService.java @@ -27,4 +27,5 @@ public interface WalletCodeUseService extends IService { * @return */ Boolean isCancelCode(Long id); + } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletActiveServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletActiveServiceImpl.java index 175d0ca0a..69d0d1a64 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletActiveServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletActiveServiceImpl.java @@ -20,7 +20,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto; import com.bsd.pjcloud.wallet.api.entity.MchManageEntity; import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity; import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; -import com.bsd.pjcloud.wallet.api.utils.MchDataUtil; +import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil; import com.bsd.pjcloud.wallet.api.vo.MchManageVo; import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo; import com.bsd.pjcloud.wallet.mapper.WalletActiveMapper; @@ -104,7 +104,7 @@ public class WalletActiveServiceImpl extends ServiceImpl mchIds = list.getRecords().stream().map(WalletActiveVo::getMerchantId).distinct().toList(); List mchList = mchManageService.list(MchManageDto.builder().ids(mchIds).build()); if (ObjectUtil.isNotEmpty(mchList)) { - MchDataUtil.convertMchList(page.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId)); + WalletDataUtil.convertMchList(page.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId)); } } return list; diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletCodeUseServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletCodeUseServiceImpl.java index 94670d7dd..1e79c44ed 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletCodeUseServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletCodeUseServiceImpl.java @@ -25,6 +25,7 @@ import com.bsd.pjcloud.hard.api.utils.HardUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.seata.spring.annotation.GlobalTransactional; import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -55,6 +56,7 @@ public class WalletCodeUseServiceImpl extends ServiceImpl pageJoin(Page page, WalletTransactionDto dto) { - Page list = baseMapper.pageJoin(page, dto); + Page list = baseMapper.scopePageList(page, dto); if (ObjectUtil.isNotEmpty(list.getRecords())) { // 用户 List userIds = list.getRecords().stream().map(WalletTransactionVo::getUserId).distinct().toList(); @@ -160,6 +177,34 @@ public class WalletTransactionServiceImpl extends ServiceImpl walletIds = list.getRecords().stream().map(WalletTransactionVo::getWalletId).distinct().toList(); + if (ObjectUtil.isNotEmpty(walletIds)) { + WalletManageDto walletManageDto = new WalletManageDto(); + walletManageDto.setWalletIds(walletIds); + List walletList = walletManageMapper.list(walletManageDto); + if (ObjectUtil.isNotEmpty(walletList)) { + WalletDataUtil.convertWalletList(list.getRecords(), CollectionUtils.convertMap(walletList, WalletManageEntity::getId)); + } + } + // 饭卡类型 + List walletTypeIds = list.getRecords().stream().map(WalletTransactionVo::getWalletTypeId).distinct().toList(); + if (ObjectUtil.isNotEmpty(walletTypeIds)) { + WalletTypeDto walletTypeDto = new WalletTypeDto(); + walletTypeDto.setWalletTypeIds(walletTypeIds); + List walletTypeList = walletTypeMapper.list(walletTypeDto); + if (ObjectUtil.isNotEmpty(walletTypeList)) { + WalletDataUtil.convertWalletTYpeList(list.getRecords(), CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId)); + } + } + // 订单 + if (dto.getIsFindOrder()) { + list.getRecords().forEach(v -> { + if (ObjectUtil.isNotEmpty(v.getBizId())) { + v.setOrderId(Long.valueOf(v.getBizId())); + } + }); + } } return list; } diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeServiceImpl.java index 278b4ac48..629d349dc 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeServiceImpl.java @@ -21,6 +21,7 @@ import com.bsd.pjcloud.wallet.service.WalletRechargeService; import com.bsd.pjcloud.wallet.service.WalletTransactionService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.seata.spring.annotation.GlobalTransactional; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -81,6 +82,7 @@ public class WalletRechargeServiceImpl extends ServiceImpl