| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.account.api.dto.ChargingCardAllocateDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardAuthDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardBalanceDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardDeductDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardExcelDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardQueryDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardSaveDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardStatusDTO; |
| | | import com.ruoyi.account.api.model.TChargingCard; |
| | | import com.ruoyi.account.api.vo.ChargingCardAllocateVO; |
| | | import com.ruoyi.account.api.vo.ChargingCardDeductVO; |
| | | import com.ruoyi.account.service.TChargingCardService; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "卡片管理") |
| | |
| | | return R.ok(chargingCardService.deleteCards(ids)); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量解绑车队(清空卡片车队归属,返回实际解绑数量)") |
| | | @RequiresPermissions(value = {"/chargingCard/unbind"}, logical = Logical.OR) |
| | | @PutMapping("/unbind-fleet") |
| | | public R<Integer> unbindFleet(@RequestBody List<Long> ids) { |
| | | return R.ok(chargingCardService.unbindFleet(ids)); |
| | | } |
| | | |
| | | @ApiOperation(value = "更新卡片启用状态") |
| | | @RequiresPermissions(value = {"/chargingCard/status"}, logical = Logical.OR) |
| | | @PutMapping("/status") |
| | |
| | | return R.ok(chargingCardService.updateStatus(dto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量更新卡片余额") |
| | | @RequiresPermissions(value = {"/chargingCard/balance"}, logical = Logical.OR) |
| | | @PutMapping("/balance") |
| | | public R<Boolean> balance(@RequestBody ChargingCardBalanceDTO dto) { |
| | | return R.ok(chargingCardService.updateBalance(dto)); |
| | | @ApiOperation(value = "额度分配概览(公司总账户余额、可分配余额)") |
| | | @RequiresPermissions(value = {"/chargingCard/allocate"}, logical = Logical.OR) |
| | | @GetMapping("/allocate-overview") |
| | | public R<ChargingCardAllocateVO> allocateOverview(@RequestParam("companyId") Integer companyId) { |
| | | return R.ok(chargingCardService.getAllocateOverview(companyId)); |
| | | } |
| | | |
| | | @ApiOperation(value = "卡片额度分配(公司可用余额划入卡片余额)") |
| | | @RequiresPermissions(value = {"/chargingCard/allocate"}, logical = Logical.OR) |
| | | @PostMapping("/allocate") |
| | | public R<ChargingCardAllocateVO> allocate(@RequestBody ChargingCardAllocateDTO dto) { |
| | | return R.ok(chargingCardService.allocateQuota(dto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出卡片") |
| | |
| | | public R<ChargingCardDeductVO> deductForCharging(@RequestBody ChargingCardDeductDTO dto) { |
| | | return R.ok(chargingCardService.deductBalanceForCharging(dto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量查询已存在充电扣款流水的订单号(内部)") |
| | | @PostMapping("/inner/deducted-order-codes") |
| | | public R<List<String>> listDeductedOrderCodes(@RequestBody List<String> orderCodes) { |
| | | return R.ok(chargingCardService.listDeductedOrderCodes(orderCodes)); |
| | | } |
| | | |
| | | @ApiOperation(value = "按公司查询卡片列表(内部):公司详情-充电用户信息聚合使用") |
| | | @GetMapping("/inner/list-by-company") |
| | | public R<List<TChargingCard>> listByCompany(@RequestParam("companyId") Integer companyId) { |
| | | return R.ok(chargingCardService.listByCompany(companyId)); |
| | | } |
| | | |
| | | @ApiOperation(value = "锁定卡片账户余额(内部):刷卡充电申请实扣冻结,余额不足返回失败") |
| | | @PostMapping("/inner/lock-balance") |
| | | public R<BigDecimal> lockBalance(@RequestParam("cardId") Long cardId, |
| | | @RequestParam("amount") BigDecimal amount) { |
| | | try { |
| | | return R.ok(chargingCardService.lockBalance(cardId, amount)); |
| | | } catch (RuntimeException ex) { |
| | | return R.fail(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "结算卡片账户余额(内部):解锁锁定额并按实扣扣减,订单号幂等") |
| | | @PostMapping("/inner/settle-charging") |
| | | public R<ChargingCardDeductVO> settleForCharging(@RequestBody ChargingCardDeductDTO dto) { |
| | | return R.ok(chargingCardService.settleBalanceForCharging(dto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "释放卡片锁定金额(内部):未产生消费/订单回滚时使用") |
| | | @PostMapping("/inner/unlock-balance") |
| | | public R<BigDecimal> unlockBalance(@RequestParam("cardId") Long cardId, |
| | | @RequestParam("amount") BigDecimal amount) { |
| | | try { |
| | | return R.ok(chargingCardService.unlockBalance(cardId, amount)); |
| | | } catch (RuntimeException ex) { |
| | | return R.fail(ex.getMessage()); |
| | | } |
| | | } |
| | | } |