package com.bosshand.virgo.api.controller; import com.bosshand.virgo.api.model.Payment; import com.bosshand.virgo.api.service.PaymentService; import com.bosshand.virgo.core.response.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.List; import java.util.Map; @RestController @RequestMapping({"payment"}) @Api(tags = {"账单缴费管理"}) public class PaymentController { @Autowired PaymentService paymentService; @ApiOperation("分页获取") @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST) public Response list(@RequestBody Payment payment, @PathVariable int currPage, @PathVariable int pageSize) { int totalCount = paymentService.getTotalCount(payment); List dataList = paymentService.getLimit(payment, currPage, pageSize); Map result = new HashMap<>(); result.put("dataList", dataList); result.put("totalCount", totalCount); return Response.ok(result); } @ApiOperation("更新状态") @RequestMapping(value = "/updateStatus/{id}/{status}", method = RequestMethod.PUT) public Response update(@PathVariable long id, @PathVariable Integer status) { paymentService.updateStatus(id, status); return Response.ok(); } @ApiOperation("生成账单") @RequestMapping(value = "/generate/{clauseId}", method = RequestMethod.GET) public Response generate(@PathVariable long clauseId) { List list = paymentService.getContractId(clauseId); if (list != null) { return Response.fail(200001, "合同下账单已生成好了!"); } paymentService.generate(clauseId); return Response.ok("账单已生成!"); } }