Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-01-09 14:01:13 +08:00
commit 474a55483f
44 files changed
+533 -176

No files matched your search

@@ -21,7 +21,7 @@ public enum HardTypeEnum {
private final String type;
private final String description;
public static HardTypeEnum valueOfByType(Integer 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();
}
@@ -6,6 +6,9 @@ import lombok.Getter;
import java.util.Arrays;
/**
* 订单状态
*/
@AllArgsConstructor
@Getter
public enum HardOrderStatusEnum {
@@ -28,8 +28,14 @@ public enum HardOrderTypeEnum {
public static final List<HardOrderTypeEnum> refundList = List.of(BELOW, RESERVE);
public static final List<HardOrderTypeEnum> payList = List.of(BELOW, RESERVE);
public static boolean isRefund(HardOrderTypeEnum type) {
return refundList.contains(type);
}
public static boolean isPay(HardOrderTypeEnum type) {
return refundList.contains(type);
}
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.hard.api.constant.refund;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum HardSaleTypeEnum {
IN_SALE("10", "售中退款"),
AFTER_SALE("20", "售后退款"),
;
private final String type;
private final String name;
}
@@ -5,4 +5,7 @@ import lombok.Data;
@Data
public class HardCarDto extends HardCarEntity {
private Long orderId;
}
@@ -3,6 +3,19 @@ package com.bsd.pjcloud.hard.api.dto.order;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import lombok.Data;
import java.util.List;
@Data
public class HardOrderDto extends HardOrderEntity {
/**
* 用户相关
*/
private List<Long> userIds;
/**
* 是否查询购物车列表
*/
private Boolean isFindCarList = false;
}
@@ -1,9 +1,8 @@
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.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -23,7 +22,7 @@ public class HardAppCreateOrderDto {
private Long userId;
@NotNull(message = "钱包类型不能为空")
private WalletTypeCodeEnum walletType;
private WalletTypeEnum walletType;
@NotNull(message = "订单类型不能为空")
private HardOrderTypeEnum orderType;
@@ -13,4 +13,6 @@ public class HardInvoiceVo extends HardInvoiceEntity implements BaseDeptInterfac
private Long merchantId;
private String merchantName;
private String logoPic;
}
@@ -13,4 +13,6 @@ public class HardManagerVo extends HardManagerEntity implements BaseDeptInterfac
private String merchantName;
private String logoPic;
}
@@ -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.HardOrderEntity;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import lombok.Data;
import java.util.List;
@Data
public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, BaseDeptInterface {
public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, BaseDeptInterface, BaseMchInterface {
/**
* 用户相关
*/
@@ -20,4 +23,23 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B
* 部门相关
*/
private String deptName;
/**
* 商户相关
*/
private String merchantName;
private String logoPic;
/**
* 设备相关
*/
private String hardName;
private String hardType;
/**
* 购物车
*/
private List<HardCarVo> carList;
}
@@ -13,6 +13,11 @@
<artifactId>pjcloud-hardware-biz</artifactId>
<dependencies>
<!--引入分布式事务-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-seata</artifactId>
</dependency>
<!--必备: 注册中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
@@ -14,6 +14,8 @@ import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleDto;
import com.bsd.pjcloud.hard.api.dto.order.HardDisagreeDto;
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleLogEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleLogVo;
import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleVo;
import com.bsd.pjcloud.hard.service.HardAfterSaleService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
@@ -42,12 +44,53 @@ public class HardAfterSaleController {
private final HardAfterSaleService hardAfterSaleService;
/* ************************************* start app start ************************************* */
@PostMapping(value = "/app/create")
@Operation(summary = "app申请售后")
@Idempotent(expireTime = 10, info = "正在申请中,请勿重复操作")
public R<Long> appCreate(@RequestBody HardAfterSaleDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(hardAfterSaleService.create(dto));
}
@GetMapping(value = "/app/cancel")
@Operation(summary = "app取消售后")
@Idempotent(expireTime = 10, info = "正在取消中,请勿重复操作")
public R<Boolean> appCancel(@RequestParam Long id) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardAfterSaleService.cancelAfterSale(user.getId(), id));
}
@GetMapping(value = "/app/history")
@Operation(summary = "app查询售后进度")
public R<List<HardAfterSaleLogEntity>> appHistory(@RequestParam Long id) {
return R.ok(hardAfterSaleService.getHistory(id));
}
@GetMapping(value = "/app/detail-by-order-id")
@Operation(summary = "app查询退款详情")
public R<HardAfterSaleVo> appDetail(@RequestParam Long orderId) {
HardAfterSaleDto dto = new HardAfterSaleDto();
dto.setOrderId(orderId);
return R.ok(hardAfterSaleService.join(dto));
}
/* ************************************* end app end ************************************* */
@GetMapping(value = "/history")
@Operation(summary = "查询售后进度")
public R<List<HardAfterSaleLogEntity>> history(@RequestParam Long id) {
return R.ok(hardAfterSaleService.getHistory(id));
}
@GetMapping(value = "/detail-by-order-id")
@Operation(summary = "查询售后进度")
public R<HardAfterSaleVo> getDetailByOrderId(@RequestParam Long orderId) {
HardAfterSaleDto dto = new HardAfterSaleDto();
dto.setOrderId(orderId);
return R.ok(hardAfterSaleService.join(dto));
}
@PutMapping("/agree")
@Operation(summary = "同意售后")
@Idempotent(expireTime = 10, info = "正在处理中,请勿重复操作")
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.controller.order;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,8 +14,12 @@ 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;
@@ -41,6 +46,7 @@ import java.util.List;
public class HardCarController {
private final HardCarService hardCarService;
private final HardOrderService hardOrderService;
/* ************************************* start app start ************************************* */
@GetMapping("/app/mch-detail")
@@ -51,7 +57,7 @@ public class HardCarController {
}
@GetMapping("/app/order-id")
@Operation(summary = "根据订单id查询当前用户购物车")
@Operation(summary = "根据订单id查询购物车")
public R<List<HardCarVo>> appOrderId(@RequestParam Long orderId) {
return R.ok(hardCarService.getByOrderId(orderId));
}
@@ -67,6 +73,16 @@ public class HardCarController {
}
/* ************************************* end app end ************************************* */
@GetMapping("/order-id")
@Operation(summary = "根据订单id查询购物车")
public R<Page<HardCarVo>> orderId(@ParameterObject Page page, @RequestParam Long orderId) {
HardOrderEntity order = hardOrderService.getById(orderId);
if (ObjectUtil.isEmpty(order)) return null;
HardCarDto dto = new HardCarDto();
dto.setParentCarId(order.getParentCarId());
return R.ok(hardCarService.pageJoin(page, dto));
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('hard_hardCar_view')")
@@ -12,12 +12,11 @@ import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
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.hard.HardCreateOrderDto;
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.service.HardOrderService;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -51,6 +50,7 @@ public class HardOrderController {
public R appPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
dto.setIsFindCarList(true);
return R.ok(hardwareOrderService.pageJoin(page, dto));
}
@@ -65,7 +65,7 @@ public class HardOrderController {
@Idempotent(expireTime = 10, info = "正在创建订单中,请勿重复操作")
public R appCreateOrder(@RequestParam Long carParentId) {
PjcloudUser user = SecurityUtils.getUser();
HardAppCreateOrderDto dto = HardAppCreateOrderDto.builder().carParentId(carParentId).walletType(WalletTypeCodeEnum.CANTEEN).userId(user.getId()).orderType(HardOrderTypeEnum.RESERVE).payType(HardPayTypeEnum.WALLET_DEFAULT).build();
HardAppCreateOrderDto dto = HardAppCreateOrderDto.builder().carParentId(carParentId).walletType(WalletTypeEnum.EAT).userId(user.getId()).orderType(HardOrderTypeEnum.RESERVE).payType(HardPayTypeEnum.WALLET_DEFAULT).build();
return R.ok(hardwareOrderService.appCreateOrder(dto));
}
/* ************************************* end app end ************************************* */
@@ -89,7 +89,7 @@ public class HardOrderController {
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(hardwareOrderService.getById(id));
return R.ok(hardwareOrderService.join(id));
}
@Operation(summary = "新增订单表", description = "新增订单表")
@@ -1,5 +1,7 @@
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.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.dto.order.HardAfterSaleLogDto;
@@ -8,6 +10,8 @@ import com.bsd.pjcloud.hard.api.vo.order.HardAfterSaleLogVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface HardAfterSaleLogMapper extends PjcloudBaseMapper<HardAfterSaleLogEntity> {
@@ -16,4 +20,13 @@ public interface HardAfterSaleLogMapper extends PjcloudBaseMapper<HardAfterSaleL
.selectAll(HardAfterSaleLogEntity.class);
return selectJoinPage(page, HardAfterSaleLogVo.class, wrapper);
}
default HardAfterSaleLogEntity getFirst(Long id) {
List<HardAfterSaleLogEntity> list = selectList(new LambdaQueryWrapper<HardAfterSaleLogEntity>()
.eq(HardAfterSaleLogEntity::getAfterSaleId, id)
.orderByAsc(HardAfterSaleLogEntity::getId)
);
if (ObjectUtil.isEmpty(list)) return null;
return list.stream().findFirst().get();
}
}
@@ -11,10 +11,17 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HardAfterSaleMapper extends PjcloudBaseMapper<HardAfterSaleEntity> {
default Page<HardAfterSaleVo> pageJoin(Page page, HardAfterSaleDto dto){
default Page<HardAfterSaleVo> pageJoin(Page page, HardAfterSaleDto dto) {
MPJLambdaWrapper<HardAfterSaleEntity> wrapper = new MPJLambdaWrapper<HardAfterSaleEntity>()
.selectAll(HardAfterSaleEntity.class);
return selectJoinPage(page, HardAfterSaleVo.class, wrapper);
}
default HardAfterSaleVo join(HardAfterSaleDto dto) {
MPJLambdaWrapper<HardAfterSaleEntity> wrapper = new MPJLambdaWrapper<HardAfterSaleEntity>()
.selectAll(HardAfterSaleEntity.class)
.eqIfExists(HardAfterSaleEntity::getId, dto.getId())
.eqIfExists(HardAfterSaleEntity::getOrderId, dto.getOrderId());
return selectJoinOne(HardAfterSaleVo.class, wrapper);
}
}
@@ -13,7 +13,8 @@ public interface HardCarMapper extends PjcloudBaseMapper<HardCarEntity> {
default Page<HardCarVo> pageJoin(Page page, HardCarDto dto) {
MPJLambdaWrapper<HardCarEntity> wrapper = new MPJLambdaWrapper<HardCarEntity>()
.selectAll(HardCarEntity.class);
.selectAll(HardCarEntity.class)
.eqIfExists(HardCarEntity::getParentCarId, dto.getParentCarId());
return selectJoinPage(page, HardCarVo.class, wrapper);
}
}
@@ -1,10 +1,13 @@
package com.bsd.pjcloud.hard.mapper.order;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.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;
@@ -12,13 +15,24 @@ import org.apache.ibatis.annotations.Mapper;
public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
default Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto) {
MPJLambdaWrapper<HardOrderEntity> wrapper = new MPJLambdaWrapper<HardOrderEntity>()
.selectAll(HardOrderEntity.class);
.selectAll(HardOrderEntity.class)
.selectAs(HardManagerEntity::getName, HardOrderVo::getHardName)
.selectAs(HardManagerEntity::getType, HardOrderVo::getHardType)
.leftJoin(HardManagerEntity.class, HardManagerEntity::getId, HardOrderEntity::getHardId)
.eqIfExists(HardOrderEntity::getOrderType, dto.getOrderType())
.eqIfExists(HardOrderEntity::getPayType, dto.getPayType())
.eqIfExists(HardOrderEntity::getOrderStatus, dto.getOrderStatus())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), HardOrderEntity::getUserId, dto.getUserIds());
return selectJoinPage(page, HardOrderVo.class, wrapper);
}
default HardOrderVo join(HardOrderDto dto) {
MPJLambdaWrapper<HardOrderEntity> wrapper = new MPJLambdaWrapper<HardOrderEntity>()
.selectAll(HardOrderEntity.class);
.selectAll(HardOrderEntity.class)
.selectAs(HardManagerEntity::getName, HardOrderVo::getHardName)
.selectAs(HardManagerEntity::getType, HardOrderVo::getHardType)
.leftJoin(HardManagerEntity.class, HardManagerEntity::getId, HardOrderEntity::getHardId)
.eqIfExists(HardOrderEntity::getId, dto.getId());
return selectJoinOne(HardOrderVo.class, wrapper);
}
}
@@ -14,6 +14,23 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
Page<HardAfterSaleVo> pageJoin(Page page, HardAfterSaleDto dto);
HardAfterSaleVo join(HardAfterSaleDto dto);
/**
* 申请售后
* @param dto
* @return
*/
Long create(HardAfterSaleDto dto);
/**
* 取消售后
* @param userId 用户id
* @param afterSaleId 售后id
* @return
*/
Boolean cancelAfterSale(Long userId, Long afterSaleId);
/**
* 获取售后进度
*
@@ -9,7 +9,6 @@ import com.bsd.pjcloud.hard.api.dto.order.HardCreateCarDto;
import com.bsd.pjcloud.hard.api.entity.order.HardCarEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@@ -2,13 +2,13 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
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.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import jakarta.validation.Valid;
public interface HardOrderService extends IService<HardOrderEntity> {
@@ -47,6 +47,11 @@ public interface HardOrderService extends IService<HardOrderEntity> {
*/
void cancelCode(HardOrderEntity order);
/**
* 扣件库存
*/
void fastenerInventory(HardOrderEntity order);
/**
* 核销硬件二维码
*
@@ -3,8 +3,10 @@ package com.bsd.pjcloud.hard.service.impl.order;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
@@ -18,6 +20,7 @@ import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
import com.bsd.pjcloud.hard.api.constant.refund.HardAfterSaleOperateTypeEnum;
import com.bsd.pjcloud.hard.api.constant.refund.HardRefundStatusEnum;
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.entity.order.HardAfterSaleEntity;
@@ -85,6 +88,67 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
return list;
}
@Override
public Long create(HardAfterSaleDto dto) {
HardOrderVo order = validateOrderCanRefund(dto.getOrderId());
HardAfterSaleEntity afterSale = getSelf().createAfterSale(order, dto);
return afterSale.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean cancelAfterSale(Long userId, Long afterSaleId) {
HardAfterSaleEntity afterSale = baseMapper.selectById(afterSaleId);
if (ObjectUtil.isEmpty(afterSale)) throw new RuntimeException("售后单不存在");
HardOrderEntity order = hardOrderService.getById(afterSale.getOrderId());
if (ObjectUtil.isEmpty(order)) throw new RuntimeException("订单不存在");
if (!ObjectUtil.equals(HardSaleStatusEnum.APPLY.getStatus(), afterSale.getStatus())) {
throw new RuntimeException("取消售后单失败,售后单状态不是【待审核】");
}
// 更新售后单的状态为【已取消】
HardAfterSaleEntity updateRefundObj = HardAfterSaleEntity.builder().id(afterSale.getId()).status(HardSaleStatusEnum.BUYER_CANCEL.getStatus()).build();
baseMapper.updateById(updateRefundObj);
// 更改订单状态为已取消
HardAfterSaleLogEntity last = hardAfterSaleLogMapper.getFirst(afterSale.getId());
if (ObjectUtil.isNotEmpty(last) && ObjectUtil.isNotEmpty(last.getAfterStatus())) {
HardOrderEntity updateOrderObj = HardOrderEntity.builder().id(order.getId()).applyCancelTime(LocalDateTime.now()).orderStatus(last.getBeforeStatus()).build();
hardOrderService.updateById(updateOrderObj);
}
// 添加售后进度
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
.afterSaleId(afterSaleId)
.userId(userId)
.operateType(HardAfterSaleOperateTypeEnum.MEMBER_CANCEL.getType())
.beforeStatus(order.getOrderStatus())
.afterStatus(HardSaleStatusEnum.BUYER_CANCEL.getStatus())
.content(HardSaleStatusEnum.BUYER_CANCEL.getContent())
.build();
hardAfterSaleLogMapper.insert(saveLogObj);
return true;
}
@Override
public HardAfterSaleVo join(HardAfterSaleDto dto) {
HardAfterSaleVo detail = baseMapper.join(dto);
if (ObjectUtil.isNotEmpty(detail)) {
// 用户
if (ObjectUtil.isNotEmpty(detail.getUserId())) {
R<UserInfo> user = userService.getByUserId(detail.getUserId());
if (ObjectUtil.isNotEmpty(user.getData())) {
DataUtil.convertUser(detail, user.getData().getSysUser());
}
}
// 部门
if (ObjectUtil.isNotEmpty(detail.getDeptId())) {
R<SysDept> dept = deptService.getDeptByDeptId(detail.getDeptId());
if (ObjectUtil.isNotEmpty(dept.getData())) {
DataUtil.convertDept(detail, dept.getData());
}
}
}
return detail;
}
@Override
public List<HardAfterSaleLogEntity> getHistory(Long id) {
return hardAfterSaleLogMapper.selectList(new LambdaQueryWrapper<HardAfterSaleLogEntity>()
@@ -161,7 +225,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
.build();
baseMapper.updateById(updateRefundObj);
// 记录售后日志
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
.afterSaleId(afterSale.getId())
.userId(userId)
.operateType(HardAfterSaleOperateTypeEnum.ADMIN_DISAGREE_APPLY.getType())
@@ -179,11 +243,11 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
// 校验订单是否可以退款
private HardOrderVo validateOrderCanRefund(Long orderId) {
HardOrderEntity order = hardOrderService.getById(orderId);
if (ObjectUtil.isEmpty(order)) throw new RuntimeException("示例订单不存在");
if (ObjectUtil.isEmpty(order)) throw new RuntimeException("订单不存在");
HardOrderVo orderVo = BeanUtils.toBean(order, HardOrderVo.class);
// 检查是否可以退款
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
if (HardOrderTypeEnum.isRefund(orderTypeEnum)) {
if (!HardOrderTypeEnum.isRefund(orderTypeEnum)) {
throw new RuntimeException("该订单类型不支持退款");
}
// 校验订单是否已退款
@@ -202,6 +266,41 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
return afterSale;
}
@Transactional(rollbackFor = Exception.class)
public HardAfterSaleEntity createAfterSale(HardOrderVo order, HardAfterSaleDto dto) {
HardAfterSaleEntity saveObj = new HardAfterSaleEntity();
// 创建售后单
String refundCode = "hard_" + order.getId();
saveObj.setStatus(HardSaleStatusEnum.APPLY.getStatus());
saveObj.setNo(refundCode);
saveObj.setOrderId(order.getId());
saveObj.setUserId(order.getUserId());
// 标记订单状态
saveObj.setOrderNo(String.valueOf(order.getId()));
String type = ObjectUtil.equal(HardOrderStatusEnum.CANCEL.getType(), order.getOrderStatus()) ?
HardSaleTypeEnum.AFTER_SALE.getType() : HardSaleTypeEnum.IN_SALE.getType();
saveObj.setType(type);
baseMapper.insert(saveObj);
// 添加售后进度
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
.afterSaleId(saveObj.getId())
.userId(order.getUserId())
.operateType(HardAfterSaleOperateTypeEnum.MEMBER_CREATE.getType())
.beforeStatus(order.getOrderStatus())
.afterStatus(HardSaleStatusEnum.APPLY.getStatus())
.content(HardSaleStatusEnum.APPLY.getContent())
.build();
hardAfterSaleLogMapper.insert(saveLogObj);
// 更新交易订单项的售后状态
LambdaUpdateWrapper<HardOrderEntity> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(HardOrderEntity::getApplyCancelTime, null)
.set(HardOrderEntity::getOrderStatus, HardOrderStatusEnum.REFUND.getType())
.set(HardOrderEntity::getRefundStatus, HardRefundStatusEnum.NONE.getStatus())
.eq(HardOrderEntity::getId, order.getId());
hardOrderService.update(updateWrapper);
return saveObj;
}
private HardAfterSaleServiceImpl getSelf() {
return SpringUtil.getBean(getClass());
}
@@ -7,6 +7,7 @@ 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;
@@ -4,12 +4,14 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
@@ -25,20 +27,21 @@ import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
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.api.vo.order.HardOrderVo;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
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.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
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.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -71,6 +74,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
private final HardManagerService hardManagerService;
private final HardCarService hardCarService;
private final HardParentCarServiceImpl hardParentCarServiceImpl;
private final RemoteMchService remoteMchService;
private final RemoteCodeUseService remoteCodeUseService;
@@ -85,16 +89,36 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
Page<HardOrderVo> list = baseMapper.pageJoin(page, dto);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 用户
List<Long> userIds = list.getRecords().stream().map(HardOrderVo::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(HardOrderVo::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(HardOrderVo::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(HardOrderVo::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> mchIds = list.getRecords().stream().map(HardOrderVo::getMerchantId).filter(ObjectUtil::isNotEmpty).distinct().toList();
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));
}
}
// 购物车
if (dto.getIsFindCarList()) {
for (HardOrderVo v : list.getRecords()) {
List<HardCarEntity> carList = hardCarService.getByParentCarId(v.getParentCarId());
List<HardCarVo> carVoList = BeanUtils.toBean(carList, HardCarVo.class);
v.setCarList(carVoList);
}
}
}
return list;
@@ -104,7 +128,31 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
public HardOrderVo join(Long id) {
HardOrderDto dto = new HardOrderDto();
dto.setId(id);
return baseMapper.join(dto);
HardOrderVo detail = baseMapper.join(dto);
if (ObjectUtil.isNotEmpty(detail)) {
// 用户
if (ObjectUtil.isNotEmpty(detail.getUserId())) {
R<UserInfo> user = userService.getByUserId(detail.getUserId());
if (ObjectUtil.isNotEmpty(user.getData())) {
DataUtil.convertUser(detail, user.getData().getSysUser());
}
}
// 部门
if (ObjectUtil.isNotEmpty(detail.getDeptId())) {
R<SysDept> dept = deptService.getDeptByDeptId(detail.getDeptId());
if (ObjectUtil.isNotEmpty(dept.getData())) {
DataUtil.convertDept(detail, dept.getData());
}
}
// 商户
if (ObjectUtil.isNotEmpty(detail.getMerchantId())) {
R<MchManageVo> mch = remoteMchService.getById(detail.getMerchantId());
if (ObjectUtil.isNotEmpty(mch.getData())) {
MchDataUtil.convertMch(detail, mch.getData());
}
}
}
return detail;
}
@@ -122,7 +170,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
// 饭卡钱包
WalletManageEntity wallet = null;
if (isPay) {
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeCodeEnum.CANTEEN);
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
}
int totalPrice = 0, extraPrice = 0, payPrice = 0;
@@ -151,7 +199,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
.orderSourceTypeId(dto.getOrderSourceTypeId())
.totalPrice(totalPrice)
.extraPrice(extraPrice)
.payPrice(0)
.payPrice(totalPrice + extraPrice)
.isOfflineOrder(YesNoEnum.NO.getCode())
.productDesc(subject)
.build();
@@ -163,7 +211,6 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
}
@Override
@GlobalTransactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public Long appCreateOrder(@Valid HardAppCreateOrderDto dto) {
// 钱包
@@ -191,7 +238,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
entity.setProductCount(v.getProductCount());
return entity;
}).toList();
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeCodeEnum.CANTEEN) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
HardTypeEnum hardType = ObjectUtil.equals(dto.getWalletType(), WalletTypeEnum.EAT) ? HardTypeEnum.CANTEEN : HardTypeEnum.SUPERMARKET;
String subject = hardCarService.computerCarSubject(hardType, carListDto);
// 添加硬件订单
HardOrderEntity orderObj = HardOrderEntity.builder()
@@ -204,6 +251,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
.orderSourceTypeId(dto.getOrderSourceTypeId())
.totalPrice(totalPrice)
.extraPrice(0)
.payPrice(totalPrice)
.isOfflineOrder(YesNoEnum.NO.getCode())
.productDesc(subject)
.build();
@@ -215,16 +263,24 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
}
@Override
@GlobalTransactional(rollbackFor = Exception.class)
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public void fastReduceBalance(HardOrderEntity order) {
boolean isPay = isPay(HardOrderTypeEnum.valueOfByType(order.getOrderType()), HardPayTypeEnum.valueOfByType(order.getPayType()));
WalletBalanceTransactionDto reduceBuild = WalletBalanceTransactionDto.builder().walletId(order.getWalletId()).price(order.getPayPrice()).bizId(String.valueOf(order.getId())).bizType(WalletBizEnum.PAYMENT).build();
WalletBalanceTransactionDto reduceBuild = new WalletBalanceTransactionDto();
reduceBuild.setWalletId(order.getWalletId());
reduceBuild.setPrice(order.getPayPrice());
reduceBuild.setBizId(String.valueOf(order.getId()));
reduceBuild.setBizType(WalletBizEnum.PAYMENT);
WalletTransactionEntity walletTransaction = walletTransactionService.reduceWalletBalance(reduceBuild).getData();
if (ObjectUtil.isNotEmpty(walletTransaction)) {
// 订单表订单状态
Integer payPrice = isPay ? order.getTotalPrice() + order.getExtraPrice() : 0;
HardOrderEntity update = HardOrderEntity.builder().id(order.getId()).payTime(LocalDateTime.now()).orderStatus(HardOrderStatusEnum.PAY.getType()).payPrice(payPrice).build();
baseMapper.updateById(update);
// 父购物车订单表订单状态
HardParentCarEntity updateParentCar = HardParentCarEntity.builder().id(order.getParentCarId()).orderStatus(HardOrderStatusEnum.PAY.getType()).build();
hardParentCarServiceImpl.updateById(updateParentCar);
// 核销二维码
cancelCode(order);
}
@@ -251,6 +307,7 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean handCancelCode(HandCancelCodeDto dto) {
// 查询订单
HardOrderEntity order = baseMapper.selectById(dto.getOrderId());
@@ -284,6 +341,23 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
}
}
@Override
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;
}
}
// 二维码类型的订单是否被核销
private boolean validateCodeIsCancel(HardOrderTypeEnum orderType, Long orderSourceTypeId) {
Boolean flag = switch (orderType) {
@@ -299,9 +373,15 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
return flag;
}
// 是否需要支付(目前只有线下的现金是不走平台扣款)
// 是否需要支付
private boolean isPay(HardOrderTypeEnum type, HardPayTypeEnum payType) {
return ObjectUtil.equals(type, HardOrderTypeEnum.BELOW) && !ObjectUtil.equals(payType, HardPayTypeEnum.CASH);
if (ObjectUtil.equals(type, HardOrderTypeEnum.BELOW) && ObjectUtil.equals(payType, HardPayTypeEnum.CASH)) {
return false;
}
if (!HardOrderTypeEnum.isPay(type)) {
return false;
}
return true;
}
// 是否需要额外支付(目前只有食堂需要)
@@ -9,7 +9,7 @@ spring:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: pjcloud-register:8848
server-addr: ${NACOS_HOST:pjcloud-register}:${NACOS_PORT:8848}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
config:
@@ -1,24 +0,0 @@
package com.bsd.pjcloud.wallet.api.constant;
import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
@Getter
@AllArgsConstructor
public enum WalletTypeCodeEnum {
SUPERMARKET("1", "超市"),
CANTEEN("2", "食堂"),
;
private final String code;
private final String desc;
public static WalletTypeCodeEnum descOf(String description) {
return Arrays.stream(WalletTypeCodeEnum.values())
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
.findFirst().get();
}
}
@@ -6,6 +6,9 @@ import lombok.Getter;
import java.util.Arrays;
/**
* 钱包的unique code
*/
@Getter
@AllArgsConstructor
public enum WalletTypeEnum {
@@ -1,6 +1,7 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
@@ -9,22 +10,23 @@ import lombok.Data;
import java.io.Serializable;
@Builder
@AllArgsConstructor
@NotEmpty
@Data
public class WalletBalanceTransactionDto {
@NotNull(message = "钱包id不能为空")
@JsonProperty("walletId")
private Long walletId;
@NotNull(message = "操作金额不能为空")
@JsonProperty("price")
private Integer price;
@NotEmpty(message = "业务类型关联id不能为空")
@JsonProperty("bizId")
private String bizId;
@NotNull(message = "业务类型不能为空")
@JsonProperty("bizType")
private WalletBizEnum bizType;
}
@@ -2,12 +2,15 @@ package com.bsd.pjcloud.wallet.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 支付设置
@@ -23,100 +26,100 @@ import java.time.LocalDateTime;
public class WalletSettingEntity extends Model<WalletSettingEntity> {
/**
* 编号
*/
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
@Schema(description = "编号")
private Long id;
/**
* 每一餐的上限(分)
*/
@Schema(description="每一餐的上限(分)")
/**
* 每一餐的上限(分)
*/
@Schema(description = "每一餐的上限(分)")
private Integer payAmountMealLimit;
/**
* 每一餐的倍数
*/
@Schema(description="每一餐的倍数")
/**
* 每一餐的倍数
*/
@Schema(description = "每一餐的倍数")
private BigDecimal payAmountMealTimes;
/**
* 是否开启每一餐的额外缴费
*/
@Schema(description="是否开启每一餐的额外缴费")
/**
* 是否开启每一餐的额外缴费
*/
@Schema(description = "是否开启每一餐的额外缴费")
private String payAmountEnable;
/**
* 是否开启钱包二维码刷新
*/
@Schema(description="是否开启钱包二维码刷新")
/**
* 是否开启钱包二维码刷新
*/
@Schema(description = "是否开启钱包二维码刷新")
private String refreshQrCodeEnable;
/**
* 二维码刷新频率
*/
@Schema(description="二维码刷新频率")
/**
* 二维码刷新频率
*/
@Schema(description = "二维码刷新频率")
private Integer refreshQrCodeFre;
/**
* 是否开启离线订单的审批
*/
@Schema(description="是否开启离线订单的审批")
/**
* 是否开启离线订单的审批
*/
@Schema(description = "是否开启离线订单的审批")
private String offLineOrderApplyEnable;
/**
* 退款理由
*/
@Schema(description="退款理由")
/**
* 退款理由
*/
@Schema(description = "退款理由")
private String afterSaleRefundReasons;
/**
* 退货理由
*/
@Schema(description="退货理由")
/**
* 退货理由
*/
@Schema(description = "退货理由")
private String afterSaleReturnReasons;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -3,7 +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.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@@ -16,11 +16,11 @@ public interface RemoteWalletService {
@NoToken
@GetMapping("/wallet-manage/get-or-create-wallet")
R<WalletManageEntity> getOrCreateWallet(@RequestParam Long userId, @RequestParam(required = false) WalletTypeCodeEnum walletTypeCode);
R<WalletManageEntity> getOrCreateWallet(@RequestParam Long userId, @RequestParam(required = false) WalletTypeEnum walletTypeCode);
@NoToken
@GetMapping("/wallet-manage/get-wallet")
R<WalletManageEntity> getWallet(@RequestParam Long userId, @RequestParam WalletTypeCodeEnum walletTypeCode);
R<WalletManageEntity> getWallet(@RequestParam Long userId, @RequestParam WalletTypeEnum walletTypeCode);
@NoToken
@GetMapping("/wallet-manage/create-wallet")
@@ -6,18 +6,18 @@ import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(contextId = "remoteWalletTransactionService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteWalletTransactionService {
@NoToken
@GetMapping("/wallet-transaction/add-balance")
@PostMapping("/wallet-transaction/add-balance")
R<WalletTransactionEntity> addWalletBalance(@RequestBody WalletBalanceTransactionDto dto);
@NoToken
@GetMapping("/wallet-transaction/reduce-balance")
@PostMapping("/wallet-transaction/reduce-balance")
R<WalletTransactionEntity> reduceWalletBalance(@RequestBody WalletBalanceTransactionDto dto);
}
@@ -21,6 +21,7 @@ public class MchDataUtil {
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;
}
@@ -27,4 +27,6 @@ public class WalletActiveVo extends WalletActiveEntity implements BaseUserInterf
* 商户相关
*/
private String merchantName;
private String logoPic;
}
@@ -16,4 +16,12 @@ public interface BaseMchInterface {
void setMerchantName(String dchName);
/**
* 商户logo
*/
String getLogoPic();
void setLogoPic(String logoPic);
}
@@ -13,6 +13,11 @@
<artifactId>pjcloud-wallet-biz</artifactId>
<dependencies>
<!--引入分布式事务-->
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-common-seata</artifactId>
</dependency>
<!--必备: undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -113,6 +113,12 @@ public class MchManageController {
return R.ok(mchManageService.pageJoin(page, dto));
}
@Operation(summary = "分页不要权限下拉", description = "分页不要权限下拉")
@GetMapping("/page-join-select")
public R pageJoinSelect(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
return R.ok(mchManageService.pageJoin(page, dto));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
@@ -6,15 +6,12 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
import com.bsd.pjcloud.common.core.util.MsgUtils;
import com.bsd.pjcloud.common.core.util.R;
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.wallet.api.constant.WalletTypeCodeEnum;
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.WalletManageService;
@@ -49,7 +46,7 @@ public class WalletManageController {
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-or-create-wallet")
public R getOrCreateWallet(@RequestParam Long userId, @RequestParam WalletTypeCodeEnum walletTypeCode) {
public R getOrCreateWallet(@RequestParam Long userId, @RequestParam WalletTypeEnum walletTypeCode) {
WalletManageEntity wallet = walletManageService.getOrCreateWallet(userId, walletTypeCode);
if (ObjectUtil.isEmpty(wallet)) {
return R.failed("用户钱包不存在");
@@ -66,7 +63,7 @@ public class WalletManageController {
@Inner
@GetMapping("/get-wallet")
public R getWallet(@RequestParam Long userId, @RequestParam WalletTypeCodeEnum walletTypeCode) {
public R getWallet(@RequestParam Long userId, @RequestParam WalletTypeEnum walletTypeCode) {
WalletManageEntity wallet = walletManageService.getWallet(userId, walletTypeCode);
if (ObjectUtil.isEmpty(wallet)) {
return R.failed("用户钱包不存在");
@@ -1,30 +1,18 @@
package com.bsd.pjcloud.wallet.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.api.dto.WalletSettingDto;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.service.WalletSettingService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 支付设置
*
@@ -46,8 +34,14 @@ public class WalletSettingController {
public R<WalletSettingVo> get() {
return R.ok(walletSettingService.getSetting());
}
/* ************************************* start 远程调用 start ************************************* */
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@GetMapping("/app/get-setting")
public R<WalletSettingVo> appGet() {
return R.ok(walletSettingService.getSetting());
}
/* ************************************* end app end ************************************* */
@Operation(summary = "获取支付配置", description = "获取支付配置")
@GetMapping("")
@@ -3,11 +3,10 @@ package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
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.api.vo.WalletManageVo;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
@@ -34,7 +33,7 @@ public interface WalletManageService extends IService<WalletManageEntity> {
*
* @param userId
*/
WalletManageEntity getOrCreateWallet(@NotNull Long userId, @NotNull WalletTypeCodeEnum walletTypeCode);
WalletManageEntity getOrCreateWallet(@NotNull Long userId, @NotNull WalletTypeEnum walletTypeCode);
/**
* 获取钱包(没有缓存)
@@ -43,7 +42,7 @@ public interface WalletManageService extends IService<WalletManageEntity> {
* @param walletTypeCode
* @return
*/
WalletManageEntity getWallet(@NotNull Long userId, @NotNull WalletTypeCodeEnum walletTypeCode);
WalletManageEntity getWallet(@NotNull Long userId, @NotNull WalletTypeEnum walletTypeCode);
/**
@@ -1,14 +1,12 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import java.io.Serializable;
public interface WalletTypeService extends IService<WalletTypeEntity> {
WalletTypeEntity getByUniqueCode(WalletTypeCodeEnum walletTypeCodeEnum);
WalletTypeEntity getByUniqueCode(WalletTypeEnum walletTypeCodeEnum);
void create(WalletTypeEntity dto);
@@ -14,7 +14,7 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
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.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
@@ -23,7 +23,6 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.MchDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.mapper.WalletActiveMapper;
import com.bsd.pjcloud.wallet.service.MchManageService;
import com.bsd.pjcloud.wallet.service.WalletActiveService;
@@ -61,7 +60,7 @@ public class WalletActiveServiceImpl extends ServiceImpl<WalletActiveMapper, Wal
public void fastCreateCard(WalletActiveDto dto) {
Long count = dto.getCount();
// 查询饭卡钱包类型
WalletTypeEntity walletType = walletTypeService.getByUniqueCode(WalletTypeCodeEnum.CANTEEN);
WalletTypeEntity walletType = walletTypeService.getByUniqueCode(WalletTypeEnum.EAT);
if (ObjectUtil.isEmpty(walletType)) throw new CheckedException("钱包类型不存在");
// 查询商户
MchManageEntity mchManage = mchManageService.getById(dto.getMerchantId());
@@ -15,7 +15,7 @@ import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
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.api.entity.WalletTypeEntity;
@@ -103,7 +103,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
}
@Override
public WalletManageEntity getOrCreateWallet(Long userId, WalletTypeCodeEnum walletTypeCode) {
public WalletManageEntity getOrCreateWallet(Long userId, WalletTypeEnum walletTypeCode) {
WalletTypeEntity walletType = walletTypeService.getByUniqueCode(walletTypeCode);
if (ObjectUtil.isEmpty(walletType)) return null;
LambdaQueryWrapper<WalletManageEntity> walletQuery = new LambdaQueryWrapper<WalletManageEntity>().eq(WalletManageEntity::getUserId, userId).eq(WalletManageEntity::getWalletTypeId, walletType.getId());
@@ -113,7 +113,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
}
@Override
public WalletManageEntity getWallet(Long userId, WalletTypeCodeEnum walletTypeCode) {
public WalletManageEntity getWallet(Long userId, WalletTypeEnum walletTypeCode) {
WalletTypeEntity walletType = walletTypeService.getByUniqueCode(walletTypeCode);
if (ObjectUtil.isEmpty(walletType)) return null;
return baseMapper.selectOne(new LambdaQueryWrapper<WalletManageEntity>()
@@ -18,6 +18,7 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
/**
* 支付设置
@@ -3,14 +3,11 @@ package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.exception.CheckedException;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.io.Serializable;
@@ -31,7 +28,7 @@ public class WalletTypeServiceImpl extends ServiceImpl<WalletTypeMapper, WalletT
@Override
public WalletTypeEntity getByUniqueCode(WalletTypeCodeEnum walletTypeCodeEnum) {
public WalletTypeEntity getByUniqueCode(WalletTypeEnum walletTypeCodeEnum) {
return baseMapper.selectOne(new LambdaQueryWrapper<WalletTypeEntity>()
.eq(WalletTypeEntity::getUniqueCode, walletTypeCodeEnum.getCode())
);