Cui Zhi Feng
2024-08-23 cadb3e2516207d2e24203c4e7139f085f3ea9bdd
src/main/java/com/mzl/flower/service/payment/OrderItemSalesService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.base.interceptor.CodeDecorator;
import com.mzl.flower.component.SequenceNo;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
@@ -17,6 +18,7 @@
import com.mzl.flower.mapper.supplier.StationMapper;
import com.mzl.flower.service.BaseService;
import com.mzl.flower.service.system.CodeService;
import com.mzl.flower.utils.ExcelExportUtil;
import com.mzl.flower.utils.UUIDGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
@@ -24,7 +26,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
@@ -56,6 +60,9 @@
    @Autowired
    private CodeService codeService;
    @Autowired
    private CodeDecorator codeDecorator;
    public String createSales(OrderItemSalesCreateDTO dto){
        Integer num = dto.getNum();
@@ -176,6 +183,60 @@
        return page;
    }
    public void exportSalesList(HttpServletResponse response, OrderItemSalesQueryDTO dto){
        dto.setOrderStartDate(parseLocalDateTime(dto.getOrderStartDateStr()));
        dto.setOrderEndDate(parseLocalDateTime(dto.getOrderEndDateStr()));
        dto.setSalesStartDate(parseLocalDateTime(dto.getSalesStartDateStr()));
        dto.setSalesEndDate(parseLocalDateTime(dto.getSalesEndDateStr()));
        List<OrderItemSalesNewListDTO> ls = orderItemSalesMapper.selectItemSalesList(null, dto);
        codeDecorator.decorate(ls);
        String[] rowsName = new String[]{"集货站", "商品名称", "商品单位", "商品颜色", "商品等级"
                , "商品分类", "收货人", "收货人手机号码", "收货地址", "商品数量", "供应商名称", "商品售价"
                , "总金额", "订单号", "售后单号", "标题", "申请数量", "理由", "实际退款", "审核结果"
                , "申请时间", "平台回复"};
        List<Object[]> dataList = new ArrayList<>();
        for (OrderItemSalesNewListDTO d : ls) {
            Object[] objs = new Object[rowsName.length];
            int a = 0;
            objs[a++] = d.getStationName();
            objs[a++] = d.getFlowerName();
            objs[a++] = d.getFlowerUnit();
            objs[a++] = d.getFlowerColor();
            objs[a++] = d.getFlowerLevelStr();
            objs[a++] = d.getFlowerCategory();
            objs[a++] = d.getCustomer();
            objs[a++] = d.getCustomerTel();
            objs[a++] = d.getCustomerAddress();
            objs[a++] = d.getFlowerNum();
            objs[a++] = d.getSupplierName();
            objs[a++] = d.getPrice();
            objs[a++] = d.getTotal();
            objs[a++] = d.getOrderNo();
            objs[a++] = d.getSalesNo();
            objs[a++] = d.getTitle();
            objs[a++] = d.getNum();
            objs[a++] = d.getReason();
            objs[a++] = d.getTotalFee();
            objs[a++] = d.getStatusStr();
            objs[a++] = format(d.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
            objs[a++] = d.getRemarks();
            dataList.add(objs);
        }
        ExcelExportUtil excelExportUtil = new ExcelExportUtil("售后申请列表", rowsName, dataList, response);
        try {
            response.addHeader("filename", URLEncoder.encode("售后申请列表.xls", "UTF-8"));
            response.addHeader("Access-Control-Expose-Headers", "filename");
            excelExportUtil.export();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    public OrderItemSalesNewDTO getSalesInfo(String id){
        OrderItemSalesNewDTO rr = new OrderItemSalesNewDTO();
        OrderItemSales sl = orderItemSalesMapper.selectById(id);
@@ -195,6 +256,7 @@
        rr.setCustomerCity(o.getCustomerCity());
        rr.setCustomerRegion(o.getCustomerRegion());
        rr.setCustomerAddress(o.getCustomerAddress());
        rr.setOrderTime(o.getCreateTime());
        OrderItem oi = orderItemMapper.selectById(sl.getOrderItemId());
        rr.setFlowerName(oi.getFlowerName());
@@ -207,6 +269,8 @@
        rr.setSupplierName(oi.getSupplierName());
        rr.setPrice(oi.getPrice());
        rr.setTotal(oi.getTotal());
        rr.setSupplierPrice(oi.getSupplierPrice());
        rr.setMarkupPartner(oi.getMarkupPartner());
        Long stationId = oi.getStationId();
        if(stationId != null) {