Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-api-cloud
This commit is contained in:
commit
77da090d4e
55 files changed
+854
-173
No files matched your search
@@ -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 '创建时间',
|
||||
|
||||
@@ -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 '流水标题',
|
||||
|
||||
+5
@@ -81,4 +81,9 @@ public interface ServiceNameConstants {
|
||||
* 钱包模块
|
||||
*/
|
||||
String WALLET_SERVICE = "pjcloud-wallet-biz";
|
||||
|
||||
/**
|
||||
* 硬件模块
|
||||
*/
|
||||
String HARDWARE_SERVICE = "pjcloud-hardware-biz";
|
||||
}
|
||||
+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() {
|
||||
|
||||
+2
@@ -11,6 +11,8 @@ import java.util.Arrays;
|
||||
public enum WalletCodeBizEnum {
|
||||
STRIDE("1", "跨单位"),
|
||||
FOREIGN("2", "外来人员"),
|
||||
CANTEEN_RESERVE("3", "食堂线上预订"),
|
||||
SUPERMARKET_RESERVE("4", "超市线上预订"),
|
||||
;
|
||||
private final String code;
|
||||
|
||||
|
||||
+2
@@ -10,4 +10,6 @@ public class WalletManageDto extends WalletManageEntity {
|
||||
|
||||
private List<Long> userIds;
|
||||
|
||||
private List<Long> walletIds;
|
||||
|
||||
}
|
||||
+8
@@ -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<String> bizTypes;
|
||||
|
||||
private LocalDate[] createTimeList;
|
||||
|
||||
/**
|
||||
* 是否查询order
|
||||
*/
|
||||
private Boolean isFindOrder = false;
|
||||
|
||||
}
|
||||
+13
@@ -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<Long> walletTypeIds;
|
||||
|
||||
}
|
||||
+1
-1
@@ -94,7 +94,7 @@ public class WalletManageEntity extends Model<WalletManageEntity> {
|
||||
* 饭卡绑定状态
|
||||
*/
|
||||
@Schema(description = "饭卡绑定状态")
|
||||
private Integer activeBindStatus;
|
||||
private String activeBindStatus;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
||||
+76
-64
@@ -21,88 +21,100 @@ import java.time.LocalDateTime;
|
||||
public class WalletTransactionEntity extends Model<WalletTransactionEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
+27
@@ -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<List<WalletCodeUseEntity>> getByBizIds(@RequestParam List<Long> ids);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/wallet-code-use/get-by-biz-id")
|
||||
R<WalletCodeUseEntity> getByBizId(@RequestParam Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 核销二维码
|
||||
*
|
||||
@@ -28,4 +42,17 @@ public interface RemoteCodeUseService {
|
||||
@NoToken
|
||||
@GetMapping("/wallet-code-use/is-cancel-code")
|
||||
R<Boolean> isCancelCode(@RequestParam Long id);
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*
|
||||
* @param id
|
||||
* @param userId
|
||||
* @param walletCodeBiz
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/wallet-code-use/generate-code")
|
||||
R<Boolean> generateCode(@RequestParam Long id, @RequestParam Long userId, @RequestParam WalletCodeBizEnum walletCodeBiz, @RequestParam Integer count);
|
||||
}
|
||||
+1
@@ -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;
|
||||
|
||||
-28
@@ -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 <T extends BaseMchInterface> List<T> convertMchList(List<T> list, Map<Long, MchManageVo> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertMch(v, map.get(v.getMerchantId())));
|
||||
}
|
||||
|
||||
public <T extends BaseMchInterface> T convertMch(T v, MchManageVo vo) {
|
||||
if (ObjectUtil.isEmpty(vo)) return v;
|
||||
v.setMerchantName(vo.getName());
|
||||
v.setLogoPic(vo.getLogoPic());
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -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 <T extends BaseMchInterface> List<T> convertMchList(List<T> list, Map<Long, MchManageVo> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertMch(v, map.get(v.getMerchantId())));
|
||||
}
|
||||
|
||||
public <T extends BaseMchInterface> T convertMch(T v, MchManageVo vo) {
|
||||
if (ObjectUtil.isEmpty(vo)) return v;
|
||||
v.setMerchantName(vo.getName());
|
||||
v.setLogoPic(vo.getLogoPic());
|
||||
return v;
|
||||
}
|
||||
|
||||
public <T extends BaseWalletTypeInterface> List<T> convertWalletTYpeList(List<T> list, Map<Long, WalletTypeEntity> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertWalletType(v, map.get(v.getWalletTypeId())));
|
||||
}
|
||||
|
||||
public <T extends BaseWalletTypeInterface> 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 <T extends BaseWalletInterface> List<T> convertWalletList(List<T> list, Map<Long, WalletManageEntity> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertWallet(v, map.get(v.getWalletId())));
|
||||
}
|
||||
|
||||
public <T extends BaseWalletInterface> 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;
|
||||
}
|
||||
|
||||
}
|
||||
+53
-1
@@ -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;
|
||||
|
||||
}
|
||||
+47
@@ -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);
|
||||
|
||||
}
|
||||
+20
@@ -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);
|
||||
}
|
||||
@@ -107,12 +107,6 @@
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-flow-task-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-hardware-api</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
+30
@@ -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<Boolean> isCancelCode(@RequestParam Long id) {
|
||||
return R.ok(walletCodeUseService.isCancelCode(id));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/generate-code")
|
||||
public R<Boolean> 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<List<WalletCodeUseEntity>> getByBizIds(@RequestParam List<Long> ids) {
|
||||
List<WalletCodeUseEntity> list = walletCodeUseService.list(new LambdaQueryWrapper<WalletCodeUseEntity>()
|
||||
.in(WalletCodeUseEntity::getBizId, ids)
|
||||
);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/get-by-biz-id")
|
||||
public R<WalletCodeUseEntity> getByBizId(@RequestParam Long id) {
|
||||
WalletCodeUseEntity detail = walletCodeUseService.getOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
|
||||
.eq(WalletCodeUseEntity::getBizId, id)
|
||||
);
|
||||
return R.ok(detail);
|
||||
}
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
+4
-1
@@ -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<Object> addPrice(@RequestParam("userIds") List<Long> userIds) {
|
||||
return R.ok(walletManageService.delWalletByUserIds(userIds));
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
|
||||
|
||||
+2
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -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<WalletManageEntity> {
|
||||
/**
|
||||
@@ -69,6 +71,16 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
|
||||
return selectJoinPage(page, WalletManageVo.class, wrapper);
|
||||
}
|
||||
|
||||
default List<WalletManageEntity> list(WalletManageDto dto) {
|
||||
LambdaUpdateWrapper<WalletManageEntity> wrapper = new LambdaUpdateWrapper<WalletManageEntity>()
|
||||
.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<WalletManageEntity> wrapper = new MPJLambdaWrapper<WalletManageEntity>()
|
||||
.selectAll(WalletManageEntity.class)
|
||||
|
||||
+20
-4
@@ -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<WalletTransac
|
||||
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
|
||||
wrapper.lt(WalletTransactionEntity::getPrice, 0);
|
||||
}
|
||||
|
||||
return selectJoinPage(page, WalletTransactionVo.class, wrapper);
|
||||
}
|
||||
|
||||
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto) {
|
||||
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
|
||||
.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;
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -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<WalletTypeEntity> {
|
||||
|
||||
|
||||
default List<WalletTypeEntity> list(WalletTypeDto dto) {
|
||||
LambdaUpdateWrapper<WalletTypeEntity> wrapper = new LambdaUpdateWrapper<WalletTypeEntity>()
|
||||
.in(ObjectUtil.isNotEmpty(dto.getWalletTypeIds()), WalletTypeEntity::getId, dto.getWalletTypeIds());
|
||||
return selectList(wrapper);
|
||||
}
|
||||
}
|
||||
+1
@@ -27,4 +27,5 @@ public interface WalletCodeUseService extends IService<WalletCodeUseEntity> {
|
||||
* @return
|
||||
*/
|
||||
Boolean isCancelCode(Long id);
|
||||
|
||||
}
|
||||
+2
-2
@@ -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<WalletActiveMapper, Wal
|
||||
List<Long> mchIds = list.getRecords().stream().map(WalletActiveVo::getMerchantId).distinct().toList();
|
||||
List<MchManageVo> 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;
|
||||
|
||||
+6
@@ -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<WalletCodeUseMapper, W
|
||||
private final RemoteFileService remoteFileService;
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void generate(Long id, Long userId, WalletCodeBizEnum biz, Integer count) {
|
||||
if (count == 0) return;
|
||||
@@ -102,6 +104,8 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean cancelCode(Long id) {
|
||||
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(codeUse)) return false;
|
||||
@@ -111,6 +115,8 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean isCancelCode(Long id) {
|
||||
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
|
||||
if (ObjectUtil.isEmpty(codeUse)) return false;
|
||||
|
||||
+49
-4
@@ -3,7 +3,6 @@ package com.bsd.pjcloud.wallet.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
@@ -15,20 +14,29 @@ import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.core.exception.CheckedException;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.seata.spring.annotation.GlobalTransactional;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -54,6 +62,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
private final WalletManageService walletManageService;
|
||||
|
||||
private final WalletManageMapper walletManageMapper;
|
||||
private final WalletTypeMapper walletTypeMapper;
|
||||
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteDeptService deptService;
|
||||
@@ -65,6 +74,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
|
||||
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
|
||||
@@ -80,6 +90,8 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
}
|
||||
Integer afterBalance = wallet.getBalance() - price;
|
||||
WalletTransactionEntity insetObj = new WalletTransactionEntity();
|
||||
insetObj.setUserId(wallet.getUserId());
|
||||
insetObj.setDeptId(wallet.getDeptId());
|
||||
insetObj.setWalletId(walletId);
|
||||
insetObj.setPrice(-price);
|
||||
insetObj.setBalance(afterBalance);
|
||||
@@ -91,7 +103,9 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
|
||||
public WalletTransactionEntity addWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
|
||||
WalletManageEntity wallet = walletManageService.getById(walletId);
|
||||
if (ObjectUtil.isEmpty(wallet)) {
|
||||
@@ -107,6 +121,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
}
|
||||
case REFUND: {
|
||||
walletManageMapper.updateWhenConsumptionRefund(wallet.getId(), price);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
log.error("|{}|,钱包id({})使用未实现的增加钱包余额的类型({}).", TAG, walletId, bizType.getDesc());
|
||||
@@ -114,6 +129,8 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
}
|
||||
}
|
||||
WalletTransactionEntity insetObj = new WalletTransactionEntity();
|
||||
insetObj.setUserId(wallet.getUserId());
|
||||
insetObj.setDeptId(wallet.getDeptId());
|
||||
insetObj.setWalletId(walletId);
|
||||
insetObj.setPrice(price);
|
||||
insetObj.setBalance(wallet.getBalance() + price);
|
||||
@@ -146,7 +163,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
|
||||
@Override
|
||||
public Page<WalletTransactionVo> pageJoin(Page page, WalletTransactionDto dto) {
|
||||
Page<WalletTransactionVo> list = baseMapper.pageJoin(page, dto);
|
||||
Page<WalletTransactionVo> list = baseMapper.scopePageList(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(WalletTransactionVo::getUserId).distinct().toList();
|
||||
@@ -160,6 +177,34 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
}
|
||||
// 饭卡
|
||||
List<Long> walletIds = list.getRecords().stream().map(WalletTransactionVo::getWalletId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(walletIds)) {
|
||||
WalletManageDto walletManageDto = new WalletManageDto();
|
||||
walletManageDto.setWalletIds(walletIds);
|
||||
List<WalletManageEntity> walletList = walletManageMapper.list(walletManageDto);
|
||||
if (ObjectUtil.isNotEmpty(walletList)) {
|
||||
WalletDataUtil.convertWalletList(list.getRecords(), CollectionUtils.convertMap(walletList, WalletManageEntity::getId));
|
||||
}
|
||||
}
|
||||
// 饭卡类型
|
||||
List<Long> walletTypeIds = list.getRecords().stream().map(WalletTransactionVo::getWalletTypeId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(walletTypeIds)) {
|
||||
WalletTypeDto walletTypeDto = new WalletTypeDto();
|
||||
walletTypeDto.setWalletTypeIds(walletTypeIds);
|
||||
List<WalletTypeEntity> 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;
|
||||
}
|
||||
|
||||
+3
-1
@@ -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<WalletRechargeMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public WalletRechargeVo refund(WalletRechargeRefundDto dto) {
|
||||
// 查询钱包
|
||||
@@ -101,7 +103,7 @@ public class WalletRechargeServiceImpl extends ServiceImpl<WalletRechargeMapper,
|
||||
.build();
|
||||
baseMapper.insert(recharge);
|
||||
// 增加金额
|
||||
walletTransactionService.addWalletBalance(wallet.getId(), recharge.getTotalPrice(), String.valueOf(dto.getAfterSaleId()), WalletBizEnum.REFUND);
|
||||
walletTransactionService.addWalletBalance(wallet.getId(), dto.getPrice(), String.valueOf(dto.getAfterSaleId()), WalletBizEnum.REFUND);
|
||||
return BeanUtils.toBean(recharge, WalletRechargeVo.class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user