package feie

import (
	"fmt"
	"strings"
	"time"

	"git.rosy.net.cn/jx-callback/business/model/dao"

	"git.rosy.net.cn/baseapi/platformapi/feieapi"
	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/business/jxutils"
	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
	"git.rosy.net.cn/jx-callback/business/model"
	"git.rosy.net.cn/jx-callback/business/partner"
	"git.rosy.net.cn/jx-callback/globals"
	"git.rosy.net.cn/jx-callback/globals/api"
)

var (
	CurPrinterHandler *PrinterHandler
)

type PrinterHandler struct {
}

func init() {
	CurPrinterHandler = new(PrinterHandler)
	partner.RegisterPrinterPlatform(CurPrinterHandler)
}

// getOrderContent 添加了BOLD 标签
func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
	expectedDeliveryTime := order.ExpectedDeliveredTime
	if utils.IsTimeZero(expectedDeliveryTime) {
		expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
	}
	orderParams := []interface{}{}
	getCode := ""
	if order.VendorID == model.VendorIDEBAI {
		getCode = fmt.Sprintf("<B>淘宝闪购取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
	}
	orderFmt := ``
	if storeDetail != nil {
		if storeDetail.BrandIsPrint == model.NO {
			orderFmt += `<CB>%s</CB><BR>`
			if order.VendorOrgCode == "34665" {
				orderParams = append(orderParams, globals.StoreNameEbai2)
			} else {
				orderParams = append(orderParams, storeDetail.BrandName)
			}
		}
	}
	orderFmt += `
<CB>%s#%d</CB><BR>
<C><BOLD>%s:%s</BOLD></C><BR>
--------------------------------<BR>
<BOLD>下单时间: %s</BOLD><BR>
<BOLD>预计送达: %s</BOLD><BR>
<BOLD>订单编号: %s</BOLD><BR>
`
	if order.BusinessType == model.BusinessTypeDingshida {
		orderFmt += `
<B>预订单</B><BR>
`
	} else {
		orderFmt += `
<B>立即送达</B><BR>
`
	}
	orderFmt += `
<QR>%s</QR><BR>
` + getCode +
		`客户: %s<BR>
<BOLD>电话: %s</BOLD><BR>
<BOLD>地址: %s</BOLD><BR>
<BR>
客户备注: <BR>
<BOLD>%s</BOLD><BR>
<BR>
商品明细: <BR>
`
	orderFmt += `品名                      数量<BR>
--------------------------------<BR>` // 报价
	//	pricePoints := `品名    数量    单价       小计<BR>
	//--------------------------------<BR>` // 扣点
	// <BOLD>实际支付:</BOLD>%s<BR>
	orderParams = append(orderParams,
		jxutils.GetVendorName(order.VendorID),
		order.OrderSeq,
		order.StoreName, storeTel,
		utils.Time2Str(order.OrderCreatedAt),
		utils.Time2Str(expectedDeliveryTime),
		order.VendorOrderID,
		order.VendorOrderID,
		order.ConsigneeName,
		order.ConsigneeMobile,
		order.ConsigneeAddress,
		order.BuyerComment,
		// jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
	)
	//switch order.EarningType { 	z
	//case model.EarningTypePoints: // 扣点
	//	orderFmt += pricePoints
	//case model.EarningTypeQuote: // 报价
	//	orderFmt += priceQuote
	//}

	for _, sku := range order.Skus {
		if sku.Count > 1 {
			orderFmt += `<BOLD>%s <RIGHT>%s</RIGHT></BOLD><BR>`
		} else {
			orderFmt += `<BOLD>%s <RIGHT>%s</RIGHT></BOLD><BR>`
		}
		orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count))
		//switch order.EarningType {
		//case model.EarningTypePoints: // 扣点
		//	orderFmt += `%s<BR>`
		//	orderFmt += `%8s%10s%10s<BR>`
		//	orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
		//case model.EarningTypeQuote: // 报价
		//	orderFmt += `%s %25s<BR>`
		//	orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count))
		//}
		//标品需要打印条形码
		if sku.Upc != "" {
			orderFmt += `upc码： %s<BR>`
			orderParams = append(orderParams, sku.Upc)
		}
	}
	orderFmt += `<BR>
<BOLD>共%d种%d件商品</BOLD><BR>
<BOLD>实付:%s</BOLD><BR>
--------------------------------<BR>
<C><BOLD>商品质量问题请联系:</BOLD></C><BR>
更多信息请关注官方微信: %s<BR>
--------------------------------<BR>
`
	// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
	orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), globals.StoreName)
	return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
}

func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
	expectedDeliveryTime := order.ExpectedDeliveredTime
	if utils.IsTimeZero(expectedDeliveryTime) {
		expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
	}
	getCode := ""
	if order.VendorID == model.VendorIDEBAI {
		getCode = fmt.Sprintf("<B>淘宝闪购取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
	}
	orderParams := []interface{}{}
	orderFmt := ``
	if storeDetail != nil {
		if storeDetail.BrandIsPrint == model.NO {
			orderFmt += `<CB>%s</CB><BR>`
			if order.VendorOrgCode == "34665" {
				orderParams = append(orderParams, globals.StoreNameEbai2)
			} else {
				orderParams = append(orderParams, storeDetail.BrandName)
			}
		}
	}
	orderFmt += `<CB>%s#%d</CB><BR>
<BOLD>%s:%s</BOLD><BR>
--------------------------------<BR>
下单时间: %s<BR>
预计送达: %s<BR>
订单编号: %s<BR>
<BR>`

	if order.BusinessType == model.BusinessTypeDingshida {
		orderFmt += `
<B>预订单</B><BR>
`
	} else {
		orderFmt += `
<B>立即送达</B><BR>
`
	}

	orderFmt += `<QR>%s</QR><BR>
` + getCode +
		`<B>客户: %s</B><BR>
电话: %s<BR>
地址: %s<BR>
<BOLD>客户备注: </BOLD><BR>
<BOLD>%s</BOLD><BR>
<BR>
<B>商品明细: </B><BR>
<B>品名数量单价小计</B><BR>
--------------------------------<BR>`
	// <B><BOLD>实际支付:</BOLD></B><B>%s<BR></B>
	orderParams = append(orderParams,
		jxutils.GetVendorName(order.VendorID),
		order.OrderSeq,
		order.StoreName, storeTel,
		utils.Time2Str(order.OrderCreatedAt),
		utils.Time2Str(expectedDeliveryTime),
		order.VendorOrderID,
		order.VendorOrderID,
		order.ConsigneeName,
		order.ConsigneeMobile,
		order.ConsigneeAddress,
		order.BuyerComment,
		// jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
	)

	for _, sku := range order.Skus {
		if sku.Count > 1 {
			orderFmt += `<B>%s <RIGHT>%s</RIGHT></B><BR>`
		} else {
			orderFmt += `<B>%s <RIGHT>%s</RIGHT></B><BR>`
		}
		orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count))

		//orderFmt += `<B>%s</B><BR>`
		//switch order.EarningType {
		//case model.EarningTypePoints: // 扣点
		//	orderFmt += `<B>%s %s %s</B><BR>`
		//	orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
		//case model.EarningTypeQuote: // 报价
		//	orderFmt += `<CB>%s</CB><BR>`
		//	orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count))
		//}
		//orderFmt += `<B>%s %s %s<BR><BR></B>`
		//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
		//标品需要打印条形码
		if sku.Upc != "" {
			orderFmt += `upc码： %s<BR>`
			orderParams = append(orderParams, sku.Upc)
		}
	}
	orderFmt += `
<BOLD>共%d种%d件商品</BOLD>
<BOLD>实付:%s</BOLD><BR>
--------------------------------<BR>
<C><BOLD>商品质量问题请联系:</BOLD></C><BR>
更多信息请关注官方微信: %s<BR>
--------------------------------<BR>
`
	// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
	orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), globals.StoreName)
	return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
}

// getOrderContentBigMiddle 中号
func (c *PrinterHandler) getOrderContentBigMiddle(order *model.GoodsOrder, storeTel string, storeDetail *dao.StoreDetail) (content string) {
	expectedDeliveryTime := order.ExpectedDeliveredTime
	if utils.IsTimeZero(expectedDeliveryTime) {
		expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
	}
	getCode := ""
	if order.VendorID == model.VendorIDEBAI {
		getCode = fmt.Sprintf("<B>淘宝闪购取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
	}
	orderParams := []interface{}{}
	orderFmt := ``
	if storeDetail != nil {
		if storeDetail.BrandIsPrint == model.NO {
			orderFmt += `<CB>%s</CB><BR>`
			if order.VendorOrgCode == "34665" {
				orderParams = append(orderParams, globals.StoreNameEbai2)
			} else {
				orderParams = append(orderParams, storeDetail.BrandName)
			}
		}
	}
	orderFmt += `<CB>%s#%d</CB><BR>
<BOLD>%s:%s</BOLD><BR>
--------------------------------<BR>
<L>下单时间: %s</L><BR>
<L>预计送达: %s</L><BR>
<L>订单编号: %s</L><BR>
<BR>`

	if order.BusinessType == model.BusinessTypeDingshida {
		orderFmt += `
<L>预订单</L><BR>
`
	} else {
		orderFmt += `
<L>立即送达</L><BR>
`
	}

	orderFmt += getCode +
		`<L>客户: %s</L><BR>
<L>电话: %s</L><BR>
<L>地址: %s</L><BR>
<L>客户备注: </L><BR>
<L>%s</L><BR>
<BR>
<L>商品明细: </L><BR>
<L>品名数量单价小计</L><BR>
--------------------------------<BR>`
	// <B><BOLD>实际支付:</BOLD></B><B>%s<BR></B>
	orderParams = append(orderParams,
		jxutils.GetVendorName(order.VendorID),
		order.OrderSeq,
		order.StoreName, storeTel,
		utils.Time2Str(order.OrderCreatedAt),
		utils.Time2Str(expectedDeliveryTime),
		order.VendorOrderID,
		//order.VendorOrderID,
		order.ConsigneeName,
		order.ConsigneeMobile,
		order.ConsigneeAddress,
		order.BuyerComment,
		// jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),
	)

	for _, sku := range order.Skus {
		if sku.Count > 1 {
			orderFmt += `<L>%s <RIGHT>%s</RIGHT></L><BR>`
		} else {
			orderFmt += `<L>%s <RIGHT>%s</RIGHT></L><BR>`
		}
		orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count))

		//orderFmt += `<B>%s</B><BR>`
		//switch order.EarningType {
		//case model.EarningTypePoints: // 扣点
		//	orderFmt += `<B>%s %s %s</B><BR>`
		//	orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
		//case model.EarningTypeQuote: // 报价
		//	orderFmt += `<CB>%s</CB><BR>`
		//	orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count))
		//}
		//orderFmt += `<B>%s %s %s<BR><BR></B>`
		//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice), jxutils.IntPrice2StandardCurrencyString(sku.VendorPrice*int64(sku.Count)))
		//标品需要打印条形码
		if sku.Upc != "" {
			orderFmt += `upc码： %s<BR>`
			orderParams = append(orderParams, sku.Upc)
		}
	}
	orderFmt += `
<BOLD>共%d种%d件商品</BOLD>
<BOLD>实付:%s</BOLD><BR>
--------------------------------<BR>
<C><BOLD>商品质量问题请联系:</BOLD></C><BR>
更多信息请关注官方微信: %s<BR>
--------------------------------<BR>
`
	// <QR>http://weixin.qq.com/r/tkkDGzTERmk5rXB49xyk</QR>
	orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), globals.StoreName)
	return fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...)
}

// 打印取消或者退款订单
func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) {
	expectedDeliveryTime := order.ExpectedDeliveredTime
	if utils.IsTimeZero(expectedDeliveryTime) {
		expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
	}
	var orderParams []interface{}
	orderFmt := ``
	if storeDetail != nil {
		if storeDetail.BrandIsPrint == model.NO {
			orderFmt += `
		<CB>%s</CB><BR><BR>
		`
			if order.VendorOrgCode == "34665" {
				orderParams = append(orderParams, globals.StoreNameEbai2)
			} else {
				orderParams = append(orderParams, storeDetail.BrandName)
			}
		}
	}

	// 加载用户取消订单售后单

	title := ``
	if printType == model.YES { // 取消订单
		title = `<CB>取消订单详情</CB><BR>`
	} else { // 售后订单
		title = `<CB>售后订单详情</CB><BR>`
	}

	orderFmt +=
		`--------------------------------\n
下单时间: %s\n
订单编号: %s\n
`

	orderFmt += `
\n
<B>%s  <B>#%d</B></B><BR>
` + title + `
--------------------------------\n`
	orderParams = append(orderParams,
		utils.Time2Str(order.OrderCreatedAt),
		order.VendorOrderID,
		jxutils.GetVendorName(order.VendorID),
		order.OrderSeq,
	)
	//orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice))
	return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
}

// 打印取消或者退款订单，大字体
func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrder, printType int, storeDetail *dao.StoreDetail) (content string) {
	expectedDeliveryTime := order.ExpectedDeliveredTime
	if utils.IsTimeZero(expectedDeliveryTime) {
		expectedDeliveryTime = order.OrderCreatedAt.Add(1 * time.Hour)
	}
	var orderParams []interface{}
	orderFmt := ``
	if storeDetail != nil {
		if storeDetail.BrandIsPrint == model.NO {
			orderFmt += `
		<CB>%s</CB><BR><BR>
		`
			if order.VendorOrgCode == "34665" {
				orderParams = append(orderParams, globals.StoreNameEbai2)
			} else {
				orderParams = append(orderParams, storeDetail.BrandName)
			}
		}
	}
	title := ``
	if printType == model.YES { // 退单
		title = `<CB>取消订单详情</CB><BR>`
	} else {
		title = `<CB>售后订单详情</CB><BR>`
	}
	orderFmt += `--------------------------------<BR>
<B>下单时间: %s</B><BR>
<B>订单编号: %s</B><BR>
<B>%s  <B>#%d</B></B><BR>
` + title + `
--------------------------------\n`
	orderParams = append(orderParams,
		utils.Time2Str(order.OrderCreatedAt),
		order.VendorOrderID,
		jxutils.GetVendorName(order.VendorID),
		order.OrderSeq,
		//order.VendorOrderID,
	)

	orderFmt += `
--------------------------------<BR>
`
	//orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice))
	return strings.Replace(fmt.Sprintf(strings.Replace(orderFmt, "\n", "", -1), orderParams...), "\\n", "\r\n", -1)
}

func (c *PrinterHandler) GetVendorID() int {
	return model.VendorIDFeiE
}

func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, id1, id2, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
	if id1 != "" {
		if globals.EnableStoreWrite {
			_, err = api.FeieAPI.PrintMsg(id1, msgContent, 1)
		}
		if err == nil {
			printerStatus, err = c.GetPrinterStatus(ctx, id1, id2)
		}
	} else {
		printerStatus = &partner.PrinterStatus{
			PrintResult: partner.PrintResultNoPrinter,
		}
	}
	return printerStatus, err
}

func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, printerSN, printerKey string) (printerStatus *partner.PrinterStatus, err error) {
	tmpStatus, err := api.FeieAPI.QueryPrinterStatus(printerSN)
	if err == nil {
		printerStatus = &partner.PrinterStatus{
			PrinterStatus: tmpStatus,
			PrintResult:   partner.PrintResultSuccess,
		}
		printerStatus.Printed, printerStatus.Waiting, err = api.FeieAPI.QueryOrderInfoByDate(printerSN, time.Now())
	}
	return printerStatus, err
}

func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder, printType string, asfOrder *model.AfsOrder) (printerStatus *partner.PrinterStatus, err error) {
	// 这个门店只打饿了么
	storeMap := map[int]int{
		669264: 1,
		//669512: 1,
	}
	if storeMap[store.ID] == model.YES && order.VendorID == model.VendorIDMTWM {
		return nil, nil
	}
	if len(order.Skus) == 0 {
		return
	}
	content := ""
	if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
		content = c.getOrderContentBig(order, store.Tel1, storeDetail)
	} else if store.PrinterFontSize == partner.PrinterFontSizeMiddle || store.PrinterFontSize == partner.PrinterFontSizeMiddle2 {
		content = c.getOrderContentBigMiddle(order, store.Tel1, storeDetail)
	} else {
		content = c.getOrderContent(order, store.Tel1, storeDetail)
	}
	return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
}

func (c *PrinterHandler) PrintStore(ctx *jxcontext.Context, store *model.Store, storeDetail *dao.StoreDetail, vendorId int) (printerStatus *partner.PrinterStatus, err error) {
	return nil, err
}

func (c *PrinterHandler) PrintCancelOrRefundOrder(ctx *jxcontext.Context, printType int, store *model.Store, storeDetail *dao.StoreDetail, order *model.GoodsOrder) (printerStatus *partner.PrinterStatus, err error) {
	// 这个门店只打饿了么
	if store.ID == 669264 && order.VendorID == model.VendorIDMTWM {
		return nil, nil
	}
	if len(order.Skus) == 0 {
		return
	}
	content := ""
	if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 {
		content = c.getCancelOrRefundOrderContent(order, printType, storeDetail)
	} else {
		content = c.getCancelOrRefundOrderContentBig(order, printType, storeDetail)
	}

	if content == "" {
		return nil, nil
	}

	return c.PrintMsg(ctx, store.PrinterSN, store.PrinterKey, order.VendorOrderID, content)
}

func (c *PrinterHandler) RegisterPrinter(ctx *jxcontext.Context, printerSN, printerKey, printerName string, storeID int64) (notUsed1, notUsed2 string, err error) {
	var no map[string]string
	if globals.EnableStoreWrite {
		_, no, err = api.FeieAPI.PrinterAddList([]*feieapi.PrinterInfo{
			&feieapi.PrinterInfo{
				SN:   printerSN,
				Key:  printerKey,
				Name: printerName,
			},
		})
	} else {
		no = make(map[string]string)
	}
	if err == nil {
		if no[printerSN] != "" {
			if no[printerSN] == feieapi.ErrMsgAlredyAdded {
				api.FeieAPI.PrinterEdit(printerSN, printerName, "")
			} else {
				err = fmt.Errorf("添加打印机出错:%s", no[printerSN])
			}
		}
	}
	return "", "", err
}

func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, printerSN, notUsed string) (err error) {
	if globals.EnableStoreWrite {
		_, _, err = api.FeieAPI.PrinterDelList([]string{printerSN})
	}
	return err
}

func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) {
	return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDFeiE])
}

func (c *PrinterHandler) RebindPrinter(ctx *jxcontext.Context, lastBindResult *partner.BindPrinterResult) (bindResult *partner.BindPrinterResult, err error) {
	return nil, fmt.Errorf("%s打印机当前不支持扫码绑定", model.VendorChineseNames[model.VendorIDFeiE])
}

func (c *PrinterHandler) EmptyPrintList(ctx *jxcontext.Context, id1, id2 string) (err error) {
	if globals.EnableStoreWrite {
		err = api.FeieAPI.DelPrinterSqs(id1)
	}
	return err
}

func (c *PrinterHandler) PlayText(ctx *jxcontext.Context, id1, id2, orderID, text string) (printerStatus *partner.PrinterStatus, err error) {
	return c.GetPrinterStatus(ctx, id1, id2)
}

func (c *PrinterHandler) SetSound(ctx *jxcontext.Context, id1, id2, sound string) (err error) {
	if globals.EnableStoreWrite {
		err = api.FeieAPI.SetSound(id1, sound)
	}
	return err
}
