mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
计算保存订单详情的总电费金额,总服务费金额
This commit is contained in:
@@ -10,6 +10,7 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.ApplyOrderInvoiceDTO;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.SettleOrderDTO;
|
||||
@@ -270,4 +271,27 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请开票接口
|
||||
*/
|
||||
public RestApiResponse<?> applyOrderInvoice(HttpServletRequest request, @RequestBody ApplyOrderInvoiceDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
orderService.applyOrderInvoice(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.error("查询未开发票订单 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error("查询未开发票订单 error", e);
|
||||
response = new RestApiResponse<>("00300003", "查询未开发票订单异常");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.jsowell.pile.domain.OrderDetail;
|
||||
import com.jsowell.pile.domain.OrderInvoiceRecord;
|
||||
import com.jsowell.pile.domain.OrderPayRecord;
|
||||
import com.jsowell.pile.domain.WxpayCallbackRecord;
|
||||
import com.jsowell.pile.dto.ApplyOrderInvoiceDTO;
|
||||
import com.jsowell.pile.dto.BasicPileDTO;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.GetPayModeDTO;
|
||||
@@ -1022,4 +1023,17 @@ public class OrderService {
|
||||
|
||||
return orderList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请开票
|
||||
* @param dto
|
||||
*/
|
||||
public void applyOrderInvoice(ApplyOrderInvoiceDTO dto) {
|
||||
// 校验订单是否已经开票
|
||||
// 入库
|
||||
OrderInvoiceRecord orderInvoiceRecord = new OrderInvoiceRecord();
|
||||
orderInvoiceRecord.setMemberId(dto.getMemberId());
|
||||
orderInvoiceRecord.setTitleId(dto.getTitleId());
|
||||
orderInvoiceRecordService.insertOrderInvoiceRecord(orderInvoiceRecord);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jsowell.pile.domain;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
@@ -13,6 +14,7 @@ import java.math.BigDecimal;
|
||||
* @author jsowell
|
||||
* @date 2023-04-10
|
||||
*/
|
||||
@Data
|
||||
public class OrderInvoiceRecord extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -27,6 +29,12 @@ public class OrderInvoiceRecord extends BaseEntity {
|
||||
@Excel(name = "会员id")
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 发票抬头id
|
||||
*/
|
||||
@Excel(name = "发票抬头id")
|
||||
private String titleId;
|
||||
|
||||
/**
|
||||
* 申请订单编号(逗号分割)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class ApplyOrderInvoiceDTO {
|
||||
// 订单编号列表
|
||||
private List<String> orderCodes;
|
||||
|
||||
// 会员id
|
||||
private String memberId;
|
||||
|
||||
// 抬头id
|
||||
private String titleId;
|
||||
}
|
||||
@@ -597,44 +597,74 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
|
||||
// 更新订单详情
|
||||
try {
|
||||
// 总电费金额,总服务费金额
|
||||
BigDecimal totalElectricityAmount = BigDecimal.ZERO;
|
||||
BigDecimal totalServiceAmount = BigDecimal.ZERO;
|
||||
|
||||
// 尖时段用电量
|
||||
String sharpUsedElectricity = data.getSharpUsedElectricity();
|
||||
if (sharpUsedElectricity != null) {
|
||||
orderDetail.setSharpUsedElectricity(new BigDecimal(sharpUsedElectricity));
|
||||
if (data.getSharpPrice() != null) {
|
||||
orderDetail.setSharpPrice(new BigDecimal(data.getSharpPrice()));
|
||||
}
|
||||
if (data.getSharpAmount() != null) {
|
||||
orderDetail.setSharpAmount(new BigDecimal(data.getSharpAmount()));
|
||||
}
|
||||
// 计算该时段电费
|
||||
BigDecimal multiply = orderDetail.getSharpElectricityPrice().multiply(new BigDecimal(sharpUsedElectricity)).setScale(2,BigDecimal.ROUND_DOWN);
|
||||
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||
}
|
||||
|
||||
// 峰时段用电量
|
||||
String peakUsedElectricity = data.getPeakUsedElectricity();
|
||||
if (peakUsedElectricity != null) {
|
||||
orderDetail.setPeakUsedElectricity(new BigDecimal(peakUsedElectricity));
|
||||
if (data.getPeakPrice() != null) {
|
||||
orderDetail.setPeakPrice(new BigDecimal(data.getPeakPrice()));
|
||||
}
|
||||
if (data.getPeakAmount() != null) {
|
||||
orderDetail.setPeakAmount(new BigDecimal(data.getPeakAmount()));
|
||||
}
|
||||
// 计算该时段电费
|
||||
BigDecimal multiply = orderDetail.getPeakElectricityPrice().multiply(new BigDecimal(peakUsedElectricity)).setScale(2,BigDecimal.ROUND_DOWN);
|
||||
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||
}
|
||||
|
||||
// 平时段用电量
|
||||
String flatUsedElectricity = data.getFlatUsedElectricity();
|
||||
if (flatUsedElectricity != null) {
|
||||
orderDetail.setFlatUsedElectricity(new BigDecimal(flatUsedElectricity));
|
||||
if (data.getFlatPrice() != null) {
|
||||
orderDetail.setFlatPrice(new BigDecimal(data.getFlatPrice()));
|
||||
}
|
||||
if (data.getFlatAmount() != null) {
|
||||
orderDetail.setFlatAmount(new BigDecimal(data.getFlatAmount()));
|
||||
}
|
||||
// 计算该时段电费
|
||||
BigDecimal multiply = orderDetail.getFlatElectricityPrice().multiply(new BigDecimal(flatUsedElectricity)).setScale(2,BigDecimal.ROUND_DOWN);
|
||||
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||
}
|
||||
|
||||
// 谷时段用电量
|
||||
String valleyUsedElectricity = data.getValleyUsedElectricity();
|
||||
if (valleyUsedElectricity != null) {
|
||||
orderDetail.setValleyUsedElectricity(new BigDecimal(valleyUsedElectricity));
|
||||
if (data.getValleyPrice() != null) {
|
||||
orderDetail.setValleyPrice(new BigDecimal(data.getValleyPrice()));
|
||||
}
|
||||
if (data.getValleyAmount() != null) {
|
||||
orderDetail.setValleyAmount(new BigDecimal(data.getValleyAmount()));
|
||||
}
|
||||
// 计算该时段电费
|
||||
BigDecimal multiply = orderDetail.getValleyElectricityPrice().multiply(new BigDecimal(valleyUsedElectricity)).setScale(2,BigDecimal.ROUND_DOWN);
|
||||
totalElectricityAmount = totalElectricityAmount.add(multiply);
|
||||
}
|
||||
|
||||
orderDetail.setTotalElectricityAmount(totalElectricityAmount);
|
||||
orderDetail.setTotalServiceAmount(orderAmount.subtract(totalElectricityAmount));
|
||||
orderDetail.setTotalUsedElectricity(new BigDecimal(data.getTotalElectricity())); // 总用电量
|
||||
orderDetail.setTotalOrderAmount(orderAmount); // 订单总金额
|
||||
if (data.getSharpUsedElectricity() != null) {
|
||||
orderDetail.setSharpUsedElectricity(new BigDecimal(data.getSharpUsedElectricity())); // 尖时段用电量
|
||||
}
|
||||
if (data.getSharpPrice() != null) {
|
||||
orderDetail.setSharpPrice(new BigDecimal(data.getSharpPrice()));
|
||||
}
|
||||
if (data.getSharpAmount() != null) {
|
||||
orderDetail.setSharpAmount(new BigDecimal(data.getSharpAmount()));
|
||||
}
|
||||
if (data.getPeakUsedElectricity() != null) {
|
||||
orderDetail.setPeakUsedElectricity(new BigDecimal(data.getPeakUsedElectricity())); // 峰时段用电量
|
||||
}
|
||||
if (data.getPeakPrice() != null) {
|
||||
orderDetail.setPeakPrice(new BigDecimal(data.getPeakPrice()));
|
||||
}
|
||||
if (data.getPeakAmount() != null) {
|
||||
orderDetail.setPeakAmount(new BigDecimal(data.getPeakAmount()));
|
||||
}
|
||||
if (data.getFlatUsedElectricity() != null) {
|
||||
orderDetail.setFlatUsedElectricity(new BigDecimal(data.getFlatUsedElectricity())); // 平时段用电量
|
||||
}
|
||||
if (data.getFlatPrice() != null) {
|
||||
orderDetail.setFlatPrice(new BigDecimal(data.getFlatPrice()));
|
||||
}
|
||||
if (data.getFlatAmount() != null) {
|
||||
orderDetail.setFlatAmount(new BigDecimal(data.getFlatAmount()));
|
||||
}
|
||||
if (data.getValleyUsedElectricity() != null) {
|
||||
orderDetail.setValleyUsedElectricity(new BigDecimal(data.getValleyUsedElectricity())); // 谷时段用电量
|
||||
}
|
||||
if (data.getValleyPrice() != null) {
|
||||
orderDetail.setValleyPrice(new BigDecimal(data.getValleyPrice()));
|
||||
}
|
||||
if (data.getValleyAmount() != null) {
|
||||
orderDetail.setValleyAmount(new BigDecimal(data.getValleyAmount()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("设置订单详情参数发生异常", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user