1
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
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 `orm:"column(id)" json:"id" db:"id"`
|
||||
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"`
|
||||
@@ -25,10 +31,19 @@ func (v *PrintSetting) TableUnique() [][]string {
|
||||
}
|
||||
}
|
||||
|
||||
func (v *PrintSetting) TableIndex() [][]string {
|
||||
return [][]string{
|
||||
[]string{"CreatedAt"},
|
||||
}
|
||||
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 打印机提示语音设置
|
||||
@@ -79,14 +94,75 @@ type ShopPickingVoice struct {
|
||||
WaitPickingVoice int `json:"wait_picking_voice"` // 待接单语音[1打开]
|
||||
}
|
||||
|
||||
// AddPrintSetting 打印机设置添加
|
||||
type AddPrintSetting struct {
|
||||
PrintNo string `json:"print_no" form:"print_no" binding:"required"`
|
||||
CallNameSetting int `json:"call_name_setting" form:"call_name_setting"`
|
||||
SystemVoice int `json:"system_voice" form:"system_voice"`
|
||||
PrintVoiceSetting *PrintVoice
|
||||
OrderVoiceSetting *OrderVoice
|
||||
RiderVoiceSetting *RiderVoice
|
||||
CustomerVoiceSetting *CustomerReceivingGoods
|
||||
PickingSetting *ShopPickingVoice
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user