feat:h5退款接口
This commit is contained in:
1 parent
964b9e87f6
commit
37a88b1d53
13 files changed
+254
-81
No files matched your search
+16
@@ -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
@@ -13,4 +13,9 @@ public class HardOrderDto extends HardOrderEntity {
|
||||
*/
|
||||
private List<Long> userIds;
|
||||
|
||||
/**
|
||||
* 是否查询购物车列表
|
||||
*/
|
||||
private Boolean isFindCarList = false;
|
||||
|
||||
}
|
||||
+7
-1
@@ -6,6 +6,8 @@ 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, BaseMchInterface {
|
||||
/**
|
||||
@@ -25,7 +27,6 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B
|
||||
/**
|
||||
* 商户相关
|
||||
*/
|
||||
|
||||
private String merchantName;
|
||||
|
||||
private String logoPic;
|
||||
@@ -36,4 +37,9 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserInterface, B
|
||||
private String hardName;
|
||||
|
||||
private String hardType;
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
*/
|
||||
private List<HardCarVo> carList;
|
||||
}
|
||||
+33
@@ -44,6 +44,39 @@ 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) {
|
||||
|
||||
+1
@@ -50,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));
|
||||
}
|
||||
|
||||
|
||||
+13
@@ -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();
|
||||
}
|
||||
}
|
||||
+15
@@ -16,6 +16,21 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
|
||||
HardAfterSaleVo join(HardAfterSaleDto dto);
|
||||
|
||||
/**
|
||||
* 申请售后
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Long create(HardAfterSaleDto dto);
|
||||
|
||||
/**
|
||||
* 取消售后
|
||||
* @param userId 用户id
|
||||
* @param afterSaleId 售后id
|
||||
* @return
|
||||
*/
|
||||
Boolean cancelAfterSale(Long userId, Long afterSaleId);
|
||||
|
||||
/**
|
||||
* 获取售后进度
|
||||
*
|
||||
|
||||
+76
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -19,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;
|
||||
@@ -86,6 +88,45 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long create(HardAfterSaleDto dto) {
|
||||
HardOrderVo order = validateOrderCanRefund(dto.getOrderId());
|
||||
HardAfterSaleEntity afterSale = 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);
|
||||
@@ -225,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());
|
||||
}
|
||||
|
||||
+11
-1
@@ -11,6 +11,7 @@ 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;
|
||||
@@ -26,6 +27,7 @@ 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;
|
||||
@@ -72,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;
|
||||
@@ -80,7 +83,6 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
private final RemoteWalletSettingService walletSettingService;
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteDeptService deptService;
|
||||
private final HardParentCarServiceImpl hardParentCarServiceImpl;
|
||||
|
||||
@Override
|
||||
public Page<HardOrderVo> pageJoin(Page page, HardOrderDto dto) {
|
||||
@@ -110,6 +112,14 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user