| | |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.returnobj.vo.AfterSaleReturnPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.returnobj.vo.AfterSaleReturnRespVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.returnobj.vo.AfterSaleReturnSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.returnobj.vo.AfterSaleRefundConfirmReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.returnobj.AfterSaleReturnDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.returnobj.AfterSaleReturnItemDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.ticket.AfterSaleTicketDO; |
| | | import cn.iocoder.yudao.module.aftersales.service.returnobj.AfterSaleReturnService; |
| | | import cn.iocoder.yudao.module.aftersales.service.ticket.AfterSaleTicketService; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | import java.util.*; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private AfterSaleReturnService returnService; |
| | | |
| | | @Resource |
| | | private AfterSaleTicketService ticketService; |
| | | |
| | | @Resource |
| | | private CrmCustomerApi customerApi; |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/complete-refund") |
| | | @Operation(summary = "确认外部退款/换货完成") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:return:refund')") |
| | | public CommonResult<Boolean> completeRefund(@Valid @RequestBody AfterSaleRefundConfirmReqVO reqVO) { |
| | | returnService.confirmRefundCompleted(reqVO.getId(), reqVO.getActualRefundPrice(), reqVO.getVoucherNo()); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/cancel") |
| | | @Operation(summary = "取消尚未入库或退款的退货申请") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:return:cancel')") |
| | | public CommonResult<Boolean> cancelReturn(@RequestParam("id") Long id) { |
| | | returnService.cancelReturn(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得退货申请") |
| | | @Parameter(name = "id", description = "退货申请编号", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:return:query')") |
| | | public CommonResult<AfterSaleReturnRespVO> getReturn(@RequestParam("id") Long id) { |
| | | AfterSaleReturnDO returnDO = returnService.getReturn(id); |
| | | List<AfterSaleReturnItemDO> items = returnService.getReturnItemListByReturnId(id); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得退货申请分页") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:return:query')") |
| | | public CommonResult<PageResult<AfterSaleReturnRespVO>> getReturnPage(@Valid AfterSaleReturnPageReqVO pageReqVO) { |
| | | PageResult<AfterSaleReturnDO> pageResult = returnService.getReturnPage(pageReqVO, getLoginUserId()); |
| | | List<AfterSaleReturnRespVO> list = buildReturnDetailList(pageResult.getList()); |
| | |
| | | // 批量加载客户名称 |
| | | Set<Long> customerIds = convertSet(returnList, AfterSaleReturnDO::getCustomerId); |
| | | Map<Long, CrmCustomerRespDTO> customerMap = customerApi.getCustomerMap(customerIds); |
| | | // 批量加载关联工单的销售订单号(反显订单信息) |
| | | Set<Long> ticketIds = convertSet(returnList, AfterSaleReturnDO::getTicketId); |
| | | Map<Long, AfterSaleTicketDO> ticketMap = convertMap(ticketService.getTicketList(ticketIds), AfterSaleTicketDO::getId); |
| | | // 拼装名称字段 |
| | | return BeanUtils.toBean(returnList, AfterSaleReturnRespVO.class, vo -> { |
| | | CrmCustomerRespDTO customer = customerMap.get(vo.getCustomerId()); |
| | | if (customer != null) vo.setCustomerName(customer.getName()); |
| | | AfterSaleTicketDO ticket = ticketMap.get(vo.getTicketId()); |
| | | if (ticket != null) vo.setSaleOrderNo(ticket.getSaleOrderNo()); |
| | | }); |
| | | } |
| | | |