Post /api/invoice 完成保存用户所要开的发票信息接口,以及使代码符合规范,修改一些bug
This commit is contained in:
parent
45f1ecffce
commit
c1a257808a
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户开发票的历史记录
|
||||
*
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.xhpc.invoice.constPackage;
|
||||
package com.xhpc.invoice.constant;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -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;
|
||||
|
||||
@ -35,6 +35,8 @@ public class InvoiceHistoryRecordsResponse {
|
||||
private Integer status;
|
||||
@JsonProperty("invoicingMoney")
|
||||
private BigDecimal invoicingMoney;
|
||||
@JsonProperty("isRead")
|
||||
private Integer isRead;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -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<Integer> historyOrderIds;
|
||||
|
||||
}
|
||||
@ -39,4 +39,15 @@ public interface XhpcHistoryOrderMapper {
|
||||
*/
|
||||
Long findAllOrdersByCondition(@Param("invoicedOrdersRequest") InvoicedOrdersRequest invoicedOrdersRequest, @Param("lockOrderNumberList") List<Integer> lockOrderNumberList);
|
||||
|
||||
/**
|
||||
* 查询指定id的历史订单
|
||||
*
|
||||
* @param historyOrderIds 历史订单id集合
|
||||
* @return 历史订单
|
||||
* @author WH
|
||||
* @date 2021/12/28 17:47
|
||||
* @since version-1.0
|
||||
*/
|
||||
List<XhpcHistoryOrder> findById(List<Integer> historyOrderIds);
|
||||
|
||||
}
|
||||
|
||||
@ -62,4 +62,25 @@ public interface XhpcInvoiceMapHistoryOrderMapper {
|
||||
*/
|
||||
List<Integer> 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<XhpcInvoiceMapHistoryOrder> getLockedOnesByHistoryOrderId(List<Integer> historyOrderIds);
|
||||
|
||||
}
|
||||
@ -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);
|
||||
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class XhpcInvoice implements Serializable {
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否已经阅读(默认0表示没有阅读,1表示已经阅读)
|
||||
* 是否已经阅读(默认未空,0表示没有阅读,1表示已经阅读)
|
||||
*/
|
||||
private Integer isRead;
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ public class XhpcInvoiceMapHistoryOrder implements Serializable {
|
||||
/**
|
||||
* 该发票所选中的历史订单是否被锁定
|
||||
*/
|
||||
private Integer delLock;
|
||||
private Integer lockFlag;
|
||||
|
||||
/**
|
||||
* 逻辑删除字段
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
|
||||
@ -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<Integer> historyOrderIds = saveInvoiceInfoRequest.getHistoryOrderIds();
|
||||
List<XhpcInvoiceMapHistoryOrder> 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<XhpcHistoryOrder> 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查找对应的发票数据
|
||||
*
|
||||
|
||||
@ -108,5 +108,19 @@
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="findById" resultType="com.xhpc.order.domain.XhpcHistoryOrder">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM
|
||||
xhpc_history_order
|
||||
WHERE
|
||||
del_flag IS NULL
|
||||
<if test="historyOrderIds!=null">
|
||||
AND history_order_id IN
|
||||
<foreach collection="historyOrderIds" open="(" close=")" item="historyOrderId" separator=",">
|
||||
#{historyOrderId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -19,6 +19,25 @@
|
||||
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
`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`
|
||||
</sql>
|
||||
|
||||
<insert id="insert" parameterType="com.xhpc.invoice.pojo.XhpcInvoiceMapHistoryOrder">
|
||||
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 @@
|
||||
<if test="terminalId != null">
|
||||
terminal_id,
|
||||
</if>
|
||||
<if test="lockFlag!=null">
|
||||
lock_flag,
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
del_flag,
|
||||
</if>
|
||||
@ -120,6 +142,9 @@
|
||||
<if test="terminalId != null">
|
||||
#{terminalId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="lockFlag!=null">
|
||||
#{lockFlag,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
#{delFlag,jdbcType=INTEGER},
|
||||
</if>
|
||||
@ -136,11 +161,17 @@
|
||||
)
|
||||
)
|
||||
</update>
|
||||
<update id="unlockHistoryOrdersByInvoiceId">
|
||||
UPDATE xhpc_invoice_map_history_order
|
||||
SET lock_flag = NULL
|
||||
WHERE invoice_id = #{invoiceId}
|
||||
</update>
|
||||
<select id="findOrdersByInvoiceId" resultMap="BaseResultMap">
|
||||
SELECT *
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM `xhpc_invoice_map_history_order`
|
||||
WHERE invoice_id = #{invoiceId}
|
||||
AND del_flag IS NULL;
|
||||
AND del_flag IS NULL;
|
||||
</select>
|
||||
<select id="getHistoryOrderScopeByInvoiceId" resultType="java.lang.String">
|
||||
SELECT MIN(create_time)
|
||||
@ -161,4 +192,16 @@
|
||||
AND history_user_id = #{userId}
|
||||
AND history_user_type = #{userType};
|
||||
</select>
|
||||
<select id="getLockedOnesByHistoryOrderId" resultType="com.xhpc.invoice.pojo.XhpcInvoiceMapHistoryOrder">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM
|
||||
xhpc_invoice_map_history_order
|
||||
WHERE
|
||||
history_order_id IN
|
||||
<foreach collection="historyOrderIds" open="(" close=")" separator="," item="historyOrderId">
|
||||
#{historyOrderId}
|
||||
</foreach>
|
||||
AND lock_flag = 0;
|
||||
</select>
|
||||
</mapper>
|
||||
@ -30,14 +30,39 @@
|
||||
<result column="update_time" jdbcType="DATE" property="updateTime"/>
|
||||
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
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`
|
||||
</sql>
|
||||
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
@ -132,19 +157,21 @@
|
||||
GROUP BY title_content LIMIT 0,3
|
||||
</select>
|
||||
<select id="selectUserLastInputInvoiceInfo" resultMap="BaseResultMap">
|
||||
SELECT *
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM `xhpc_invoice`
|
||||
WHERE creator_id = #{creatorId}
|
||||
AND creator_type = #{creatorType}
|
||||
AND creator_type = #{creatorType}
|
||||
ORDER BY invoice_id DESC LIMIT 0,1
|
||||
</select>
|
||||
<select id="findInvoicesByCreatorIdAndCreatorType" resultMap="BaseResultMap">
|
||||
SELECT *
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM xhpc_invoice
|
||||
WHERE del_flag IS NULL
|
||||
AND creator_id = #{creatorId}
|
||||
AND creator_type = #{creatorType} LIMIT #{currentPage}
|
||||
, #{items}
|
||||
AND creator_id = #{creatorId}
|
||||
AND creator_type = #{creatorType}
|
||||
LIMIT #{currentPage}, #{items}
|
||||
</select>
|
||||
<select id="getUserInvoiceItemsByCreatorIdAndCreatorType" resultType="java.lang.Long">
|
||||
SELECT count(invoice_id)
|
||||
@ -153,6 +180,14 @@
|
||||
AND creator_id = #{creatorId}
|
||||
AND creator_type = #{creatorType}
|
||||
</select>
|
||||
<select id="findNotReadCount" resultType="java.lang.Long">
|
||||
SELECT count(invoice_id)
|
||||
FROM xhpc_invoice
|
||||
WHERE del_flag IS NULL
|
||||
AND is_read = 0
|
||||
AND creator_id = #{creatorId}
|
||||
AND creator_type = #{creatorType}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete
|
||||
from xhpc_invoice
|
||||
@ -343,6 +378,170 @@
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertSelectiveAndReturnId" parameterType="com.xhpc.invoice.pojo.XhpcInvoice"
|
||||
keyProperty="invoiceId">
|
||||
insert into xhpc_invoice
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="receiveEmail != null">
|
||||
receive_email,
|
||||
</if>
|
||||
<if test="titleType != null">
|
||||
title_type,
|
||||
</if>
|
||||
<if test="titleContent != null">
|
||||
title_content,
|
||||
</if>
|
||||
<if test="dutyNumber != null">
|
||||
duty_number,
|
||||
</if>
|
||||
<if test="invoiceContent != null">
|
||||
invoice_content,
|
||||
</if>
|
||||
<if test="invoiceMoney != null">
|
||||
invoice_money,
|
||||
</if>
|
||||
<if test="invoiceOrderEletricTotalMoney != null">
|
||||
invoice_order_eletric_total_money,
|
||||
</if>
|
||||
<if test="invoiceOrderServiceTotalMoney != null">
|
||||
invoice_order_service_total_money,
|
||||
</if>
|
||||
<if test="firmAddress != null">
|
||||
firm_address,
|
||||
</if>
|
||||
<if test="firmPhone != null">
|
||||
firm_phone,
|
||||
</if>
|
||||
<if test="firmBank != null">
|
||||
firm_bank,
|
||||
</if>
|
||||
<if test="firmBankAccount != null">
|
||||
firm_bank_account,
|
||||
</if>
|
||||
<if test="isShowDate != null">
|
||||
is_show_date,
|
||||
</if>
|
||||
<if test="userNotes != null">
|
||||
user_notes,
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
creator_id,
|
||||
</if>
|
||||
<if test="creatorType != null">
|
||||
creator_type,
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status`,
|
||||
</if>
|
||||
<if test="invoicingTime != null">
|
||||
invoicing_time,
|
||||
</if>
|
||||
<if test="drawer != null">
|
||||
drawer,
|
||||
</if>
|
||||
<if test="financeNotes != null">
|
||||
finance_notes,
|
||||
</if>
|
||||
<if test="electricInvoiceUrl != null">
|
||||
electric_invoice_url,
|
||||
</if>
|
||||
<if test="updator != null">
|
||||
updator,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
del_flag,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="receiveEmail != null">
|
||||
#{receiveEmail,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="titleType != null">
|
||||
#{titleType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="titleContent != null">
|
||||
#{titleContent,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="dutyNumber != null">
|
||||
#{dutyNumber,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="invoiceContent != null">
|
||||
#{invoiceContent,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="invoiceMoney != null">
|
||||
#{invoiceMoney,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="invoiceOrderEletricTotalMoney != null">
|
||||
#{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="invoiceOrderServiceTotalMoney != null">
|
||||
#{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="firmAddress != null">
|
||||
#{firmAddress,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="firmPhone != null">
|
||||
#{firmPhone,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="firmBank != null">
|
||||
#{firmBank,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="firmBankAccount != null">
|
||||
#{firmBankAccount,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isShowDate != null">
|
||||
#{isShowDate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="userNotes != null">
|
||||
#{userNotes,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
#{creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="creatorType != null">
|
||||
#{creatorType,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
#{creator,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="invoicingTime != null">
|
||||
#{invoicingTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="drawer != null">
|
||||
#{drawer,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="financeNotes != null">
|
||||
#{financeNotes,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="electricInvoiceUrl != null">
|
||||
#{electricInvoiceUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updator != null">
|
||||
#{updator,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=DATE},
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
#{delFlag,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.invoice.pojo.XhpcInvoice">
|
||||
update xhpc_invoice
|
||||
<set>
|
||||
@ -464,7 +663,8 @@
|
||||
invoicing_time = #{invoicingTime},
|
||||
electric_invoice_url = #{eletricInvoiceUrl},
|
||||
`status` = #{status},
|
||||
drawer = #{drawer}
|
||||
drawer = #{drawer},
|
||||
is_read = 0
|
||||
WHERE invoice_id = #{invoiceId};
|
||||
</update>
|
||||
|
||||
@ -474,7 +674,7 @@
|
||||
invoicing_time = #{invoicingTime},
|
||||
electric_invoice_url = #{eletricInvoiceUrl},
|
||||
`status` = #{status},
|
||||
drawer = #{drawer}
|
||||
drawer = #{drawer} is_read = 0
|
||||
WHERE invoice_id = #{invoiceId}
|
||||
</update>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user