| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.model.TInvoiceInformation; |
| | | import com.ruoyi.account.service.TInvoiceInformationService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/t-invoice-information") |
| | | public class TInvoiceInformationController { |
| | | |
| | | @Resource |
| | | private TInvoiceInformationService invoiceInformationService; |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getInvoiceInformationList") |
| | | @ApiOperation(value = "获取开票抬头数据列表", tags = {"小程序-充电发票"}) |
| | | public AjaxResult<List<TInvoiceInformation>> getInvoiceInformationList(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | List<TInvoiceInformation> list = invoiceInformationService.list(new LambdaQueryWrapper<TInvoiceInformation>().eq(TInvoiceInformation::getAppUserId, userId).eq(TInvoiceInformation::getDelFlag, 0)); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/addInvoiceInformation") |
| | | @ApiOperation(value = "添加开票抬头数据", tags = {"小程序-充电发票"}) |
| | | public AjaxResult addInvoiceInformation(@RequestBody TInvoiceInformation invoiceInformation){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | //如果当前是默认抬头,则需要去除其他的默认配置 |
| | | if(1 == invoiceInformation.getIsDefault()){ |
| | | TInvoiceInformation one = invoiceInformationService.getOne(new LambdaQueryWrapper<TInvoiceInformation>().eq(TInvoiceInformation::getDelFlag, 0) |
| | | .eq(TInvoiceInformation::getIsDefault, 1).eq(TInvoiceInformation::getAppUserId, userId)); |
| | | if(null != one){ |
| | | one.setIsDefault(0); |
| | | invoiceInformationService.updateById(one); |
| | | } |
| | | } |
| | | |
| | | invoiceInformation.setAppUserId(userId); |
| | | invoiceInformationService.save(invoiceInformation); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getInvoiceInformationInfo/{id}") |
| | | @ApiOperation(value = "获取开票抬头详情数据", tags = {"小程序-充电发票"}) |
| | | public AjaxResult<TInvoiceInformation> getInvoiceInformationInfo(@PathVariable String id){ |
| | | TInvoiceInformation information = invoiceInformationService.getById(id); |
| | | return AjaxResult.success(information); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/editInvoiceInformation") |
| | | @ApiOperation(value = "编辑开票抬头数据", tags = {"小程序-充电发票"}) |
| | | public AjaxResult editInvoiceInformation(@RequestBody TInvoiceInformation invoiceInformation){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | //如果当前是默认抬头,则需要去除其他的默认配置 |
| | | if(1 == invoiceInformation.getIsDefault()){ |
| | | TInvoiceInformation one = invoiceInformationService.getOne(new LambdaQueryWrapper<TInvoiceInformation>().eq(TInvoiceInformation::getDelFlag, 0) |
| | | .eq(TInvoiceInformation::getIsDefault, 1).eq(TInvoiceInformation::getAppUserId, userId)); |
| | | if(null != one && !one.getId().equals(invoiceInformation.getId())){ |
| | | one.setIsDefault(0); |
| | | invoiceInformationService.updateById(one); |
| | | } |
| | | } |
| | | invoiceInformationService.updateById(invoiceInformation); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |
| | | |