|
|
|
|
@@ -1,18 +1,19 @@
|
|
|
|
|
package model
|
|
|
|
|
package dao
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
|
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
|
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var SystemTempObj map[string]*SystemTemp
|
|
|
|
|
var SystemTempObj map[string]*model.SystemTemp
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
SystemTempObj = make(map[string]*SystemTemp, 0)
|
|
|
|
|
SystemTempObj = make(map[string]*model.SystemTemp, 0)
|
|
|
|
|
sysTempList, err := QuerySystemTemp()
|
|
|
|
|
if err != nil {
|
|
|
|
|
globals.SugarLogger.Debug("query system temp err :", err)
|
|
|
|
|
@@ -23,64 +24,64 @@ func init() {
|
|
|
|
|
// 不存在系统模板,初始化系统模板
|
|
|
|
|
//InitSystemTemp()
|
|
|
|
|
}
|
|
|
|
|
temp := make(map[string]*SystemTemp, 0)
|
|
|
|
|
temp := make(map[string]*model.SystemTemp, 0)
|
|
|
|
|
for _, v := range sysTempList {
|
|
|
|
|
temp[v.TempSize] = v
|
|
|
|
|
SystemTempObj[v.TempSize] = v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
now := time.Now()
|
|
|
|
|
param := &SystemTemp{
|
|
|
|
|
param := &model.SystemTemp{
|
|
|
|
|
CreatedAt: &now,
|
|
|
|
|
UpdatedAt: &now,
|
|
|
|
|
LastOperator: "system",
|
|
|
|
|
DeletedAt: &utils.DefaultTimeValue,
|
|
|
|
|
TempName: "",
|
|
|
|
|
TempRank: SystemTempKey,
|
|
|
|
|
TempRank: model.SystemTempKey,
|
|
|
|
|
Temp: "",
|
|
|
|
|
UserId: "system_user",
|
|
|
|
|
TempType: TempTypeMerchant,
|
|
|
|
|
TempSize: SystemTempSizeBig,
|
|
|
|
|
TempType: model.TempTypeMerchant,
|
|
|
|
|
TempSize: model.SystemTempSizeBig,
|
|
|
|
|
PrintSn: "system",
|
|
|
|
|
IsUse: 1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化大字体模板
|
|
|
|
|
if _, v := temp[SystemTempSizeBig]; !v {
|
|
|
|
|
param.TempName = "system" + SystemTempSizeBig
|
|
|
|
|
param.Temp = SystemTempValue
|
|
|
|
|
if _, v := temp[model.SystemTempSizeBig]; !v {
|
|
|
|
|
param.TempName = "system" + model.SystemTempSizeBig
|
|
|
|
|
param.Temp = model.SystemTempValue
|
|
|
|
|
if err := AddTemp(param); err != nil {
|
|
|
|
|
globals.SugarLogger.Debug("init system temp err :", err)
|
|
|
|
|
}
|
|
|
|
|
SystemTempObj[SystemTempSizeBig] = param
|
|
|
|
|
SystemTempObj[model.SystemTempSizeBig] = param
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化中字体模板
|
|
|
|
|
if _, v := temp[SystemTempSizeMedium]; !v {
|
|
|
|
|
param.TempName = "system" + SystemTempSizeMedium
|
|
|
|
|
medium := strings.Replace(SystemTempValue, "<b>", "<hb>", -1)
|
|
|
|
|
if _, v := temp[model.SystemTempSizeMedium]; !v {
|
|
|
|
|
param.TempName = "system" + model.SystemTempSizeMedium
|
|
|
|
|
medium := strings.Replace(model.SystemTempValue, "<b>", "<hb>", -1)
|
|
|
|
|
medium2 := strings.Replace(medium, "</b>", "</hb>", -1)
|
|
|
|
|
param.Temp = medium2
|
|
|
|
|
param.TempSize = SystemTempSizeMedium
|
|
|
|
|
param.TempSize = model.SystemTempSizeMedium
|
|
|
|
|
param.IsUse = 2
|
|
|
|
|
if err := AddTemp(param); err != nil {
|
|
|
|
|
globals.SugarLogger.Debug("init system temp err :", err)
|
|
|
|
|
}
|
|
|
|
|
SystemTempObj[SystemTempSizeMedium] = param
|
|
|
|
|
SystemTempObj[model.SystemTempSizeMedium] = param
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化小字体模板
|
|
|
|
|
if _, v := temp[SystemTempSizeSmall]; !v {
|
|
|
|
|
param.TempName = "system" + SystemTempSizeSmall
|
|
|
|
|
medium := strings.Replace(SystemTempValue, "<b>", " ", -1)
|
|
|
|
|
if _, v := temp[model.SystemTempSizeSmall]; !v {
|
|
|
|
|
param.TempName = "system" + model.SystemTempSizeSmall
|
|
|
|
|
medium := strings.Replace(model.SystemTempValue, "<b>", " ", -1)
|
|
|
|
|
medium2 := strings.Replace(medium, "</b>", " ", -1)
|
|
|
|
|
param.Temp = medium2
|
|
|
|
|
param.TempSize = SystemTempSizeSmall
|
|
|
|
|
param.TempSize = model.SystemTempSizeSmall
|
|
|
|
|
param.IsUse = 2
|
|
|
|
|
if err := AddTemp(param); err != nil {
|
|
|
|
|
globals.SugarLogger.Debug("init system temp err :", err)
|
|
|
|
|
}
|
|
|
|
|
SystemTempObj[SystemTempSizeSmall] = param
|
|
|
|
|
SystemTempObj[model.SystemTempSizeSmall] = param
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -88,13 +89,13 @@ func init() {
|
|
|
|
|
// MakePrintMsgOnTemp 将打印数据渲染到模板当中
|
|
|
|
|
func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error) {
|
|
|
|
|
// 查询用户默认模板,不存在则使用系统默认模板
|
|
|
|
|
var userTemp *SystemTemp
|
|
|
|
|
userTemp, isHave, err := SelectUserDefaultTemp(userId, TempTypeMerchant)
|
|
|
|
|
var userTemp *model.SystemTemp
|
|
|
|
|
userTemp, isHave, err := SelectUserDefaultTemp(userId, model.TempTypeMerchant)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
if userTemp == nil || !isHave {
|
|
|
|
|
userTemp = SystemTempObj[SystemTempSizeBig]
|
|
|
|
|
userTemp = SystemTempObj[model.SystemTempSizeBig]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 需要打印数据
|
|
|
|
|
@@ -105,29 +106,29 @@ func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error)
|
|
|
|
|
case "skuName", "skuNumber", "skuPrice", "skuAllPrice", "allSkuTypeCount", "allSkuCount":
|
|
|
|
|
continue
|
|
|
|
|
case "goodsListDetail":
|
|
|
|
|
printMsg += TempTag[v]
|
|
|
|
|
skuList := make([]*SkuListPrintOrder, 0, 0)
|
|
|
|
|
printMsg += model.TempTag[v]
|
|
|
|
|
skuList := make([]*model.SkuListPrintOrder, 0, 0)
|
|
|
|
|
if err := json.Unmarshal([]byte(param[v]), skuList); err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
for i := 0; i < len(skuList); i++ {
|
|
|
|
|
printMsg += TempTag["skuName"]
|
|
|
|
|
printMsg += TempTag["skuNumber"]
|
|
|
|
|
printMsg += TempTag["skuPrice"]
|
|
|
|
|
printMsg += TempTag["skuAllPrice"]
|
|
|
|
|
printMsg += model.TempTag["skuName"]
|
|
|
|
|
printMsg += model.TempTag["skuNumber"]
|
|
|
|
|
printMsg += model.TempTag["skuPrice"]
|
|
|
|
|
printMsg += model.TempTag["skuAllPrice"]
|
|
|
|
|
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuName, skuList[i].SalePrice, skuList[i].TotalCountPrice)
|
|
|
|
|
if skuList[i].Upc != "" {
|
|
|
|
|
printMsg += TempTag["sku"]
|
|
|
|
|
printMsg += model.TempTag["sku"]
|
|
|
|
|
printValue = append(printValue, skuList[i].Upc)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
case "businessType":
|
|
|
|
|
if param[v] == "2" { // 是预订单
|
|
|
|
|
printMsg += TempTag[v]
|
|
|
|
|
printMsg += model.TempTag[v]
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
printMsg += TempTag[v]
|
|
|
|
|
printMsg += model.TempTag[v]
|
|
|
|
|
printValue = append(printValue, param[v])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -137,9 +138,9 @@ func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MakePrintMsgOnTempVoice 制作平台语音
|
|
|
|
|
func MakePrintMsgOnTempVoice(param map[string]string, setting *PrintSettingObj, userId string) (string, error) {
|
|
|
|
|
func MakePrintMsgOnTempVoice(param map[string]string, setting *model.PrintSettingObj, userId string) (string, error) {
|
|
|
|
|
// 打订单
|
|
|
|
|
if param[OrderStatusPrint] != "" {
|
|
|
|
|
if param[model.OrderStatusPrint] != "" {
|
|
|
|
|
// 订单提示设置
|
|
|
|
|
printMsg, err := PrinterOrderVoice(param, setting, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -149,42 +150,42 @@ func MakePrintMsgOnTempVoice(param map[string]string, setting *PrintSettingObj,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打运单
|
|
|
|
|
if param[WayBillStatusPrint] != "" {
|
|
|
|
|
switch param[WayBillStatusPrint] {
|
|
|
|
|
case utils.Int2Str(WaybillStatusCourierAssigned): // 分配骑手
|
|
|
|
|
if param[model.WayBillStatusPrint] != "" {
|
|
|
|
|
switch param[model.WayBillStatusPrint] {
|
|
|
|
|
case utils.Int2Str(model.WaybillStatusCourierAssigned): // 分配骑手
|
|
|
|
|
return PrintWayBillOrderStatus(param, setting), nil
|
|
|
|
|
case utils.Int2Str(WaybillStatusDeliverReminder): // 催单
|
|
|
|
|
case utils.Int2Str(model.WaybillStatusDeliverReminder): // 催单
|
|
|
|
|
printVoiceMsg := ``
|
|
|
|
|
printVoiceValue := make([]interface{}, 0, 0)
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, ReminderOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.ReminderOrderVoice)
|
|
|
|
|
return strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1), nil
|
|
|
|
|
case utils.Int2Str(WaybillStatusDelivered): // 送达
|
|
|
|
|
case utils.Int2Str(model.WaybillStatusDelivered): // 送达
|
|
|
|
|
printVoiceMsg := ``
|
|
|
|
|
printVoiceValue := make([]interface{}, 0, 0)
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, FinialsOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.FinialsOrderVoice)
|
|
|
|
|
return strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 门店状态
|
|
|
|
|
if param[StoreStatusPrint] != "" {
|
|
|
|
|
if param[model.StoreStatusPrint] != "" {
|
|
|
|
|
return PrintStoreStatus(param, setting), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 进店咨询
|
|
|
|
|
if param[EnterTheStorePrint] != "" {
|
|
|
|
|
if param[model.EnterTheStorePrint] != "" {
|
|
|
|
|
return `<sound>19</sound>`, nil
|
|
|
|
|
}
|
|
|
|
|
return "", nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrinterOrderVoice 打印机订单提示设置
|
|
|
|
|
func PrinterOrderVoice(param map[string]string, setting *PrintSettingObj, userId string) (string, error) {
|
|
|
|
|
func PrinterOrderVoice(param map[string]string, setting *model.PrintSettingObj, userId string) (string, error) {
|
|
|
|
|
var (
|
|
|
|
|
printVoiceMsg string //语音信息
|
|
|
|
|
printVoiceValue = make([]interface{}, 0, 0)
|
|
|
|
|
@@ -192,120 +193,120 @@ func PrinterOrderVoice(param map[string]string, setting *PrintSettingObj, userId
|
|
|
|
|
err error
|
|
|
|
|
)
|
|
|
|
|
// 称谓设置/平台语音设置
|
|
|
|
|
if (setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66) && setting.SystemVoice == SettingOpen {
|
|
|
|
|
if (setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66) && setting.SystemVoice == model.SettingOpen {
|
|
|
|
|
// 老板
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 订单状态
|
|
|
|
|
switch param[OrderStatusPrint] {
|
|
|
|
|
switch param[model.OrderStatusPrint] {
|
|
|
|
|
// 新订单
|
|
|
|
|
case utils.Int2Str(OrderStatusNew):
|
|
|
|
|
case utils.Int2Str(model.OrderStatusNew):
|
|
|
|
|
// 订单设置
|
|
|
|
|
if setting.OrderVoiceSetting.PrintOrder == SettingOpen { // 打印订单
|
|
|
|
|
if setting.OrderVoiceSetting.PrintOrder == model.SettingOpen { // 打印订单
|
|
|
|
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.OrderVoiceSetting.OrderNotice == SettingOpen && setting.SystemVoice == SettingOpen { // 订单通知
|
|
|
|
|
if setting.OrderVoiceSetting.OrderNotice == model.SettingOpen && setting.SystemVoice == model.SettingOpen { // 订单通知
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound><sound>%s</sound>` // 你来新订单了
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NewOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NewOrderVoice)
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
}
|
|
|
|
|
// 申请取消
|
|
|
|
|
case utils.Int2Str(ApplyOrderCancel):
|
|
|
|
|
case utils.Int2Str(model.ApplyOrderCancel):
|
|
|
|
|
// 订单设置
|
|
|
|
|
if setting.OrderVoiceSetting.UserOrderCancel == SettingOpen { // 申请取消打印
|
|
|
|
|
if setting.OrderVoiceSetting.UserOrderCancel == model.SettingOpen { // 申请取消打印
|
|
|
|
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.OrderVoiceSetting.UserOrderCancelVoice == SettingOpen && setting.SystemVoice == SettingOpen { // 申请取消语音
|
|
|
|
|
if setting.OrderVoiceSetting.UserOrderCancelVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen { // 申请取消语音
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound><sound>%s</sound>` // 你来新订单了
|
|
|
|
|
printVoiceValue = append(printVoiceValue, ApplyCancelVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.ApplyCancelVoice)
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
}
|
|
|
|
|
// 申请退款
|
|
|
|
|
case utils.Int2Str(ApplyOrderRefund):
|
|
|
|
|
case utils.Int2Str(model.ApplyOrderRefund):
|
|
|
|
|
// 订单设置
|
|
|
|
|
if setting.OrderVoiceSetting.RefundOrder == SettingOpen { // 取消打印订单
|
|
|
|
|
if setting.OrderVoiceSetting.RefundOrder == model.SettingOpen { // 取消打印订单
|
|
|
|
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.OrderVoiceSetting.RefundOrderVoice == SettingOpen && setting.SystemVoice == SettingOpen {
|
|
|
|
|
if setting.OrderVoiceSetting.OrderNotice == SettingOpen && setting.SystemVoice == SettingOpen {
|
|
|
|
|
if setting.OrderVoiceSetting.RefundOrderVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
|
|
|
|
if setting.OrderVoiceSetting.OrderNotice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, ApplyRefundVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.ApplyRefundVoice)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 取消打印
|
|
|
|
|
case utils.Int2Str(OrderStatusCanceled):
|
|
|
|
|
case utils.Int2Str(model.OrderStatusCanceled):
|
|
|
|
|
// 订单设置
|
|
|
|
|
if setting.OrderVoiceSetting.BusinessOrderCancel == SettingOpen { // 取消打印订单
|
|
|
|
|
if setting.OrderVoiceSetting.BusinessOrderCancel == model.SettingOpen { // 取消打印订单
|
|
|
|
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.OrderVoiceSetting.BusinessOrderCancelVoice == SettingOpen && setting.SystemVoice == SettingOpen {
|
|
|
|
|
if setting.OrderVoiceSetting.OrderNotice == SettingOpen && setting.SystemVoice == SettingOpen { // 订单取消语音通知
|
|
|
|
|
if setting.OrderVoiceSetting.BusinessOrderCancelVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
|
|
|
|
if setting.OrderVoiceSetting.OrderNotice == model.SettingOpen && setting.SystemVoice == model.SettingOpen { // 订单取消语音通知
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>` // 你来新订单了
|
|
|
|
|
printVoiceValue = append(printVoiceValue, CancelOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.CancelOrderVoice)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case utils.Int2Str(OrderStatusAccepted): // 待拣货
|
|
|
|
|
if setting.PickingSetting.WaitPickingPrint == SettingOpen { // 打印订单
|
|
|
|
|
case utils.Int2Str(model.OrderStatusAccepted): // 待拣货
|
|
|
|
|
if setting.PickingSetting.WaitPickingPrint == model.SettingOpen { // 打印订单
|
|
|
|
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.PickingSetting.WaitPickingVoice == SettingOpen && setting.SystemVoice == SettingOpen { // 订单通知
|
|
|
|
|
if setting.PickingSetting.WaitPickingVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen { // 订单通知
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound><sound>%s</sound>` // 你有订单未拣货
|
|
|
|
|
printVoiceValue = append(printVoiceValue, WaitPickUpOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.WaitPickUpOrderVoice)
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
}
|
|
|
|
|
case utils.Int2Str(OrderStatusWaitAccepted): // 待接单
|
|
|
|
|
if setting.PickingSetting.WaitPickingPrint == SettingOpen { // 打印订单
|
|
|
|
|
case utils.Int2Str(model.OrderStatusWaitAccepted): // 待接单
|
|
|
|
|
if setting.PickingSetting.WaitPickingPrint == model.SettingOpen { // 打印订单
|
|
|
|
|
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.PickingSetting.WaitPickingVoice == SettingOpen && setting.SystemVoice == SettingOpen { // 订单通知
|
|
|
|
|
if setting.PickingSetting.WaitPickingVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen { // 订单通知
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound><sound>%s</sound>` // 你有订单未接单(订单未处理)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, WaitOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.WaitOrderVoice)
|
|
|
|
|
printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
|
|
|
|
}
|
|
|
|
|
case utils.Int2Str(OrderStatusRejection): // 拒收
|
|
|
|
|
if setting.CustomerVoiceSetting.CustomerRejectionVoice == SettingOpen && setting.SystemVoice == SettingOpen {
|
|
|
|
|
case utils.Int2Str(model.OrderStatusRejection): // 拒收
|
|
|
|
|
if setting.CustomerVoiceSetting.CustomerRejectionVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
|
|
|
|
// 暂无语音打印
|
|
|
|
|
}
|
|
|
|
|
if setting.CustomerVoiceSetting.CustomerRejectionPrint == SettingOpen { // 客户拒收打印
|
|
|
|
|
if setting.CustomerVoiceSetting.CustomerRejectionPrint == model.SettingOpen { // 客户拒收打印
|
|
|
|
|
rejection := ``
|
|
|
|
|
rejectionValue := make([]interface{}, 0, 0)
|
|
|
|
|
rejection += `<center><b>客户拒收信息:</b></center><br>`
|
|
|
|
|
rejection += `<center><b>订单号: %s</b></center><br>`
|
|
|
|
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
|
|
|
|
rejection += `<center><b>拒收原因: %s</b></center><br>`
|
|
|
|
|
rejectionValue = append(rejectionValue, param[OrderNoPrint], param[VendorNamePrint], param[VendorOrderNoPrint], param[RejectionReasonPrint])
|
|
|
|
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.RejectionReasonPrint])
|
|
|
|
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case utils.Int2Str(OrderStatusCustomerService): // 客服退款
|
|
|
|
|
if setting.CustomerVoiceSetting.CustcareRefundVoice == SettingOpen && setting.SystemVoice == SettingOpen {
|
|
|
|
|
case utils.Int2Str(model.OrderStatusCustomerService): // 客服退款
|
|
|
|
|
if setting.CustomerVoiceSetting.CustcareRefundVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, BusinessResponsibilityVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.BusinessResponsibilityVoice)
|
|
|
|
|
}
|
|
|
|
|
if setting.CustomerVoiceSetting.CustcareRefundPrint == SettingOpen {
|
|
|
|
|
if setting.CustomerVoiceSetting.CustcareRefundPrint == model.SettingOpen {
|
|
|
|
|
rejection := ``
|
|
|
|
|
rejectionValue := make([]interface{}, 0, 0)
|
|
|
|
|
rejection += `<center><b>客服退款详情:</b></center><br>`
|
|
|
|
|
@@ -313,7 +314,7 @@ func PrinterOrderVoice(param map[string]string, setting *PrintSettingObj, userId
|
|
|
|
|
rejection += `<center><b>订单来源: %s # %s</b></center><br>`
|
|
|
|
|
rejection += `<center><b>退款原因: %s</b></center><br>`
|
|
|
|
|
rejection += `<center><b>退款时间: %s</b></center><br>`
|
|
|
|
|
rejectionValue = append(rejectionValue, param[OrderNoPrint], param[VendorNamePrint], param[VendorOrderNoPrint], param[CustcareRefundReasonPrint], utils.Time2DateStr(time.Now()))
|
|
|
|
|
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], param[model.CustcareRefundReasonPrint], utils.Time2DateStr(time.Now()))
|
|
|
|
|
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -324,7 +325,7 @@ func PrinterOrderVoice(param map[string]string, setting *PrintSettingObj, userId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrintWayBillOrderStatus 打印运单类通知消息
|
|
|
|
|
func PrintWayBillOrderStatus(param map[string]string, setting *PrintSettingObj) string {
|
|
|
|
|
func PrintWayBillOrderStatus(param map[string]string, setting *model.PrintSettingObj) string {
|
|
|
|
|
var (
|
|
|
|
|
printVoiceMsg string //语音信息
|
|
|
|
|
printVoiceValue = make([]interface{}, 0, 0)
|
|
|
|
|
@@ -332,21 +333,21 @@ func PrintWayBillOrderStatus(param map[string]string, setting *PrintSettingObj)
|
|
|
|
|
textMsgValue = make([]interface{}, 0, 0) // 文本信息
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
switch param[WayBillStatusPrint] {
|
|
|
|
|
case utils.Int2Str(WaybillStatusAccepted), utils.Int2Str(WaybillStatusCourierAssigned): // 分配骑手
|
|
|
|
|
if setting.RiderVoiceSetting.RiderTakeOrder == SettingOpen { // 打印订单
|
|
|
|
|
switch param[model.WayBillStatusPrint] {
|
|
|
|
|
case utils.Int2Str(model.WaybillStatusAccepted), utils.Int2Str(model.WaybillStatusCourierAssigned): // 分配骑手
|
|
|
|
|
if setting.RiderVoiceSetting.RiderTakeOrder == model.SettingOpen { // 打印订单
|
|
|
|
|
textMsg += `<center><b>接单骑手信息:</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>骑手姓名: %s</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>骑手电话: %s</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>接单时间: %s</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>订单来源: %s</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>单号: #%s</b></center><br>`
|
|
|
|
|
textMsgValue = append(textMsgValue, param[RiderNamePrint], param[RiderPhonePrint], utils.Time2DateStr(time.Now()), param[VendorNamePrint], param[VendorOrderNoPrint])
|
|
|
|
|
textMsgValue = append(textMsgValue, param[model.RiderNamePrint], param[model.RiderPhonePrint], utils.Time2DateStr(time.Now()), param[model.VendorNamePrint], param[model.VendorOrderNoPrint])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if setting.RiderVoiceSetting.RiderTakeOrderVoice == SettingOpen && setting.SystemVoice == SettingOpen { // 骑手接单语音通知
|
|
|
|
|
if setting.RiderVoiceSetting.RiderTakeOrderVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen { // 骑手接单语音通知
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound><sound>%s</sound>` // 骑手已经接单了
|
|
|
|
|
printVoiceValue = append(printVoiceValue, RiderGetOrderVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.RiderGetOrderVoice)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
|
|
|
|
@@ -355,7 +356,7 @@ func PrintWayBillOrderStatus(param map[string]string, setting *PrintSettingObj)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrintStoreStatus 打印门店状态
|
|
|
|
|
func PrintStoreStatus(param map[string]string, setting *PrintSettingObj) string {
|
|
|
|
|
func PrintStoreStatus(param map[string]string, setting *model.PrintSettingObj) string {
|
|
|
|
|
var (
|
|
|
|
|
printVoiceMsg string //语音信息
|
|
|
|
|
printVoiceValue = make([]interface{}, 0, 0)
|
|
|
|
|
@@ -364,17 +365,17 @@ func PrintStoreStatus(param map[string]string, setting *PrintSettingObj) string
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 离线打印文本开启
|
|
|
|
|
if setting.PickingSetting.BusinessOffLine == SettingOpen {
|
|
|
|
|
if setting.PickingSetting.BusinessOffLine == model.SettingOpen {
|
|
|
|
|
textMsg += `<center><b>门店下线通知</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>门店:%s</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>平台:%s</b></center><br>`
|
|
|
|
|
textMsg += `<center><b>下线时间:%s</b></center><br>`
|
|
|
|
|
textMsgValue = append(textMsgValue, param[EBailOrderNoPrint], param[VendorNamePrint], utils.Time2DateStr(time.Now()))
|
|
|
|
|
textMsgValue = append(textMsgValue, param[model.EBailOrderNoPrint], param[model.VendorNamePrint], utils.Time2DateStr(time.Now()))
|
|
|
|
|
}
|
|
|
|
|
// 离线打印语音开启
|
|
|
|
|
if setting.SystemVoice == SettingOpen && setting.PickingSetting.BusinessOffLineVoice == SettingOpen {
|
|
|
|
|
if setting.SystemVoice == model.SettingOpen && setting.PickingSetting.BusinessOffLineVoice == model.SettingOpen {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, StoreOfflineVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.StoreOfflineVoice)
|
|
|
|
|
}
|
|
|
|
|
voice := strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
|
|
|
|
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
|
|
|
|
@@ -385,54 +386,54 @@ func PrintStoreStatus(param map[string]string, setting *PrintSettingObj) string
|
|
|
|
|
// SyntheticSpeech 合成语音 (美团xxx号订单)
|
|
|
|
|
func SyntheticSpeech(printVoiceMsg string, printVoiceValue []interface{}, param map[string]string) (string, []interface{}) {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>` // 美团
|
|
|
|
|
switch param[VendOrIDPrint] {
|
|
|
|
|
case utils.Int2Str(VendorIDJD): // 京东
|
|
|
|
|
printVoiceValue = append(printVoiceValue, JdVoice)
|
|
|
|
|
case utils.Int2Str(VendorIDMTWM): // 美团
|
|
|
|
|
printVoiceValue = append(printVoiceValue, MtVoice)
|
|
|
|
|
case utils.Int2Str(VendorIDELM): // 饿了么
|
|
|
|
|
printVoiceValue = append(printVoiceValue, ElmVoice)
|
|
|
|
|
case utils.Int2Str(VendorIDEBAI): // 饿百
|
|
|
|
|
printVoiceValue = append(printVoiceValue, ElmVoice)
|
|
|
|
|
case utils.Int2Str(VendorIDJDShop): // 京东商城
|
|
|
|
|
printVoiceValue = append(printVoiceValue, JdToHose)
|
|
|
|
|
case utils.Int2Str(VendorIDTT): // 抖音
|
|
|
|
|
switch param[model.VendOrIDPrint] {
|
|
|
|
|
case utils.Int2Str(model.VendorIDJD): // 京东
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.JdVoice)
|
|
|
|
|
case utils.Int2Str(model.VendorIDMTWM): // 美团
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.MtVoice)
|
|
|
|
|
case utils.Int2Str(model.VendorIDELM): // 饿了么
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.ElmVoice)
|
|
|
|
|
case utils.Int2Str(model.VendorIDEBAI): // 饿百
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.ElmVoice)
|
|
|
|
|
case utils.Int2Str(model.VendorIDJDShop): // 京东商城
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.JdToHose)
|
|
|
|
|
case utils.Int2Str(model.VendorIDTT): // 抖音
|
|
|
|
|
// 暂无
|
|
|
|
|
}
|
|
|
|
|
if param[VendorOrderNoPrint] != "" {
|
|
|
|
|
switch len(param[VendorOrderNoPrint]) {
|
|
|
|
|
if param[model.VendorOrderNoPrint] != "" {
|
|
|
|
|
switch len(param[model.VendorOrderNoPrint]) {
|
|
|
|
|
case 1:
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint]])
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint]])
|
|
|
|
|
case 2:
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][:1]+"0"])
|
|
|
|
|
if param[VendorOrderNoPrint][1:] != "0" {
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][:1]+"0"])
|
|
|
|
|
if param[model.VendorOrderNoPrint][1:] != "0" {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][1:]])
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:]])
|
|
|
|
|
}
|
|
|
|
|
case 3:
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][0:1]+"00"])
|
|
|
|
|
if param[VendorOrderNoPrint][1:2] == "0" && param[VendorOrderNoPrint][2:] == "0" {
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][0:1]+"00"])
|
|
|
|
|
if param[model.VendorOrderNoPrint][1:2] == "0" && param[model.VendorOrderNoPrint][2:] == "0" {
|
|
|
|
|
|
|
|
|
|
} else if param[VendorOrderNoPrint][1:2] == "0" && param[VendorOrderNoPrint][2:] != "0" {
|
|
|
|
|
} else if param[model.VendorOrderNoPrint][1:2] == "0" && param[model.VendorOrderNoPrint][2:] != "0" {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][1:2]])
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]])
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][2:]])
|
|
|
|
|
} else if param[VendorOrderNoPrint][1:2] != "0" && param[VendorOrderNoPrint][2:] == "0" {
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][2:]])
|
|
|
|
|
} else if param[model.VendorOrderNoPrint][1:2] != "0" && param[model.VendorOrderNoPrint][2:] == "0" {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][1:2]+"0"])
|
|
|
|
|
} else if param[VendorOrderNoPrint][1:2] != "0" && param[VendorOrderNoPrint][2:] != "0" {
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]+"0"])
|
|
|
|
|
} else if param[model.VendorOrderNoPrint][1:2] != "0" && param[model.VendorOrderNoPrint][2:] != "0" {
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][1:2]+"0"])
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]+"0"])
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, NumberVoiceMap[param[VendorOrderNoPrint][2:]])
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][2:]])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printVoiceMsg += `<sound>%s</sound>`
|
|
|
|
|
printVoiceValue = append(printVoiceValue, OrderNoVoice)
|
|
|
|
|
printVoiceValue = append(printVoiceValue, model.OrderNoVoice)
|
|
|
|
|
return printVoiceMsg, printVoiceValue
|
|
|
|
|
}
|