|
|
@@ -0,0 +1,212 @@
|
|
|
+package org.springblade.salesPart.recycling.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.salesPart.recycling.dto.GreenRecyclingDTO;
|
|
|
+import org.springblade.salesPart.recycling.entity.GreenRecyclingItem;
|
|
|
+import org.springblade.salesPart.recycling.service.IGreenRecyclingItemService;
|
|
|
+import org.springblade.salesPart.recycling.service.IGreenRecyclingRecordService;
|
|
|
+import org.springblade.salesPart.recycling.vo.GreenRecyclingRecordVo;
|
|
|
+import org.springblade.salesPart.recycling.wrapper.GreenRecyclingWrapper;
|
|
|
+import org.springblade.system.entity.DictBiz;
|
|
|
+import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.springblade.salesPart.recycling.entity.GreenRecycling;
|
|
|
+import org.springblade.salesPart.recycling.vo.GreenRecyclingVO;
|
|
|
+import org.springblade.salesPart.recycling.service.IGreenRecyclingService;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 余额充值表 控制器
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2025-06-06
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/green/recycling")
|
|
|
+@Api(value = "余额充值表", tags = "余额充值表接口")
|
|
|
+public class GreenRecyclingController extends BladeController {
|
|
|
+
|
|
|
+ private final IGreenRecyclingService greenRecyclingService;
|
|
|
+
|
|
|
+ private final IGreenRecyclingItemService greenRecyclingItemService;
|
|
|
+
|
|
|
+ private final IGreenRecyclingRecordService greenRecyclingRecordService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ */
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "详情", notes = "传入greenRecycling")
|
|
|
+ public R<GreenRecyclingVO> detail(GreenRecycling greenRecycling) {
|
|
|
+ GreenRecycling detail = greenRecyclingService.getOne(Condition.getQueryWrapper(greenRecycling));
|
|
|
+ if (ObjectUtils.isEmpty(detail)) {
|
|
|
+ return R.fail("未找到回收单");
|
|
|
+ }
|
|
|
+ GreenRecyclingVO greenRecyclingVO = GreenRecyclingWrapper.build().entityVO(detail);
|
|
|
+ List<GreenRecyclingItem> greenRecyclingItemList = greenRecyclingItemService.list(new LambdaQueryWrapper<GreenRecyclingItem>()
|
|
|
+ .eq(GreenRecyclingItem::getPid, detail.getId())
|
|
|
+ .eq(GreenRecyclingItem::getTenantId, AuthUtil.getTenantId()));
|
|
|
+ greenRecyclingVO.setGreenRecyclingItemList(greenRecyclingItemList);
|
|
|
+ return R.data(greenRecyclingVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页 余额充值表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入greenRecycling")
|
|
|
+ public R<IPage<GreenRecyclingVO>> list(GreenRecycling greenRecycling, Query query) {
|
|
|
+ IPage<GreenRecycling> pages = greenRecyclingService.page(Condition.getPage(query), Condition.getQueryWrapper(greenRecycling));
|
|
|
+ return R.data(GreenRecyclingWrapper.build().pageVO(pages));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义分页 余额充值表
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入greenRecycling")
|
|
|
+ public R<IPage<GreenRecyclingDTO>> page(GreenRecyclingVO greenRecyclingVO, Query query) {
|
|
|
+ greenRecyclingVO.setTenantId(AuthUtil.getTenantId());
|
|
|
+ IPage<GreenRecyclingDTO> pages = greenRecyclingService.selectGreenRecyclingPage(Condition.getPage(query), greenRecyclingVO);
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增 余额充值表
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "新增", notes = "传入greenRecycling")
|
|
|
+ public R<Long> save(@Valid @RequestBody GreenRecyclingVO greenRecycling) {
|
|
|
+ greenRecycling.setTenantId(AuthUtil.getTenantId());
|
|
|
+ greenRecycling.setCreateUser(AuthUtil.getUserId());
|
|
|
+ greenRecycling.setCreateTime(LocalDateTime.now());
|
|
|
+ return greenRecyclingService.saveAll(greenRecycling);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改 余额充值表
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "修改", notes = "传入greenRecycling")
|
|
|
+ public R update(@Valid @RequestBody GreenRecycling greenRecycling) {
|
|
|
+ return R.status(greenRecyclingService.updateById(greenRecycling));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增或修改 余额充值表
|
|
|
+ */
|
|
|
+ @PostMapping("/submit")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "新增或修改", notes = "传入greenRecycling")
|
|
|
+ public R submit(@Valid @RequestBody GreenRecycling greenRecycling) {
|
|
|
+ return R.status(greenRecyclingService.saveOrUpdate(greenRecycling));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除 余额充值表
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "删除", notes = "传入ids")
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+ return R.status(greenRecyclingService.removeByIds(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除 余额充值表
|
|
|
+ */
|
|
|
+ @PostMapping("/delGreenRecycling")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ public R<GreenRecyclingItem> delGreenRecycling(@RequestParam("id") Long id) {
|
|
|
+ GreenRecycling greenRecycling = new GreenRecycling();
|
|
|
+ greenRecycling.setId(id);
|
|
|
+ greenRecycling.setIsDeleted(1);
|
|
|
+ greenRecycling.setTenantId(AuthUtil.getTenantId());
|
|
|
+ greenRecycling.setUpdateTime(LocalDateTime.now());
|
|
|
+ greenRecycling.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ boolean isUpdate = greenRecyclingService.updateById(greenRecycling);
|
|
|
+ return isUpdate ? R.success("删除成功") : R.fail("删除失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取充值明细表
|
|
|
+ *
|
|
|
+ * @param id 主表id
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/getGreenRecyclingItemList")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ public R<List<GreenRecyclingItem>> getGreenRecyclingItemList(@RequestParam("id") Long id) {
|
|
|
+ List<GreenRecyclingItem> greenRecyclingItemList = greenRecyclingItemService.list(new LambdaQueryWrapper<GreenRecyclingItem>()
|
|
|
+ .eq(GreenRecyclingItem::getPid, id).eq(GreenRecyclingItem::getTenantId, AuthUtil.getTenantId()));
|
|
|
+ return R.data(greenRecyclingItemList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 充值审核
|
|
|
+ *
|
|
|
+ * @param greenRecycling 参数
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/greenRecyclingAudit")
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
+ public R<String> greenRecyclingAudit(@RequestBody GreenRecycling greenRecycling) {
|
|
|
+ greenRecycling.setUpdateTime(LocalDateTime.now());
|
|
|
+ greenRecycling.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ return greenRecyclingService.greenRecyclingAudit(greenRecycling);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从字典中获取明细
|
|
|
+ *
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/greenRecyclingGoods")
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
+ public R<List<DictBiz>> greenRecyclingGoods() {
|
|
|
+ return greenRecyclingService.greenRecyclingGoods();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询余额使用记录
|
|
|
+ *
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/getCustomerGreenRecyclingRecordList")
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
+ public R<List<GreenRecyclingRecordVo>> getCustomerGreenRecyclingRecordList(@RequestBody GreenRecyclingRecordVo greenRecyclingRecordVo) {
|
|
|
+ greenRecyclingRecordVo.setTenantId(AuthUtil.getTenantId());
|
|
|
+ return R.data(greenRecyclingRecordService.getCustomerGreenRecyclingRecordList(greenRecyclingRecordVo));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|