KKSU
2024-11-29 b3a60ae2f32f9ef251ecb5f3630472dfd648a11a
refactor(mall): 优化退款金额计算逻辑

- 修改了退款金额计算方式,仅在满足特定条件时添加运费
- 新增 MallOrderItemMapper 接口方法,用于获取指定状态和订单 ID 的订单项列表
- 在 MallOrderItemMapper.xml 中添加对应的 SQL 查询语句
- 在 orderRefundList.html 中添加图片放大功能
4 files modified
41 ■■■■■ changed files
src/main/java/cc/mrbird/febs/mall/mapper/MallOrderItemMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java 16 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/MallOrderItemMapper.xml 5 ●●●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/order/orderRefundList.html 18 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/mapper/MallOrderItemMapper.java
@@ -17,4 +17,6 @@
    void updateStateByOrderId(@Param("state")Integer i,  @Param("orderId")Long id);
    List<MallOrderItem> selectListByOrderId(@Param("orderId")Long id);
    List<MallOrderItem> selectListByStateAndOrderId(@Param("state")Integer i, @Param("orderId")Long orderId);
}
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallTeamLeaderServiceImpl.java
@@ -2,7 +2,6 @@
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.*;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.properties.XcxProperties;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.SpringContextHolder;
@@ -37,7 +36,10 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@@ -420,7 +422,15 @@
            //退款退款金额
            BigDecimal refundAmount = mallRefundEntity.getAmount();
            refundAmount = refundAmount.add(mallOrderInfo.getCarriage());
            List<MallOrderItem> mallOrderItemListOnly = mallOrderItemMapper.selectListByStateAndOrderId(1,orderId);
            List<MallOrderItem> mallOrderItemListIng = mallOrderItemMapper.selectListByStateAndOrderId(2,orderId);
            if(CollUtil.isEmpty(mallOrderItemListOnly) && CollUtil.isNotEmpty(mallOrderItemListIng) ){
                if(1 == mallOrderItemListIng.size() ){
                    refundAmount = refundAmount.add(mallOrderInfo.getCarriage());
                    log.info("退款订单编号为{},订单金额:{},待退款订单:{},退款金额:{}", refundNo,orderAmount,mallOrderItemListOnly.size(),refundAmount);
                }
            }
//            refundAmount = refundAmount.add(mallOrderInfo.getCarriage());
            BigDecimal bb = new BigDecimal(100);
            int refundMoney = refundAmount.multiply(bb).intValue();
src/main/resources/mapper/modules/MallOrderItemMapper.xml
@@ -30,5 +30,10 @@
        where a.order_id=#{orderId}
    </select>
    <select id="selectListByStateAndOrderId" resultType="cc.mrbird.febs.mall.entity.MallOrderItem">
        select a.* from mall_order_item a
        where a.state = #{state} and a.order_id=#{orderId}
    </select>
</mapper>
src/main/resources/templates/febs/views/modules/order/orderRefundList.html
@@ -83,12 +83,28 @@
    暂无图片
    {{#  } else { }}
    {{# for(var i=0;i < d.refundPicList.length;i++){ }}
        <img id="refundPic" width='100' style="cursor: pointer;" height='100' src="{{ d.refundPicList[i]}}" />
        <a href="javascript:;" onclick="showBigImage('{{ d.refundPicList[i]}}')">
            <img id="refundPic" width='100' style="cursor: pointer;" height='100' src="{{ d.refundPicList[i]}}"/>
        </a>
    {{# } }}
    {{#  } }}
</script>
<!-- 表格操作栏 end -->
<script data-th-inline="none" type="text/javascript">
    //图片放大
    function showBigImage(url) {
        layer.open({
            type: 1,
            title: "图片",
            skin: 'layui-layer-rim', //加上边框
            area: ['80%', '100%'], //宽高
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<img src="' + url + '" alt="Big Image" style="max-width: 100%; height: auto;">'
        });
    }
    // 引入组件并初始化
    layui.use([ 'jquery', 'form', 'table', 'febs', 'formSelects'], function () {
        var $ = layui.jquery,