SubOrderDTOConvert.java 2.17 KB
package cn.com.glsx.stoassistant.convert;

import cn.com.glsx.scrm.shopmall.dto.order.PlatformSubOrderGoodsDTO;
import cn.com.glsx.scrm.shopmall.enums.GoodsDeliveryTypeEnum;
import cn.com.glsx.scrm.shopmall.enums.OrderSourceEnum;
import cn.com.glsx.scrm.shopmall.util.PlatformOrderStatusConvertUtils;
import cn.com.glsx.stoassistant.response.order.OrderGoodsResponse;
import cn.com.glsx.stoassistant.response.order.OrderWeappPageResponse;
import org.mapstruct.Mapper;

import java.util.Collections;

@Mapper
public interface SubOrderDTOConvert {


    static OrderWeappPageResponse toOrderWeappPageResponse(PlatformSubOrderGoodsDTO dto){
        OrderWeappPageResponse response = new OrderWeappPageResponse();
        response.setMainOrderCode(dto.getOrderCode());
        response.setOrderCode(dto.getSubOrderCode());
        response.setCreatedDate(dto.getOrderCreatedDate());
        Byte orderStatus = PlatformOrderStatusConvertUtils.convertOrderStatus(dto.getPayStatus(), dto.getOrderStatus(), dto.getCancelStatus());
        response.setOrderStatus(orderStatus);
        //售后状态
        Byte afterSaleStatus = PlatformOrderStatusConvertUtils.convertAfterSalesStatus(dto.getReturnOrderStatus(), dto.getOutRefundType());
        response.setAfterSaleStatus(afterSaleStatus);
        response.setPayPrice(dto.getPayPrice());
        response.setOrderSource(OrderSourceEnum.SHOP_MALL.getValue());
        response.setDeliveryType(GoodsDeliveryTypeEnum.DELIVERY.getValue());
        response.setGoodsAmount(dto.getSellQty());
        response.setOrderClassify(5);
        response.setPlatformOrderStatus(dto.getOrderStatus());

        OrderGoodsResponse goods = new OrderGoodsResponse();
        goods.setBrandName(dto.getBrandName());
        goods.setGoodsSkuCode(dto.getGoodsSkuCode());
        goods.setGoodsName(dto.getGoodsSkuName());
        goods.setGoodsImage(dto.getGoodsImageUrl());
        goods.setRetailPrice(dto.getSalePrice());
        goods.setGoodsNumber(dto.getSellQty());
        goods.setSpecificationData(dto.getSpecificationData());
        goods.setRedeemPoints(dto.getRedeemPoints());
        response.setOrderGoods(Collections.singletonList(goods));
        return response;
    }
}