更新清分金额分开电费和服务费计算

This commit is contained in:
panshuling321 2022-06-21 11:31:36 +08:00
parent 9dc6f0f7d9
commit 8f280f701f
5 changed files with 50 additions and 18 deletions

View File

@ -1084,4 +1084,16 @@ CREATE TABLE `xhpc_clearing_receipt`
`create_time` datetime DEFAULT NULL COMMENT '上传时间',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
PRIMARY KEY (`clearing_receipt_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='清分银行回执信息表';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='清分银行回执信息表';
ALTER TABLE `xhpc_clearing_checkout`
ADD COLUMN `apply_power_amount` decimal(10,2) NULL DEFAULT NULL COMMENT '申请电费金额' AFTER `apply_amount`;
ALTER TABLE `xhpc_clearing_checkout`
ADD COLUMN `apply_service_amount` decimal(10,2) NULL DEFAULT NULL COMMENT '申请服务费金额' AFTER `apply_power_amount`;
ALTER TABLE `xhpc_clearing_checkout`
ADD COLUMN `received_power_amount` decimal(10,2) NULL DEFAULT NULL COMMENT '到账电费金额' AFTER `received_amount`;
ALTER TABLE `xhpc_clearing_checkout`
ADD COLUMN `received_service_amount` decimal(10,2) NULL DEFAULT NULL COMMENT '到账服务费金额' AFTER `received_power_amount`;

View File

@ -82,7 +82,12 @@ public class XhpcClearingCheckoutController extends BaseController {
public R getTmpCheckoutData(HttpServletRequest request) {
LoginUser loginUser = logUserUtils.getLogUser(request);
return R.ok(checkoutService.getTmpCheckoutData(loginUser.getSysUser().getOperatorId()));
Long operatorId = loginUser.getSysUser().getOperatorId();
if(operatorId == null || operatorId < 0){
throw new CustomException("运营商ID错误,请登陆运营商账户再试");
}
return R.ok(checkoutService.getTmpCheckoutData(operatorId));
}

View File

@ -6,13 +6,10 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface XhpcClearingReceiptMapper {
int deleteByPrimaryKey(Long clearingReceiptId);
int insert(XhpcClearingReceiptDomain record);
XhpcClearingReceiptDomain selectByPrimaryKey(Long clearingReceiptId);
int deleteByCheckoutId(@Param("checkoutId")Long checkoutId);
int insretBatch(List<XhpcClearingReceiptDomain> domainList);
int insretBatch(@Param("domainList") List<XhpcClearingReceiptDomain> domainList);
}

View File

@ -85,7 +85,7 @@ public class XhpcClearingCheckoutServiceImpl extends BaseService implements Xhpc
return checkoutMapper.selectByParams(params);
}else{
//查询赋值的场站
params.put("type", 1);
params.put("type", 2);
params.put("logOperatorId",sysUserId);
return checkoutMapper.selectByParams(params);
}
@ -113,17 +113,24 @@ public class XhpcClearingCheckoutServiceImpl extends BaseService implements Xhpc
BigDecimal handlingRate = BigDecimal.TEN;
Map<String, Object> cashMap = historyOrderMapper.selectCashAmount(operatorId.toString());
BigDecimal bankFee = new BigDecimal(cashMap.get("amount").toString()).multiply(bankRate).setScale(2, BigDecimal.ROUND_UP);
BigDecimal actAmount = new BigDecimal(cashMap.get("amount").toString()).subtract(handlingRate).subtract(bankFee);
BigDecimal powerAmount = new BigDecimal(cashMap.get("powerAmount").toString()).setScale(2, BigDecimal.ROUND_UP);
BigDecimal serviceAmount = new BigDecimal(cashMap.get("serviceAmount").toString()).setScale(2, BigDecimal.ROUND_UP);
BigDecimal actAmount = serviceAmount.subtract(handlingRate);
BigDecimal bankFee = actAmount.multiply(bankRate).setScale(2, BigDecimal.ROUND_UP);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("bankNo", bankDomain.getBankNo());
resultMap.put("contactPhone", bankDomain.getContactPhone());
resultMap.put("applyAmount", cashMap.get("amount"));
resultMap.put("applyAmount", powerAmount.add(serviceAmount));
resultMap.put("clearingOrderIds", cashMap.get("clearingOrderIds"));
resultMap.put("handlingFee", handlingRate);
resultMap.put("bankFee", bankFee);
resultMap.put("receivedAmount", actAmount.compareTo(BigDecimal.ZERO) >= 0 ? actAmount : BigDecimal.ZERO);
resultMap.put("applyPowerAmount", powerAmount);
resultMap.put("applyServiceAmount", serviceAmount);
resultMap.put("receivedPowerAmount", powerAmount);
resultMap.put("receivedServiceAmount", actAmount.subtract(bankFee));
resultMap.put("receivedAmount", powerAmount.add(actAmount).subtract(bankFee).compareTo(BigDecimal.ZERO) >= 0 ? powerAmount.add(actAmount).subtract(bankFee) : BigDecimal.ZERO);
resultMap.put("clearingBankId", bankDomain.getClearingBankId());
return resultMap;
}
@ -285,7 +292,7 @@ public class XhpcClearingCheckoutServiceImpl extends BaseService implements Xhpc
String checkoutIds = checkoutList.stream().map(CheckoutBankVo::getIndex).collect(Collectors.joining(","));
String unReceiptIds = checkoutMapper.selectIdsByStatusAndIds(checkoutIds, 1);
if (unReceiptIds.length() > 1) {
if (StringUtils.isNotEmpty(unReceiptIds)) {
List<XhpcClearingReceiptDomain> receiptDomainList = receiptVo.getReceiptList();
for (XhpcClearingReceiptDomain receiptDomain : receiptDomainList) {
receiptDomain.setClearingCheckoutIds(unReceiptIds);

View File

@ -5,9 +5,13 @@
<id column="clearing_checkout_id" jdbcType="BIGINT" property="clearingCheckoutId" />
<result column="clearing_bank_id" jdbcType="BIGINT" property="clearingBankId" />
<result column="apply_amount" jdbcType="DECIMAL" property="applyAmount" />
<result column="apply_power_amount" property="applyPowerAmount" />
<result column="apply_service_amount" property="applyServiceAmount" />
<result column="handling_fee" jdbcType="DECIMAL" property="handlingFee" />
<result column="bank_fee" jdbcType="DECIMAL" property="bankFee" />
<result column="received_amount" jdbcType="DECIMAL" property="receivedAmount" />
<result column="received_power_amount" property="receivedPowerAmount" />
<result column="received_service_amount" property="receivedServiceAmount" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="operator_id" jdbcType="BIGINT" property="operatorId" />
@ -20,13 +24,14 @@
<result column="check_time" jdbcType="TIMESTAMP" property="checkTime" />
</resultMap>
<sql id="Base_Column_List">
cc.clearing_checkout_id, cc.clearing_bank_id, cc.apply_amount, cc.handling_fee, cc.received_amount, cc.bank_fee, cc.del_flag,
cc.clearing_checkout_id, cc.clearing_bank_id, cc.apply_amount, cc.apply_power_amount, cc.apply_service_amount, cc.handling_fee,
cc.received_amount, cc.bank_fee, cc.del_flag, cc.received_power_amount, cc.received_service_amount,
cc.`status`, cc.operator_id, cc.tenant_id, cc.create_by, cc.create_time, cc.update_by, cc.update_time, cc.check_by, cc.check_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultType="com.xhpc.activity.domain.XhpcClearingCheckoutDomain">
select
select
<include refid="Base_Column_List" />, xo.name as 'operator_name'
from xhpc_clearing_checkout cc
left join xhpc_operator xo on xo.operator_id = cc.operator_id
@ -171,12 +176,14 @@
<insert id="insert" keyColumn="clearing_checkout_id" keyProperty="clearingCheckoutId" parameterType="com.xhpc.activity.domain.XhpcClearingCheckoutDomain" useGeneratedKeys="true">
insert into xhpc_clearing_checkout (clearing_bank_id, apply_amount, handling_fee, bank_fee,
received_amount, del_flag, `status`, operator_id, tenant_id,
insert into xhpc_clearing_checkout (clearing_bank_id, apply_amount, apply_power_amount, apply_service_amount,
handling_fee, bank_fee,
received_amount, received_power_amount, received_service_amount, del_flag, `status`, operator_id, tenant_id,
create_by, create_time,
update_by,update_time, check_by, check_time)
values (#{clearingBankId,jdbcType=BIGINT}, #{applyAmount,jdbcType=DECIMAL}, #{handlingFee,jdbcType=DECIMAL}, #{bankFee},
#{receivedAmount,jdbcType=DECIMAL}, 0, #{status}, #{operatorId}, #{tenantId,jdbcType=VARCHAR},
values (#{clearingBankId,jdbcType=BIGINT}, #{applyAmount,jdbcType=DECIMAL}, #{applyPowerAmount}, #{applyServiceAmount},
#{handlingFee,jdbcType=DECIMAL}, #{bankFee},
#{receivedAmount,jdbcType=DECIMAL}, #{receivedPowerAmount}, #{receivedServiceAmount}, 0, #{status}, #{operatorId}, #{tenantId,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, sysdate(), #{updateBy,jdbcType=VARCHAR},
sysdate(), #{checkBy}, sysdate())
</insert>
@ -186,9 +193,13 @@
update xhpc_clearing_checkout
set clearing_bank_id = #{clearingBankId,jdbcType=BIGINT},
apply_amount = #{applyAmount,jdbcType=DECIMAL},
apply_power_amount=#{applyPowerAmount},
apply_service_amount=#{applyServiceAmount},
handling_fee = #{handlingFee,jdbcType=DECIMAL},
bank_fee = #{bankFee},
received_amount = #{receivedAmount,jdbcType=DECIMAL},
received_power_amount=#{receivedPowerAmount},
received_service_amount=#{receivedServiceAmount}
`status` = #{status,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = sysdate()