169 lines
7.4 KiB
Go
169 lines
7.4 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
"time"
|
|
)
|
|
|
|
// PrintSetting 打印机设置
|
|
type PrintSetting struct {
|
|
ID int `json:"id" db:"id"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
DeletedAt time.Time `json:"deleted_at" db:"deleted_at"`
|
|
PrintNo string `orm:"type(varchar);size(32)" json:"print_no" db:"print_no"` // 打印机编号
|
|
CallNameSetting int `orm:"type(int);size(4);default(64)" json:"call_name_setting" db:"call_name_setting"` // 称谓设置 [64-默认老板]
|
|
SystemVoice int `orm:"type(tinyint);size(2);default(1)" json:"system_voice" db:"system_voice"` // 平台语音开关[1打开]
|
|
|
|
PrintVoiceSetting string `orm:"type(varchar);size(255)" json:"print_voice_setting" db:"print_voice_setting"` // 打印机提示语音设置
|
|
OrderVoiceSetting string `orm:"type(varchar);size(255)" json:"order_voice_setting" db:"order_voice_setting"` // 订单提示设置
|
|
RiderVoiceSetting string `orm:"type(varchar);size(255)" json:"rider_voice_setting" db:"rider_voice_setting"` // 骑手动态提示设置
|
|
CustomerVoiceSetting string `orm:"type(varchar);size(255)" json:"customer_voice_setting" db:"customer_voice_setting"` // 客户收货提示设置
|
|
PickingSetting string `orm:"type(varchar);size(255)" json:"picking_setting" db:"picking_setting"` // 拣货语音设置
|
|
}
|
|
|
|
func (v *PrintSetting) TableUnique() [][]string {
|
|
return [][]string{
|
|
[]string{"PrintNo"},
|
|
}
|
|
}
|
|
|
|
type PrintSettingObj struct {
|
|
ID int
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
DeletedAt time.Time
|
|
PrintNo string // 打印机编号
|
|
CallNameSetting int // 称谓设置 [64-默认老板]
|
|
SystemVoice int // 平台语音开关[1打开]
|
|
PrintVoiceSetting *PrintVoice // 打印机提示语音设置
|
|
OrderVoiceSetting *OrderVoice // 订单提示设置
|
|
RiderVoiceSetting *RiderVoice // 骑手动态提示设置
|
|
CustomerVoiceSetting *CustomerReceivingGoods // 客户收货提示设置
|
|
PickingSetting *ShopPickingVoice // 拣货语音设置
|
|
}
|
|
|
|
// PrintVoice 打印机提示语音设置
|
|
type PrintVoice struct {
|
|
TimeVoice int `json:"time_voice"` // 平台语音开关[1打开]
|
|
PaperShortageVoice int `json:"paper_shortage_voice"` // 缺纸语音开关[1打开]
|
|
DisconnectVoice int `json:"disconnect_voice"` // 打印机断开连接提示[1打开]
|
|
LoseAuthorization int `json:"lose_authorization"` // 失去授权语音提示[1打开]
|
|
}
|
|
|
|
// OrderVoice 订单提示设置
|
|
type OrderVoice struct {
|
|
PrintOrder int `json:"print_order"` // 打印订单[1打开]必须
|
|
OrderNotice int `json:"order_notice"` // 订单通知[1打开]必须
|
|
UserOrderCancel int `json:"user_order_cancel"` // 用户取消订单打印[1打开]
|
|
UserOrderCancelVoice int `json:"user_order_cancel_voice"` // 用户取消订单订单语音提示[1打开]
|
|
RefundOrder int `json:"refund_order"` // 退款打印[1打开]
|
|
RefundOrderVoice int `json:"refund_order_voice"` // 退款提示语音[1打开]
|
|
BusinessOrderCancel int `json:"business_order_cancel"` // 商家取消打印[1打开]
|
|
BusinessOrderCancelVoice int `json:"business_order_cancel_voice"` // 商家取消订单语音提示[1打开]
|
|
}
|
|
|
|
// RiderVoice 骑手动态语音提示
|
|
type RiderVoice struct {
|
|
RiderTakeOrder int `json:"rider_take_order"` // 骑手接单打印[1打开]
|
|
RiderTakeOrderVoice int `json:"rider_take_order_voice"` // 骑手接单语音[1打开]
|
|
RiderServiceVoice int `json:"rider_service_voice"` // 骑手送达语音[1打开]
|
|
RiderReminderVoice int `json:"rider_reminder_voice"` // 骑手催单语音[1打开]
|
|
}
|
|
|
|
// CustomerReceivingGoods 客户收货语音提示
|
|
type CustomerReceivingGoods struct {
|
|
CustomerRejectionPrint int `json:"customer_rejection_print"` // 客户拒收打印[1打开]
|
|
CustomerRejectionVoice int `json:"customer_rejection_voice"` // 客户拒收语音[1打开]
|
|
CustcareRefundPrint int `json:"custcare_refund_print"` // 客服退款打印[1打开]
|
|
CustcareRefundVoice int `json:"custcare_refund_voice"` // 客服退款语音[1打开]
|
|
ConsultingPrint int `json:"consulting_print"` // 进店咨询打印[1打开]
|
|
ConsultingVoice int `json:"consulting_voice"` // 进店咨询语音[1打开]
|
|
}
|
|
|
|
// ShopPickingVoice 店铺拣货语音提示
|
|
type ShopPickingVoice struct {
|
|
BusinessOffLine int `json:"business_off_line"` // 店铺离线打印[1打开]
|
|
BusinessOffLineVoice int `json:"business_off_line_voice"` // 店铺离线语音[1打开]
|
|
WaitOrderPrint int `json:"wait_order_print"` // 待接单打印[1打开]
|
|
WaitOrderVoice int `json:"wait_order_voice"` // 待接单语音[1打开]
|
|
WaitPickingPrint int `json:"wait_picking_print"` // 待接单打印[1打开]
|
|
WaitPickingVoice int `json:"wait_picking_voice"` // 待接单语音[1打开]
|
|
}
|
|
|
|
func GetPrintSetting(printNo string) (*PrintSettingObj, error) {
|
|
sql := ` SELECT * FROM print_setting WHERE print_no = ? and deleted_at = ? `
|
|
sqlParams := []interface{}{
|
|
printNo,
|
|
utils.DefaultTimeValue,
|
|
}
|
|
|
|
var printSetting *PrintSetting
|
|
if err := dao.GetRows(dao.GetDB(), &printSetting, sql, sqlParams...); err != nil {
|
|
return nil, err
|
|
}
|
|
if printSetting == nil {
|
|
return nil, errors.New("数据查询异常")
|
|
}
|
|
|
|
return UnMarshalString2Json(printSetting)
|
|
}
|
|
|
|
// 将打印机设置转换一下
|
|
|
|
// UnMarshalString2Json 将字符串设置转换为对象设置
|
|
func UnMarshalString2Json(param *PrintSetting) (*PrintSettingObj, error) {
|
|
var (
|
|
printVoiceSetting = &PrintVoice{}
|
|
orderVoiceSetting = &OrderVoice{}
|
|
riderVoiceSetting = &RiderVoice{}
|
|
customerVoiceSetting = &CustomerReceivingGoods{}
|
|
pickingSetting = &ShopPickingVoice{}
|
|
)
|
|
|
|
result := &PrintSettingObj{
|
|
ID: param.ID,
|
|
CreatedAt: param.CreatedAt,
|
|
UpdatedAt: param.UpdatedAt,
|
|
DeletedAt: param.DeletedAt,
|
|
PrintNo: param.PrintNo,
|
|
CallNameSetting: param.CallNameSetting,
|
|
SystemVoice: param.SystemVoice,
|
|
PrintVoiceSetting: nil,
|
|
OrderVoiceSetting: nil,
|
|
RiderVoiceSetting: nil,
|
|
CustomerVoiceSetting: nil,
|
|
PickingSetting: nil,
|
|
}
|
|
|
|
if err := json.Unmarshal([]byte(param.PrintVoiceSetting), printVoiceSetting); err != nil {
|
|
return nil, err
|
|
}
|
|
result.PrintVoiceSetting = printVoiceSetting
|
|
|
|
if err := json.Unmarshal([]byte(param.OrderVoiceSetting), orderVoiceSetting); err != nil {
|
|
return nil, err
|
|
}
|
|
result.OrderVoiceSetting = orderVoiceSetting
|
|
|
|
if err := json.Unmarshal([]byte(param.RiderVoiceSetting), riderVoiceSetting); err != nil {
|
|
return nil, err
|
|
}
|
|
result.RiderVoiceSetting = riderVoiceSetting
|
|
|
|
if err := json.Unmarshal([]byte(param.CustomerVoiceSetting), customerVoiceSetting); err != nil {
|
|
return nil, err
|
|
}
|
|
result.CustomerVoiceSetting = customerVoiceSetting
|
|
|
|
if err := json.Unmarshal([]byte(param.PickingSetting), pickingSetting); err != nil {
|
|
return nil, err
|
|
}
|
|
result.PickingSetting = pickingSetting
|
|
|
|
return result, nil
|
|
}
|