Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-05-16 12:16:17 +08:00
commit 64cbf18a75
5 files changed
+84 -21

No files matched your search

@@ -94,6 +94,18 @@ public class HardAfterSaleController {
}
/* ************************************* end app end ************************************* */
/* ************************************* start android start ************************************* */
@GetMapping(value = "/ad/time-limit-refund")
@Operation(summary = "消费机限时退款")
@Idempotent(expireTime = 5, info = "正在退款中,请勿重复操作")
public R<Boolean> adTimeLintRefund(@RequestParam Long orderId, @RequestParam String reason) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardAfterSaleService.adTimeLintRefund(orderId, reason, user));
}
/* ************************************* end android end ************************************* */
@PostMapping(value = "/admin-refund")
@Operation(summary = "后台退款")
@Idempotent(expireTime = 10, info = "正在退款中,请勿重复操作")
@@ -23,32 +23,21 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
/**
* 申请售后
*
* @param dto
* @return
*/
Long create(HardAfterSaleDto dto);
/**
* 取消售后
*
* @param userId 用户id
* @param afterSaleId 售后id
* @return
*/
Boolean cancelAfterSale(Long userId, Long afterSaleId);
/**
* 获取售后进度
*
* @param id 售后id
*/
List<HardAfterSaleLogEntity> getHistory(Long id);
/**
* 退款
*
* @param afterSaleId 售后id
*/
void refund(Long afterSaleId);
@@ -56,18 +45,11 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
/**
* 同意售后
*
* @param userId 用户id
* @param id 售后id
*/
Boolean agreeAfterSale(Long userId, Long id);
/**
* 拒绝售后
*
* @param userId 用户id
* @param dto
* @return
*/
Boolean disagreeRefund(Long userId, HardDisagreeDto dto);
@@ -78,9 +60,11 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
/**
* 后台退款
*
* @param dto
* @return
*/
Boolean adminRefund(HardAdminRefundDto dto, PjcloudUser user);
/**
* 消费机限时退款
*/
Boolean adTimeLintRefund(Long orderId, String reason, PjcloudUser user);
}
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.service.impl.order;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -65,6 +66,8 @@ import java.util.Map;
@Service
public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, HardAfterSaleEntity> implements HardAfterSaleService {
static private final String TAG = "售后订单";
private final HardAfterSaleLogMapper hardAfterSaleLogMapper;
private final HardOrderService hardOrderService;
@@ -403,6 +406,62 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
return true;
}
/**
* 消费机限时退款
*/
@Override
public Boolean adTimeLintRefund(Long orderId, String reason, PjcloudUser user) {
try {
HardOrderEntity orderDetail = hardOrderService.getById(orderId);
if (ObjectUtil.isEmpty(orderDetail)) throw new RuntimeException("订单不存在");
orderDetail = validateOrderCanRefund(orderDetail.getId());
if (ObjectUtil.isEmpty(orderDetail)) throw new RuntimeException("订单已退款");
// 超过#{hours}小时不能退款
int hours = 4;
if (ObjectUtil.isNotEmpty(orderDetail.getPayTime())) {
if (orderDetail.getPayTime().plusHours(hours).isBefore(LocalDateTime.now())) {
throw new RuntimeException("订单已超过" + hours + "个小时,不能退款");
}
}
// 添加售后订单
String refundCode = "hard|ad_" + orderDetail.getId();
HardAfterSaleEntity saveObj = new HardAfterSaleEntity();
saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType());
saveObj.setStatus(HardSaleStatusEnum.COMPLETE.getStatus());
saveObj.setNo(refundCode);
saveObj.setWay("10");
saveObj.setOrderId(orderDetail.getId());
saveObj.setRefundPrice(orderDetail.getPayPrice());
saveObj.setUserId(orderDetail.getUserId());
saveObj.setAuditUserId(user.getId());
saveObj.setAuditTime(LocalDateTime.now());
saveObj.setApplyReason(reason);
saveObj.setAuditReason(reason);
saveObj.setApplyDescription(reason);
this.save(saveObj);
// 添加售后进度
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
.afterSaleId(saveObj.getId())
.userId(orderDetail.getUserId())
.operateType(HardAfterSaleOperateTypeEnum.ADMIN_REFUND.getType())
.beforeStatus(orderDetail.getOrderStatus())
.afterStatus(HardSaleStatusEnum.COMPLETE.getStatus())
.content(HardSaleStatusEnum.COMPLETE.getContent())
.build();
hardAfterSaleLogMapper.insert(saveLogObj);
// 执行退款
getSelf().refund(saveObj.getId(), "hard|ad");
// 退库存
hardOrderService.fastenerInventory(orderDetail, YesNoEnum.NO);
} catch (Exception e) {
String msg = String.format("|%s|第三方退款错误,dto|%s|", TAG, JSONUtil.toJsonStr(orderId), e);
log.error(msg, e.getMessage());
// 抛出错误
throw new RuntimeException(e.getMessage());
}
return true;
}
private HardAfterSaleServiceImpl getSelf() {
return SpringUtil.getBean(getClass());
}
@@ -20,6 +20,8 @@ public class MchManageDto extends MchManageEntity {
private List<Long> notIds;
private List<String> typesList;
private String type;
private Boolean parentIsNull = true;
@@ -85,6 +85,12 @@
<if test="dto.name != null">
and a.name like concat('%', #{dto.name}, '%')
</if>
<if test="dto.typesList != null and dto.typesList.size() != 0">
and a.types in
<foreach collection="dto.typesList" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
and a.dept_id in
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">