package com.yiqi.common.utils;

import com.yiqi.common.config.SnowFlakeConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OrderNoUtils {
    @Autowired
    SnowFlakeConfig snowFlakeConfig;

    public final static String cloth_wash_code_header = "WA";
    public final static String cloth_wash_adjust_code_header = "WD";
    public final static String activity_order_header = "AC";
    public final static String cloth_order_header = "CL";
    public final static String purchase_order_header = "PU";
    public final static String goods_order_header = "GO";
    public final static String recharge_order_header = "RE";
    public final static String delivery_order_header = "DE";
    public final static String refund_order_header = "RF";



    /**
     * 洗衣水洗唛号生成
     * @return
     */
    public String getClothWashCode(){
        return getOrderNo(cloth_wash_code_header);
    }

    /**
     * 洗衣水洗附件单号
     * @return
     */
    public String getClothWashAdjustCode(){
        return getOrderNo(cloth_wash_adjust_code_header);
    }

    /**
     * 洗衣订单号生成
     * @return
     */
    public String getClothOrderNo(){
        return getOrderNo(cloth_order_header);
    }

    /**
     * 进货订单号生成
     * @return
     */
    public String getPurchaseOrderNo(){
        return getOrderNo(purchase_order_header);
    }

    /**
     * 商品订单号生成
     * @return
     */
    public String getGoodsOrderNo(){
        return getOrderNo(goods_order_header);
    }

    /**
     * 活动订单号生成
     * @return
     */
    public String getActivityOrderNo(){
        return getOrderNo(activity_order_header);
    }

    /**
     * 充值订单号生成
     * @return
     */
    public String getRechargeOrderNo(){
        return getOrderNo(recharge_order_header);
    }

    /**
     * 配送费订单号生成
     * @return
     */
    public String getDeliveryOrderNo(){
        return getOrderNo(delivery_order_header);
    }


    public String getOrderNo(String headerKey){
        return headerKey + snowFlakeConfig.getInstance().nextId();
    }

    public String getOrderNo(){
        return getOrderNo("");
    }
}
