diff --git a/jeecg-boot-module/jeecg-module-service/src/main/java/org/jeecg/modules/system/controller/CommissionRefundController.java b/jeecg-boot-module/jeecg-module-service/src/main/java/org/jeecg/modules/system/controller/CommissionRefundController.java new file mode 100644 index 0000000..1b0820f --- /dev/null +++ b/jeecg-boot-module/jeecg-module-service/src/main/java/org/jeecg/modules/system/controller/CommissionRefundController.java @@ -0,0 +1,161 @@ +package org.jeecg.modules.system.controller; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.modules.system.dto.CommissionRefundUpdateDTO; +import org.jeecg.modules.system.entity.CardDeliveryPerson; +import org.jeecg.modules.system.entity.CommissionRefund; +import org.jeecg.modules.system.service.ICommissionRefundService; +import org.jeecg.modules.system.vo.CardDeliveryPersonVO; +import org.jeecg.modules.system.vo.CommissionRefundVO; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Description: 佣金返还 + * @Author: jeecg-boot + * @Date: 2025-09-26 + * @Version: V1.0 + */ +@Tag(name="佣金返还") +@RestController +@RequestMapping("/system/commissionRefund") +@Slf4j +public class CommissionRefundController extends JeecgController { + @Autowired + private ICommissionRefundService commissionRefundService; + + /** + * 分页列表查询 + * + * @param commissionRefund + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "佣金返还-分页列表查询") + @Operation(summary="佣金返还-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(CommissionRefund commissionRefund, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + + + // 参数校验 + if (pageNo <= 0) { + pageNo = 1; + } + if (pageSize <= 0 || pageSize > 100) { + pageSize = 10; + } + + try { + // 构建查询条件 + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(commissionRefund, req.getParameterMap()); + + // 分页查询 + Page page = new Page<>(pageNo, pageSize); + IPage pageList = commissionRefundService.page(page, queryWrapper); + + // 转换为VO对象 + Page voPage = new Page<>(pageList.getCurrent(), pageList.getSize(), pageList.getTotal()); + List voList = pageList.getRecords().stream().map(record -> { + CommissionRefundVO vo = new CommissionRefundVO(); + BeanUtils.copyProperties(record, vo); + //处理时间 + if (record.getRefundableTime() != null){ + vo.setRefundableTime(DateUtil.format(record.getRefundableTime(), "yyyy-MM-dd HH:mm:ss")); + } + if (record.getCardAmountTime() != null){ + vo.setCardAmountTime(DateUtil.format(record.getCardAmountTime(), "yyyy-MM-dd HH:mm:ss")); + } + if (record.getCardApplicationTime() != null){ + vo.setCardApplicationTime(DateUtil.format(record.getCardApplicationTime(), "yyyy-MM-dd HH:mm:ss")); + } + if (record.getReservationTime() != null){ + vo.setReservationTime(DateUtil.format(record.getReservationTime(), "yyyy-MM-dd HH:mm:ss")); + } + return vo; + }).collect(Collectors.toList()); + + voPage.setRecords(voList); + + return Result.OK(voPage); + } catch (Exception e) { + log.error("查询佣金返还列表失败", e); + return Result.error("查询失败:" + e.getMessage()); + } + } + + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "佣金返还-通过id查询") + @Operation(summary="佣金返还-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + CommissionRefund commissionRefund = commissionRefundService.getById(id); + if(commissionRefund==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(commissionRefund); + } + + /** + * 导出excel + * + * @param request + * @param commissionRefund + */ + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, CommissionRefund commissionRefund) { + return super.exportXls(request, commissionRefund, CommissionRefund.class, "佣金返还"); + } + + /** + * 更新各操作返利 + * + * @param dto + * @return + */ + @RequestMapping(value = "/updateAmount", method = RequestMethod.POST) + public Result updateAmount(@RequestBody CommissionRefundUpdateDTO dto) { + if (StringUtils.isBlank(dto.getId())){ + return Result.error("ID不能为空"); + } + if (dto.getAmount() == null){ + return Result.error("金额不能为空"); + } + if (StringUtils.isBlank(dto.getOperationType())){ + return Result.error("操作类型不能为空"); + } + commissionRefundService.updateAmount(dto); + return Result.OK("操作成功"); + } +}