feat: sale manager
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
SaleTypeStaff uint8 = 1 // 销售人员
|
||||
SaleTypeAgentCorp uint8 = 2 // 销售商(法人)
|
||||
SaleTypeAgentPerson uint8 = 3 // 销售商(个人)
|
||||
|
||||
SaleStatusPending uint8 = 9 // 待处理
|
||||
SaleStatusApproved uint8 = 1 // 已通过
|
||||
SaleStatusRejected uint8 = 2 // 未通过
|
||||
SaleStatusDisabled uint8 = 3 // 禁用
|
||||
)
|
||||
|
||||
type RegionNames struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
District string `json:"district"`
|
||||
}
|
||||
|
||||
func (r RegionNames) Value() (driver.Value, error) {
|
||||
buf, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return string(buf), nil
|
||||
}
|
||||
|
||||
func (r *RegionNames) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
*r = RegionNames{}
|
||||
return nil
|
||||
}
|
||||
var raw []byte
|
||||
switch v := value.(type) {
|
||||
case []byte:
|
||||
raw = v
|
||||
case string:
|
||||
raw = []byte(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported region type: %T", value)
|
||||
}
|
||||
if len(raw) == 0 {
|
||||
*r = RegionNames{}
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(raw, r)
|
||||
}
|
||||
|
||||
type SaleCreate struct {
|
||||
Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
SaleId int64 `gorm:"column:sale_id" json:"sale_id"`
|
||||
Mobile string `gorm:"column:mobile" json:"mobile"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
IdCardFront string `gorm:"column:id_card_front" json:"id_card_front"`
|
||||
IdCardBack string `gorm:"column:id_card_back" json:"id_card_back"`
|
||||
BusinessLicense string `gorm:"column:business_license" json:"business_license"`
|
||||
Region RegionNames `gorm:"column:region;type:json" json:"region"`
|
||||
ProvinceId int64 `gorm:"column:province_id" json:"province_id"`
|
||||
CityId int64 `gorm:"column:city_id" json:"city_id"`
|
||||
DistrictId int64 `gorm:"column:district_id" json:"district_id"`
|
||||
TerritoryId int64 `gorm:"column:territory_id" json:"territory_id"`
|
||||
TerritoryName string `gorm:"column:territory_name" json:"territory_name"`
|
||||
GroupId int64 `gorm:"column:group_id" json:"group_id"`
|
||||
Address string `gorm:"column:address" json:"address"`
|
||||
Status uint8 `gorm:"column:status" json:"status"`
|
||||
Avatar string `gorm:"column:avatar" json:"avatar"`
|
||||
Account string `gorm:"column:account" json:"account"`
|
||||
Type uint8 `gorm:"column:type" json:"type"`
|
||||
Sex uint8 `gorm:"column:sex" json:"sex"`
|
||||
BirthDate string `gorm:"column:birth_date" json:"birth_date"`
|
||||
AdminId int64 `gorm:"column:admin_id" json:"admin_id"`
|
||||
AdminName string `gorm:"column:admin_name" json:"admin_name"`
|
||||
}
|
||||
|
||||
type SaleInfo struct {
|
||||
Id int64 `gorm:"column:id" json:"id"`
|
||||
SaleId int64 `gorm:"column:sale_id" json:"sale_id"`
|
||||
Mobile string `gorm:"column:mobile" json:"mobile"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
IdCardFront string `gorm:"column:id_card_front" json:"id_card_front"`
|
||||
IdCardBack string `gorm:"column:id_card_back" json:"id_card_back"`
|
||||
BusinessLicense string `gorm:"column:business_license" json:"business_license"`
|
||||
Region RegionNames `gorm:"column:region;type:json" json:"region"`
|
||||
ProvinceId int64 `gorm:"column:province_id" json:"province_id"`
|
||||
CityId int64 `gorm:"column:city_id" json:"city_id"`
|
||||
DistrictId int64 `gorm:"column:district_id" json:"district_id"`
|
||||
TerritoryId int64 `gorm:"column:territory_id" json:"territory_id"`
|
||||
TerritoryName string `gorm:"column:territory_name" json:"territory_name"`
|
||||
GroupId int64 `gorm:"column:group_id" json:"group_id"`
|
||||
Address string `gorm:"column:address" json:"address"`
|
||||
Status uint8 `gorm:"column:status" json:"status"`
|
||||
Avatar string `gorm:"column:avatar" json:"avatar"`
|
||||
Account string `gorm:"column:account" json:"account"`
|
||||
Type uint8 `gorm:"column:type" json:"type"`
|
||||
Sex uint8 `gorm:"column:sex" json:"sex"`
|
||||
BirthDate string `gorm:"column:birth_date" json:"birth_date"`
|
||||
Reason string `gorm:"column:reason" json:"reason"`
|
||||
AdminId int64 `gorm:"column:admin_id" json:"admin_id"`
|
||||
AdminName string `gorm:"column:admin_name" json:"admin_name"`
|
||||
CreateTime utils.CustomTime `gorm:"column:create_time" json:"create_time"`
|
||||
UpdateTime utils.CustomTime `gorm:"column:update_time" json:"update_time"`
|
||||
OriginMobile string `gorm:"-" json:"origin_mobile"`
|
||||
}
|
||||
|
||||
type SaleStatusUpdate struct {
|
||||
Id int64 `gorm:"column:id;primaryKey" json:"id"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
Status uint8 `gorm:"column:status" json:"status"`
|
||||
Reason string `gorm:"column:reason" json:"reason"`
|
||||
AdminId int64 `gorm:"column:admin_id" json:"admin_id"`
|
||||
AdminName string `gorm:"column:admin_name" json:"admin_name"`
|
||||
}
|
||||
|
||||
type SaleNameItem struct {
|
||||
Id int64 `gorm:"column:id" json:"id"`
|
||||
Mobile string `gorm:"column:mobile" json:"mobile"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
}
|
||||
|
||||
type SaleTypeOption struct {
|
||||
Value uint8 `json:"value"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
Reference in New Issue
Block a user