package com.seer.teach.mall.app.order.convert;

import com.seer.teach.common.enums.pay.PayOrderSourceEnum;
import com.seer.teach.mall.entity.GoodsEntity;
import com.seer.teach.mall.entity.OrderEntity;
import com.seer.teach.pay.api.order.dto.PayOrderCreateReqDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface AppOrderConvert {

    AppOrderConvert INSTANCE = Mappers.getMapper(AppOrderConvert.class);

    default PayOrderCreateReqDTO convertPayOrderCreateReqDTO(OrderEntity order, GoodsEntity goods){
        return PayOrderCreateReqDTO.builder()
                .orderSourceEnum(PayOrderSourceEnum.MALL_ORDER_PAYMENT)
                .merchantOrderId(String.valueOf(order.getId()))
                .merchantOrderSn(order.getOrderSn())
                .subject(goods.getName())
                .userId(order.getUserId()).build();
    }

}