1
This commit is contained in:
25
business/model/dao/dao_print_setting.go
Normal file
25
business/model/dao/dao_print_setting.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetPrintSetting(printNo string) (*model.PrintSettingObj, error) {
|
||||
sql := ` SELECT * FROM print_setting WHERE print_no = ? and deleted_at = ? `
|
||||
sqlParams := []interface{}{
|
||||
printNo,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
|
||||
var printSetting *model.PrintSetting
|
||||
if err := GetRow(GetDB(), &printSetting, sql, sqlParams...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if printSetting == nil {
|
||||
return nil, errors.New("数据查询异常")
|
||||
}
|
||||
|
||||
return model.UnMarshalString2Json(printSetting)
|
||||
}
|
||||
539
business/model/dao/print_temp_utils.go
Normal file
539
business/model/dao/print_temp_utils.go
Normal file
@@ -0,0 +1,539 @@
|
||||
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-print/globals"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var SystemTempObj map[string]*model.SystemTemp
|
||||
|
||||
func Init() {
|
||||
SystemTempObj = make(map[string]*model.SystemTemp, 0)
|
||||
sysTempList, err := QuerySystemTemp()
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("query system temp err :", err)
|
||||
return
|
||||
}
|
||||
SystemTempObj[sysTempList.TempSize] = sysTempList
|
||||
|
||||
//now := time.Now()
|
||||
//param := &model.SystemTemp{
|
||||
// CreatedAt: &now,
|
||||
// UpdatedAt: &now,
|
||||
// LastOperator: "system",
|
||||
// DeletedAt: &utils.DefaultTimeValue,
|
||||
// TempName: "",
|
||||
// TempRank: model.SystemTempKey,
|
||||
// Temp: "",
|
||||
// UserId: "system_user",
|
||||
// TempType: model.TempTypeMerchant,
|
||||
// TempSize: model.SystemTempSizeBig,
|
||||
// PrintSn: "system",
|
||||
// IsUse: 1,
|
||||
//}
|
||||
|
||||
// 初始化大字体模板
|
||||
//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[model.SystemTempSizeBig] = param
|
||||
//}
|
||||
|
||||
// 初始化中字体模板
|
||||
//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 = model.SystemTempSizeMedium
|
||||
// param.IsUse = 2
|
||||
// if err := AddTemp(param); err != nil {
|
||||
// globals.SugarLogger.Debug("init system temp err :", err)
|
||||
// }
|
||||
// SystemTempObj[model.SystemTempSizeMedium] = param
|
||||
//}
|
||||
|
||||
// 初始化小字体模板
|
||||
//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 = model.SystemTempSizeSmall
|
||||
// param.IsUse = 2
|
||||
// if err := AddTemp(param); err != nil {
|
||||
// globals.SugarLogger.Debug("init system temp err :", err)
|
||||
// }
|
||||
// SystemTempObj[model.SystemTempSizeSmall] = param
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
// MakePrintMsgOnTemp 将打印数据渲染到模板当中
|
||||
func MakePrintMsgOnTemp(param map[string]string, userId string) (string, error) {
|
||||
// 查询用户默认模板,不存在则使用系统默认模板
|
||||
userTemp := &model.SystemTemp{}
|
||||
userTemp, isHave, err := SelectUserDefaultTemp(userId, model.TempTypeMerchantUser)
|
||||
if err != nil || !isHave {
|
||||
userTemp, err = QuerySystemTemp()
|
||||
}
|
||||
if userTemp == nil || !isHave || err != nil {
|
||||
if userTemp.TempType != "" {
|
||||
userTemp = SystemTempObj[userTemp.TempSize]
|
||||
} else {
|
||||
userTemp = SystemTempObj[model.SystemTempSizeBig]
|
||||
}
|
||||
}
|
||||
// 需要打印数据
|
||||
printMsg := ""
|
||||
printValue := make([]interface{}, 0, 0)
|
||||
userTempMap := make(map[string]string, 0)
|
||||
if err := json.Unmarshal([]byte(userTemp.Temp), &userTempMap); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, v := range strings.Split(userTemp.TempRank, ",") {
|
||||
switch v {
|
||||
case "skuName", "skuNumber", "skuPrice", "skuAllPrice", "allSkuTypeCount", "allSkuCount", "skuUpc", "userPayMoney":
|
||||
continue
|
||||
case "goodsListDetail":
|
||||
printMsg += userTempMap[v]
|
||||
skuList := make([]*model.SkuListPrintOrder, 0, 0)
|
||||
if err := json.Unmarshal([]byte(param["skuList"]), &skuList); err != nil {
|
||||
return "", err
|
||||
}
|
||||
for i := 0; i < len(skuList); i++ {
|
||||
printMsg += userTempMap["skuName"]
|
||||
printMsg += userTempMap["skuNumber"]
|
||||
printMsg += userTempMap["skuPrice"]
|
||||
printMsg += userTempMap["skuAllPrice"]
|
||||
printValue = append(printValue, skuList[i].SkuName, skuList[i].SkuCount, skuList[i].SalePrice, skuList[i].TotalCountPrice)
|
||||
if skuList[i].Upc != "" {
|
||||
printMsg += userTempMap["skuUpc"]
|
||||
printValue = append(printValue, skuList[i].Upc)
|
||||
}
|
||||
|
||||
}
|
||||
printMsg += userTempMap["allSkuTypeCount"]
|
||||
printValue = append(printValue, param["allSkuTypeCount"])
|
||||
printMsg += userTempMap["allSkuCount"]
|
||||
printValue = append(printValue, param["allSkuCount"])
|
||||
printMsg += userTempMap["userPayMoney"]
|
||||
printValue = append(printValue, param["userPayMoney"])
|
||||
case "businessType":
|
||||
if param[v] == "2" { // 是预订单
|
||||
printMsg += userTempMap[v]
|
||||
printValue = append(printValue, param[v])
|
||||
}
|
||||
case "divider":
|
||||
printMsg += userTempMap[v]
|
||||
case "title":
|
||||
printMsg += userTempMap[v]
|
||||
case "qrcOrder": // 老版打印机展示不要
|
||||
//printMsg += userTempMap[v]
|
||||
//printValue = append(printValue, param[v])
|
||||
printMsg += `<b>%s #%s</b>`
|
||||
printValue = append(printValue, param["vendorName"], param["vendorOrderNo"])
|
||||
default:
|
||||
printMsg += userTempMap[v]
|
||||
printValue = append(printValue, param[v])
|
||||
}
|
||||
|
||||
}
|
||||
return strings.Replace(fmt.Sprintf(strings.Replace(printMsg, "\n", "", -1), printValue...), "\\n", "\r\n", -1), nil
|
||||
//}
|
||||
}
|
||||
|
||||
// MakePrintMsgOnTempVoice 制作平台语音
|
||||
func MakePrintMsgOnTempVoice(param map[string]string, setting *model.PrintSettingObj, userId string) (string, error) {
|
||||
// 打订单
|
||||
if param[model.OrderStatusPrint] != "" {
|
||||
// 订单提示设置
|
||||
printMsg, err := PrinterOrderVoice(param, setting, userId)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("err Unmarshal userTemp.printMsg", err)
|
||||
return "", err
|
||||
}
|
||||
return printMsg, nil
|
||||
}
|
||||
// 打运单
|
||||
if param[model.WayBillStatusPrint] != "" {
|
||||
switch param[model.WayBillStatusPrint] {
|
||||
case utils.Int2Str(model.WaybillStatusCourierAssigned): // 分配骑手
|
||||
return PrintWayBillOrderStatus(param, setting), nil
|
||||
case utils.Int2Str(model.WaybillStatusDeliverReminder): // 催单
|
||||
printVoiceMsg := ``
|
||||
printVoiceValue := make([]interface{}, 0, 0)
|
||||
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.ReminderOrderVoice)
|
||||
return strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1), nil
|
||||
case utils.Int2Str(model.WaybillStatusDelivered): // 送达
|
||||
printVoiceMsg := ``
|
||||
printVoiceValue := make([]interface{}, 0, 0)
|
||||
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.FinialsOrderVoice)
|
||||
return strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1), nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 门店状态
|
||||
if param[model.StoreStatusPrint] != "" {
|
||||
return PrintStoreStatus(param, setting), nil
|
||||
}
|
||||
|
||||
// 进店咨询
|
||||
if param[model.EnterTheStorePrint] != "" && setting.VoiceSetting.ConsultingPrint == model.SettingOpen {
|
||||
return `<sound>19</sound>`, nil
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// PrinterOrderVoice 打印机订单提示设置
|
||||
func PrinterOrderVoice(param map[string]string, setting *model.PrintSettingObj, userId string) (string, error) {
|
||||
var (
|
||||
printVoiceMsg string //语音信息
|
||||
printVoiceValue = make([]interface{}, 0, 0)
|
||||
textMsg string // 文本信息
|
||||
err error
|
||||
)
|
||||
|
||||
// 订单状态
|
||||
switch param[model.OrderStatusPrint] {
|
||||
// 新订单(待接单)
|
||||
case utils.Int2Str(model.OrderStatusNew): // utils.Int2Str(model.OrderStatusFinishedPickup), utils.Int2Str(model.OrderStatusAccepted)
|
||||
//if param[model.OrderStatusPrint] != utils.Int2Str(model.OrderStatusNew) && param[model.VendorIDPrint] == utils.Int64ToStr(model.VendorIDMTWM) {
|
||||
// return "", err
|
||||
//}
|
||||
//if param[model.OrderStatusPrint] == utils.Int2Str(model.OrderStatusFinishedPickup) && param[model.VendorIDPrint] == utils.Int64ToStr(model.VendorIDEBAI) {
|
||||
// return "", err
|
||||
//}
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
// 订单设置
|
||||
if setting.PrintSetting.WaitOrderPrint == model.SettingOpen { // 打印订单
|
||||
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
if setting.VoiceSetting.WaitOrderVoice == model.SettingOpen { // 订单通知
|
||||
printVoiceMsg += `<sound>%d</sound>` // 你来新订单了
|
||||
printVoiceValue = append(printVoiceValue, model.NewOrderVoice)
|
||||
}
|
||||
// 申请取消
|
||||
case utils.Int2Str(model.ApplyOrderCancel):
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
// 订单设置
|
||||
if setting.PrintSetting.ApplyUserCancelOrder == 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[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint], utils.Time2DateStr(time.Now()))
|
||||
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||
}
|
||||
if setting.VoiceSetting.ApplyUserOrderCancelVoice == model.SettingOpen { // 申请取消语音
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.ApplyCancelVoice)
|
||||
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||
}
|
||||
// 申请退货
|
||||
case utils.Int2Str(model.ApplyOrderRefundGoods):
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
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[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)
|
||||
|
||||
if setting.VoiceSetting.ApplyRefundGoodsVoice == model.SettingOpen { // 申请退货语音
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.ApplyReturnGoodsVoice)
|
||||
// printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||
}
|
||||
// 申请退款
|
||||
case utils.Int2Str(model.ApplyOrderRefund):
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
// 订单设置
|
||||
if setting.PrintSetting.ApplyUserRefund == model.SettingOpen { // 取消退款订单
|
||||
textMsg, err = MakePrintMsgOnTemp(param, userId)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
if setting.VoiceSetting.ApplyRefundOrderVoice == model.SettingOpen {
|
||||
//printVoiceMsg, printVoiceValue = SyntheticSpeech(printVoiceMsg, printVoiceValue, param)
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.ApplyRefundVoice)
|
||||
}
|
||||
// 取消打印
|
||||
|
||||
case utils.Int2Str(model.OrderStatusRejection): // 拒收
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
//if setting.VoiceSetting.CustomerRejectionVoice == model.SettingOpen && setting.SystemVoice == model.SettingOpen {
|
||||
// // 暂无语音打印
|
||||
//}
|
||||
// 拒收暂无语音设置,使用文本提示
|
||||
if setting.PrintSetting.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[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(model.OrderStatusCustomerService): // 客服退款
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
if setting.VoiceSetting.CusterRefundVoice == model.SettingOpen {
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.BusinessResponsibilityVoice)
|
||||
}
|
||||
if setting.PrintSetting.CusterRefundPrint == 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>`
|
||||
rejection += `<center><b>退款时间: %s</b></center><br>`
|
||||
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)
|
||||
}
|
||||
case utils.Int2Str(model.OrderStatusCanceled), utils.Int2Str(model.CancelOrderSuccess): // 取消订单成功
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
if setting.VoiceSetting.RefundGoodsVoice == model.SettingOpen {
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.CancelOrderVoice)
|
||||
}
|
||||
}
|
||||
if setting.PrintSetting.CusterRefundPrint == 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>`
|
||||
rejection += `<center><b>取消成功时间: %s</b></center><br>`
|
||||
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)
|
||||
}
|
||||
case utils.Int2Str(model.BusinessCancelOrder): // 商家取消打印
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
if setting.PrintSetting.BusinessOrderCancel == 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>`
|
||||
rejection += `<center><b>取消成功时间: %s</b></center><br>`
|
||||
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)
|
||||
}
|
||||
case utils.Int2Str(model.OrderRefundMoneySuccess): // 订单退款成功打印
|
||||
// 称谓设置/平台语音设置
|
||||
if setting.CallNameSetting == 64 || setting.CallNameSetting == 65 || setting.CallNameSetting == 66 {
|
||||
// 老板
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, setting.CallNameSetting)
|
||||
}
|
||||
if setting.PrintSetting.OrderCancelSuccess == 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>`
|
||||
rejectionValue = append(rejectionValue, param[model.OrderNoPrint], param[model.VendorNamePrint], param[model.VendorOrderNoPrint])
|
||||
textMsg = strings.Replace(fmt.Sprintf(strings.Replace(rejection, "\n", "", -1), rejectionValue...), "\\n", "\r\n", -1)
|
||||
}
|
||||
}
|
||||
|
||||
voice := strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||
return voice + textMsg, nil
|
||||
}
|
||||
|
||||
// PrintWayBillOrderStatus 打印运单类通知消息
|
||||
func PrintWayBillOrderStatus(param map[string]string, setting *model.PrintSettingObj) string {
|
||||
var (
|
||||
printVoiceMsg string //语音信息
|
||||
printVoiceValue = make([]interface{}, 0, 0)
|
||||
textMsg string // 文本信息
|
||||
textMsgValue = make([]interface{}, 0, 0) // 文本信息
|
||||
)
|
||||
|
||||
switch param[model.WayBillStatusPrint] {
|
||||
case utils.Int2Str(model.WaybillStatusAccepted), utils.Int2Str(model.WaybillStatusCourierAssigned): // 分配骑手
|
||||
if setting.PrintSetting.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[model.RiderNamePrint], param[model.RiderPhonePrint], utils.Time2DateStr(time.Now()), param[model.VendorNamePrint], param[model.VendorOrderNoPrint])
|
||||
}
|
||||
}
|
||||
if setting.VoiceSetting.RiderTakeOrderVoice == model.SettingOpen { // 骑手接单语音通知
|
||||
printVoiceMsg += `<sound>%d</sound><sound>%d</sound>` // 骑手已经接单了
|
||||
printVoiceValue = append(printVoiceValue, model.RiderGetOrderVoice)
|
||||
}
|
||||
|
||||
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
||||
voice := strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||
return voice + msg
|
||||
}
|
||||
|
||||
// PrintStoreStatus 打印门店状态
|
||||
func PrintStoreStatus(param map[string]string, setting *model.PrintSettingObj) string {
|
||||
var (
|
||||
printVoiceMsg string //语音信息
|
||||
printVoiceValue = make([]interface{}, 0, 0)
|
||||
textMsg string // 文本信息
|
||||
textMsgValue = make([]interface{}, 0, 0)
|
||||
)
|
||||
|
||||
switch utils.Str2Int(param[model.StoreStatusPrint]) {
|
||||
case -9: // 丢失授权
|
||||
var voice string
|
||||
if setting.VoiceSetting.LoseAuthorization == model.SettingOpen {
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.LoseTokenVoice)
|
||||
voice = strings.Replace(fmt.Sprintf(strings.Replace(printVoiceMsg, "\n", "", -1), printVoiceValue...), "\\n", "\r\n", -1)
|
||||
}
|
||||
|
||||
textMsg += `<left><b>门店丢失授权通知</b></left><br>`
|
||||
textMsg += `<left><b>门店:%s</b></left><br>`
|
||||
textMsg += `<left><b>平台:%s</b></left><br>`
|
||||
textMsg += `<left><b>下线时间:%s</b></left><br>`
|
||||
textMsg += `<left><b>授权丢失,将无法继续打压订单!!!!</b></left><br>`
|
||||
textMsgValue = append(textMsgValue, param[model.StoreNamePrint], param[model.VendorNamePrint], utils.Time2DateStr(time.Now()))
|
||||
msg := strings.Replace(fmt.Sprintf(strings.Replace(textMsg, "\n", "", -1), textMsgValue...), "\\n", "\r\n", -1)
|
||||
return voice + msg
|
||||
default:
|
||||
// 离线打印文本开启
|
||||
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[model.StoreNamePrint], param[model.VendorNamePrint], utils.Time2DateStr(time.Now()))
|
||||
// 离线打印语音开启
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
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)
|
||||
|
||||
return voice + msg
|
||||
}
|
||||
}
|
||||
|
||||
// SyntheticSpeech 合成语音 (美团xxx号订单)
|
||||
func SyntheticSpeech(printVoiceMsg string, printVoiceValue []interface{}, param map[string]string) (string, []interface{}) {
|
||||
printVoiceMsg += `<sound>%d</sound>` // 美团
|
||||
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[model.VendorOrderNoPrint] != "" {
|
||||
switch len(param[model.VendorOrderNoPrint]) {
|
||||
case 1:
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint]])
|
||||
case 2:
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][:1]+"0"])
|
||||
if param[model.VendorOrderNoPrint][1:] != "0" {
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:]])
|
||||
}
|
||||
case 3:
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
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[model.VendorOrderNoPrint][1:2] == "0" && param[model.VendorOrderNoPrint][2:] != "0" {
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]])
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][2:]])
|
||||
} else if param[model.VendorOrderNoPrint][1:2] != "0" && param[model.VendorOrderNoPrint][2:] == "0" {
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
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>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][1:2]+"0"])
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.NumberVoiceMap[param[model.VendorOrderNoPrint][2:]])
|
||||
}
|
||||
}
|
||||
}
|
||||
printVoiceMsg += `<sound>%d</sound>`
|
||||
printVoiceValue = append(printVoiceValue, model.OrderNoVoice)
|
||||
return printVoiceMsg, printVoiceValue
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/client/orm"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
@@ -383,6 +384,14 @@ func (c *ApiController) DoPrint(dataMap map[string]interface{}) (data, errCode s
|
||||
return msgID, errCode, err
|
||||
}
|
||||
|
||||
func RandStringBytes(n int) string {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
//获取某打印消息
|
||||
func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (data map[string]interface{}, errCode string, err error) {
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user