feat:二维码
This commit is contained in:
1 parent
872ebe235f
commit
fdab8dfd7a
55 files changed
+854
-173
No files matched your search
+9
@@ -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<HardTypeEnum> 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();
|
||||
|
||||
+3
@@ -3,6 +3,9 @@ package com.bsd.pjcloud.hard.api.constant.refund;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 订单退款类型
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum HardRefundStatusEnum {
|
||||
|
||||
+4
-1
@@ -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;
|
||||
|
||||
|
||||
+9
@@ -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<Long> userIds;
|
||||
|
||||
private LocalDate[] createTimeList;
|
||||
|
||||
}
|
||||
+12
@@ -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<Long> userIds;
|
||||
|
||||
private List<Long> orderIds;
|
||||
|
||||
private List<Long> hardIds;
|
||||
|
||||
private List<Long> mchIds;
|
||||
|
||||
private LocalDate[] createTimeList;
|
||||
|
||||
private LocalDate[] payTimeList;
|
||||
|
||||
/**
|
||||
* 是否查询购物车列表
|
||||
*/
|
||||
|
||||
+4
@@ -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;
|
||||
|
||||
}
|
||||
+7
@@ -43,6 +43,13 @@ public class HardParentCarEntity extends Model<HardParentCarEntity> {
|
||||
@Schema(description="商户id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 硬件设备类型
|
||||
*/
|
||||
@Schema(description="硬件设备类型")
|
||||
private String hardType;
|
||||
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
|
||||
+20
@@ -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<List<HardOrderEntity>> getByIds(@RequestParam List<Long> ids);
|
||||
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
@author pigx archetype
|
||||
* <p>
|
||||
* feign client 存放目录,注意 @EnablePigxFeignClients 的扫描范围
|
||||
*/
|
||||
package com.bsd.pjcloud.hard.api.feign;
|
||||
+26
@@ -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 <T extends BaseOrderInterface> List<T> convertOrderList(List<T> list, Map<Long, HardOrderEntity> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertOrder(v, map.get(v.getOrderId())));
|
||||
}
|
||||
|
||||
public <T extends BaseOrderInterface> 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;
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -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);
|
||||
}
|
||||
+25
-1
@@ -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;
|
||||
}
|
||||
+4
@@ -5,4 +5,8 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardCarVo extends HardCarEntity {
|
||||
|
||||
// 商品id【超市的商品存的是 sku id】
|
||||
private Long supId;
|
||||
|
||||
}
|
||||
+6
@@ -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<HardCarVo> carList;
|
||||
|
||||
/**
|
||||
* 预约二维码信息
|
||||
*/
|
||||
private String reserveCode;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService
|
||||
+1
-1
@@ -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<Boolean> disagreeRefund(@RequestBody HardDisagreeDto dto) {
|
||||
|
||||
+6
-4
@@ -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<List<HardCarEntity>> appMchDetail(@RequestParam Long merchantId) {
|
||||
public R<List<HardCarVo>> 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);
|
||||
}
|
||||
|
||||
+18
-2
@@ -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<List<HardOrderEntity>> getByIds(@RequestParam List<Long> 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 ************************************* */
|
||||
|
||||
+19
@@ -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<HardAfterSaleEnti
|
||||
return selectJoinPage(page, HardAfterSaleVo.class, wrapper);
|
||||
}
|
||||
|
||||
default Page<HardAfterSaleVo> scopePageList(Page page, HardAfterSaleDto dto) {
|
||||
LambdaQueryWrapper<HardAfterSaleEntity> wrapper = new LambdaQueryWrapper<HardAfterSaleEntity>()
|
||||
.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<HardAfterSaleEntity> wrapper = new MPJLambdaWrapper<HardAfterSaleEntity>()
|
||||
.selectAll(HardAfterSaleEntity.class)
|
||||
|
||||
+39
-1
@@ -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<HardOrderEntity> {
|
||||
|
||||
default Page<HardOrderVo> scopePageList(Page page, HardOrderDto dto) {
|
||||
LambdaQueryWrapper<HardOrderEntity> wrapper = new LambdaQueryWrapper<HardOrderEntity>()
|
||||
.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<HardOrderVo> pageJoin(Page page, HardOrderDto dto) {
|
||||
MPJLambdaWrapper<HardOrderEntity> wrapper = new MPJLambdaWrapper<HardOrderEntity>()
|
||||
.selectAll(HardOrderEntity.class)
|
||||
@@ -35,4 +67,10 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
.eqIfExists(HardOrderEntity::getId, dto.getId());
|
||||
return selectJoinOne(HardOrderVo.class, wrapper);
|
||||
}
|
||||
|
||||
default List<HardOrderEntity> list(HardOrderDto dto) {
|
||||
LambdaQueryWrapper<HardOrderEntity> wrapper = new LambdaQueryWrapper<HardOrderEntity>()
|
||||
.in(ObjectUtil.isNotEmpty(dto.getOrderIds()), HardOrderEntity::getId, dto.getOrderIds());
|
||||
return selectListByScope(wrapper, DataScope.of());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -49,7 +49,7 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
* 同意售后
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param id
|
||||
* @param id 售后id
|
||||
*/
|
||||
Boolean agreeAfterSale(Long userId, Long id);
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public interface HardCarService extends IService<HardCarEntity> {
|
||||
|
||||
List<HardCarEntity> getByParentCarId(Long parentCarId);
|
||||
|
||||
List<HardCarEntity> mchDetail(Long merchantId, Long userId);
|
||||
List<HardCarVo> mchDetail(Long merchantId, Long userId,HardTypeEnum hardType);
|
||||
|
||||
Integer computerCarTotalPrice(@NotNull HardTypeEnum sysType, @NotEmpty List<HardCreateCarDto> list);
|
||||
|
||||
|
||||
+5
@@ -47,6 +47,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
|
||||
*/
|
||||
void cancelCode(HardOrderEntity order);
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
void generateCode(HardOrderEntity order);
|
||||
|
||||
/**
|
||||
* 扣件库存
|
||||
*/
|
||||
|
||||
+2
-2
@@ -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<HardManagerMapper, HardM
|
||||
List<Long> mchIds = list.getRecords().stream().map(HardManagerVo::getMerchantId).distinct().toList();
|
||||
R<List<MchManageVo>> 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;
|
||||
|
||||
+38
-13
@@ -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<HardAfterSaleMapper, H
|
||||
private final HardAfterSaleLogMapper hardAfterSaleLogMapper;
|
||||
private final HardOrderService hardOrderService;
|
||||
|
||||
private final HardOrderMapper hardOrderMapper;
|
||||
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteDeptService deptService;
|
||||
private final RemoteWalletRechargeService walletRechargeService;
|
||||
@@ -70,19 +75,31 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
|
||||
@Override
|
||||
public Page<HardAfterSaleVo> pageJoin(Page page, HardAfterSaleDto dto) {
|
||||
Page<HardAfterSaleVo> list = baseMapper.pageJoin(page, dto);
|
||||
Page<HardAfterSaleVo> list = baseMapper.scopePageList(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(HardAfterSaleVo::getUserId).distinct().toList();
|
||||
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
List<Long> userIds = list.getRecords().stream().map(HardAfterSaleVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
|
||||
}
|
||||
}
|
||||
// 部门
|
||||
List<Long> deptIds = list.getRecords().stream().map(HardAfterSaleVo::getDeptId).distinct().toList();
|
||||
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
List<Long> deptIds = list.getRecords().stream().map(HardAfterSaleVo::getDeptId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
}
|
||||
}
|
||||
// 订单
|
||||
List<Long> orderIds = list.getRecords().stream().map(HardAfterSaleVo::getOrderId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(orderIds)) {
|
||||
HardOrderDto hardOrderDto = new HardOrderDto();
|
||||
hardOrderDto.setOrderIds(orderIds);
|
||||
List<HardOrderEntity> orderList = hardOrderMapper.list(hardOrderDto);
|
||||
HardUtil.convertOrderList(list.getRecords(), CollectionUtils.convertMap(orderList, HardOrderEntity::getId));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -129,7 +146,12 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
|
||||
@Override
|
||||
public HardAfterSaleVo join(HardAfterSaleDto dto) {
|
||||
HardAfterSaleVo detail = baseMapper.join(dto);
|
||||
List<HardAfterSaleEntity> list = baseMapper.selectList(new LambdaQueryWrapper<HardAfterSaleEntity>()
|
||||
.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<HardAfterSaleMapper, H
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional(rollbackFor = Exception.class)
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refund(Long afterSaleId) {
|
||||
HardAfterSaleEntity afterSale = baseMapper.selectById(afterSaleId);
|
||||
@@ -167,7 +189,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
// 生成退款单号
|
||||
String refundCode = "hard_" + order.getId();
|
||||
// 创建退款单
|
||||
WalletRechargeRefundDto hardRefundDto = WalletRechargeRefundDto.builder().orderId(order.getId()).afterSaleId(afterSale.getId()).refundCode(refundCode).reason("订单退款").price(order.getPayPrice()).build();
|
||||
WalletRechargeRefundDto hardRefundDto = WalletRechargeRefundDto.builder().walletId(order.getWalletId()).orderId(order.getId()).afterSaleId(afterSale.getId()).refundCode(refundCode).reason("订单退款").price(order.getPayPrice()).build();
|
||||
R<WalletRechargeVo> 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<HardAfterSaleMapper, H
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean agreeAfterSale(Long userId, Long id) {
|
||||
HardAfterSaleEntity afterSale = validateAfterSaleAuditable(id);
|
||||
HardOrderEntity order = hardOrderService.getById(afterSale.getOrderId());
|
||||
@@ -221,7 +245,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
.status(HardSaleStatusEnum.SELLER_DISAGREE.getStatus())
|
||||
.auditUserId(userId)
|
||||
.auditTime(LocalDateTime.now())
|
||||
.applyReason(dto.getAuditReason())
|
||||
.auditReason(dto.getAuditReason())
|
||||
.build();
|
||||
baseMapper.updateById(updateRefundObj);
|
||||
// 记录售后日志
|
||||
@@ -274,6 +298,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
saveObj.setStatus(HardSaleStatusEnum.APPLY.getStatus());
|
||||
saveObj.setNo(refundCode);
|
||||
saveObj.setOrderId(order.getId());
|
||||
saveObj.setRefundPrice(order.getPayPrice());
|
||||
saveObj.setUserId(order.getUserId());
|
||||
// 标记订单状态
|
||||
saveObj.setOrderNo(String.valueOf(order.getId()));
|
||||
|
||||
+33
-11
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteOnlineCanteenSpuService;
|
||||
import com.bsd.pjcloud.canteen.vo.app.CanteenOnlineSpuAppVO;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
@@ -59,10 +58,27 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HardCarEntity> mchDetail(Long merchantId, Long userId) {
|
||||
HardParentCarEntity parentCarDO = getParentCar(merchantId, userId);
|
||||
public List<HardCarVo> mchDetail(Long merchantId, Long userId, HardTypeEnum hardTypeEnum) {
|
||||
HardParentCarEntity parentCarDO = getParentCar(merchantId, userId, hardTypeEnum);
|
||||
if (ObjectUtil.isEmpty(parentCarDO)) return null;
|
||||
return getByParentCarId(parentCarDO.getId());
|
||||
List<HardCarEntity> carList = getByParentCarId(parentCarDO.getId());
|
||||
if (ObjectUtil.isEmpty(carList)) return null;
|
||||
List<HardCarVo> resultList = BeanUtils.toBean(carList, HardCarVo.class);
|
||||
List<Long> 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<SupermarketUnitWithSpuVo> 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<HardCarMapper, HardCarEntity
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrUpload(HardCarSaveOrUpdateDto dto) {
|
||||
List<HardCreateCarDto> 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<HardCarEntity>().eq(HardCarEntity::getParentCarId, parentCar.getId()));
|
||||
// 添加购物车
|
||||
@@ -97,7 +113,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
return;
|
||||
}
|
||||
// 添加父订单
|
||||
HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(dto.getUserId()).merchantId(dto.getMerchantId()).orderStatus(HardOrderStatusEnum.CREATE.getType()).build();
|
||||
HardParentCarEntity parentCarObj = HardParentCarEntity.builder().userId(dto.getUserId()).merchantId(dto.getMerchantId()).hardType(dto.getHardType().getType()).orderStatus(HardOrderStatusEnum.CREATE.getType()).build();
|
||||
hardParentCarMapper.insert(parentCarObj);
|
||||
// 添加购物车
|
||||
getSelf().appCreateCard(parentCarObj.getId(), HardTypeEnum.CANTEEN, carList);
|
||||
@@ -120,11 +136,16 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
yield canteenTotalPrice.get();
|
||||
}
|
||||
case SUPERMARKET -> {
|
||||
int supermarketTotalPrice = 0;
|
||||
// 查询超市商品
|
||||
AtomicInteger supermarketTotalPrice = new AtomicInteger();
|
||||
List<SupermarketUnitWithSpuVo> 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<HardCarMapper, HardCarEntity
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createCard(Long userId, Long merchantId, HardTypeEnum sysType, List<HardCreateCarDto> 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<HardCarMapper, HardCarEntity
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
private HardParentCarEntity getParentCar(Long merchantId, Long userId) {
|
||||
private HardParentCarEntity getParentCar(Long merchantId, Long userId, HardTypeEnum hardTypeEnum) {
|
||||
if (!ObjectUtil.isAllNotEmpty(merchantId, userId)) return null;
|
||||
return hardParentCarMapper.selectOne(new LambdaQueryWrapper<HardParentCarEntity>()
|
||||
.eq(HardParentCarEntity::getUserId, userId)
|
||||
.eq(HardParentCarEntity::getMerchantId, merchantId)
|
||||
.eq(HardParentCarEntity::getHardType, hardTypeEnum.getType())
|
||||
.eq(HardParentCarEntity::getOrderStatus, HardOrderStatusEnum.CREATE.getType())
|
||||
);
|
||||
}
|
||||
|
||||
+59
-14
@@ -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<HardOrderMapper, HardO
|
||||
|
||||
@Override
|
||||
public Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto) {
|
||||
Page<HardOrderVo> list = baseMapper.pageJoin(page, dto);
|
||||
Page<HardOrderVo> list = baseMapper.scopePageList(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(HardOrderVo::getUserId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
@@ -109,7 +111,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
if (ObjectUtil.isNotEmpty(mchIds)) {
|
||||
R<List<MchManageVo>> 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<HardOrderMapper, HardO
|
||||
if (ObjectUtil.isNotEmpty(detail.getMerchantId())) {
|
||||
R<MchManageVo> 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<HardOrderMapper, HardO
|
||||
|
||||
/* ************************************* start 支付相关 start ************************************* */
|
||||
@Override
|
||||
@GlobalTransactional(rollbackFor = Exception.class)
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createOrder(HardCreateOrderDto dto) {
|
||||
if (!validateCreateOrderDto(dto)) return null;
|
||||
@@ -244,6 +253,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
HardOrderEntity orderObj = HardOrderEntity.builder()
|
||||
.userId(dto.getUserId())
|
||||
.parentCarId(dto.getCarParentId())
|
||||
.sysType(dto.getHardType().getType())
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.merchantId(parentCar.getMerchantId())
|
||||
.orderType(dto.getOrderType().getType())
|
||||
@@ -259,6 +269,8 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
baseMapper.insert(orderObj);
|
||||
// 钱包扣款
|
||||
if (isPay) getSelf().fastReduceBalance(orderObj);
|
||||
// 是否需要创建二维码
|
||||
generateCode(orderObj);
|
||||
return orderObj.getId();
|
||||
}
|
||||
|
||||
@@ -283,6 +295,8 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
hardParentCarServiceImpl.updateById(updateParentCar);
|
||||
// 核销二维码
|
||||
cancelCode(order);
|
||||
// 扣件库存
|
||||
fastenerInventory(order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +337,8 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelCode(HardOrderEntity order) {
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (!ObjectUtil.isAllNotEmpty(orderTypeEnum, order.getOrderSourceTypeId())) return;
|
||||
@@ -330,28 +346,45 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
switch (orderTypeEnum) {
|
||||
// 线下购买
|
||||
case BELOW -> {
|
||||
|
||||
}
|
||||
// 线上订餐
|
||||
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<HardOrderMapper, HardO
|
||||
return true;
|
||||
}
|
||||
|
||||
// 是否有二维码
|
||||
private Boolean isHaveCode(HardOrderEntity order) {
|
||||
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
|
||||
if (ObjectUtil.isEmpty(orderTypeEnum)) return false;
|
||||
if (!ObjectUtil.equals(HardOrderTypeEnum.RESERVE, orderTypeEnum)) {
|
||||
return false;
|
||||
}
|
||||
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(order.getSysType());
|
||||
if (ObjectUtil.isEmpty(hardTypeEnum)) return false;
|
||||
return HardTypeEnum.isReserve(hardTypeEnum);
|
||||
}
|
||||
|
||||
/* ************************************* end 支付相关 end ************************************* */
|
||||
|
||||
private HardwareOrderServiceImpl getSelf() {
|
||||
|
||||
Reference in new issue
Block a user