Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -78,19 +78,21 @@ public class ShopProdStatistic implements Serializable {
|
||||
* @return true=有效,false=无效
|
||||
*/
|
||||
public boolean isValid() {
|
||||
// 1. 校验所有字段是否为 null
|
||||
if (saleCount == null || saleAmount == null || refundCount == null || refundAmount == null) {
|
||||
return false;
|
||||
}
|
||||
// 2. 校验所有字段是否大于 0(BigDecimal 需用 compareTo 比较,不能直接用 >)
|
||||
if (saleCount.compareTo(BigDecimal.ZERO) <= 0 ||
|
||||
saleAmount.compareTo(BigDecimal.ZERO) <= 0 ||
|
||||
refundCount.compareTo(BigDecimal.ZERO) <= 0 ||
|
||||
refundAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return false;
|
||||
}
|
||||
// 3. 所有条件满足,返回 true
|
||||
return true;
|
||||
// 定义一个方法,统一校验“字段非空且大于0”
|
||||
// 避免重复代码,提高可读性
|
||||
return isPositive(saleCount) ||
|
||||
isPositive(saleAmount) ||
|
||||
isPositive(refundCount) ||
|
||||
isPositive(refundAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验 BigDecimal 字段是否非空且大于0
|
||||
* @param value 待校验字段
|
||||
* @return true=非空且大于0,false=否则
|
||||
*/
|
||||
private boolean isPositive(BigDecimal value) {
|
||||
// 先判断是否非空,再用 compareTo 比较是否大于0(compareTo 返回 >0 表示当前值大)
|
||||
return value != null && value.compareTo(BigDecimal.ZERO) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -42,8 +43,8 @@ public class CountPayTypeVo {
|
||||
/**
|
||||
* 合并实时数据和历史统计数据
|
||||
*/
|
||||
public static List<CountPayTypeVo> mergePayTypeData(Map<String, Integer> realTimeData,
|
||||
Map<String, Integer> historyData) {
|
||||
public static List<CountPayTypeVo> mergePayTypeData(Map<String, BigDecimal> realTimeData,
|
||||
Map<String, BigDecimal> historyData) {
|
||||
|
||||
List<CountPayTypeVo> result = new ArrayList<>();
|
||||
|
||||
@@ -51,13 +52,13 @@ public class CountPayTypeVo {
|
||||
String payCode = entry.getKey();
|
||||
String payName = entry.getValue();
|
||||
|
||||
Integer realTimeCount = getSafeValue(realTimeData, payCode);
|
||||
Integer historyCount = getSafeValue(historyData, payCode);
|
||||
BigDecimal realTimeCount = getSafeValue(realTimeData, payCode);
|
||||
BigDecimal historyCount = getSafeValue(historyData, payCode);
|
||||
|
||||
int totalCount = (realTimeCount != null ? realTimeCount : 0)
|
||||
+ (historyCount != null ? historyCount : 0);
|
||||
BigDecimal totalCount = (realTimeCount != null ? realTimeCount : BigDecimal.ZERO)
|
||||
.add(historyCount != null ? historyCount : BigDecimal.ZERO);
|
||||
|
||||
result.add(new CountPayTypeVo(totalCount, payName));
|
||||
result.add(new CountPayTypeVo(totalCount.intValue(), payName));
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ public class CountPayTypeVo {
|
||||
/**
|
||||
* 安全获取Map中的值,处理null情况
|
||||
*/
|
||||
private static Integer getSafeValue(Map<String, Integer> data, String key) {
|
||||
private static BigDecimal getSafeValue(Map<String, BigDecimal> data, String key) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
|
||||
" shop_id = #{shopId} " +
|
||||
"and trade_day = #{tradeDay} " +
|
||||
"and paid_time is not null ")
|
||||
Map<String, Integer> getOnlinePayTypeDate(Long shopId, LocalDate tradeDay);
|
||||
Map<String, BigDecimal> getOnlinePayTypeDate(Long shopId, LocalDate tradeDay);
|
||||
|
||||
/**
|
||||
* 订单支付方式统计 按日期范围查询
|
||||
@@ -136,7 +136,7 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
|
||||
" WHERE shop_id = #{shopId} " +
|
||||
" AND statistic_date >= #{start} " +
|
||||
" AND statistic_date <= #{end} ")
|
||||
Map<String, Integer> getPayTypeDateRangeRaw(Long shopId, LocalDate start, LocalDate end);
|
||||
Map<String, BigDecimal> getPayTypeDateRangeRaw(Long shopId, LocalDate start, LocalDate end);
|
||||
|
||||
|
||||
//*********************以下为日常统计********************************************************************************
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
@@ -20,27 +18,29 @@ import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.exception.PaySuccessException;
|
||||
import com.czg.market.dto.MemberOrderDTO;
|
||||
import com.czg.market.entity.MemberOrder;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.entity.MkShopRecharge;
|
||||
import com.czg.market.entity.MkShopRechargeDetail;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.MkShopRechargeVO;
|
||||
import com.czg.order.dto.BigDecimalDTO;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
import com.czg.order.dto.OrderInfoRefundDTO;
|
||||
import com.czg.market.entity.MemberOrder;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.service.*;
|
||||
import com.czg.order.service.CreditBuyerOrderService;
|
||||
import com.czg.order.service.OrderDetailService;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.CzgPayService;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.market.service.impl.MemberOrderServiceImpl;
|
||||
import com.czg.service.order.dto.*;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.service.order.mapper.OrderPaymentMapper;
|
||||
import com.czg.service.order.service.PayService;
|
||||
@@ -707,6 +707,7 @@ public class PayServiceImpl implements PayService {
|
||||
if (returnNum.compareTo(BigDecimal.ZERO) <= 0 || returnNum.compareTo(refundDetail.getNum()) < 0) {
|
||||
throw new CzgException("退单失败," + orderDetail.getProductName() + "可退数量不足");
|
||||
}
|
||||
refundDetail.setReturnAmount(refundDetail.getNum().multiply(orderDetail.getUnitPrice()).setScale(2, RoundingMode.UP));
|
||||
if (isPay) {
|
||||
orderDetail.setRefundNum(orderDetail.getRefundNum().add(refNum));
|
||||
if (orderDetail.getNum().compareTo(orderDetail.getRefundNum().add(orderDetail.getReturnNum())) == 0) {
|
||||
@@ -722,12 +723,12 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
orderDetail.setRefundNo(refPayOrderNo);
|
||||
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
|
||||
if (isPay) {
|
||||
orderDetail.setReturnAmount(refundDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
|
||||
// if (isPay) {
|
||||
orderDetail.setReturnAmount(orderDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
|
||||
if (orderDetail.getReturnAmount().compareTo(orderDetail.getPayAmount()) > 0) {
|
||||
orderDetail.setReturnAmount(orderDetail.getPayAmount());
|
||||
}
|
||||
}
|
||||
// }
|
||||
orderDetailService.updateById(orderDetail);
|
||||
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
||||
returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum());
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
<select id="selectProStatByDay" resultType="com.czg.order.entity.ShopProdStatistic">
|
||||
SELECT
|
||||
#{shopId} as shopId,
|
||||
#{day} as createDay,
|
||||
CASE WHEN detail.is_temporary = 1 THEN -1 ELSE detail.product_id END AS prodId,
|
||||
CASE WHEN detail.is_temporary = 1 THEN '临时菜' ELSE prod.name END AS productName,
|
||||
sum(detail.num-detail.return_num) as saleCount,
|
||||
|
||||
Reference in New Issue
Block a user