From 45f1ecffcee4a9f9128fca368382f0cbcf44c577 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Mon, 27 Dec 2021 17:36:58 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AF=8F=E4=B8=AA?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=9A=84bootstrap.yml=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=9C=AC=E5=9C=B0=E6=B5=8B=E8=AF=95=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E9=89=B4=E6=9D=83=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=9C=AC=E5=9C=B0=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap.yml | 4 +- ruoyi-auth/src/main/resources/bootstrap.yml | 4 +- .../com/xhpc/gateway/filter/AuthFilter.java | 69 +++++++++---------- .../src/main/resources/bootstrap.yml | 6 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- .../src/main/resources/bootstrap.yml | 4 +- 15 files changed, 62 insertions(+), 65 deletions(-) diff --git a/evcs-modules/evcs-core/src/main/resources/bootstrap.yml b/evcs-modules/evcs-core/src/main/resources/bootstrap.yml index 200f8415..1cd5322f 100644 --- a/evcs-modules/evcs-core/src/main/resources/bootstrap.yml +++ b/evcs-modules/evcs-core/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-auth/src/main/resources/bootstrap.yml b/ruoyi-auth/src/main/resources/bootstrap.yml index e7e2a0b1..bd7dd225 100644 --- a/ruoyi-auth/src/main/resources/bootstrap.yml +++ b/ruoyi-auth/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java index a6d18156..84508f74 100644 --- a/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java +++ b/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java @@ -1,11 +1,9 @@ package com.xhpc.gateway.filter; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.xhpc.common.core.constant.CacheConstants; import com.xhpc.common.core.constant.Constants; import com.xhpc.common.core.domain.R; -import com.xhpc.common.core.utils.ServletUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.redis.service.RedisService; import com.xhpc.gateway.config.properties.IgnoreWhiteProperties; @@ -16,7 +14,6 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.Ordered; import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.data.redis.core.ValueOperations; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; @@ -25,8 +22,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; -import javax.annotation.Resource; - /** * 网关鉴权 * @@ -34,6 +29,7 @@ import javax.annotation.Resource; */ @Component public class AuthFilter implements GlobalFilter, Ordered { + private static final Logger log = LoggerFactory.getLogger(AuthFilter.class); private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60; @@ -42,45 +38,46 @@ public class AuthFilter implements GlobalFilter, Ordered { @Autowired private IgnoreWhiteProperties ignoreWhite; - @Resource(name = "stringRedisTemplate") - private ValueOperations sops; +// @Resource(name = "stringRedisTemplate") +// private ValueOperations sops; @Autowired private RedisService redisService; @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + String url = exchange.getRequest().getURI().getPath(); - // 跳过不需要验证的路径 - if (StringUtils.matches(url, ignoreWhite.getWhites())) { - return chain.filter(exchange); - } - String token = getToken(exchange.getRequest()); - if (StringUtils.isBlank(token)) { - return setUnauthorizedResponse(exchange, "令牌不能为空"); - } - String userStr = sops.get(getTokenKey(token)); - if (StringUtils.isNull(userStr)) { - userStr = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); - if (StringUtils.isNull(userStr)) { - return setUnauthorizedResponse(exchange, "登录状态已过期"); - } - } - JSONObject obj = JSONObject.parseObject(userStr); - String userid = obj.getString("userid"); - String username = obj.getString("username"); - if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) { - return setUnauthorizedResponse(exchange, "令牌验证失败"); - } +// // 跳过不需要验证的路径 +// if (StringUtils.matches(url, ignoreWhite.getWhites())) { +// return chain.filter(exchange); +// } +// String token = getToken(exchange.getRequest()); +// if (StringUtils.isBlank(token)) { +// return setUnauthorizedResponse(exchange, "令牌不能为空"); +// } +// String userStr = sops.get(getTokenKey(token)); +// if (StringUtils.isNull(userStr)) { +// userStr = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); +// if (StringUtils.isNull(userStr)) { +// return setUnauthorizedResponse(exchange, "登录状态已过期"); +// } +// } +// JSONObject obj = JSONObject.parseObject(userStr); +// String userid = obj.getString("userid"); +// String username = obj.getString("username"); +// if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) { +// return setUnauthorizedResponse(exchange, "令牌验证失败"); +// } +// +// // 设置过期时间 +// redisService.expire(getTokenKey(token), EXPIRE_TIME); +// // 设置用户信息到请求 +// ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid) +// .header(CacheConstants.DETAILS_USERNAME, ServletUtils.urlEncode(username)).build(); +// ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); - // 设置过期时间 - redisService.expire(getTokenKey(token), EXPIRE_TIME); - // 设置用户信息到请求 - ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid) - .header(CacheConstants.DETAILS_USERNAME, ServletUtils.urlEncode(username)).build(); - ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); - - return chain.filter(mutableExchange); + return chain.filter(exchange); } private Mono setUnauthorizedResponse(ServerWebExchange exchange, String msg) { diff --git a/ruoyi-gateway/src/main/resources/bootstrap.yml b/ruoyi-gateway/src/main/resources/bootstrap.yml index 2a75caef..9bc1a55c 100644 --- a/ruoyi-gateway/src/main/resources/bootstrap.yml +++ b/ruoyi-gateway/src/main/resources/bootstrap.yml @@ -16,10 +16,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 @@ -35,7 +35,7 @@ spring: datasource: ds1: nacos: - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 dataId: sentinel-ruoyi-gateway groupId: DEFAULT_GROUP data-type: json diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml index 6c2cdb09..f1b6134d 100644 --- a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml index de9b5154..48d8988c 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml index cce34971..65b833c4 100644 --- a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml index 6881c7e6..9f189be1 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml index e61a355f..4a049625 100644 --- a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml +++ b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-general/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-general/src/main/resources/bootstrap.yml index 8c383dbe..d1cc6f1e 100644 --- a/xhpc-modules/xhpc-general/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-general/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-order/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-order/src/main/resources/bootstrap.yml index dde4d751..5571b791 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-order/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml index 8f3891cf..339e2e7c 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-payment/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml index df3a5bc9..8c12f14b 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-power-pile/src/main/resources/bootstrap.yml @@ -18,10 +18,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml index 38aa8d6e..c570dc4f 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-user/src/main/resources/bootstrap.yml @@ -14,10 +14,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml index c6ad3564..35c8095c 100644 --- a/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml @@ -16,10 +16,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 config: # 配置中心地址 - server-addr: 172.31.183.135:8848 + server-addr: 127.0.0.1:8848 # 配置文件格式 file-extension: yml # 共享配置 From c1a257808a51847be2cd431f4ee792408481e955 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Wed, 29 Dec 2021 14:46:24 +0800 Subject: [PATCH 02/14] =?UTF-8?q?Post=20/api/invoice=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=94=A8=E6=88=B7=E6=89=80=E8=A6=81=E5=BC=80?= =?UTF-8?q?=E7=9A=84=E5=8F=91=E7=A5=A8=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?,=E4=BB=A5=E5=8F=8A=E4=BD=BF=E4=BB=A3=E7=A0=81=E7=AC=A6?= =?UTF-8?q?=E5=90=88=E8=A7=84=E8=8C=83=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invoice/api/XhpcInvoiceApiController.java | 28 +++ .../InvoiceMapHistoryOrderStatusConst.java | 27 +++ .../InvoiceStatusConst.java | 2 +- .../controller/XhpcInvoiceController.java | 2 +- .../domain/InvoiceHistoryRecordsResponse.java | 2 + .../domain/SaveInvoiceInfoRequest.java | 57 +++++ .../mapper/XhpcHistoryOrderMapper.java | 11 + .../XhpcInvoiceMapHistoryOrderMapper.java | 21 ++ .../invoice/mapper/XhpcInvoiceMapper.java | 22 ++ .../com/xhpc/invoice/pojo/XhpcInvoice.java | 2 +- .../pojo/XhpcInvoiceMapHistoryOrder.java | 2 +- .../invoice/service/XhpcInvoiceService.java | 23 ++ .../service/impl/XhpcInvoiceServiceImpl.java | 103 +++++++- .../mapper/XhpcHistoryOrderMapper.xml | 14 ++ .../XhpcInvoiceMapHistoryOrderMapper.xml | 47 +++- .../resources/mapper/XhpcInvoiceMapper.xml | 228 ++++++++++++++++-- 16 files changed, 570 insertions(+), 21 deletions(-) create mode 100644 xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceMapHistoryOrderStatusConst.java rename xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/{constPackage => constant}/InvoiceStatusConst.java (92%) create mode 100644 xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/SaveInvoiceInfoRequest.java diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java index 35198b86..6a375e8e 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java @@ -22,6 +22,34 @@ public class XhpcInvoiceApiController extends BaseController { @Resource XhpcInvoiceService xhpcInvoiceService; + /** + * 查询用户显示小红点,查询用户有几个未读的已开发票 + * + * @author WH + * @date 2021/12/28 18:51 + * @since version-1.0 + */ + @GetMapping("/user/no-read") + public AjaxResult findNotReadCount(@RequestParam Long creatorId, @RequestParam Integer creatorType) { + + Long notRead = xhpcInvoiceService.findNotReadCount(creatorId, creatorType); + return AjaxResult.success(notRead); + } + + /** + * 保存用户所要开的发票信息 + * + * @author WH + * @date 2021/12/28 14:54 + * @since version-1.0 + */ + @PostMapping() + public AjaxResult saveInvoiceInfo(@RequestBody SaveInvoiceInfoRequest saveInvoiceInfoRequest) throws Exception { + + xhpcInvoiceService.saveInvoiceInfo(saveInvoiceInfoRequest); + return AjaxResult.success(); + } + /** * 查询用户开发票的历史记录 * diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceMapHistoryOrderStatusConst.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceMapHistoryOrderStatusConst.java new file mode 100644 index 00000000..185c5333 --- /dev/null +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceMapHistoryOrderStatusConst.java @@ -0,0 +1,27 @@ +package com.xhpc.invoice.constant; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 发票所包含的订单状态的常量类 + * + * @author WH + * @date 2021/12/29 10:34 + * @since version-1.0 + */ +@Data +@NoArgsConstructor +public class InvoiceMapHistoryOrderStatusConst { + + /** + * 已被发票包含,即锁定 + */ + public static final Integer LOCK = 0; + + /** + * 解除发票包含关系,即解锁 + */ + public static final Integer UNLOCK = 0; + +} diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constPackage/InvoiceStatusConst.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceStatusConst.java similarity index 92% rename from xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constPackage/InvoiceStatusConst.java rename to xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceStatusConst.java index 8615d4af..111f5272 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constPackage/InvoiceStatusConst.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/constant/InvoiceStatusConst.java @@ -1,4 +1,4 @@ -package com.xhpc.invoice.constPackage; +package com.xhpc.invoice.constant; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java index c9126f51..239dd00f 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java @@ -2,7 +2,7 @@ package com.xhpc.invoice.controller; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; -import com.xhpc.invoice.constPackage.InvoiceStatusConst; +import com.xhpc.invoice.constant.InvoiceStatusConst; import com.xhpc.invoice.domain.AllInvoiceOrdersRequest; import com.xhpc.invoice.domain.AllInvoiceOrdersResponse; import com.xhpc.invoice.domain.InvoiceToUserRequest; diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/InvoiceHistoryRecordsResponse.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/InvoiceHistoryRecordsResponse.java index 3656ed30..a8c47abb 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/InvoiceHistoryRecordsResponse.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/InvoiceHistoryRecordsResponse.java @@ -35,6 +35,8 @@ public class InvoiceHistoryRecordsResponse { private Integer status; @JsonProperty("invoicingMoney") private BigDecimal invoicingMoney; + @JsonProperty("isRead") + private Integer isRead; } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/SaveInvoiceInfoRequest.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/SaveInvoiceInfoRequest.java new file mode 100644 index 00000000..6cd389be --- /dev/null +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/SaveInvoiceInfoRequest.java @@ -0,0 +1,57 @@ +package com.xhpc.invoice.domain; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.List; + +/** + * POST /invoice/接口的请求包装类 + * + * @author WH + * @date 2021/12/28 14:29 + * @since version-1.0 + */ +@NoArgsConstructor +@Data +public class SaveInvoiceInfoRequest { + + + @JsonProperty("receiveEmail") + private String receiveEmail; + @JsonProperty("titleType") + private Integer titleType; + @JsonProperty("titleContent") + private String titleContent; + @JsonProperty("dutyNumber") + private String dutyNumber; + @JsonProperty("invoiceContent") + private String invoiceContent; + @JsonProperty("invoiceMoney") + private BigDecimal invoiceMoney; + @JsonProperty("firmAddress") + private String firmAddress; + @JsonProperty("firmPhone") + private String firmPhone; + @JsonProperty("firmBank") + private String firmBank; + @JsonProperty("firmBankAccount") + private String firmBankAccount; + @JsonProperty("isShowDate") + private Integer isShowDate; + @JsonProperty("userNotes") + private String userNotes; + @JsonProperty("creatorId") + private Long creatorId; + @JsonProperty("creatorType") + private Integer creatorType; + @JsonProperty("creator") + private String creator; + @JsonProperty("createTime") + private String createTime; + @JsonProperty("historyOrderIds") + private List historyOrderIds; + +} diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcHistoryOrderMapper.java index ca16faf1..a32da202 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcHistoryOrderMapper.java @@ -39,4 +39,15 @@ public interface XhpcHistoryOrderMapper { */ Long findAllOrdersByCondition(@Param("invoicedOrdersRequest") InvoicedOrdersRequest invoicedOrdersRequest, @Param("lockOrderNumberList") List lockOrderNumberList); + /** + * 查询指定id的历史订单 + * + * @param historyOrderIds 历史订单id集合 + * @return 历史订单 + * @author WH + * @date 2021/12/28 17:47 + * @since version-1.0 + */ + List findById(List historyOrderIds); + } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapHistoryOrderMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapHistoryOrderMapper.java index 9603f691..c707e43f 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapHistoryOrderMapper.java @@ -62,4 +62,25 @@ public interface XhpcInvoiceMapHistoryOrderMapper { */ List findLockOrdersByUserIdAndUserType(InvoicedOrdersRequest invoicedOrdersRequest); + /** + * 解除锁定的用户历史订单 + * + * @param invoiceId 发票id + * @author WH + * @date 2021/12/29 11:00 + * @since version-1.0 + */ + void unlockHistoryOrdersByInvoiceId(Long invoiceId); + + /** + * 查询该发票关联表中,该历史订单是否已经被存储且被锁定 + * + * @param historyOrderIds 历史订单id集合 + * @return 返回被某发票包含,且已经锁定的历史订单记录 + * @author WH + * @date 2021/12/29 14:30 + * @since version-1.0 + */ + List getLockedOnesByHistoryOrderId(List historyOrderIds); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java index 9f51f66b..7d612d8c 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java @@ -136,6 +136,7 @@ public interface XhpcInvoiceMapper { * * @param creatorId 用户id * @param creatorType 用户类型 + * * @return 用户发票条数 * @author WH * @date 2021/12/27 16:47 @@ -143,5 +144,26 @@ public interface XhpcInvoiceMapper { */ Long getUserInvoiceItemsByCreatorIdAndCreatorType(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType); + /** + * 插入发票记录,获取所插入的发票记录的发票id(会被放置到实体类id属性中) + * + * @param xhpcInvoice 发票记录 + * @author WH + * @date 2021/12/28 15:09 + * @since version-1.0 + */ + void insertSelectiveAndReturnId(XhpcInvoice xhpcInvoice); + + /** + * 查找指定用户开了的发票未读的数量 + * + * @param creatorId 用户id + * @param creatorType 用户类型 + * @return 返回发票未读的数量 + * @author WH + * @date 2021/12/28 20:31 + * @since version-1.0 + */ + Long findNotReadCount(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java index 4bfa93ce..aa635593 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java @@ -145,7 +145,7 @@ public class XhpcInvoice implements Serializable { private Date updateTime; /** - * 是否已经阅读(默认0表示没有阅读,1表示已经阅读) + * 是否已经阅读(默认未空,0表示没有阅读,1表示已经阅读) */ private Integer isRead; diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java index 7b955be7..278f745c 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java @@ -82,7 +82,7 @@ public class XhpcInvoiceMapHistoryOrder implements Serializable { /** * 该发票所选中的历史订单是否被锁定 */ - private Integer delLock; + private Integer lockFlag; /** * 逻辑删除字段 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java index a3821193..92cd12d4 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java @@ -110,4 +110,27 @@ public interface XhpcInvoiceService { */ InvoiceHistoryRecordsResponse selectInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest); + /** + * 将用户申请的发票信息,保存到数据库中 + * + * @param saveInvoiceInfoRequest 发票信息 + * @throws Exception 传入发票金额参数与内部该发票所包含的所有订单金额参数不一致出现,出现此异常 + * @author WH + * @date 2021/12/28 14:33 + * @since version-1.0 + */ + void saveInvoiceInfo(SaveInvoiceInfoRequest saveInvoiceInfoRequest) throws Exception; + + /** + * 查询指定用户没有查看的已开的发票的数量,即该用户有几个未读发票 + * + * @param creatorId 用户id + * @param creatorType 用户类型 + * @return 未读发票数量 + * @author WH + * @date 2021/12/28 19:01 + * @since version-1.0 + */ + Long findNotReadCount(Long creatorId, Integer creatorType); + } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index c764362d..454c6209 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.extra.mail.MailUtil; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.utils.bean.BeanUtils; import com.xhpc.common.domain.XhpcChargingStation; +import com.xhpc.invoice.constant.InvoiceMapHistoryOrderStatusConst; import com.xhpc.invoice.domain.*; import com.xhpc.invoice.mapper.*; import com.xhpc.invoice.pojo.XhpcInvoice; @@ -131,8 +132,10 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { //根据操作人的id,查询操作人的名字 SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(requestData.getDrawer())); requestData.setDrawer(sysUser.getNickName()); - //入库更新 + //更新发票状态 xhpcInvoiceMapper.failInvoiceToUser(requestData); + //解除锁定 + xhpcInvoiceMapHistoryOrderMapper.unlockHistoryOrdersByInvoiceId(requestData.getInvoiceId()); } @Override @@ -246,6 +249,9 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { historyOrdersDTO.setHistoryOrdersData(historyOrdersDataDTOS); historyOrdersDTO.setTotalItems(historyOrdersList.size()); specificInvoicedResponse.setHistoryOrders(historyOrdersDTO); + + //todo 一旦掉了详情接口,去掉未读状态 + return specificInvoicedResponse; } @@ -276,6 +282,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { itemsDTO.setCreateTime(DateUtils.parseDateToStr(xhpcInvoice.getCreateTime())); itemsDTO.setStatus(xhpcInvoice.getStatus()); itemsDTO.setInvoicingMoney(xhpcInvoice.getInvoiceMoney()); + itemsDTO.setIsRead(xhpcInvoice.getIsRead()); itemsDTOS.add(itemsDTO); } InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = new InvoiceHistoryRecordsResponse(); @@ -285,6 +292,100 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { return invoiceHistoryRecordsResponse; } + /** + * 将用户申请的发票信息,保存到数据库中 + * + * @param saveInvoiceInfoRequest 发票信息 + * @throws Exception 传入发票金额参数与内部该发票所包含的所有订单金额参数不一致出现,出现此异常 + * @author WH + * @date 2021/12/28 14:33 + * @since version-1.0 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveInvoiceInfo(SaveInvoiceInfoRequest saveInvoiceInfoRequest) throws Exception { + //判断传入的历史订单是否被其他发票包含 + List historyOrderIds = saveInvoiceInfoRequest.getHistoryOrderIds(); + List lockOrderList = xhpcInvoiceMapHistoryOrderMapper.getLockedOnesByHistoryOrderId(historyOrderIds); + if (lockOrderList != null) { + throw new Exception("该历史订单已被其他发票包含"); + } + //将该发票记录放入数据库生成发票记录,除了所包含的历史订单的总电费,总服务费 + XhpcInvoice xhpcInvoice = new XhpcInvoice(); + xhpcInvoice.setReceiveEmail(saveInvoiceInfoRequest.getReceiveEmail()); + xhpcInvoice.setTitleType(saveInvoiceInfoRequest.getTitleType()); + xhpcInvoice.setTitleContent(saveInvoiceInfoRequest.getTitleContent()); + xhpcInvoice.setDutyNumber(saveInvoiceInfoRequest.getDutyNumber()); + xhpcInvoice.setInvoiceContent(saveInvoiceInfoRequest.getInvoiceContent()); + xhpcInvoice.setInvoiceMoney(saveInvoiceInfoRequest.getInvoiceMoney()); + xhpcInvoice.setFirmAddress(saveInvoiceInfoRequest.getFirmAddress()); + xhpcInvoice.setFirmPhone(saveInvoiceInfoRequest.getFirmPhone()); + xhpcInvoice.setFirmBank(saveInvoiceInfoRequest.getFirmBank()); + xhpcInvoice.setFirmBankAccount(saveInvoiceInfoRequest.getFirmBankAccount()); + xhpcInvoice.setIsShowDate(saveInvoiceInfoRequest.getIsShowDate()); + xhpcInvoice.setUserNotes(saveInvoiceInfoRequest.getUserNotes()); + xhpcInvoice.setCreatorId(saveInvoiceInfoRequest.getCreatorId()); + xhpcInvoice.setCreatorType(saveInvoiceInfoRequest.getCreatorType()); + xhpcInvoice.setCreator(saveInvoiceInfoRequest.getCreator()); + xhpcInvoice.setCreateTime(DateUtils.parseDate(saveInvoiceInfoRequest.getCreateTime())); + xhpcInvoice.setStatus(0); + xhpcInvoiceMapper.insertSelectiveAndReturnId(xhpcInvoice); + //建立订单与发票之间的关联 + List xhpcHistoryOrderList = xhpcHistoryOrderMapper.findById(historyOrderIds); + //获取所插入的发票id + Long invoiceId = xhpcInvoice.getInvoiceId(); + //存储该发票所包含的所有历史订单总电量 + double totalPowerPrice = 0; + //存储该发票所包含的所有历史订单总服务费 + double totalServicePrice = 0; + //该变量是用来计算内部存储的历史订单金额是否与传入的一致 + double totalActPrice = 0; + for (XhpcHistoryOrder xhpcHistoryOrder : xhpcHistoryOrderList) { + XhpcInvoiceMapHistoryOrder xhpcInvoiceMapHistoryOrder = new XhpcInvoiceMapHistoryOrder(); + xhpcInvoiceMapHistoryOrder.setInvoiceId(invoiceId); + xhpcInvoiceMapHistoryOrder.setHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); + xhpcInvoiceMapHistoryOrder.setHistoryUserId(xhpcHistoryOrder.getUserId()); + xhpcInvoiceMapHistoryOrder.setHistoryUserType(Long.valueOf(xhpcHistoryOrder.getSource())); + xhpcInvoiceMapHistoryOrder.setHisotrySerialNumber(xhpcHistoryOrder.getSerialNumber()); + xhpcInvoiceMapHistoryOrder.setPowerPriceTotal(xhpcHistoryOrder.getActPowerPrice()); + xhpcInvoiceMapHistoryOrder.setServicePriceTotal(xhpcHistoryOrder.getActServicePrice()); + xhpcInvoiceMapHistoryOrder.setPromotionDiscount(xhpcHistoryOrder.getPromotionDiscount()); + xhpcInvoiceMapHistoryOrder.setHistoryActPrice(xhpcHistoryOrder.getActPrice()); + xhpcInvoiceMapHistoryOrder.setCreateTime(xhpcHistoryOrder.getCreateTime()); + xhpcInvoiceMapHistoryOrder.setChargingMode(xhpcHistoryOrder.getChargingMode()); + xhpcInvoiceMapHistoryOrder.setChargingStationId(xhpcHistoryOrder.getChargingStationId()); + xhpcInvoiceMapHistoryOrder.setTerminalId(xhpcHistoryOrder.getTerminalId()); + xhpcInvoiceMapHistoryOrder.setLockFlag(InvoiceMapHistoryOrderStatusConst.LOCK); + xhpcInvoiceMapHistoryOrderMapper.insertSelective(xhpcInvoiceMapHistoryOrder); + totalPowerPrice += xhpcHistoryOrder.getActPowerPrice().doubleValue(); + totalServicePrice += xhpcHistoryOrder.getActServicePrice().doubleValue(); + totalActPrice += xhpcHistoryOrder.getActPrice().doubleValue(); + } + if (!BigDecimal.valueOf(totalActPrice).equals(saveInvoiceInfoRequest.getInvoiceMoney())) { + throw new Exception("传入的发票金额与实际包含的历史订单总金额参数不匹配"); + } + xhpcInvoice.setInvoiceOrderEletricTotalMoney(BigDecimal.valueOf(totalPowerPrice)); + xhpcInvoice.setInvoiceOrderServiceTotalMoney(BigDecimal.valueOf(totalServicePrice)); + xhpcInvoiceMapper.insertSelective(xhpcInvoice); + } + + /** + * 查询指定用户没有查看的已开的发票的数量,即该用户有几个未读发票 + * + * @param creatorId 用户id + * @param creatorType 用户类型 + * @return 未读发票数量 + * @author WH + * @date 2021/12/28 19:01 + * @since version-1.0 + */ + @Override + public Long findNotReadCount(Long creatorId, Integer creatorType) { + + return xhpcInvoiceMapper.findNotReadCount(creatorId, creatorType); + } + + /** * 通过发票id查找对应的发票数据 * diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 0e20c160..f9748596 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -108,5 +108,19 @@ + diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml index abd34273..e27f2de6 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml @@ -19,6 +19,25 @@ + + `invoice_id` + , + `history_order_id`, + `history_user_id`, + `history_user_type`, + `hisotry_serial_number`, + `power_price_total`, + `service_price_total`, + `promotion_discount`, + `history_act_price`, + `create_time`, + `charging_mode`, + `charging_station_id`, + `terminal_id`, + `lock_flag`, + `del_flag` + + insert into xhpc_invoice_map_history_order (invoice_id, history_order_id, history_user_id, history_user_type, hisotry_serial_number, power_price_total, @@ -76,6 +95,9 @@ terminal_id, + + lock_flag, + del_flag, @@ -120,6 +142,9 @@ #{terminalId,jdbcType=BIGINT}, + + #{lockFlag,jdbcType=INTEGER}, + #{delFlag,jdbcType=INTEGER}, @@ -136,11 +161,17 @@ ) ) + + UPDATE xhpc_invoice_map_history_order + SET lock_flag = NULL + WHERE invoice_id = #{invoiceId} + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml index e95a89a4..0f28e800 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -30,14 +30,39 @@ + - invoice_id - , receive_email, title_type, title_content, duty_number, invoice_content, - invoice_money, invoice_order_eletric_total_money, invoice_order_service_total_money, - firm_address, firm_phone, firm_bank, firm_bank_account, is_show_date, user_notes, - creator_id, creator_type, creator, create_time, `status`, invoicing_time, drawer, - finance_notes, electric_invoice_url, updator, update_time, del_flag + `invoice_id` + , + `receive_email`, + `title_type`, + `title_content`, + `duty_number`, + `invoice_content`, + `invoice_money`, + `invoice_order_eletric_total_money`, + `invoice_order_service_total_money`, + `firm_address`, + `firm_phone`, + `firm_bank`, + `firm_bank_account`, + `is_show_date`, + `user_notes`, + `creator_id`, + `creator_type`, + `creator`, + `create_time`, + `status`, + `invoicing_time`, + `drawer`, + `finance_notes`, + `electric_invoice_url`, + `updator`, + `update_time`, + `is_read`, + `del_flag` + + delete from xhpc_invoice @@ -343,6 +378,170 @@ + + insert into xhpc_invoice + + + receive_email, + + + title_type, + + + title_content, + + + duty_number, + + + invoice_content, + + + invoice_money, + + + invoice_order_eletric_total_money, + + + invoice_order_service_total_money, + + + firm_address, + + + firm_phone, + + + firm_bank, + + + firm_bank_account, + + + is_show_date, + + + user_notes, + + + creator_id, + + + creator_type, + + + creator, + + + create_time, + + + `status`, + + + invoicing_time, + + + drawer, + + + finance_notes, + + + electric_invoice_url, + + + updator, + + + update_time, + + + del_flag, + + + + + #{receiveEmail,jdbcType=VARCHAR}, + + + #{titleType,jdbcType=INTEGER}, + + + #{titleContent,jdbcType=VARCHAR}, + + + #{dutyNumber,jdbcType=VARCHAR}, + + + #{invoiceContent,jdbcType=VARCHAR}, + + + #{invoiceMoney,jdbcType=DECIMAL}, + + + #{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL}, + + + #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL}, + + + #{firmAddress,jdbcType=VARCHAR}, + + + #{firmPhone,jdbcType=VARCHAR}, + + + #{firmBank,jdbcType=VARCHAR}, + + + #{firmBankAccount,jdbcType=VARCHAR}, + + + #{isShowDate,jdbcType=INTEGER}, + + + #{userNotes,jdbcType=VARCHAR}, + + + #{creatorId,jdbcType=BIGINT}, + + + #{creatorType,jdbcType=INTEGER}, + + + #{creator,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{status,jdbcType=INTEGER}, + + + #{invoicingTime,jdbcType=TIMESTAMP}, + + + #{drawer,jdbcType=VARCHAR}, + + + #{financeNotes,jdbcType=VARCHAR}, + + + #{electricInvoiceUrl,jdbcType=VARCHAR}, + + + #{updator,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=DATE}, + + + #{delFlag,jdbcType=INTEGER}, + + + update xhpc_invoice @@ -464,7 +663,8 @@ invoicing_time = #{invoicingTime}, electric_invoice_url = #{eletricInvoiceUrl}, `status` = #{status}, - drawer = #{drawer} + drawer = #{drawer}, + is_read = 0 WHERE invoice_id = #{invoiceId}; @@ -474,7 +674,7 @@ invoicing_time = #{invoicingTime}, electric_invoice_url = #{eletricInvoiceUrl}, `status` = #{status}, - drawer = #{drawer} + drawer = #{drawer} is_read = 0 WHERE invoice_id = #{invoiceId} From 2f58a3a85a15f0fec832faf61c4d066249f129bc Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Wed, 29 Dec 2021 14:48:45 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml index e27f2de6..69bd1187 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml @@ -15,7 +15,7 @@ - + From aa4baa541b99375b81da8938a529b2c9b1f0a657 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Wed, 29 Dec 2021 16:43:15 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=87=B3=E9=98=BF=E9=87=8C=E4=BA=91=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xhpc-modules/xhpc-invoice/pom.xml | 6 ++++ .../controller/XhpcInvoiceController.java | 31 +++++++++++++++++++ .../src/main/resources/bootstrap.yml | 16 +++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/xhpc-modules/xhpc-invoice/pom.xml b/xhpc-modules/xhpc-invoice/pom.xml index 0d54c218..2cae6d59 100644 --- a/xhpc-modules/xhpc-invoice/pom.xml +++ b/xhpc-modules/xhpc-invoice/pom.xml @@ -109,6 +109,12 @@ 3.0.0 compile + + com.aliyun.oss + aliyun-sdk-oss + 3.10.2 + compile + diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java index 239dd00f..a480949f 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java @@ -1,5 +1,7 @@ package com.xhpc.invoice.controller; +import com.aliyun.oss.OSSClient; +import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.invoice.constant.InvoiceStatusConst; @@ -8,12 +10,15 @@ import com.xhpc.invoice.domain.AllInvoiceOrdersResponse; import com.xhpc.invoice.domain.InvoiceToUserRequest; import com.xhpc.invoice.domain.SpecificInvoiceWrap; import com.xhpc.invoice.service.XhpcInvoiceService; +import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.IOException; import java.util.Map; /** @@ -29,6 +34,32 @@ public class XhpcInvoiceController extends BaseController { @Resource XhpcInvoiceService xhpcInvoiceService; + @Resource + Environment environment; + + /** + * 上传图片到阿里云接口 + * + * @param invoicePdf 文件二进制对象 + * @return 该文件在阿里云中的地址 + * @author WH + * @date 2021/12/29 16:40 + * @since version-1.0 + */ + @PostMapping("/pdf") + public AjaxResult uploadPdf(MultipartFile invoicePdf) throws IOException { + + String filename = "electronicInvoice" + DateUtils.dateTimeNow() + ".pdf"; + // 上传文件到阿里云 + OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key")); + // 放置到哪个块中去,key为目录,file为文件 + ossClient.putObject(environment.getProperty("oss.bucket-name"), environment.getProperty("file.aliyunPath") + filename, invoicePdf.getInputStream()); + ossClient.shutdown(); + // 返回上传到阿里云中的文件的uri地址 + String fileAddress = "/" + environment.getProperty("file.aliyunPath") + filename; + return AjaxResult.success(fileAddress); + } + /** * 给指定用户开发票,开票完成之后将开出的电子发票发送至用户的接收邮箱 diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml index bacdb6d8..c5679461 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml @@ -22,4 +22,18 @@ spring: file-extension: yml # 共享配置 shared-configs: - - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} \ No newline at end of file + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + +#oss默认配置 +oss: + enabled: true + name: qiniu + tenant-mode: true + endpoint: oss-accelerate.aliyuncs.com + access-key: LTAI5tBWjnuQGxGicnThwMF1 + secret-key: b0WNtFYtWyTEkZzcr2WOAPoZg6w2Xu + bucket-name: xhpc-bucket1 + +#文件路径 +file: + aliyunPath: invoicePdf/ \ No newline at end of file From 02bc08b1e4126d2112bb5dadddcfbd4fca0bf22d Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Wed, 29 Dec 2021 18:16:39 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E7=94=B5=E5=AD=90=E5=8F=91=E7=A5=A8pdf?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E9=83=A8=E5=88=86=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8F=91=E7=A5=A8Excel=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XhpcInvoiceController.java | 21 +++++++++++++++---- .../invoice/mapper/XhpcInvoiceMapper.java | 10 +++++++++ .../service/impl/XhpcInvoiceServiceImpl.java | 19 +++++++++++++---- .../src/main/resources/bootstrap.yml | 3 ++- .../resources/mapper/XhpcInvoiceMapper.xml | 6 ++++++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java index a480949f..ec2a649c 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java @@ -11,14 +11,12 @@ import com.xhpc.invoice.domain.InvoiceToUserRequest; import com.xhpc.invoice.domain.SpecificInvoiceWrap; import com.xhpc.invoice.service.XhpcInvoiceService; import org.springframework.core.env.Environment; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -37,11 +35,26 @@ public class XhpcInvoiceController extends BaseController { @Resource Environment environment; + /** + * 导出发票Excel接口 + * + * @author WH + * @date 2021/12/29 16:45 + * @since version-1.0 + */ + @GetMapping("/excel") + public AjaxResult exportExcel(@RequestParam("invoiceIds") List invoiceIds) { + //todo 将指定发票信息导入到excel表中,然后返回出去 + return AjaxResult.success("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/69852145895461/202109151137358636985214589546101.png"); + } + + /** * 上传图片到阿里云接口 * * @param invoicePdf 文件二进制对象 * @return 该文件在阿里云中的地址 + * * @author WH * @date 2021/12/29 16:40 * @since version-1.0 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java index 7d612d8c..fbd11b3f 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java @@ -166,4 +166,14 @@ public interface XhpcInvoiceMapper { */ Long findNotReadCount(@Param("creatorId") Long creatorId, @Param("creatorType") Integer creatorType); + /** + * 更新发票状态,从未读变成已读 + * + * @param invoiceId 要更新的发票id + * @author WH + * @date 2021/12/29 17:26 + * @since version-1.0 + */ + void updateByInvoiceId(Long invoiceId); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index 454c6209..8ad50225 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -1,6 +1,7 @@ package com.xhpc.invoice.service.impl; import cn.hutool.extra.mail.MailUtil; +import cn.hutool.http.HttpUtil; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.utils.bean.BeanUtils; import com.xhpc.common.domain.XhpcChargingStation; @@ -12,6 +13,7 @@ import com.xhpc.invoice.pojo.XhpcInvoiceMapHistoryOrder; import com.xhpc.invoice.service.XhpcInvoiceService; import com.xhpc.order.domain.XhpcHistoryOrder; import com.xhpc.system.api.domain.SysUser; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,6 +46,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { SysUserMapper sysUserMapper; @Resource XhpcHistoryOrderMapper xhpcHistoryOrderMapper; + @Resource + Environment environment; /** * 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息 @@ -110,13 +114,19 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { //发送电子发票pdf到接收者邮箱 XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(requestData.getInvoiceId()); String receiveEmail = xhpcInvoice.getReceiveEmail(); - //todo 从阿里云上下载下来电子发票 - File electricInvoiceFile = new File("D:\\Enterprise_Resources\\ElectricInvoice\\ElectricInvoice.pdf"); + //从阿里云上下载下来电子发票 + String fileUrl = requestData.getEletricInvoiceUrl(); + File electricInvoiceFile = new File(environment.getProperty("file.serverStoreDisposableFileLocation") + "ElectricInvoice.pdf"); + HttpUtil.downloadFile(fileUrl, electricInvoiceFile); try { MailUtil.send(receiveEmail, "【小华充电】电子发票", "邮件来自小华充电", false, electricInvoiceFile); } catch (Exception e) { System.out.println(e.getMessage()); return Boolean.FALSE; + } finally { + if (electricInvoiceFile.exists()) { + electricInvoiceFile.delete(); + } } //更新发票数据 Long successFlag = xhpcInvoiceMapper.invoiceToUser(requestData); @@ -219,6 +229,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override + @Transactional(rollbackFor = Exception.class) public SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId) { //对拷发票部分数据 @@ -250,8 +261,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { historyOrdersDTO.setTotalItems(historyOrdersList.size()); specificInvoicedResponse.setHistoryOrders(historyOrdersDTO); - //todo 一旦掉了详情接口,去掉未读状态 - + //一旦调了详情接口,就去掉该已开发票的未读状态 + xhpcInvoiceMapper.updateByInvoiceId(invoiceId); return specificInvoicedResponse; } diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml index c5679461..9f962452 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/bootstrap.yml @@ -36,4 +36,5 @@ oss: #文件路径 file: - aliyunPath: invoicePdf/ \ No newline at end of file + aliyunPath: invoicePdf/ + serverStoreDisposableFileLocation: /www/wwwroot/xhpc.scxhua.com/disposableFiles/ \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml index 0f28e800..ce830f28 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -677,5 +677,11 @@ drawer = #{drawer} is_read = 0 WHERE invoice_id = #{invoiceId} + + UPDATE xhpc_invoice + SET is_read = 1 + WHERE del_flag IS NULL + AND invoice_id = #{invoiceId} + \ No newline at end of file From edbab6dbee78504fbda91c669900a52c45a1ff1e Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Thu, 30 Dec 2021 14:00:55 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9Auth=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E6=96=B9=E4=BE=BF=E6=B5=8B=E8=AF=95=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9C=AA=E8=AF=BB=E7=BA=A2=E7=82=B9=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=87=B3Redis=E4=B8=AD=EF=BC=8C=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E5=88=AB=E4=BA=BA=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/security/service/TokenService.java | 2 +- .../com/xhpc/gateway/filter/AuthFilter.java | 65 ++++++----- .../invoice/mapper/XhpcInvoiceMapper.java | 2 +- .../service/impl/XhpcInvoiceServiceImpl.java | 107 +++++++++++++++++- 4 files changed, 142 insertions(+), 34 deletions(-) diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java index f13c4ebb..237db200 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java @@ -27,7 +27,7 @@ public class TokenService { @Autowired private RedisService redisService; - private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60; + private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 6000; private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY; diff --git a/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java index 84508f74..69394c89 100644 --- a/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java +++ b/ruoyi-gateway/src/main/java/com/xhpc/gateway/filter/AuthFilter.java @@ -1,9 +1,11 @@ package com.xhpc.gateway.filter; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.xhpc.common.core.constant.CacheConstants; import com.xhpc.common.core.constant.Constants; import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.utils.ServletUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.redis.service.RedisService; import com.xhpc.gateway.config.properties.IgnoreWhiteProperties; @@ -14,6 +16,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.Ordered; import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.data.redis.core.ValueOperations; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; @@ -22,6 +25,8 @@ import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; +import javax.annotation.Resource; + /** * 网关鉴权 * @@ -38,8 +43,8 @@ public class AuthFilter implements GlobalFilter, Ordered { @Autowired private IgnoreWhiteProperties ignoreWhite; -// @Resource(name = "stringRedisTemplate") -// private ValueOperations sops; + @Resource(name = "stringRedisTemplate") + private ValueOperations sops; @Autowired private RedisService redisService; @@ -48,34 +53,34 @@ public class AuthFilter implements GlobalFilter, Ordered { public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { String url = exchange.getRequest().getURI().getPath(); -// // 跳过不需要验证的路径 -// if (StringUtils.matches(url, ignoreWhite.getWhites())) { -// return chain.filter(exchange); -// } -// String token = getToken(exchange.getRequest()); -// if (StringUtils.isBlank(token)) { -// return setUnauthorizedResponse(exchange, "令牌不能为空"); -// } -// String userStr = sops.get(getTokenKey(token)); -// if (StringUtils.isNull(userStr)) { -// userStr = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); -// if (StringUtils.isNull(userStr)) { -// return setUnauthorizedResponse(exchange, "登录状态已过期"); -// } -// } -// JSONObject obj = JSONObject.parseObject(userStr); -// String userid = obj.getString("userid"); -// String username = obj.getString("username"); -// if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) { -// return setUnauthorizedResponse(exchange, "令牌验证失败"); -// } -// -// // 设置过期时间 -// redisService.expire(getTokenKey(token), EXPIRE_TIME); -// // 设置用户信息到请求 -// ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid) -// .header(CacheConstants.DETAILS_USERNAME, ServletUtils.urlEncode(username)).build(); -// ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); + // 跳过不需要验证的路径 + if (StringUtils.matches(url, ignoreWhite.getWhites())) { + return chain.filter(exchange); + } + String token = getToken(exchange.getRequest()); + if (StringUtils.isBlank(token)) { + return setUnauthorizedResponse(exchange, "令牌不能为空"); + } + String userStr = sops.get(getTokenKey(token)); + if (StringUtils.isNull(userStr)) { + userStr = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + if (StringUtils.isNull(userStr)) { + return setUnauthorizedResponse(exchange, "登录状态已过期"); + } + } + JSONObject obj = JSONObject.parseObject(userStr); + String userid = obj.getString("userid"); + String username = obj.getString("username"); + if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) { + return setUnauthorizedResponse(exchange, "令牌验证失败"); + } + + // 设置过期时间 + redisService.expire(getTokenKey(token), EXPIRE_TIME); + // 设置用户信息到请求 + ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(CacheConstants.DETAILS_USER_ID, userid) + .header(CacheConstants.DETAILS_USERNAME, ServletUtils.urlEncode(username)).build(); + ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); return chain.filter(exchange); } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java index fbd11b3f..4974e0b7 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java @@ -75,7 +75,7 @@ public interface XhpcInvoiceMapper { BigDecimal allNotInvoicedMoney(); /** - * 更新指定发票状态,让其成为已开发票状态 + * 更新指定发票状态,让其成为已开发票状态,并设置用户未阅读标签 * * @param requestData 更新数据的来源 * @return Long 返回更新受影响的条数 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index 8ad50225..52e0cd11 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -1,10 +1,14 @@ package com.xhpc.invoice.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.extra.mail.MailUtil; import cn.hutool.http.HttpUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.utils.bean.BeanUtils; import com.xhpc.common.domain.XhpcChargingStation; +import com.xhpc.common.redis.service.RedisService; import com.xhpc.invoice.constant.InvoiceMapHistoryOrderStatusConst; import com.xhpc.invoice.domain.*; import com.xhpc.invoice.mapper.*; @@ -48,6 +52,8 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { XhpcHistoryOrderMapper xhpcHistoryOrderMapper; @Resource Environment environment; + @Resource + RedisService redisService; /** * 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息 @@ -128,11 +134,13 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { electricInvoiceFile.delete(); } } - //更新发票数据 + //更新发票数据,并设置用户未阅读状态 Long successFlag = xhpcInvoiceMapper.invoiceToUser(requestData); if (successFlag == 0) { throw new RuntimeException("无法更新指定发票,传入的数据有问题"); } + //将该用户未阅读的数量放入到redis中 + putNoReadInvoiceCountIntoRedis(requestData); return Boolean.TRUE; } @@ -146,6 +154,28 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { xhpcInvoiceMapper.failInvoiceToUser(requestData); //解除锁定 xhpcInvoiceMapHistoryOrderMapper.unlockHistoryOrdersByInvoiceId(requestData.getInvoiceId()); + //将该用户未阅读的数量放入到redis中 + putNoReadInvoiceCountIntoRedis(requestData); + } + + /** + * 将该用户没有阅读的发票的数量放入到Redis中保存,供别人调用 + * + * @author WH + * @date 2021/12/30 13:54 + * @since version-1.0 + */ + private void putNoReadInvoiceCountIntoRedis(InvoiceToUserRequest requestData) { + + XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(requestData.getInvoiceId()); + String redisKey = generateRedisKey(xhpcInvoice); + if (redisService.getCacheObject(redisKey) == null) { + redisService.setCacheObject(redisKey, 1); + } else { + Integer noReadCount = redisService.getCacheObject(redisKey); + noReadCount = noReadCount + 1; + redisService.setCacheObject(redisKey, noReadCount); + } } @Override @@ -261,11 +291,62 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { historyOrdersDTO.setTotalItems(historyOrdersList.size()); specificInvoicedResponse.setHistoryOrders(historyOrdersDTO); - //一旦调了详情接口,就去掉该已开发票的未读状态 + //一旦调了详情接口,就去掉该已开发票的未读状态,同时redis中的未读数量数据-1 xhpcInvoiceMapper.updateByInvoiceId(invoiceId); + reduceNoReadInvoiceCount(xhpcInvoice); return specificInvoicedResponse; } + /** + * 将用户未读的发票数量-1 + * + * @param xhpcInvoice 用户查看的发票 + * @author WH + * @date 2021/12/30 13:55 + * @since version-1.0 + */ + private void reduceNoReadInvoiceCount(XhpcInvoice xhpcInvoice) { + + String redisKey = generateRedisKey(xhpcInvoice); + if (redisService.getCacheObject(redisKey).equals(1)) { + redisService.deleteObject(redisKey); + } else { + Integer noReadCount = redisService.getCacheObject(redisKey); + noReadCount = noReadCount - 1; + redisService.setCacheObject(redisKey, noReadCount); + } + } + + /** + * 生成该用户在Redis中的唯一表示key + * + * @param xhpcInvoice 用户查看的发票 + * @author WH + * @date 2021/12/30 13:52 + * @since version-1.0 + */ + private String generateRedisKey(XhpcInvoice xhpcInvoice) { + + String redisKey = "global:invoice:"; + switch (xhpcInvoice.getCreatorType()) { + case 0: + redisKey = redisKey + "C" + xhpcInvoice.getCreatorId(); + break; + case 1: + redisKey = redisKey + "L" + xhpcInvoice.getCreatorId(); + break; + case 2: + redisKey = redisKey + "ST" + xhpcInvoice.getCreatorId(); + break; + case 3: + redisKey = redisKey + "BE" + xhpcInvoice.getCreatorId(); + break; + default: + break; + } + return redisKey; + } + /** * 根据前端传递过来的请求参数,查询所需要的开发票历史记录 * @@ -396,6 +477,28 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { return xhpcInvoiceMapper.findNotReadCount(creatorId, creatorType); } + /** + * 导出所有发票记录(已开与未开)到Excel中 + * + * @param invoiceIds 发票id + * @author WH + * @date 2021/12/30 10:16 + * @since version-1.0 + */ + @Override + public void exportExcel(List invoiceIds) { + + Integer integer = invoiceIds.get(0); + //获取要导出的发票记录 + XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(Long.valueOf(integer)); + List rows = CollUtil.newArrayList(xhpcInvoice); + //写出记录到excel表中 + ExcelWriter writer = ExcelUtil.getWriter("d:/writeTest.xlsx"); + writer.write(rows); + writer.close(); + //写入到Response中 + } + /** * 通过发票id查找对应的发票数据 From 762fe744eab6db8394b189a057efb4a28b76e996 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Thu, 30 Dec 2021 16:06:33 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=B8=AD=E5=AD=98=E5=9C=A8=E7=9A=84=E9=9A=90?= =?UTF-8?q?=E8=97=8FBug=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=AD=94=E6=B3=95=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../general/constant/AliyunSendResult.java | 17 +++++++ .../xhpc/general/constant/AliyunTemplate.java | 42 ++++++++++++++++++ .../constant/AliyunTemplateKeyWord.java | 38 ++++++++++++++++ .../general/controller/XhpcSmsController.java | 32 +++++++------- .../general/service/XhpcSmsServiceImpl.java | 44 ++++++++----------- 5 files changed, 132 insertions(+), 41 deletions(-) create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunSendResult.java create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java create mode 100644 xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunSendResult.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunSendResult.java new file mode 100644 index 00000000..369e3d9a --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunSendResult.java @@ -0,0 +1,17 @@ +package com.xhpc.general.constant; + +/** + * 阿里云短信服务发送结果常量类 + * + * @author WH + * @date 2021/12/30 14:56 + * @since version-1.0 + */ +public class AliyunSendResult { + + /** + * 短信发送成功 + */ + public static final String SUCCESS = "OK"; + +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java new file mode 100644 index 00000000..e04df85b --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplate.java @@ -0,0 +1,42 @@ +package com.xhpc.general.constant; + +/** + * 阿里云短信模板常量类 + * + * @author WH + * @date 2021/12/30 14:40 + * @since version-1.0 + */ +public class AliyunTemplate { + + /** + * 阿里云短信签名 + */ + public static final String SIGNATURE_NAME = "小华充电"; + /** + * 电量充满 + */ + public static final String CHARGE_FULL = "SMS_227005968"; + /** + * 充电金额不足 + */ + public static final String CHARGE_MONEY_INSUFFICIENT = "SMS_226935795"; + /** + * 直流桩停止充电 + */ + public static final String DIRECT_STREAM_PILE_STOP_CHARGE = "SMS_226945037"; + /** + * 直流桩停止充电 + */ + public static final String INTERFLOW_STREAM_PILE_STOP_CHARGE = "SMS_226786374"; + /** + * 验证码 + */ + public static final String VALIDATE_CODE = "SMS_226786362"; + /** + * 退款失败 + */ + public static final String REFUND_FAIL = "SMS_231445428"; + + +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java new file mode 100644 index 00000000..0e46ec9d --- /dev/null +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java @@ -0,0 +1,38 @@ +package com.xhpc.general.constant; + +/** + * 阿里云模板内容关键字常量类 + * 根据模板话语判断该调用哪个模板id + * + * @author WH + * @date 2021/12/30 15:59 + * @since version-1.0 + */ +public class AliyunTemplateKeyWord { + + /** + * 电量充满 + */ + public static final String CHARGE_FULL = "设定的SOC"; + /** + * 充电金额不足 + */ + public static final String CHARGE_MONEY_INSUFFICIENT = "余额小于"; + /** + * 直流桩停止充电 + */ + public static final String DIRECT_STREAM_PILE_STOP_CHARGE = "电量为"; + /** + * 直流桩停止充电 + */ + public static final String INTERFLOW_STREAM_PILE_STOP_CHARGE = "总费用为"; + /** + * 验证码 + */ + public static final String VALIDATE_CODE = "SMS_226786362"; + /** + * 退款失败 + */ + public static final String REFUND_FAIL = "退款-尊敬的用户"; + +} diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java index 44400c04..72327ae2 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java @@ -3,6 +3,8 @@ package com.xhpc.general.controller; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.general.constant.AliyunTemplate; +import com.xhpc.general.constant.AliyunTemplateKeyWord; import com.xhpc.general.service.IXhpcSmsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -58,21 +60,21 @@ public class XhpcSmsController extends BaseController { paramMap.remove("phone"); paramMap.remove("content"); //判断内容是什么,调用相应的模板 - if (content.contains("电量为")) { - signatureName = "小华充电"; - templateId = "SMS_226945037"; - } else if (content.contains("总费用为")) { - signatureName = "小华充电"; - templateId = "SMS_226786374"; - } else if (content.contains("余额小于")) { - signatureName = "小华充电"; - templateId = "SMS_226935795"; - } else if (content.contains("设定的SOC")) { - signatureName = "小华充电"; - templateId = "SMS_227005968"; - }else if (content.contains("退款-尊敬的用户")) { - signatureName = "小华充电"; - templateId = "SMS_231445428"; + if (content.contains(AliyunTemplateKeyWord.DIRECT_STREAM_PILE_STOP_CHARGE)) { + signatureName = AliyunTemplate.SIGNATURE_NAME; + templateId = AliyunTemplate.DIRECT_STREAM_PILE_STOP_CHARGE; + } else if (content.contains(AliyunTemplateKeyWord.INTERFLOW_STREAM_PILE_STOP_CHARGE)) { + signatureName = AliyunTemplate.SIGNATURE_NAME; + templateId = AliyunTemplate.INTERFLOW_STREAM_PILE_STOP_CHARGE; + } else if (content.contains(AliyunTemplateKeyWord.CHARGE_MONEY_INSUFFICIENT)) { + signatureName = AliyunTemplate.SIGNATURE_NAME; + templateId = AliyunTemplate.CHARGE_MONEY_INSUFFICIENT; + } else if (content.contains(AliyunTemplateKeyWord.CHARGE_FULL)) { + signatureName = AliyunTemplate.SIGNATURE_NAME; + templateId = AliyunTemplate.CHARGE_FULL; + } else if (content.contains(AliyunTemplateKeyWord.REFUND_FAIL)) { + signatureName = AliyunTemplate.SIGNATURE_NAME; + templateId = AliyunTemplate.REFUND_FAIL; } xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap); diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java index 4aebb25d..83b54977 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java @@ -7,6 +7,8 @@ import com.aliyun.dysmsapi20170525.models.SendSmsResponse; import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.redis.service.RedisService; +import com.xhpc.general.constant.AliyunSendResult; +import com.xhpc.general.constant.AliyunTemplate; import com.xhpc.general.domain.XhpcSms; import com.xhpc.general.mapper.XhpcSmsMapper; import com.xhpc.general.util.sms.SmsUtil; @@ -103,7 +105,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { //判断发送结果 String statusCode = neededParam.get("statusCode"); - if (statusCode.equals("OK")) { + if (statusCode.equals(AliyunSendResult.SUCCESS)) { REDIS.setCacheObject(pvToken, random, 300L, TimeUnit.SECONDS); //1分钟有效时间设置,防止用户频繁调用 REDIS.setCacheObject(token, random, 60L, TimeUnit.SECONDS); @@ -152,7 +154,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { //判断发送结果 String statusCode = neededParam.get("statusCode"); - if ("OK".equals(statusCode)) { + if (AliyunSendResult.SUCCESS.equals(statusCode)) { xhpcSms.setStatus(0); } else { xhpcSms.setStatus(1); @@ -217,40 +219,30 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService { private String getTemplateContent(String templateId, Map paramMap) throws Exception { - if (templateId == "SMS_227005968") { + if (AliyunTemplate.CHARGE_FULL.equals(templateId)) { String battery = paramMap.get("battery"); - String templateContent = "尊敬的用户,你的车辆已充电达至设定的SOC:" + battery + "%并停止充电,请您尽快将车辆挪走以方便他人使用充电桩,谢谢合作。"; - return templateContent; + return "尊敬的用户,你的车辆已充电达至设定的SOC:" + battery + "%并停止充电,请您尽快将车辆挪走以方便他人使用充电桩,谢谢合作。"; } - if (templateId == "SMS_226935795") { + if (AliyunTemplate.CHARGE_MONEY_INSUFFICIENT.equals(templateId)) { String money = paramMap.get("money"); - String templateContent = "尊敬的用户,你的账户余额小于" + money + "元,为不影响您的正常充电,请您尽快充值交费,谢谢。"; - return templateContent; + return "尊敬的用户,你的账户余额小于" + money + "元,为不影响您的正常充电,请您尽快充值交费,谢谢。"; } - if (templateId == "SMS_226786374") { - String sumMoney = paramMap.get("sumMoney"); - String templateContent = "尊敬的用户,你的爱车已停止充电,请尽快挪车。总费用为:" + sumMoney + "元,充电费用明细,请查询小华充电小程序,谢谢。"; - return templateContent; - } - if (templateId == "SMS_227005968") { + if (AliyunTemplate.DIRECT_STREAM_PILE_STOP_CHARGE.equals(templateId)) { String elec = paramMap.get("elec"); String sumMoney = paramMap.get("sumMoney"); - String templateContent = "尊敬的用户,你的爱车已停止充电,请尽快挪车。电量为:" + elec + ",总费用为:" + sumMoney + "元,充电费用明细,请查询小华充电小程序,谢谢。"; - return templateContent; + return "尊敬的用户,你的爱车已停止充电,请尽快挪车。电量为:" + elec + ",总费用为:" + sumMoney + "元,充电费用明细,请查询小华充电小程序,谢谢。"; } - if (templateId == "SMS_226786362") { + if (AliyunTemplate.INTERFLOW_STREAM_PILE_STOP_CHARGE.equals(templateId)) { + String sumMoney = paramMap.get("sumMoney"); + return "尊敬的用户,你的爱车已停止充电,请尽快挪车。总费用为:" + sumMoney + "元,充电费用明细,请查询小华充电小程序,谢谢。"; + } + if (AliyunTemplate.VALIDATE_CODE.equals(templateId)) { String code = paramMap.get("code"); - String templateContent = "您的验证码是:" + code + ",有效期为5分钟。如非本人操作,可不用理会。"; - return templateContent; + return "您的验证码是:" + code + ",有效期为5分钟。如非本人操作,可不用理会。"; } - if (templateId == "SMS_231445428") { - String templateContent = "【小华充电】退款-尊敬的用户,当前退款人数较多,申请退款失败,请您重新提交申请!"; - return templateContent; + if (AliyunTemplate.REFUND_FAIL.equals(templateId)) { + return "【小华充电】退款-尊敬的用户,当前退款人数较多,申请退款失败,请您重新提交申请!"; } - throw new Exception("没有对应的模板id"); - } - - } From cf89e40ccf8336a070e355335b00bcd5210b5b0f Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Mon, 3 Jan 2022 12:45:05 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E5=8F=91=E7=A5=A8=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=87=B3Excel=E4=B8=AD=EF=BC=8C=E7=84=B6=E5=90=8E=E4=BE=9B?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XhpcInvoiceController.java | 13 ++- .../xhpc/invoice/domain/ExcelInvoiceRow.java | 47 +++++++++ .../invoice/mapper/XhpcInvoiceMapper.java | 12 +++ .../invoice/service/XhpcInvoiceService.java | 16 ++++ .../service/impl/XhpcInvoiceServiceImpl.java | 95 ++++++++++++++++--- .../resources/mapper/XhpcInvoiceMapper.xml | 42 ++++++++ 6 files changed, 210 insertions(+), 15 deletions(-) create mode 100644 xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/ExcelInvoiceRow.java diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java index ec2a649c..dfe50cd5 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java @@ -15,7 +15,9 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -43,9 +45,12 @@ public class XhpcInvoiceController extends BaseController { * @since version-1.0 */ @GetMapping("/excel") - public AjaxResult exportExcel(@RequestParam("invoiceIds") List invoiceIds) { - //todo 将指定发票信息导入到excel表中,然后返回出去 - return AjaxResult.success("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/69852145895461/202109151137358636985214589546101.png"); + public AjaxResult exportExcel(@RequestParam("invoiceIds") String invoiceIds, HttpServletResponse response) throws IOException { + //处理字符串,转换成数组 + String[] ids = invoiceIds.split(","); + List resultList = Arrays.asList(ids); + xhpcInvoiceService.exportExcel(resultList, response); + return AjaxResult.success(); } @@ -62,7 +67,7 @@ public class XhpcInvoiceController extends BaseController { @PostMapping("/pdf") public AjaxResult uploadPdf(MultipartFile invoicePdf) throws IOException { - String filename = "electronicInvoice" + DateUtils.dateTimeNow() + ".pdf"; + String filename = "electricInvoice" + DateUtils.dateTimeNow() + ".pdf"; // 上传文件到阿里云 OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key")); // 放置到哪个块中去,key为目录,file为文件 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/ExcelInvoiceRow.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/ExcelInvoiceRow.java new file mode 100644 index 00000000..6035bedf --- /dev/null +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/ExcelInvoiceRow.java @@ -0,0 +1,47 @@ +package com.xhpc.invoice.domain; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 用于存储导出发票的一行记录的Bean类 + * + * @author WH + * @date 2021/12/30 14:13 + * @since version-1.0 + */ +@Data +@NoArgsConstructor +public class ExcelInvoiceRow { + + private Integer rowsNumber; + private String invoiceType; + private String receiveEmail; + private String titleType; + private String titleContent; + private String dutyNumber; + private String invoiceContent; + private String invoiceOrderElectricTotalMoney; + private String invoiceOrderServiceTotalMoney; + private String firmAddress; + private String firmPhone; + private String firmBank; + private String firmBankAccount; + private String isShowDate; + private String userNotes; + private String creatorType; + private String iCreateTime; + private String invoicingTime; + private String drawer; + private String financeNotes; + private String electricInvoiceUrl; + private String isRead; + private String historySerialNumber; + private String powerPriceTotal; + private String servicePriceTotal; + private String promotionDiscount; + private String historyActPrice; + private String hCreateTime; + private String chargingMode; + +} diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java index 4974e0b7..638a9cad 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java @@ -1,6 +1,7 @@ package com.xhpc.invoice.mapper; import com.xhpc.invoice.domain.AllInvoiceOrdersRequest; +import com.xhpc.invoice.domain.ExcelInvoiceRow; import com.xhpc.invoice.domain.InvoiceHistoryRecordsRequest; import com.xhpc.invoice.domain.InvoiceToUserRequest; import com.xhpc.invoice.pojo.XhpcInvoice; @@ -176,4 +177,15 @@ public interface XhpcInvoiceMapper { */ void updateByInvoiceId(Long invoiceId); + /** + * 获取发票内容 + * + * @param invoiceId 发票id + * @return 专门用于放置到Excel中Map + * @author WH + * @date 2021/12/30 18:08 + * @since version-1.0 + */ + List selectExcelInvoiceById(Long invoiceId); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java index 92cd12d4..5b73a643 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java @@ -2,6 +2,10 @@ package com.xhpc.invoice.service; import com.xhpc.invoice.domain.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + /** * 用于处理发票相关请求的Service * @@ -133,4 +137,16 @@ public interface XhpcInvoiceService { */ Long findNotReadCount(Long creatorId, Integer creatorType); + /** + * 导出所有发票记录(已开与未开)到Excel中 + * + * @param invoiceIds 发票id + * @param response 响应的response + * @throws IOException 该Response对象不存在时,抛出该异常对象 + * @author WH + * @date 2021/12/30 10:16 + * @since version-1.0 + */ + void exportExcel(List invoiceIds, HttpServletResponse response) throws IOException; + } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index 52e0cd11..ecadba21 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -1,6 +1,5 @@ package com.xhpc.invoice.service.impl; -import cn.hutool.core.collection.CollUtil; import cn.hutool.extra.mail.MailUtil; import cn.hutool.http.HttpUtil; import cn.hutool.poi.excel.ExcelUtil; @@ -22,7 +21,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -481,22 +482,94 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * 导出所有发票记录(已开与未开)到Excel中 * * @param invoiceIds 发票id + * @param response 响应对象 * @author WH * @date 2021/12/30 10:16 * @since version-1.0 */ @Override - public void exportExcel(List invoiceIds) { - - Integer integer = invoiceIds.get(0); - //获取要导出的发票记录 - XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(Long.valueOf(integer)); - List rows = CollUtil.newArrayList(xhpcInvoice); - //写出记录到excel表中 - ExcelWriter writer = ExcelUtil.getWriter("d:/writeTest.xlsx"); - writer.write(rows); - writer.close(); + public void exportExcel(List invoiceIds, HttpServletResponse response) throws IOException { + //创建Excel写入对象 + ExcelWriter writer = ExcelUtil.getWriter("record.xlsx"); + //设置单元格标题别名 + setExcelCellName(writer); + //定义每一行的行号(1,2,3,4...) + int rowsNumber = 1; + //设定初始合并行参数(即第一行该从哪行开始合并,合并几行) + int rowStart = 1; + int lastRow = 0; + for (String invoiceId : invoiceIds) { + List excelInvoiceRows = xhpcInvoiceMapper.selectExcelInvoiceById(Long.valueOf(invoiceId)); + //往记录中塞入行号 + for (ExcelInvoiceRow excelInvoiceRow : excelInvoiceRows) { + excelInvoiceRow.setRowsNumber(rowsNumber); + } + //写入记录 + writer.write(excelInvoiceRows); + int invoiceCount = excelInvoiceRows.size(); + //如果写入的发票记录只有一个,就不合并单元格,增加合并行索引,为下面需要合并的行做准备。 + if (invoiceCount == 1) { + lastRow = lastRow + 1; + rowStart = rowStart + 1; + } else { + //计算每条要合并发票记录的行的最后一个行号 + lastRow = lastRow + invoiceCount; + //合并单元格 + for (int columnIndex = 0; columnIndex <= 21; columnIndex++) { + writer.merge(rowStart, lastRow, columnIndex, columnIndex, null, false); + } + //计算每条要合并发票记录的行的第一个行号 + rowStart = rowStart + invoiceCount; + } + rowsNumber++; + } + //设置文件类型 + response.setContentType(ExcelUtil.XLSX_CONTENT_TYPE); + //让浏览器下载 + response.addHeader("Content-Disposition", "attachment;filename=" + "invoiceRecord.xlsx"); //设置返回的文件名称 //写入到Response中 + writer.flush(response.getOutputStream(), true); + } + + /** + * 设置生成的Excel表格单元格标题 + * + * @param writer Excel写入器 + * @author WH + * @date 2021/12/31 11:10 + * @since version-1.0 + */ + private void setExcelCellName(ExcelWriter writer) { + + writer.addHeaderAlias("rowsNumber", "序号"); + writer.addHeaderAlias("invoiceType", "发票类型"); + writer.addHeaderAlias("receiveEmail", "接收邮箱"); + writer.addHeaderAlias("titleType", "抬头类型"); + writer.addHeaderAlias("titleContent", "抬头内容"); + writer.addHeaderAlias("dutyNumber", "税号"); + writer.addHeaderAlias("invoiceContent", "发票内容"); + writer.addHeaderAlias("invoiceOrderElectricTotalMoney", "总电量金额"); + writer.addHeaderAlias("invoiceOrderServiceTotalMoney", "总服务费金额"); + writer.addHeaderAlias("firmAddress", "地址"); + writer.addHeaderAlias("firmPhone", "电话号码"); + writer.addHeaderAlias("firmBank", "开户行"); + writer.addHeaderAlias("firmBankAccount", "银行开户账号"); + writer.addHeaderAlias("isShowDate", "用户是否要求展示交易日期"); + writer.addHeaderAlias("userNotes", "用户备注"); + writer.addHeaderAlias("creatorType", "用户类型"); + writer.addHeaderAlias("iCreateTime", "发票申请时间"); + writer.addHeaderAlias("invoicingTime", "发票开票时间"); + writer.addHeaderAlias("drawer", "开票人"); + writer.addHeaderAlias("financeNotes", "财物备注"); + writer.addHeaderAlias("electricInvoiceUrl", "电子发票地址"); + writer.addHeaderAlias("isRead", "用户是否阅读发票信息"); + writer.addHeaderAlias("historySerialNumber", "订单编号"); + writer.addHeaderAlias("powerPriceTotal", "订单电费"); + writer.addHeaderAlias("servicePriceTotal", "订单服务费"); + writer.addHeaderAlias("promotionDiscount", "折扣费用"); + writer.addHeaderAlias("historyActPrice", "用户实际支付金额"); + writer.addHeaderAlias("hCreateTime", "订单创建时间"); + writer.addHeaderAlias("chargingMode", "订单来源"); } diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml index ce830f28..05f75e36 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -188,6 +188,48 @@ AND creator_id = #{creatorId} AND creator_type = #{creatorType} + delete from xhpc_invoice From 45a69c2296a0004e7299a6b760b2176fde330081 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Mon, 3 Jan 2022 21:02:32 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/AllInvoiceOrdersRequest.java | 5 ++ .../domain/AllInvoiceOrdersResponse.java | 5 ++ .../invoice/mapper/XhpcInvoiceMapper.java | 10 +++ .../com/xhpc/invoice/pojo/XhpcInvoice.java | 7 +- .../pojo/XhpcInvoiceMapHistoryOrder.java | 6 +- .../service/impl/XhpcInvoiceServiceImpl.java | 43 +++++++---- .../mapper/XhpcHistoryOrderMapper.xml | 72 +++++++++++++++---- .../XhpcInvoiceMapHistoryOrderMapper.xml | 14 ++-- .../resources/mapper/XhpcInvoiceMapper.xml | 20 +++++- 9 files changed, 142 insertions(+), 40 deletions(-) diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersRequest.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersRequest.java index 711ab6a3..36e4609c 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersRequest.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersRequest.java @@ -25,6 +25,11 @@ public class AllInvoiceOrdersRequest { */ @JsonProperty("creatorType") private Integer creatorType; + /** + * 发票类型 0为普票,1为专票 + */ + @JsonProperty("invoiceType") + private Integer invoiceType; /** * 发票状态(0表示未开票,1表示已经开票,2表示开票失败) */ diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersResponse.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersResponse.java index f865a59e..ebeeffe6 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersResponse.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/domain/AllInvoiceOrdersResponse.java @@ -58,6 +58,11 @@ public class AllInvoiceOrdersResponse { */ @JsonProperty("creatorType") private Integer creatorType; + /** + * 发票类型 0为普票,1为专票 + */ + @JsonProperty("invoiceType") + private Integer invoiceType; /** * 发票金额 */ diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java index 638a9cad..3c277857 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/mapper/XhpcInvoiceMapper.java @@ -188,4 +188,14 @@ public interface XhpcInvoiceMapper { */ List selectExcelInvoiceById(Long invoiceId); + /** + * 更新发票所包含的电量总金额,服务费总金额 + * + * @param xhpcInvoice 存放要更新数据的实体类 + * @author WH + * @date 2022/1/3 17:06 + * @since version-1.0 + */ + void updateElectricAndServiceById(XhpcInvoice xhpcInvoice); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java index aa635593..474fa6e5 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoice.java @@ -9,7 +9,7 @@ import java.util.Date; /** * xhpc_invoice * - * @author + * @author WH */ @Data public class XhpcInvoice implements Serializable { @@ -19,6 +19,11 @@ public class XhpcInvoice implements Serializable { */ private Long invoiceId; + /** + * 发票类型(默认0普票,1为专票) + */ + private Integer invoiceType; + /** * 接收邮箱 */ diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java index 278f745c..232887b3 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/pojo/XhpcInvoiceMapHistoryOrder.java @@ -1,6 +1,7 @@ package com.xhpc.invoice.pojo; import lombok.Data; +import lombok.NoArgsConstructor; import java.io.Serializable; import java.math.BigDecimal; @@ -9,8 +10,9 @@ import java.util.Date; /** * xhpc_invoice_map_history_order * - * @author + * @author WH */ +@NoArgsConstructor @Data public class XhpcInvoiceMapHistoryOrder implements Serializable { @@ -37,7 +39,7 @@ public class XhpcInvoiceMapHistoryOrder implements Serializable { /** * 该发票所选中的历史订单订单编号 */ - private String hisotrySerialNumber; + private String historySerialNumber; /** * 该发票所选中的历史订单电费 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index ecadba21..d74fdd63 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -9,6 +9,7 @@ import com.xhpc.common.core.utils.bean.BeanUtils; import com.xhpc.common.domain.XhpcChargingStation; import com.xhpc.common.redis.service.RedisService; import com.xhpc.invoice.constant.InvoiceMapHistoryOrderStatusConst; +import com.xhpc.invoice.constant.InvoiceStatusConst; import com.xhpc.invoice.domain.*; import com.xhpc.invoice.mapper.*; import com.xhpc.invoice.pojo.XhpcInvoice; @@ -57,7 +58,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { RedisService redisService; /** - * 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息 + * 通过requestData中的申请人、申请人类型、发票类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息 * * @param requestData 传递过来的查询参数 * @return AllInvoiceOrdersResponse 发票列表对象 @@ -69,19 +70,22 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { public AllInvoiceOrdersResponse selectAllInvoiceOrders(AllInvoiceOrdersRequest requestData) { //计算分页索引 requestData.setCurrentPage((requestData.getCurrentPage() - 1) * requestData.getItems()); - //获取每个历史订单信息 + //获取每张发票信息 List xhpcInvoiceList = xhpcInvoiceMapper.selectAllInvoiceOrdersByCondition(requestData); //对拷,放置到itemsDTO中,然后将itemsDTO存放到itemsDTOList中 ArrayList itemsDTOList = new ArrayList<>(); for (XhpcInvoice xhpcInvoice : xhpcInvoiceList) { AllInvoiceOrdersResponse.ItemsDTO itemsDTO = new AllInvoiceOrdersResponse.ItemsDTO(); itemsDTO.setInvoiceId(xhpcInvoice.getInvoiceId()); + itemsDTO.setInvoiceType(xhpcInvoice.getInvoiceType()); itemsDTO.setCreator(xhpcInvoice.getCreator()); itemsDTO.setCreatorType(xhpcInvoice.getCreatorType()); itemsDTO.setInvoiceMoney(xhpcInvoice.getInvoiceMoney()); itemsDTO.setStatus(xhpcInvoice.getStatus()); itemsDTO.setCreateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcInvoice.getCreateTime())); - itemsDTO.setInvoicingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcInvoice.getInvoicingTime())); + if (xhpcInvoice.getInvoicingTime() != null) { + itemsDTO.setInvoicingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcInvoice.getInvoicingTime())); + } itemsDTO.setDrawer(xhpcInvoice.getDrawer()); itemsDTOList.add(itemsDTO); } @@ -99,6 +103,10 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { allInvoiceOrdersResponse.setInvoicedSumMoney(allInvoicedMoney); //查询所有未开发票总金额 BigDecimal allNotInvoicedMoney = xhpcInvoiceMapper.allNotInvoicedMoney(); + if (allNotInvoicedMoney == null) { + //如果没有任何未开发票,那么总金额就设置成0.00 + allNotInvoicedMoney = new BigDecimal("0.00"); + } allInvoiceOrdersResponse.setNotInvoiceSumMoney(allNotInvoicedMoney); return allInvoiceOrdersResponse; } @@ -283,7 +291,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { SpecificInvoicedResponse.HistoryOrdersDTO.HistoryOrdersDataDTO historyOrdersDataDTO = new SpecificInvoicedResponse.HistoryOrdersDTO.HistoryOrdersDataDTO(); historyOrdersDataDTO.setHistoryOrderId(xhpcInvoiceMapHistoryOrder.getHistoryOrderId()); historyOrdersDataDTO.setActPrice(xhpcInvoiceMapHistoryOrder.getHistoryActPrice()); - historyOrdersDataDTO.setHistorySerialNumber(xhpcInvoiceMapHistoryOrder.getHisotrySerialNumber()); + historyOrdersDataDTO.setHistorySerialNumber(xhpcInvoiceMapHistoryOrder.getHistorySerialNumber()); historyOrdersDataDTO.setOrderCreateTime(DateUtils.parseDateToStr(xhpcInvoiceMapHistoryOrder.getCreateTime())); historyOrdersDataDTOS.add(historyOrdersDataDTO); } @@ -292,6 +300,11 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { historyOrdersDTO.setTotalItems(historyOrdersList.size()); specificInvoicedResponse.setHistoryOrders(historyOrdersDTO); + //如果用户在该发票还没有被处理时,点击查看该发票详情,那么就直接返回数据。 + if (xhpcInvoice.getStatus().equals(InvoiceStatusConst.INVOICING)) { + return specificInvoicedResponse; + } + //一旦调了详情接口,就去掉该已开发票的未读状态,同时redis中的未读数量数据-1 xhpcInvoiceMapper.updateByInvoiceId(invoiceId); reduceNoReadInvoiceCount(xhpcInvoice); @@ -400,7 +413,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { //判断传入的历史订单是否被其他发票包含 List historyOrderIds = saveInvoiceInfoRequest.getHistoryOrderIds(); List lockOrderList = xhpcInvoiceMapHistoryOrderMapper.getLockedOnesByHistoryOrderId(historyOrderIds); - if (lockOrderList != null) { + if (lockOrderList.size() > 0) { throw new Exception("该历史订单已被其他发票包含"); } //将该发票记录放入数据库生成发票记录,除了所包含的历史订单的总电费,总服务费 @@ -439,9 +452,9 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { xhpcInvoiceMapHistoryOrder.setHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); xhpcInvoiceMapHistoryOrder.setHistoryUserId(xhpcHistoryOrder.getUserId()); xhpcInvoiceMapHistoryOrder.setHistoryUserType(Long.valueOf(xhpcHistoryOrder.getSource())); - xhpcInvoiceMapHistoryOrder.setHisotrySerialNumber(xhpcHistoryOrder.getSerialNumber()); - xhpcInvoiceMapHistoryOrder.setPowerPriceTotal(xhpcHistoryOrder.getActPowerPrice()); - xhpcInvoiceMapHistoryOrder.setServicePriceTotal(xhpcHistoryOrder.getActServicePrice()); + xhpcInvoiceMapHistoryOrder.setHistorySerialNumber(xhpcHistoryOrder.getSerialNumber()); + xhpcInvoiceMapHistoryOrder.setPowerPriceTotal(xhpcHistoryOrder.getPowerPriceTotal()); + xhpcInvoiceMapHistoryOrder.setServicePriceTotal(BigDecimal.valueOf(xhpcHistoryOrder.getServicePriceTotal().doubleValue() - xhpcHistoryOrder.getPromotionDiscount().doubleValue())); xhpcInvoiceMapHistoryOrder.setPromotionDiscount(xhpcHistoryOrder.getPromotionDiscount()); xhpcInvoiceMapHistoryOrder.setHistoryActPrice(xhpcHistoryOrder.getActPrice()); xhpcInvoiceMapHistoryOrder.setCreateTime(xhpcHistoryOrder.getCreateTime()); @@ -450,16 +463,16 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { xhpcInvoiceMapHistoryOrder.setTerminalId(xhpcHistoryOrder.getTerminalId()); xhpcInvoiceMapHistoryOrder.setLockFlag(InvoiceMapHistoryOrderStatusConst.LOCK); xhpcInvoiceMapHistoryOrderMapper.insertSelective(xhpcInvoiceMapHistoryOrder); - totalPowerPrice += xhpcHistoryOrder.getActPowerPrice().doubleValue(); - totalServicePrice += xhpcHistoryOrder.getActServicePrice().doubleValue(); - totalActPrice += xhpcHistoryOrder.getActPrice().doubleValue(); + totalPowerPrice += xhpcHistoryOrder.getPowerPriceTotal().doubleValue(); + totalServicePrice += (xhpcHistoryOrder.getServicePriceTotal().doubleValue() - xhpcHistoryOrder.getPromotionDiscount().doubleValue()); + totalActPrice += xhpcHistoryOrder.getTotalPrice().doubleValue(); } if (!BigDecimal.valueOf(totalActPrice).equals(saveInvoiceInfoRequest.getInvoiceMoney())) { throw new Exception("传入的发票金额与实际包含的历史订单总金额参数不匹配"); } xhpcInvoice.setInvoiceOrderEletricTotalMoney(BigDecimal.valueOf(totalPowerPrice)); xhpcInvoice.setInvoiceOrderServiceTotalMoney(BigDecimal.valueOf(totalServicePrice)); - xhpcInvoiceMapper.insertSelective(xhpcInvoice); + xhpcInvoiceMapper.updateElectricAndServiceById(xhpcInvoice); } /** @@ -591,7 +604,9 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { specificInvoiceWrap.setInvoiceMoney(xhpcInvoice.getInvoiceMoney()); specificInvoiceWrap.setInvoiceTotalEletricMoney(xhpcInvoice.getInvoiceOrderEletricTotalMoney()); specificInvoiceWrap.setInvoiceTotalServiceMoney(xhpcInvoice.getInvoiceOrderServiceTotalMoney()); - specificInvoiceWrap.setInvoicingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcInvoice.getInvoicingTime())); + if (xhpcInvoice.getInvoicingTime() != null) { + specificInvoiceWrap.setInvoicingTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcInvoice.getInvoicingTime())); + } //处理包装类内层数据 specificInvoiceWrap.setHistoryOrders(new SpecificInvoiceWrap.HistoryOrdersDTO()); SpecificInvoiceWrap.HistoryOrdersDTO historyOrdersDTO = specificInvoiceWrap.getHistoryOrders(); @@ -608,7 +623,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { historyOrdersDataDTO.setHistoryCreateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, xhpcInvoiceMapHistoryOrder.getCreateTime())); historyOrdersDataDTO.setServiceMoney(xhpcInvoiceMapHistoryOrder.getServicePriceTotal()); historyOrdersDataDTO.setEletricMoney(xhpcInvoiceMapHistoryOrder.getPowerPriceTotal()); - historyOrdersDataDTO.setHistorySerialNumber(xhpcInvoiceMapHistoryOrder.getHisotrySerialNumber()); + historyOrdersDataDTO.setHistorySerialNumber(xhpcInvoiceMapHistoryOrder.getHistorySerialNumber()); XhpcChargingStation xhpcChargingStation = xhpcChargingStationMapper.selectXhpcChargingStationById(xhpcInvoiceMapHistoryOrder.getChargingStationId()); Map operatorInfo = xhpcOperatorMapper.info(xhpcChargingStation.getOperatorId()); String operatorName = (String) operatorInfo.get("name"); diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index f9748596..d273a0b1 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -53,21 +53,67 @@ + history_order_id - , charging_station_id, charge_order_id, user_id, terminal_id, serial_number, - internet_serial_number, power_price_total, service_price_total, total_price, promotion_discount, - act_price, act_power_price, act_service_price, internet_commission, internet_svc_commission, - platform_commission, platform_svc_commisssion, operation_commission, operation_svc_commission, - start_soc, end_soc, reconciliation_status, sorting_status, `type`, `status`, del_flag, - create_time, create_by, update_time, update_by, remark, `state`, vin_normal, search_value, - operator_id_evcs, charge_model_evcs, connector_power_evcs, meter_value_end_evcs, - meter_value_start_evcs, operator_id3rdpty_evcs, start_time, stop_reason_evcs, total_power, - user_name_evcs, phone, rate_model_id + , + charging_station_id, + charge_order_id, + user_id, + terminal_id, + serial_number, + internet_serial_number, + power_price_total, + service_price_total, + total_price, + promotion_discount, + act_price, + act_power_price, + act_service_price, + internet_commission, + internet_svc_commission, + platform_commission, + platform_svc_commisssion, + operation_commission, + operation_svc_commission, + start_soc, + end_soc, + reconciliation_status, + sorting_status, + type, + status, + del_flag, + create_time, + create_by, + update_time, + update_by, + remark, + state, + vin_normal, + search_value, + operator_id_evcs, + charge_model_evcs, + connector_power_evcs, + meter_value_end_evcs, + meter_value_start_evcs, + operator_id3rdpty_evcs, + start_time, + end_time, + stop_reason_evcs, + total_power, + user_name_evcs, + phone, + evcs_order_no, + confirm_Result, + rate_model_id, + charging_mode, + internet_degree_commission, + source, + tenant_id - SELECT FROM xhpc_history_order WHERE - del_flag IS NULL - + del_flag = 0 + AND history_order_id IN - + #{historyOrderId} diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml index 69bd1187..1fda4377 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapHistoryOrderMapper.xml @@ -6,7 +6,7 @@ - + @@ -25,7 +25,7 @@ `history_order_id`, `history_user_id`, `history_user_type`, - `hisotry_serial_number`, + `history_serial_number`, `power_price_total`, `service_price_total`, `promotion_discount`, @@ -68,8 +68,8 @@ history_user_type, - - hisotry_serial_number, + + history_serial_number, power_price_total, @@ -115,8 +115,8 @@ #{historyUserType,jdbcType=BIGINT}, - - #{hisotrySerialNumber,jdbcType=VARCHAR}, + + #{historySerialNumber,jdbcType=VARCHAR}, #{powerPriceTotal,jdbcType=DECIMAL}, @@ -199,7 +199,7 @@ xhpc_invoice_map_history_order WHERE history_order_id IN - + #{historyOrderId} AND lock_flag = 0; diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml index 05f75e36..1c3495ec 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcInvoiceMapper.xml @@ -3,6 +3,7 @@ + @@ -72,6 +73,7 @@ - select - cs.charging_station_id as chargingStationId, - cs.name as name, - ope.name as operatorName, - cs.address as address, - (select url from xhpc_img where img_id = cs.img_id and del_flag =0 limit 1) as url, - cs.client_visible as clientVisible, - cs.status as status - from xhpc_charging_station as cs - left join xhpc_operator as ope on cs.operator_id = ope.operator_id - where cs.del_flag =0 - - and cs.name like CONCAT('%',#{name},'%') - - - and ope.name like CONCAT('%',#{operatorName},'%') - - - and cs.charging_station_id in(select charging_station_id from xhpc_charging_station where - operator_id=#{operatorId}) - - - and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where - user_id=#{operatorId}) - - - - - - - - insert into xhpc_charging_station - - charging_station_id, - name, - operator_id, - type, - construction_site, - service_facilities, - periphery_facilities, - area_code, - address, - detailed_address, - longitude, - latitude, - parking_instructions, - serial_number, - client_visible, - status, - del_flag, - create_time, - create_by, - update_time, - update_by, - remark, - rate_model_id, - - - #{chargingStationId}, - #{name}, - #{operatorId}, - #{type}, - #{constructionSite}, - #{serviceFacilities}, - #{peripheryFacilities}, - #{areaCode}, - #{address}, - #{detailedAddress}, - #{longitude}, - #{latitude}, - #{parkingInstructions}, - #{serialNumber}, - #{clientVisible}, - #{status}, - #{delFlag}, - #{createTime}, - #{createBy}, - #{updateTime}, - #{updateBy}, - #{remark}, - #{rateModelId}, - - - - - update xhpc_charging_station - - name = #{name}, - operator_id = #{operatorId}, - type = #{type}, - construction_site = #{constructionSite}, - service_facilities = #{serviceFacilities}, - periphery_facilities = #{peripheryFacilities}, - area_code = #{areaCode}, - address = #{address}, - detailed_address = #{detailedAddress}, - longitude = #{longitude}, - latitude = #{latitude}, - parking_instructions = #{parkingInstructions}, - serial_number = #{serialNumber}, - client_visible = #{clientVisible}, - status = #{status}, - del_flag = #{delFlag}, - create_time = #{createTime}, - create_by = #{createBy}, - update_time = #{updateTime}, - update_by = #{updateBy}, - remark = #{remark}, - rate_model_id = #{rateModelId}, - business_instructions = #{businessInstructions}, - reminder_instructions = #{reminderInstructions}, - img_id = #{imgId}, - station_type = #{stationType}, - operator_id_evcs = #{operatorIdEvcs}, - service_tel = #{serviceTel}, - park_nums = #{parkNums} - - where charging_station_id = #{chargingStationId} - - - - update xhpc_charging_station - set del_flag =1 - where charging_station_id = #{chargingStationId} - - - - update xhpc_charging_station set del_flag =1 where charging_station_id in - - #{chargingStationId} - - - - - update xhpc_charging_station - set status =#{status} - where charging_station_id = #{chargingStationId} - and del_flag = 0 - - - - update xhpc_charging_station - set client_visible =#{clientVisible} - where charging_station_id = #{chargingStationId} - and del_flag = 0 - - - - - - - - - - - - - - - - - - - - - insert into xhpc_rate_model - - - status, - - - del_flag, - - - create_time, - - - create_by, - - - update_time, - - - update_by, - - - remark - - - - - #{status}, - - - #{delFlag}, - - - #{createTime}, - - - #{createBy}, - - - #{updateTime}, - - - #{updateBy}, - - - #{remark} - - - - - - insert into xhpc_charging_station - - - name, - - - operator_id, - - - type, - - - construction_site, - - - service_facilities, - - - periphery_facilities, - - - area_code, - - - address, - - - detailed_address, - - - longitude, - - - latitude, - - - parking_instructions, - - - serial_number, - - - client_visible, - - - rate_model_id, - - - img_id, - - - business_instructions, - - - reminder_instructions, - - - status, - - - del_flag, - - - create_time, - - - create_by, - - - update_time, - - - update_by, - - - remark, - - - station_type, - - - operator_id_evcs, - - - service_tel, - - - park_nums - - - - - #{name}, - - - #{operatorId}, - - - #{type}, - - - #{constructionSite}, - - - #{serviceFacilities}, - - - #{peripheryFacilities}, - - - #{areaCode}, - - - #{address}, - - - #{detailedAddress}, - - - #{longitude}, - - - #{latitude}, - - - #{parkingInstructions}, - - - #{serialNumber}, - - - #{clientVisible}, - - - #{rateModelId}, - - - #{imgId}, - - - #{businessInstructions}, - - - #{reminderInstructions}, - - - #{status}, - - - #{delFlag}, - - - #{createTime}, - - - #{createBy}, - - - #{updateTime}, - - - #{updateBy}, - - - #{remark}, - - - #{stationType}, - - - #{operatorIdEvcs}, - - - #{serviceTel}, - - - #{parkNums} - - - - - - insert into xhpc_rate - - - charging_station_id, - - - power_fee, - - - service_fee, - - - name, - - - del_flag, - - - create_time, - - - create_by, - - - update_time, - - - update_by, - - - remark, - - - rate_value, - - - rate_model_id - - - - - #{chargingStationId}, - - - #{powerFee}, - - - #{serviceFee}, - - - #{name}, - - - #{status}, - - - #{delFlag}, - - - #{createTime}, - - - #{createBy}, - - - #{updateTime}, - - - #{updateBy}, - - - #{remark}, - - - #{rateValue}, - - - #{rateModelId} - - - - - - - - insert into xhpc_rate_time - - - charging_station_id, - - - rate_id, - - - start_time, - - - end_time, - - - rate_model_id, - - - sort, - - - status, - - - del_flag, - - - create_time, - - - create_by, - - - update_time, - - - update_by, - - - remark, - - - type, - - - rate_value - - - - - #{chargingStationId}, - - - #{rateId}, - - - #{startTime}, - - - #{endTime}, - - - #{rateModelId}, - - - #{sort}, - - - #{status}, - - - #{delFlag}, - - - #{createTime}, - - - #{createBy}, - - - #{updateTime}, - - - #{updateBy}, - - - #{remark}, - - - #{type}, - - - #{rateValue} - - - - - - - - - - - - update xhpc_rate - set del_flag =1 - where charging_station_id = #{chargingStationId} - and del_flag = 0 - - - - update xhpc_rate_time - set del_flag =1 - where charging_station_id = #{chargingStationId} - and del_flag = 0 - - - - - - - - update xhpc_charging_pile - set rate_model_id=#{rateModelId} - WHERE charging_station_id = #{chargingStationId} - - - - update xhpc_terminal - set rate_model_id=#{rateModelId} - WHERE charging_station_id = #{chargingStationId} - - - - - - insert into xhpc_user_privilege( - - user_id, - - - charging_station_id - - )values( - - #{userId}, - - - #{chargingStationId} - - ) - diff --git a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcOperatorMapper.xml b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcOperatorMapper.xml index 7e0568e3..0b82fb81 100644 --- a/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcOperatorMapper.xml +++ b/xhpc-modules/xhpc-invoice/src/main/resources/mapper/XhpcOperatorMapper.xml @@ -51,236 +51,6 @@ xo.create_by createBy, xo.update_time updateTime, xo.update_by updateBy, xo.remark, - - insert into xhpc_operator - - - name, - - - contact_name, - - - contact_phone, - - - phone, - - - attribute, - - - duty_paragraph, - - - detailed_address, - - - open_bank, - - - card_number, - - - area_code, - - - address, - - - longitude, - - - latitude, - - - email, - - - commission_type, - - - platform_commission_rate, - - - maintenance_commission_rate, - - - business_license_id, - - - withdrawal_time, - - - soc, - - - status, - - - del_flag, - - - create_time, - - - create_by, - - - update_time, - - - update_by, - - - remark, - - - operator_id_evcs - - - - - #{name}, - - - #{contactName}, - - - #{contactPhone}, - - - #{phone}, - - - #{attribute}, - - - #{dutyParagraph}, - - - #{detailedAddress}, - - - #{openBank}, - - - #{cardNumber}, - - - #{areaCode}, - - - #{address}, - - - #{longitude}, - - - #{latitude}, - - - #{email}, - - - #{commissionType}, - - - #{platformCommissionRate}, - - - #{maintenanceCommissionRate}, - - - #{businessLicenseId}, - - - #{withdrawalTime}, - - - #{soc}, - - - #{status}, - - - #{delFlag}, - - - #{createTime}, - - - #{createBy}, - - - #{updateTime}, - - - #{updateBy}, - - - #{remark}, - - - #{operatorIdEvcs} - - - - - - UPDATE xhpc_operator - - operator_id = #{operatorId}, - name = #{name}, - contact_name = #{contactName}, - contact_phone = #{contactPhone}, - phone = #{phone}, - attribute = #{attribute}, - open_bank = #{openBank}, - card_number = #{cardNumber}, - area_code = #{areaCode}, - address = #{address}, - longitude = #{longitude}, - latitude = #{latitude}, - email = #{email}, - commission_type = #{commissionType}, - platform_commission_rate = - #{platformCommissionRate}, - - maintenance_commission_rate - = #{maintenanceCommissionRate}, - - business_license_id = - #{businessLicenseId}, - - withdrawal_time = #{withdrawalTime}, - soc = #{soc}, - status = #{status}, - del_flag = #{delFlag}, - create_time = #{createTime}, - create_by = #{createBy}, - update_time = #{updateTime}, - update_by = #{updateBy}, - remark = #{remark}, - operator_id_evcs = #{operatorIdEvcs} - - WHERE operator_id = #{operatorId} - - - - delete from xhpc_operator where operator_id in - - #{ids} - - - - - - - - - delete - from sys_user_role - where user_id = #{userId} - - - - delete - from sys_user_post - where user_id = #{userId} - - - - update sys_user - set del_flag = #{delFlag} - where user_id = #{userId} - - - - - - - - - delete - from sys_role - where role_name = #{roleName} - From 525848b786e52860c7c852a9098f380ab552e129 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Tue, 4 Jan 2022 11:23:09 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Log=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3Controller=E8=AF=B7=E6=B1=82=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=B8=BARestful=E9=A3=8E=E6=A0=BC=E4=BD=BF=E5=85=B6=E8=A7=84?= =?UTF-8?q?=E8=8C=83=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8C=E9=9D=9Emapper=E5=B1=82=E4=B8=8D=E7=94=A8sel?= =?UTF-8?q?ect=E5=85=B3=E9=94=AE=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invoice/api/XhpcInvoiceApiController.java | 43 ++++++++++--------- .../invoice/service/XhpcInvoiceService.java | 10 ++--- .../service/impl/XhpcInvoiceServiceImpl.java | 10 ++--- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java index 6a375e8e..7bfbdaaf 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java @@ -2,6 +2,8 @@ package com.xhpc.invoice.api; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.log.annotation.Log; +import com.xhpc.common.log.enums.BusinessType; import com.xhpc.invoice.domain.*; import com.xhpc.invoice.service.XhpcInvoiceService; import org.springframework.web.bind.annotation.*; @@ -37,13 +39,14 @@ public class XhpcInvoiceApiController extends BaseController { } /** - * 保存用户所要开的发票信息 + * 保存用户提交的开发票的信息 * * @author WH * @date 2021/12/28 14:54 * @since version-1.0 */ - @PostMapping() + @Log(title = "用户要开发票", businessType = BusinessType.INSERT) + @PostMapping("/user/commit") public AjaxResult saveInvoiceInfo(@RequestBody SaveInvoiceInfoRequest saveInvoiceInfoRequest) throws Exception { xhpcInvoiceService.saveInvoiceInfo(saveInvoiceInfoRequest); @@ -57,15 +60,15 @@ public class XhpcInvoiceApiController extends BaseController { * @date 2021/12/27 12:23 * @since version-1.0 */ - @PostMapping(value = "/selectInvoiceHistoryRecords") - public AjaxResult selectInvoiceHistoryRecords(@RequestBody InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest) { + @GetMapping(value = "/user/history") + public AjaxResult findInvoiceHistoryRecords(@RequestBody InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest) { - InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = xhpcInvoiceService.selectInvoiceHistoryRecords(invoiceHistoryRecordsRequest); + InvoiceHistoryRecordsResponse invoiceHistoryRecordsResponse = xhpcInvoiceService.findInvoiceHistoryRecords(invoiceHistoryRecordsRequest); return AjaxResult.success(invoiceHistoryRecordsResponse); } /** - * 回显已经处理的开的的电子发票的详情信息 + * 回显电子发票详情信息 * * @param invoiceId 要回显的发票id * @return 返回包含了指定数据的AjaxResult @@ -73,28 +76,28 @@ public class XhpcInvoiceApiController extends BaseController { * @date 2021/12/27 13:11 * @since version-1.0 */ - @GetMapping(value = "/selectSpecificInvoiced") - public AjaxResult selectSpecificInvoiced(@RequestParam Long invoiceId) { + @GetMapping(value = "/specific-info") + public AjaxResult findSpecificInvoicedInfo(@RequestParam Long invoiceId) { - SpecificInvoicedResponse specificInvoicedResponse = xhpcInvoiceService.selectSpecificInvoiced(invoiceId); + SpecificInvoicedResponse specificInvoicedResponse = xhpcInvoiceService.findSpecificInvoicedInfo(invoiceId); return AjaxResult.success(specificInvoicedResponse); } /** - * 根据用户id,用户类型,要查询的当前时间的年月日,查询该用户3个月内可以开发票的订单 + * 根据用户id,用户类型,要查询的当前时间的年月日,查询该用户3个月内可以开发票的历史订单 * * @author WH * @date 2021/12/24 14:10 * @since version-1.0 */ - @PostMapping(value = "/selectInvoicedOrders") - public AjaxResult selectInvoicedOrders(@RequestBody InvoicedOrdersRequest invoicedOrdersRequest) { + @GetMapping(value = "/user/history-orders") + public AjaxResult findUserHistoryOrders(@RequestBody InvoicedOrdersRequest invoicedOrdersRequest) { if (invoicedOrdersRequest.getCurrentPage() == null || invoicedOrdersRequest.getItems() == null) { return AjaxResult.error("分页参数不能为空:当前页数参数或当页要显示的条数为空"); } - InvoiceOrdersResponse invoiceOrdersResponse = xhpcInvoiceService.selectInvoicedOrders(invoicedOrdersRequest); + InvoiceOrdersResponse invoiceOrdersResponse = xhpcInvoiceService.findUserHistoryOrders(invoicedOrdersRequest); return AjaxResult.success(invoiceOrdersResponse); @@ -107,24 +110,24 @@ public class XhpcInvoiceApiController extends BaseController { * @date 2021/12/23 15:07 * @since version-1.0 */ - @GetMapping(value = "/selectInvoiceTitleInfo") - public AjaxResult selectInvoiceTitleInfo(@RequestParam(value = "firmName") String firmName) { + @GetMapping(value = "/title-info") + public AjaxResult findTitleInfo(@RequestParam(value = "firmName") String firmName) { - InvoiceTitleResponse invoiceTitleResponse = xhpcInvoiceService.selectInvoiceTitleInfo(firmName); + InvoiceTitleResponse invoiceTitleResponse = xhpcInvoiceService.findTitleInfo(firmName); return AjaxResult.success(invoiceTitleResponse); } /** - * 查询用户最后一次输入的发票信息 + * 查询用户最后一次所提交的发票信息 * * @author WH * @date 2021/12/23 15:07 * @since version-1.0 */ - @GetMapping(value = "/selectUserInputInvoiceInfo") - public AjaxResult selectUserInputInvoiceInfo(@RequestParam(value = "creatorId") Long creatorId, @RequestParam("creatorType") Integer creatorType) { + @GetMapping(value = "/user/last-info") + public AjaxResult findUserLastInputInfo(@RequestParam(value = "creatorId") Long creatorId, @RequestParam("creatorType") Integer creatorType) { - TitleResponse titleResponse = xhpcInvoiceService.selectUserInputInvoiceInfo(creatorId, creatorType); + TitleResponse titleResponse = xhpcInvoiceService.findUserLastInputInfo(creatorId, creatorType); return AjaxResult.success(titleResponse); } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java index 5b73a643..e7b70639 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java @@ -67,7 +67,7 @@ public interface XhpcInvoiceService { * @date 2021/12/23 15:29 * @since version-1.0 */ - InvoiceTitleResponse selectInvoiceTitleInfo(String firmName); + InvoiceTitleResponse findTitleInfo(String firmName); /** * 查询用户输入的最后一次的开发票所填写的信息 @@ -79,7 +79,7 @@ public interface XhpcInvoiceService { * @date 2021/12/23 17:23 * @since version-1.0 */ - TitleResponse selectUserInputInvoiceInfo(Long creatorId, Integer creatorType); + TitleResponse findUserLastInputInfo(Long creatorId, Integer creatorType); /** * 根据用户id,用户类型,要查询的当前时间的年月日,查询该用户3个月内可以开发票的订单 @@ -90,7 +90,7 @@ public interface XhpcInvoiceService { * @date 2021/12/24 10:42 * @since version-1.0 */ - InvoiceOrdersResponse selectInvoicedOrders(InvoicedOrdersRequest invoicedOrdersRequest); + InvoiceOrdersResponse findUserHistoryOrders(InvoicedOrdersRequest invoicedOrdersRequest); /** * 根据发票id,查询回显发票所需要的数据 @@ -101,7 +101,7 @@ public interface XhpcInvoiceService { * @date 2021/12/27 13:12 * @since version-1.0 */ - SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId); + SpecificInvoicedResponse findSpecificInvoicedInfo(Long invoiceId); /** * 根据前端传递过来的请求参数,查询所需要的开发票历史记录 @@ -112,7 +112,7 @@ public interface XhpcInvoiceService { * @date 2021/12/27 14:49 * @since version-1.0 */ - InvoiceHistoryRecordsResponse selectInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest); + InvoiceHistoryRecordsResponse findInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest); /** * 将用户申请的发票信息,保存到数据库中 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index c1120442..dc85a2df 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -188,7 +188,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { } @Override - public InvoiceTitleResponse selectInvoiceTitleInfo(String firmName) { + public InvoiceTitleResponse findTitleInfo(String firmName) { List xhpcInvoiceList = xhpcInvoiceMapper.selectInvoiceTitleInfo(firmName); ArrayList dataDTOList = new ArrayList<>(); @@ -214,7 +214,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override - public TitleResponse selectUserInputInvoiceInfo(Long creatorId, Integer creatorType) { + public TitleResponse findUserLastInputInfo(Long creatorId, Integer creatorType) { XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectUserLastInputInvoiceInfo(creatorId, creatorType); TitleResponse titleResponse = new TitleResponse(); @@ -233,7 +233,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override - public InvoiceOrdersResponse selectInvoicedOrders(InvoicedOrdersRequest invoicedOrdersRequest) { + public InvoiceOrdersResponse findUserHistoryOrders(InvoicedOrdersRequest invoicedOrdersRequest) { //计算分页索引,放置到currentPage属性中 int startIndex = (invoicedOrdersRequest.getCurrentPage() - 1) * invoicedOrdersRequest.getItems(); invoicedOrdersRequest.setCurrentPage(startIndex); @@ -269,7 +269,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { */ @Override @Transactional(rollbackFor = Exception.class) - public SpecificInvoicedResponse selectSpecificInvoiced(Long invoiceId) { + public SpecificInvoicedResponse findSpecificInvoicedInfo(Long invoiceId) { //对拷发票部分数据 XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(invoiceId); @@ -371,7 +371,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override - public InvoiceHistoryRecordsResponse selectInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest) { + public InvoiceHistoryRecordsResponse findInvoiceHistoryRecords(InvoiceHistoryRecordsRequest invoiceHistoryRecordsRequest) { //计算分页索引 int startIndex = (int) ((invoiceHistoryRecordsRequest.getCurrentPage() - 1) * invoiceHistoryRecordsRequest.getItems()); if (startIndex < 0) { From 0bf00a46d41fee77bfebbf72866ced4da454e08d Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Tue, 4 Jan 2022 13:02:42 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=B7=BB=E5=8A=A0Log?= =?UTF-8?q?=E6=97=A5=E5=BF=97=EF=BC=8C=E4=BF=AE=E6=94=B9Controller?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=B7=AF=E5=BE=84=E4=B8=BARestful=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=E4=BD=BF=E5=85=B6=E8=A7=84=E8=8C=83=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B9=E6=B3=95=E5=90=8D=E7=A7=B0=EF=BC=8C=E9=9D=9E?= =?UTF-8?q?mapper=E5=B1=82=E4=B8=8D=E7=94=A8select=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=EF=BC=8C=20=E5=AE=8C=E6=88=90=E8=AF=A5=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/XhpcChargingPileServiceImpl.java | 4 ++-- .../invoice/api/XhpcInvoiceApiController.java | 2 +- .../controller/XhpcInvoiceController.java | 18 +++++++++++------- .../invoice/service/XhpcInvoiceService.java | 4 ++-- .../service/impl/XhpcInvoiceServiceImpl.java | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index 0d10e68f..46fe544b 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -181,10 +181,10 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { if (xhpc.getSerialNumber() != xhpc.getSerialNumber()) { return AjaxResult.error("桩编号不能编辑"); } - if(xhpcChargingPile.getGunNumber() ==null || xhpcChargingPile.getGunNumber()>26){ + if (xhpcChargingPile.getGunNumber() == null || xhpcChargingPile.getGunNumber() > 26) { return AjaxResult.error("终端数量不能大于26"); } - if (!xhpcChargingPile.getGunNumber().equals(xhpc.getGunNumber())) { + if (!xhpcChargingPile.getGunNumber().equals(xhpc.getGunNumber()) || !xhpcChargingPile.getSerialNumber().equals(xhpc.getSerialNumber())) { //删除之前的终端 xhpcChargingPileMapper.updateXhpcTerminal(chargingPileId); int number = xhpcChargingPileMapper.countXhpcTerminal(xhpcChargingPile.getChargingStationId()); diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java index 7bfbdaaf..0f4c192d 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/api/XhpcInvoiceApiController.java @@ -25,7 +25,7 @@ public class XhpcInvoiceApiController extends BaseController { XhpcInvoiceService xhpcInvoiceService; /** - * 查询用户显示小红点,查询用户有几个未读的已开发票 + * 查询用户显示小红点,即查询用户有几个未读的已开发票 * * @author WH * @date 2021/12/28 18:51 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java index dfe50cd5..646a9a4e 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/controller/XhpcInvoiceController.java @@ -4,6 +4,8 @@ import com.aliyun.oss.OSSClient; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.log.annotation.Log; +import com.xhpc.common.log.enums.BusinessType; import com.xhpc.invoice.constant.InvoiceStatusConst; import com.xhpc.invoice.domain.AllInvoiceOrdersRequest; import com.xhpc.invoice.domain.AllInvoiceOrdersResponse; @@ -64,6 +66,7 @@ public class XhpcInvoiceController extends BaseController { * @date 2021/12/29 16:40 * @since version-1.0 */ + @Log(title = "电子发票上传", businessType = BusinessType.INSERT) @PostMapping("/pdf") public AjaxResult uploadPdf(MultipartFile invoicePdf) throws IOException { @@ -87,7 +90,8 @@ public class XhpcInvoiceController extends BaseController { * @date 2021/12/22 12:03 * @since version-1.0 */ - @PostMapping("/invoiceToUser") + @Log(title = "用户提交发票状态", businessType = BusinessType.UPDATE) + @PatchMapping() public AjaxResult invoiceToUser(@RequestBody InvoiceToUserRequest requestData) { //前置条件 if (requestData.getInvoiceId() == null) { @@ -128,13 +132,13 @@ public class XhpcInvoiceController extends BaseController { * @date 2021/12/21 11:33 * @since version-1.0 */ - @PostMapping("/selectAllInvoiceOrders") - public AjaxResult selectAllInvoiceOrders(@RequestBody AllInvoiceOrdersRequest requestData) { + @GetMapping("/all-info") + public AjaxResult findAllInvoiceOrders(@RequestBody AllInvoiceOrdersRequest requestData) { if (requestData.getCurrentPage() == null || requestData.getItems() == null) { return AjaxResult.error("当前页数、每页要显示的条数为必传递项"); } - AllInvoiceOrdersResponse allInvoiceOrdersResponse = xhpcInvoiceService.selectAllInvoiceOrders(requestData); + AllInvoiceOrdersResponse allInvoiceOrdersResponse = xhpcInvoiceService.findAllInvoiceOrders(requestData); return AjaxResult.success(allInvoiceOrdersResponse); } @@ -147,11 +151,11 @@ public class XhpcInvoiceController extends BaseController { * @date 2021/12/20 10:48 * @since version-1.0 */ - @PostMapping("/selectSpecificInvoice") - public AjaxResult selectSpecificInvoice(@RequestBody Map invoiceIdMap) { + @GetMapping("/detail") + public AjaxResult findSpecificInvoice(@RequestBody Map invoiceIdMap) { Long invoiceId = Long.valueOf(String.valueOf(invoiceIdMap.get("invoiceId"))); - SpecificInvoiceWrap specificInvoiceWrap = xhpcInvoiceService.selectSpecificInvoice(invoiceId); + SpecificInvoiceWrap specificInvoiceWrap = xhpcInvoiceService.findSpecificInvoice(invoiceId); if (specificInvoiceWrap == null) { return AjaxResult.error("要回显的订单发票id有误"); } diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java index e7b70639..39d0ad3b 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/XhpcInvoiceService.java @@ -24,7 +24,7 @@ public interface XhpcInvoiceService { * @date 2021/12/20 14:10 * @since version-1.0 */ - SpecificInvoiceWrap selectSpecificInvoice(Long invoiceId); + SpecificInvoiceWrap findSpecificInvoice(Long invoiceId); /** * 通过requestData中的申请人、申请人类型、发票状态、发票起始时间、发票申请终止时间、开票起始时间、开票终点时间、当前所在页数、当前页所要显示几行,来查询发票列表信息 @@ -35,7 +35,7 @@ public interface XhpcInvoiceService { * @date 2021/12/21 16:02 * @since version-1.0 */ - AllInvoiceOrdersResponse selectAllInvoiceOrders(AllInvoiceOrdersRequest requestData); + AllInvoiceOrdersResponse findAllInvoiceOrders(AllInvoiceOrdersRequest requestData); /** * 存储开发票的状态,将开票信息入库,并向指定用户的邮箱发送短信 diff --git a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java index dc85a2df..8a7f5133 100644 --- a/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-invoice/src/main/java/com/xhpc/invoice/service/impl/XhpcInvoiceServiceImpl.java @@ -67,7 +67,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override - public AllInvoiceOrdersResponse selectAllInvoiceOrders(AllInvoiceOrdersRequest requestData) { + public AllInvoiceOrdersResponse findAllInvoiceOrders(AllInvoiceOrdersRequest requestData) { //计算分页索引 requestData.setCurrentPage((requestData.getCurrentPage() - 1) * requestData.getItems()); //获取每张发票信息 @@ -594,7 +594,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { * @since version-1.0 */ @Override - public SpecificInvoiceWrap selectSpecificInvoice(Long invoiceId) { + public SpecificInvoiceWrap findSpecificInvoice(Long invoiceId) { //处理包装类外层数据 XhpcInvoice xhpcInvoice = xhpcInvoiceMapper.selectByPrimaryKey(invoiceId);