修复部分Bug

This commit is contained in:
wen 2022-01-03 21:02:32 +08:00
parent cf89e40ccf
commit 45a69c2296
9 changed files with 142 additions and 40 deletions

View File

@ -25,6 +25,11 @@ public class AllInvoiceOrdersRequest {
*/
@JsonProperty("creatorType")
private Integer creatorType;
/**
* 发票类型 0为普票1为专票
*/
@JsonProperty("invoiceType")
private Integer invoiceType;
/**
* 发票状态0表示未开票1表示已经开票2表示开票失败
*/

View File

@ -58,6 +58,11 @@ public class AllInvoiceOrdersResponse {
*/
@JsonProperty("creatorType")
private Integer creatorType;
/**
* 发票类型 0为普票1为专票
*/
@JsonProperty("invoiceType")
private Integer invoiceType;
/**
* 发票金额
*/

View File

@ -188,4 +188,14 @@ public interface XhpcInvoiceMapper {
*/
List<ExcelInvoiceRow> selectExcelInvoiceById(Long invoiceId);
/**
* 更新发票所包含的电量总金额服务费总金额
*
* @param xhpcInvoice 存放要更新数据的实体类
* @author WH
* @date 2022/1/3 17:06
* @since version-1.0
*/
void updateElectricAndServiceById(XhpcInvoice xhpcInvoice);
}

View File

@ -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;
/**
* 接收邮箱
*/

View File

@ -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;
/**
* 该发票所选中的历史订单电费

View File

@ -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<XhpcInvoice> xhpcInvoiceList = xhpcInvoiceMapper.selectAllInvoiceOrdersByCondition(requestData);
//对拷放置到itemsDTO中,然后将itemsDTO存放到itemsDTOList中
ArrayList<AllInvoiceOrdersResponse.ItemsDTO> 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<Integer> historyOrderIds = saveInvoiceInfoRequest.getHistoryOrderIds();
List<XhpcInvoiceMapHistoryOrder> 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<String, Object> operatorInfo = xhpcOperatorMapper.info(xhpcChargingStation.getOperatorId());
String operatorName = (String) operatorInfo.get("name");

View File

@ -53,21 +53,67 @@
<result column="total_power" jdbcType="DOUBLE" property="totalPower"/>
<result column="user_name_evcs" jdbcType="VARCHAR" property="userNameEvcs"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="charging_mode" jdbcType="VARCHAR" property="chargingMode"/>
<result column="internet_degree_commission" jdbcType="DECIMAL" property="internetDegreeCommission"/>
<result column="source" jdbcType="INTEGER" property="source"/>
</resultMap>
<sql id="Base_Column_List">
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
</sql>
<select id="findByCondition" resultMap="XhpcHistoryOrderResult">
@ -108,16 +154,16 @@
</foreach>
</if>
</select>
<select id="findById" resultType="com.xhpc.order.domain.XhpcHistoryOrder">
<select id="findById" resultMap="XhpcHistoryOrderResult">
SELECT
<include refid="Base_Column_List"/>
FROM
xhpc_history_order
WHERE
del_flag IS NULL
<if test="historyOrderIds!=null">
del_flag = 0
<if test="collection!=null">
AND history_order_id IN
<foreach collection="historyOrderIds" open="(" close=")" item="historyOrderId" separator=",">
<foreach collection="collection" open="(" close=")" item="historyOrderId" separator=",">
#{historyOrderId}
</foreach>
</if>

View File

@ -6,7 +6,7 @@
<result column="history_order_id" jdbcType="BIGINT" property="historyOrderId"/>
<result column="history_user_id" jdbcType="BIGINT" property="historyUserId"/>
<result column="history_user_type" jdbcType="BIGINT" property="historyUserType"/>
<result column="hisotry_serial_number" jdbcType="VARCHAR" property="hisotrySerialNumber"/>
<result column="history_serial_number" jdbcType="VARCHAR" property="historySerialNumber"/>
<result column="power_price_total" jdbcType="DECIMAL" property="powerPriceTotal"/>
<result column="service_price_total" jdbcType="DECIMAL" property="servicePriceTotal"/>
<result column="promotion_discount" jdbcType="DECIMAL" property="promotionDiscount"/>
@ -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 @@
<if test="historyUserType != null">
history_user_type,
</if>
<if test="hisotrySerialNumber != null">
hisotry_serial_number,
<if test="historySerialNumber != null">
history_serial_number,
</if>
<if test="powerPriceTotal != null">
power_price_total,
@ -115,8 +115,8 @@
<if test="historyUserType != null">
#{historyUserType,jdbcType=BIGINT},
</if>
<if test="hisotrySerialNumber != null">
#{hisotrySerialNumber,jdbcType=VARCHAR},
<if test="historySerialNumber != null">
#{historySerialNumber,jdbcType=VARCHAR},
</if>
<if test="powerPriceTotal != null">
#{powerPriceTotal,jdbcType=DECIMAL},
@ -199,7 +199,7 @@
xhpc_invoice_map_history_order
WHERE
history_order_id IN
<foreach collection="historyOrderIds" open="(" close=")" separator="," item="historyOrderId">
<foreach collection="collection" open="(" close=")" separator="," item="historyOrderId">
#{historyOrderId}
</foreach>
AND lock_flag = 0;

View File

@ -3,6 +3,7 @@
<mapper namespace="com.xhpc.invoice.mapper.XhpcInvoiceMapper">
<resultMap id="BaseResultMap" type="com.xhpc.invoice.pojo.XhpcInvoice">
<id column="invoice_id" jdbcType="BIGINT" property="invoiceId"/>
<result column="invoice_type" jdbcType="INTEGER" property="invoiceType"/>
<result column="receive_email" jdbcType="VARCHAR" property="receiveEmail"/>
<result column="title_type" jdbcType="INTEGER" property="titleType"/>
<result column="title_content" jdbcType="VARCHAR" property="titleContent"/>
@ -72,6 +73,7 @@
<select id="selectAllInvoiceOrdersByCondition" resultMap="BaseResultMap">
SELECT
invoice_id,
invoice_type,
creator,
creator_type,
invoice_money,
@ -87,7 +89,10 @@
and creator = #{creator}
</if>
<if test="creatorType!=null">
and creatorType = #{creatorType}
and creator_type = #{creatorType}
</if>
<if test="invoiceType!=null">
and invoice_type = #{invoiceType}
</if>
<if test="status!=null">
and status = #{status}
@ -118,7 +123,10 @@
and creator = #{creator}
</if>
<if test="creatorType!=null">
and creatorType = #{creatorType}
and creator_type = #{creatorType}
</if>
<if test="invoiceType!=null">
and invoice_type = #{invoiceType}
</if>
<if test="status!=null">
and status = #{status}
@ -421,7 +429,7 @@
</trim>
</insert>
<insert id="insertSelectiveAndReturnId" parameterType="com.xhpc.invoice.pojo.XhpcInvoice"
keyProperty="invoiceId">
keyProperty="invoiceId" useGeneratedKeys="true">
insert into xhpc_invoice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="receiveEmail != null">
@ -725,5 +733,11 @@
WHERE del_flag IS NULL
AND invoice_id = #{invoiceId}
</update>
<update id="updateElectricAndServiceById">
UPDATE xhpc_invoice
SET invoice_order_eletric_total_money = #{invoiceOrderEletricTotalMoney},
invoice_order_service_total_money = #{invoiceOrderServiceTotalMoney}
WHERE invoice_id = #{invoiceId};
</update>
</mapper>