xiaoyong931011
2021-06-28 910ca2f0f8594a1353f822d653c88a7924902217
gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
@@ -1,6 +1,9 @@
package com.xzx.gc.order.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.utils.IdUtils;
import com.xzx.gc.entity.AddressInfo;
@@ -13,6 +16,7 @@
import com.xzx.gc.order.mapper.JhyOrderItemsMapper;
import com.xzx.gc.order.mapper.JhyOrderMapper;
import com.xzx.gc.order.mapper.SysEnvironmentalInfoMapper;
import com.xzx.gc.order.vo.JhyOrderDetailsVo;
import com.xzx.gc.order.vo.JhyOrderListVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -91,7 +95,27 @@
        }
    }
    public List<JhyOrderListVo> orderList(JhyOrderListDto orderListDto) {
        return null;
    public PageInfo<JhyOrderListVo> orderList(JhyOrderListDto orderListDto) {
        PageHelper.startPage(orderListDto.getPageNo(), orderListDto.getPageSize());
        List<JhyOrderListVo> data = jhyOrderMapper.selectJhyOrderList(orderListDto);
        return new PageInfo<>(data);
    }
    public JhyOrderDetailsVo orderDetails(Long orderId, String userId) {
        JhyOrder order = jhyOrderMapper.selectByPrimaryKey(orderId);
        List<JhyOrderItems> items = jhyOrderItemsMapper.selectOrderItems(orderId);
        BigDecimal total = BigDecimal.ZERO;
        for (JhyOrderItems item : items) {
            total = total.add(StrUtil.isNotBlank(item.getScore()) ? new BigDecimal(item.getScore()) : BigDecimal.ZERO);
        }
        JhyOrderDetailsVo detailsVo = new JhyOrderDetailsVo();
        BeanUtil.copyProperties(order, detailsVo);
        detailsVo.setAddress(order.getArea() + order.getAddress());
        detailsVo.setTotalPrice(total);
        detailsVo.setItems(items);
        return detailsVo;
    }
}