mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、软件购买金额字段赋值问题修复;2、手工调账单个金额提交异常问题修复;3、可开票金额获取来源错误修复;
This commit is contained in:
+16
-4
@@ -1,6 +1,8 @@
|
||||
package com.cf.imes.module.system.dal.mysql.funds.purchase;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@@ -61,16 +63,26 @@ public interface PurchaseRecordMapper extends BaseMapperX<PurchaseRecordDO> {
|
||||
* @return
|
||||
*/
|
||||
default PageResult<PurchaseRecordDO> selectPage(InvoiceAmountAndAvailablePageReqVO pageReqVO) {
|
||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<PurchaseRecordDO>()
|
||||
LambdaQueryWrapper<PurchaseRecordDO> queryWrapper = new LambdaQueryWrapperX<PurchaseRecordDO>()
|
||||
.betweenIfPresent(PurchaseRecordDO::getCreateTime, pageReqVO.getCreateTime())
|
||||
.geIfPresent(PurchaseRecordDO::getTotalAmount, ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[0] : null)
|
||||
.leIfPresent(PurchaseRecordDO::getTotalAmount, ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[1] : null)
|
||||
.eq(PurchaseRecordDO::getOrganId, SecurityFrameworkUtils.getUserOrganId())
|
||||
.eq(PurchaseRecordDO::getDeleted, false)
|
||||
.in(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.INVOICABLE.getCode(), InvoiceStatusEnum.INVOICINGFAILED.getCode())
|
||||
.ne(PurchaseRecordDO::getInitial, true)
|
||||
.orderByDesc(PurchaseRecordDO::getCreateTime)
|
||||
.orderByDesc(PurchaseRecordDO::getCreateTime);
|
||||
Integer[] invoiceAmount = pageReqVO.getInvoiceAmount();
|
||||
if (ArrayUtil.isNotEmpty(invoiceAmount) && invoiceAmount.length == 2) {
|
||||
queryWrapper.and(w ->
|
||||
w.between(PurchaseRecordDO::getAccountBalanceSpent,
|
||||
ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[0] : null,
|
||||
ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[1] : null)
|
||||
.or()
|
||||
.between(PurchaseRecordDO::getExternalSpent,
|
||||
ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[0] : null,
|
||||
ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[1] : null)
|
||||
);
|
||||
}
|
||||
return selectPage(pageReqVO, queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -81,6 +81,7 @@ public class IncomeExpenseServiceImpl implements IncomeExpenseService {
|
||||
// 手工调账算到充值
|
||||
respVO.setTradeType(TradeTypeEnum.RECHARGE.getCode());
|
||||
respVO.setPaymentMethod(TradeTypeEnum.MANUAL_ADJUST.getDesc());
|
||||
respVO.setOrderNo(i.getOrderNo());
|
||||
}
|
||||
// 查询操作组织名
|
||||
OrganizationDO organ = organService.getOrganWithDeleted(i.getOrganId());
|
||||
|
||||
+6
-6
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -42,6 +41,7 @@ import com.cf.imes.module.system.enums.pay.InvoiceStatusEnum;
|
||||
import com.cf.imes.module.system.enums.pay.TradeTypeEnum;
|
||||
import com.cf.imes.module.system.service.organ.OrganService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -205,8 +205,8 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
availablePageRespVO.setId(i.getId());
|
||||
availablePageRespVO.setCreateTime(i.getCreateTime());
|
||||
availablePageRespVO.setTradeType(TradeTypeEnum.PRODUCT.getCode());
|
||||
// 可开票金额=总额扣除赠送金
|
||||
availablePageRespVO.setAvailableAmount(i.getTotalAmount().subtract(i.getGiftMoneySpent()));
|
||||
// 可开票金额=余额支付+扫码支付
|
||||
availablePageRespVO.setAvailableAmount(i.getAccountBalanceSpent().add(i.getExternalSpent()));
|
||||
availablePageRespVO.setProductName(i.getProductName());
|
||||
availablePageRespVO.setTotalAmount(i.getTotalAmount());
|
||||
availablePageRespVOS.add(availablePageRespVO);
|
||||
@@ -231,7 +231,7 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
boolean uninvoicableExist = purchaseRecordDOS.stream().filter(p -> !InvoiceStatusEnum.INVOICABLE.getCode().equals(p.getIsInvocing())).findAny().isPresent();
|
||||
AssertUtils.isTrue(uninvoicableExist, INVOICE_APPLY_UNINVOICEABLE_EXIST);
|
||||
|
||||
// 查询可开票金额
|
||||
// 查询可开票金额:余额支付+扫码支付
|
||||
BigDecimal invoicableAmount = purchaseRecordMapper.getInvoicableAmount(organId, purchaseRecordId);
|
||||
// 可开票金额不能为0
|
||||
AssertUtils.isTrue(ObjectUtils.isNull(invoicableAmount) || invoicableAmount.compareTo(BigDecimal.ZERO) == 0, INVOICE_AMOUNT_ZERO_ERROR);
|
||||
@@ -387,8 +387,8 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||
* @return
|
||||
*/
|
||||
public static String getFileExtension(String fileName) {
|
||||
if (StrUtil.isEmpty(fileName)) {
|
||||
return ""; // 或者返回 null,看你需求
|
||||
if (StringUtils.isEmpty(fileName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int lastDotIndex = fileName.lastIndexOf('.');
|
||||
|
||||
+11
-7
@@ -128,6 +128,7 @@ public class ManualAdjustAccountBalanceServiceImpl implements ManualAdjustAccoun
|
||||
IncomeExpenseDetailsDO incomeExpenseDetailsDO = IncomeExpenseDetailsDO.builder()
|
||||
.organId(organId)
|
||||
.businessNo(snowflakeSerialNoWorker3rd.nextSerialNo())
|
||||
.orderNo(String.valueOf(payOrderDO.getId()))
|
||||
.tradeType(TradeTypeEnum.MANUAL_ADJUST.getCode())
|
||||
.incomeExpenseType(incomeExpenseType)
|
||||
.cashAmountChange(rechargeAmount)
|
||||
@@ -152,7 +153,7 @@ public class ManualAdjustAccountBalanceServiceImpl implements ManualAdjustAccoun
|
||||
Long payOrderId = IdUtil.getSnowflake(mybatisIdProperties.getWorkerId(), mybatisIdProperties.getDatacenterId()).nextId();
|
||||
payOrderDO.setId(payOrderId);
|
||||
payOrderDO.setStatus(PayOrderStatusEnum.SUCCESS);
|
||||
payOrderDO.setPrice(recharge);
|
||||
payOrderDO.setPrice(ObjectUtil.isNull(recharge) ? BigDecimal.ZERO : recharge);
|
||||
payOrderDO.setSubject("手工调账");
|
||||
payOrderDO.setChannelCode(PayChannelCodeEnum.MANUAL_ADJUST);
|
||||
payOrderDO.setOrganId(organId);
|
||||
@@ -168,8 +169,11 @@ public class ManualAdjustAccountBalanceServiceImpl implements ManualAdjustAccoun
|
||||
*/
|
||||
private OrganRechargeAmountRespVO recharge(OrganAmountDO organAmountDO, BigDecimal price, BigDecimal gift) {
|
||||
Long organId = organAmountDO.getOrganId();
|
||||
BigDecimal newAmount = organAmountDO.getAmount().add(price);
|
||||
BigDecimal newGift = null;
|
||||
BigDecimal newAmount = organAmountDO.getAmount();
|
||||
if (ObjectUtil.isNotNull(price)) {
|
||||
newAmount = organAmountDO.getAmount().add(price);
|
||||
}
|
||||
BigDecimal newGift = organAmountDO.getGiftAmount();
|
||||
if (ObjectUtil.isNotNull(gift)) {
|
||||
newGift = organAmountDO.getGiftAmount().add(gift);
|
||||
}
|
||||
@@ -177,7 +181,7 @@ public class ManualAdjustAccountBalanceServiceImpl implements ManualAdjustAccoun
|
||||
int updated = organAmountMapper.update(new LambdaUpdateWrapperX<OrganAmountDO>()
|
||||
.eq(OrganAmountDO::getOrganId, organId)
|
||||
.eq(OrganAmountDO::getVersion, organAmountDO.getVersion())
|
||||
.setIfPresent(OrganAmountDO::getGiftAmount, newGift)
|
||||
.set(OrganAmountDO::getGiftAmount, newGift)
|
||||
.set(OrganAmountDO::getAmount, newAmount)
|
||||
.set(OrganAmountDO::getVersion, organAmountDO.getVersion() + 1));
|
||||
// 1. 首次更新失败,认为出现并发,再查一次再更新
|
||||
@@ -189,17 +193,17 @@ public class ManualAdjustAccountBalanceServiceImpl implements ManualAdjustAccoun
|
||||
updated = organAmountMapper.update(new LambdaUpdateWrapperX<OrganAmountDO>()
|
||||
.eq(OrganAmountDO::getOrganId, organId)
|
||||
.eq(OrganAmountDO::getVersion, organAmountDO.getVersion())
|
||||
.setIfPresent(OrganAmountDO::getGiftAmount, newGift)
|
||||
.set(OrganAmountDO::getGiftAmount, newGift)
|
||||
.set(OrganAmountDO::getAmount, newAmount)
|
||||
.set(OrganAmountDO::getVersion, organAmountDO.getVersion() + 1));
|
||||
// 2. 第二次更新失败,资金表可能不存在
|
||||
if (updated == 0) {
|
||||
throw exception(ORGAN_RECHARGE_AMOUNT_UPDATE_ERROR);
|
||||
} else {
|
||||
return new OrganRechargeAmountRespVO(ObjectUtil.isNull(newGift) ? newAmount : newAmount.add(newGift), newAmount, newGift);
|
||||
return new OrganRechargeAmountRespVO(newAmount.add(newGift), newAmount, newGift);
|
||||
}
|
||||
} else {
|
||||
return new OrganRechargeAmountRespVO(ObjectUtil.isNull(newGift) ? newAmount : newAmount.add(newGift), newAmount, newGift);
|
||||
return new OrganRechargeAmountRespVO(newAmount.add(newGift), newAmount, newGift);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -101,6 +101,9 @@ public class PayProductProcessorNew {
|
||||
private Long previousPurchaseRecordId;
|
||||
|
||||
// 产品支付价格
|
||||
private BigDecimal productPrice;
|
||||
|
||||
// 按序流转价格
|
||||
private BigDecimal price;
|
||||
|
||||
// 组织赠送金
|
||||
@@ -163,8 +166,10 @@ public class PayProductProcessorNew {
|
||||
boolean initialPurchaseExist = ObjectUtil.isNotNull(orgInitialPurchaseRecord);
|
||||
if (initialPurchaseExist) {
|
||||
price = computePrice();
|
||||
productPrice = price;
|
||||
} else {
|
||||
price = computeInitialProductPayAmount();
|
||||
productPrice = price;
|
||||
// 首次购买记录是空,那么当前就是首次订购
|
||||
initialized = true;
|
||||
}
|
||||
@@ -270,9 +275,11 @@ public class PayProductProcessorNew {
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.paymentMethod(payType)
|
||||
.totalAmount(price)
|
||||
.totalAmount(productPrice)
|
||||
.originalAmount(originalPrice)
|
||||
.monthAverageAmount(monthAverageAmount)
|
||||
.accountBalanceSpent(usedBalance)
|
||||
.giftMoneySpent(usedGift)
|
||||
.isInvocing(justPayGift ? null : InvoiceStatusEnum.INVOICABLE.getCode())
|
||||
.initial(initialized)
|
||||
.status(PurchaseRecordStatusEnum.ACTIVE.getStatus())
|
||||
|
||||
+8
-6
@@ -15,7 +15,7 @@
|
||||
AND i.business_no = #{reqVO.businessNo}
|
||||
</if>
|
||||
<if test="reqVO.orderNo != null and reqVO.orderNo != ''">
|
||||
AND i.order_no = #{reqVO.orderNo}
|
||||
AND (i.order_no = #{reqVO.orderNo} or i.purchase_id = #{reqVO.orderNo})
|
||||
</if>
|
||||
<if test="reqVO.tradeType != null">
|
||||
<choose>
|
||||
@@ -33,17 +33,19 @@
|
||||
<if test="reqVO.incomeExpenseType != null">
|
||||
AND i.income_expense_type = #{reqVO.incomeExpenseType}
|
||||
</if>
|
||||
<if test="reqVO.createTime != null and reqVO.createTime.size() == 2">
|
||||
AND i.create_time between #{reqVo.createTime[0]} and #{reqVo.createTime[1]}
|
||||
<if test="reqVO.createTime != null and reqVO.createTime.length == 2">
|
||||
AND i.create_time between #{reqVO.createTime[0]} and #{reqVO.createTime[1]}
|
||||
</if>
|
||||
<if test="reqVO.productPrice != null">
|
||||
AND p.total_amount = #{reqVo.productPrice}
|
||||
AND p.total_amount = #{reqVO.productPrice}
|
||||
</if>
|
||||
<if test="reqVO.rechargeAmount != null">
|
||||
AND i.cash_amount_change = #{reqVo.rechargeAmount}
|
||||
AND i.cash_amount_change = #{reqVO.rechargeAmount}
|
||||
AND (i.trade_type = '${@com.cf.imes.module.system.enums.pay.TradeTypeEnum@RECHARGE.code}' or i.trade_type = '${@com.cf.imes.module.system.enums.pay.TradeTypeEnum@MANUAL_ADJUST.code}')
|
||||
</if>
|
||||
<if test="reqVO.giftAmount != null">
|
||||
AND i.gift_amount_change = #{reqVo.giftAmount}
|
||||
AND i.gift_amount_change = #{reqVO.giftAmount}
|
||||
AND (i.trade_type = '${@com.cf.imes.module.system.enums.pay.TradeTypeEnum@RECHARGE.code}' or i.trade_type = '${@com.cf.imes.module.system.enums.pay.TradeTypeEnum@MANUAL_ADJUST.code}')
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
+4
-4
@@ -18,7 +18,7 @@
|
||||
SUM(
|
||||
CASE
|
||||
WHEN is_invocing = '${@com.cf.imes.module.system.enums.pay.InvoiceStatusEnum@INVOICABLE.code}'
|
||||
THEN CASE WHEN initial = TRUE THEN total_amount ELSE account_balance_spent END
|
||||
THEN account_balance_spent + external_spent
|
||||
ELSE 0
|
||||
END
|
||||
) AS invocable,
|
||||
@@ -26,7 +26,7 @@
|
||||
SUM(
|
||||
CASE
|
||||
WHEN is_invocing = '${@com.cf.imes.module.system.enums.pay.InvoiceStatusEnum@PENDINGINVOICING.code}'
|
||||
THEN CASE WHEN initial = TRUE THEN total_amount ELSE account_balance_spent END
|
||||
THEN account_balance_spent + external_spent
|
||||
ELSE 0
|
||||
END
|
||||
) AS inTheInvoice,
|
||||
@@ -34,7 +34,7 @@
|
||||
SUM(
|
||||
CASE
|
||||
WHEN is_invocing = '${@com.cf.imes.module.system.enums.pay.InvoiceStatusEnum@INVOICINGSUCCESSFUL.code}'
|
||||
THEN CASE WHEN initial = TRUE THEN total_amount ELSE account_balance_spent END
|
||||
THEN account_balance_spent + external_spent
|
||||
ELSE 0
|
||||
END
|
||||
) AS invoiced
|
||||
@@ -43,7 +43,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getInvoicableAmount" resultType="java.math.BigDecimal">
|
||||
select sum(total_amount - gift_money_spent) from purchase_record
|
||||
select sum(account_balance_spent + external_spent) from purchase_record
|
||||
where organ_id = #{organId} and is_invocing = '${@com.cf.imes.module.system.enums.pay.InvoiceStatusEnum@INVOICABLE.code}'
|
||||
and id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
|
||||
Reference in New Issue
Block a user