mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-04 10:00:11 +08:00
update 更新数据接口
This commit is contained in:
@@ -154,6 +154,11 @@ public class SpringBootTestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IPileAuthCardService pileAuthCardService;
|
private IPileAuthCardService pileAuthCardService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testupdateElecAmount() {
|
||||||
|
orderBasicInfoService.updateElecAmount();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectSomeStatusCardInfo() {
|
public void testSelectSomeStatusCardInfo() {
|
||||||
PileAuthCard pileAuthCard = pileAuthCardService.selectCardInfoByLogicCard("1111111111111111");
|
PileAuthCard pileAuthCard = pileAuthCardService.selectCardInfoByLogicCard("1111111111111111");
|
||||||
|
|||||||
@@ -201,4 +201,8 @@ public interface OrderBasicInfoMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AccumulativeInfoVO> getAccumulativeInfoForLianLian(QueryStationInfoDTO dto);
|
List<AccumulativeInfoVO> getAccumulativeInfoForLianLian(QueryStationInfoDTO dto);
|
||||||
|
|
||||||
|
List<OrderDetail> queryElecAmountNullList();
|
||||||
|
|
||||||
|
int batchUpdateOrderDetail(@Param("list") List<OrderDetail> orderDetailList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ public interface IOrderBasicInfoService {
|
|||||||
|
|
||||||
List<OrderVO> getListByMemberIdAndOrderStatus(String memberId, List<String> orderStatusList, LocalDateTime dateTime);
|
List<OrderVO> getListByMemberIdAndOrderStatus(String memberId, List<String> orderStatusList, LocalDateTime dateTime);
|
||||||
|
|
||||||
|
void updateElecAmount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结算订单退款和用户余额退款调这个方法
|
* 结算订单退款和用户余额退款调这个方法
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.jsowell.pile.service.impl;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
@@ -605,9 +607,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
|
|
||||||
// 更新订单详情
|
// 更新订单详情
|
||||||
try {
|
try {
|
||||||
// 总电费金额,总服务费金额
|
// 总电费金额
|
||||||
BigDecimal totalElectricityAmount = BigDecimal.ZERO;
|
BigDecimal totalElectricityAmount = BigDecimal.ZERO;
|
||||||
BigDecimal totalServiceAmount = BigDecimal.ZERO;
|
|
||||||
|
|
||||||
// 尖时段用电量
|
// 尖时段用电量
|
||||||
String sharpUsedElectricity = data.getSharpUsedElectricity();
|
String sharpUsedElectricity = data.getSharpUsedElectricity();
|
||||||
@@ -694,6 +695,74 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateElecAmount() {
|
||||||
|
// 查询 elecAmount为空的订单数据
|
||||||
|
int pageNum = 1;
|
||||||
|
int pageSize = 10;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
// 分页处理
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
List<OrderDetail> list = orderBasicInfoMapper.queryElecAmountNullList();
|
||||||
|
PageInfo<OrderDetail> pageInfo = new PageInfo<>(list);
|
||||||
|
if (CollectionUtils.isEmpty(pageInfo.getList())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算电量总金额
|
||||||
|
List<OrderDetail> orderDetailList = calculateData(pageInfo.getList());
|
||||||
|
|
||||||
|
// 更新数据库
|
||||||
|
orderBasicInfoMapper.batchUpdateOrderDetail(orderDetailList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算数据
|
||||||
|
private List<OrderDetail> calculateData(List<OrderDetail> list) {
|
||||||
|
for (OrderDetail orderDetail : list) {
|
||||||
|
// 总电费金额
|
||||||
|
BigDecimal totalElectricityAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
// 尖时段用电量
|
||||||
|
BigDecimal sharpUsedElectricity = orderDetail.getSharpUsedElectricity();
|
||||||
|
if (sharpUsedElectricity != null) {
|
||||||
|
// 计算该时段电费
|
||||||
|
BigDecimal multiply = orderDetail.getSharpElectricityPrice().multiply(sharpUsedElectricity).setScale(2,BigDecimal.ROUND_DOWN);
|
||||||
|
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 峰时段用电量
|
||||||
|
BigDecimal peakUsedElectricity = orderDetail.getPeakUsedElectricity();
|
||||||
|
if (peakUsedElectricity != null) {
|
||||||
|
// 计算该时段电费
|
||||||
|
BigDecimal multiply = orderDetail.getPeakElectricityPrice().multiply(peakUsedElectricity).setScale(2,BigDecimal.ROUND_DOWN);
|
||||||
|
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 平时段用电量
|
||||||
|
BigDecimal flatUsedElectricity = orderDetail.getFlatUsedElectricity();
|
||||||
|
if (flatUsedElectricity != null) {
|
||||||
|
// 计算该时段电费
|
||||||
|
BigDecimal multiply = orderDetail.getFlatElectricityPrice().multiply(flatUsedElectricity).setScale(2,BigDecimal.ROUND_DOWN);
|
||||||
|
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 谷时段用电量
|
||||||
|
BigDecimal valleyUsedElectricity = orderDetail.getValleyUsedElectricity();
|
||||||
|
if (valleyUsedElectricity != null) {
|
||||||
|
// 计算该时段电费
|
||||||
|
BigDecimal multiply = orderDetail.getValleyElectricityPrice().multiply(valleyUsedElectricity).setScale(2,BigDecimal.ROUND_DOWN);
|
||||||
|
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||||
|
}
|
||||||
|
|
||||||
|
orderDetail.setTotalElectricityAmount(totalElectricityAmount);
|
||||||
|
orderDetail.setTotalServiceAmount(orderDetail.getTotalOrderAmount().subtract(totalElectricityAmount));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额支付 计算需要退回的金额
|
* 余额支付 计算需要退回的金额
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -940,4 +940,38 @@
|
|||||||
AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryElecAmountNullList" resultMap="OrderDetailResult">
|
||||||
|
select
|
||||||
|
<include refid="Detail_Base_Column_List"/>
|
||||||
|
from order_detail
|
||||||
|
where del_flag = '0'
|
||||||
|
and total_order_amount is not null
|
||||||
|
AND total_order_amount > '0.00'
|
||||||
|
and total_electricity_amount is null
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="batchUpdateOrderDetail">
|
||||||
|
update order_detail
|
||||||
|
<trim prefix="set" suffixOverrides=",">
|
||||||
|
<trim prefix="total_electricity_amount =case" suffix="end,">
|
||||||
|
<foreach collection="list" item="item" index="index">
|
||||||
|
<if test="item.totalElectricityAmount!=null">
|
||||||
|
when id=#{item.id} then #{item.totalElectricityAmount}
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="total_service_amount =case" suffix="end,">
|
||||||
|
<foreach collection="list" item="item" index="index">
|
||||||
|
<if test="item.totalServiceAmount!=null">
|
||||||
|
when id=#{item.id} then #{item.totalServiceAmount}
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</trim>
|
||||||
|
</trim>
|
||||||
|
where
|
||||||
|
<foreach collection="list" separator="or" item="i" index="index" >
|
||||||
|
id=#{i.id}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user