package org.springblade.modules.api.service;

import org.springblade.modules.api.request.SubmitOrderRequest;
import org.springblade.modules.finance.entity.Order;
import org.springblade.modules.finance.entity.OrderDetail;
import org.springblade.modules.finance.entity.OrderGrouponGoods;
import org.springblade.modules.platform.entity.UserAddress;

/**
 * Author pangqijun
 * Date 2023/5/29
 * Description
 */
public interface SubmitOrderService {

    /**
     * 下单
     * @param request
     * @return
     */
    String submitOrder(SubmitOrderRequest request);

    default void confirmOrder(String pickupCode, Long userId) {};

    /**
     * 支付成功后处理操作，默认不处理，各实现类可自行实现覆盖
     * @param order
     */
    default void paySuccessAfter(Order order) {}

    /**
     * 构建订单明细实体
     */
    default OrderDetail buildOrderDetail(String remark, UserAddress userAddress) {
        OrderDetail orderDetail = new OrderDetail();
        orderDetail.setProvince(userAddress.getProvince());
        orderDetail.setCity(userAddress.getCity());
        orderDetail.setDistrict(userAddress.getDistrict());
        orderDetail.setStreet(userAddress.getStreet());
        orderDetail.setAddress(userAddress.getDetail());
        orderDetail.setRemark(remark);
        return orderDetail;
    }

    default void releaseGoodsStock(Order order) {}

}
