Compare commits

...

18 Commits

Author SHA1 Message Date
RIceWqy cd3708d08f goods
2 years ago
RIceWqy fb3e342da7 goods
2 years ago
RIceWqy 27ce1433ff goods
2 years ago
RIceWqy d5c365d226 goods
2 years ago
RIceWqy 5f6f9175bd goods
2 years ago
RIceWqy 6d4bf6474f goods
2 years ago
RIceWqy c0c9c249b8 goods
2 years ago
RIceWqy e818c6a652 init
2 years ago
RIceWqy c95d5088b4 init
2 years ago
RIceWqy 7cfde1a702 init
2 years ago
RIceWqy 1d6cf839cd init
2 years ago
RIceWqy 895645334a init
2 years ago
RIceWqy 1126f682c1 init
2 years ago
RIceWqy 79dc513129 init
2 years ago
RIceWqy b229f3df56 init
2 years ago
RIceWqy a392c4502a init
2 years ago
RIceWqy d4534efecd init
2 years ago
RIceWqy 31deb7ba5d init
2 years ago

@ -0,0 +1,215 @@
{
"id": 1416,
"type": "normal",
"title": "多规格123123",
"subtitle": "多规格",
"weigh": 0,
"category_ids": "46",
"image": "https://demo.shopro.top/uploads/20230821/00e97b4723771626fb44bdbf56d35a73.jpg",
"images": [
"https://demo.shopro.top/uploads/20230823/170a1630b9b3124e28feacd95646b453.png",
"https://demo.shopro.top/uploads/20230823/16f27aeea875d3ff395786ad48f2e38b.png",
"https://demo.shopro.top/uploads/20230821/00e97b4723771626fb44bdbf56d35a73.jpg"
],
"params": null,
"content": "\u003cp\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230821/00e97b4723771626fb44bdbf56d35a73.jpg\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230821/da48a8a2595d0efd619984ebd7e22bd9.jpg\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230819/8659310afe6e0f2680457c26da4f6d3d.jpg\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230819/655d7da134ea4669625007c65f934931.jpg\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230819/a6a57d00022b06e5b412dcfc6df06f1d.jpg\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230819/8a477ec231722200e268c722f87d95a3.jpg\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230818/18889719294b8c8bef913a3bbcc73e60.png\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230817/5aea7892240b08ee32e3b47c8b210053.png\" style=\"width: 500px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230816/f0238ed4eef0068f18f03699c4b8979c.png\" style=\"width: 612px;\"\u003e\u003cimg src=\"https://demo.shopro.top/uploads/20230815/f68d107a4c703780c900c049a65cd47c.jpeg\" style=\"width: 612px;\"\u003e\u003cbr\u003e\u003c/p\u003e",
"price": "11.00",
"original_price": "22.00",
"is_sku": 1,
"likes": 0,
"views": 623,
"sales": 0,
"show_sales": 0,
"total_sales": 4,
"service_ids": "28",
"dispatch_type": "express",
"dispatch_ids": "23",
"deletetime": null,
"activity": {
"id": 0,
"title": "",
"type": "",
"richtext_id": 0,
"richtext_title": "",
"starttime": 0,
"endtime": 0,
"rules": {
"activity_auto_close": "",
"fictitious_num": "",
"is_alone": "",
"is_fictitious": "",
"limit_buy": "",
"order_auto_close": "",
"team_card": "",
"team_num": "",
"valid_time": ""
},
"status_code": ""
},
"activity_type": "",
"buyers": null,
"sku_price": [
{
"id": 2365,
"goods_sku_ids": [
1676,
1679
],
"goods_id": 1416,
"weigh": 0,
"image": "https://demo.shopro.top/uploads/20230819/8659310afe6e0f2680457c26da4f6d3d.jpg",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "1.00",
"goods_sku_text": "红色,xl",
"status": "up",
"groupon_price": "",
"activity_type": "",
"activity_id": 0,
"item_goods_sku_price": {
"id": 0,
"activity_id": 0,
"sku_price_id": 0,
"goods_id": 0,
"stock": 0,
"sales": 0,
"price": "",
"status": ""
},
"goods_sku_id_arr": [
"1676",
"1679"
]
},
{
"id": 2366,
"goods_sku_ids": [
1677,
1679
],
"goods_id": 1416,
"weigh": 0,
"image": "",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "2.00",
"goods_sku_text": "绿色,xl",
"status": "up",
"groupon_price": "",
"activity_type": "",
"activity_id": 0,
"item_goods_sku_price": {
"id": 0,
"activity_id": 0,
"sku_price_id": 0,
"goods_id": 0,
"stock": 0,
"sales": 0,
"price": "",
"status": ""
},
"goods_sku_id_arr": [
"1677",
"1679"
]
},
{
"id": 2367,
"goods_sku_ids": [
1676,
1680
],
"goods_id": 1416,
"weigh": 0,
"image": "",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "3.00",
"goods_sku_text": "红色,m",
"status": "up",
"groupon_price": "",
"activity_type": "",
"activity_id": 0,
"item_goods_sku_price": {
"id": 0,
"activity_id": 0,
"sku_price_id": 0,
"goods_id": 0,
"stock": 0,
"sales": 0,
"price": "",
"status": ""
},
"goods_sku_id_arr": [
"1676",
"1680"
]
},
{
"id": 2368,
"goods_sku_ids": [
1677,
1680
],
"goods_id": 1416,
"weigh": 0,
"image": "",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "4.00",
"goods_sku_text": "绿色,m",
"status": "up",
"groupon_price": "",
"activity_type": "",
"activity_id": 0,
"item_goods_sku_price": {
"id": 0,
"activity_id": 0,
"sku_price_id": 0,
"goods_id": 0,
"stock": 0,
"sales": 0,
"price": "",
"status": ""
},
"goods_sku_id_arr": [
"1677",
"1680"
]
}
],
"stock": 1,
"activity_discounts": [
"",
""
],
"activity_discounts_types": "",
"activity_discounts_tags": [],
"favorite": null,
"dispatch_type_arr": [
"express"
],
"service": [
{
"id": 28,
"name": "免费包邮",
"image": "https://demo.shopro.top/uploads/20230710/f7f6bf60f2898f583bbe09acd221d9f1.png",
"description": "123"
}
],
"sku": null,
"coupons": null,
"groupon_price": ""
}

@ -0,0 +1,226 @@
{
"id": 1416,
"type": "normal",
"title": "多规格",
"subtitle": "多规格",
"weigh": 0,
"category_ids": "46",
"image": "https://demo.shopro.top/uploads/20230821/00e97b4723771626fb44bdbf56d35a73.jpg",
"images": [
"https://demo.shopro.top/uploads/20230823/170a1630b9b3124e28feacd95646b453.png",
"https://demo.shopro.top/uploads/20230823/16f27aeea875d3ff395786ad48f2e38b.png",
"https://demo.shopro.top/uploads/20230821/00e97b4723771626fb44bdbf56d35a73.jpg"
],
"params": [],
"content": "<p><img src=\"https://demo.shopro.top/uploads/20230821/00e97b4723771626fb44bdbf56d35a73.jpg\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230821/da48a8a2595d0efd619984ebd7e22bd9.jpg\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230819/8659310afe6e0f2680457c26da4f6d3d.jpg\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230819/655d7da134ea4669625007c65f934931.jpg\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230819/a6a57d00022b06e5b412dcfc6df06f1d.jpg\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230819/8a477ec231722200e268c722f87d95a3.jpg\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230818/18889719294b8c8bef913a3bbcc73e60.png\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230817/5aea7892240b08ee32e3b47c8b210053.png\" style=\"width: 500px;\"><img src=\"https://demo.shopro.top/uploads/20230816/f0238ed4eef0068f18f03699c4b8979c.png\" style=\"width: 612px;\"><img src=\"https://demo.shopro.top/uploads/20230815/f68d107a4c703780c900c049a65cd47c.jpeg\" style=\"width: 612px;\"><br></p>",
"price": "11",
"original_price": "22.00",
"is_sku": 1,
"likes": 0,
"views": 631,
"sales": 0,
"show_sales": 0,
"service_ids": "28",
"dispatch_type": "express",
"dispatch_ids": "23",
"deletetime": null,
"activity": null,
"activity_type": null,
"buyers": [],
"sku_price": [
{
"id": 2365,
"goods_sku_ids": "1676,1679",
"goods_id": 1416,
"weigh": 0,
"image": "https://demo.shopro.top/uploads/20230819/8659310afe6e0f2680457c26da4f6d3d.jpg",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "1.00",
"goods_sku_text": "红色,xl",
"status": "up",
"goods_sku_id_arr": [
"1676",
"1679"
]
},
{
"id": 2366,
"goods_sku_ids": "1677,1679",
"goods_id": 1416,
"weigh": 0,
"image": "",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "2.00",
"goods_sku_text": "绿色,xl",
"status": "up",
"goods_sku_id_arr": [
"1677",
"1679"
]
},
{
"id": 2367,
"goods_sku_ids": "1676,1680",
"goods_id": 1416,
"weigh": 0,
"image": "",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "3.00",
"goods_sku_text": "红色,m",
"status": "up",
"goods_sku_id_arr": [
"1676",
"1680"
]
},
{
"id": 2368,
"goods_sku_ids": "1677,1680",
"goods_id": 1416,
"weigh": 0,
"image": "",
"stock": 1,
"stock_warning": null,
"sales": 0,
"sn": "",
"weight": 0,
"price": "4.00",
"goods_sku_text": "绿色,m",
"status": "up",
"goods_sku_id_arr": [
"1677",
"1680"
]
}
],
"stock": 4,
"activity_discounts": [],
"activity_discounts_types": "",
"activity_discounts_tags": [],
"favorite": null,
"dispatch_type_arr": [
"express"
],
"service": [
{
"id": 28,
"name": "免费包邮",
"image": "https://demo.shopro.top/uploads/20230710/f7f6bf60f2898f583bbe09acd221d9f1.png",
"description": "123"
}
],
"sku": [
{
"id": 1675,
"name": "颜色",
"pid": 0,
"goods_id": 1416,
"weigh": 0,
"content": [
{
"id": 1676,
"name": "红色",
"pid": 1675,
"goods_id": 1416,
"weigh": 0
},
{
"id": 1677,
"name": "绿色",
"pid": 1675,
"goods_id": 1416,
"weigh": 0
}
]
},
{
"id": 1678,
"name": "尺码",
"pid": 0,
"goods_id": 1416,
"weigh": 0,
"content": [
{
"id": 1679,
"name": "xl",
"pid": 1678,
"goods_id": 1416,
"weigh": 0
},
{
"id": 1680,
"name": "m",
"pid": 1678,
"goods_id": 1416,
"weigh": 0
}
]
}
],
"coupons": [
{
"id": 35,
"name": "新人优惠券",
"type": "cash",
"goods_ids": "0",
"amount": "10.00",
"enough": "100.00",
"stock": 999760,
"limit": 1,
"gettime": {
"start": 1665849600,
"end": 1732896000
},
"usetime": {
"start": 1732896000,
"end": 1764345600
},
"description": "新人可领asdfasd",
"usetimestart": 1732896000,
"usetimeend": 1764345600,
"gettimestart": 1665849600,
"gettimeend": 1732896000,
"status_code": "can_get",
"status_name": "可以领取",
"user_coupons": []
},
{
"id": 83,
"name": "111",
"type": "cash",
"goods_ids": "0",
"amount": "5.00",
"enough": "10.00",
"stock": 99992,
"limit": 1,
"gettime": {
"start": 1699200000,
"end": 1703520000
},
"usetime": {
"start": 1699200000,
"end": 1703692800
},
"description": "1",
"usetimestart": 1699200000,
"usetimeend": 1703692800,
"gettimestart": 1699200000,
"gettimeend": 1703520000,
"status_code": "can_get",
"status_name": "可以领取",
"user_coupons": []
}
]
}

@ -2,9 +2,9 @@
{ {
"DbType":"mysql", "DbType":"mysql",
"IsMaster":true, "IsMaster":true,
"Dsn":"server=127.0.0.1;user id=root;password=root;database=fushouxian", "Dsn":"root:root@tcp(localhost:3306)/fushouxian?charset=utf8mb4",
"sqlMaxIdleConns":1, "sqlMaxIdleConns":1,
"sqlMaxOpenConns":1, "sqlMaxOpenConns":1,
"sqlLogLevel":2 "sqlLogLevel":1
} }
] ]

@ -1,7 +1,7 @@
{ {
"Priority":100, "Priority":100,
"ModuleName":"digital-employee-server-go", "ModuleName":"fushouxian-server",
"ServerUrls":[ "ServerUrls":[
"ws://172.0.0.19:19000/websocket/jsonrpc" "wss://shop.ruixininfo.com/websocket/jsonrpc"
] ]
} }

@ -1,16 +1,13 @@
package main package main
import ( import (
"fmt"
"log" "log"
"net/http" "net/http"
"os"
_ "src/init" _ "src/init"
"github.com/towgo/towgo/dao/basedboperat" "github.com/towgo/towgo/dao/basedboperat"
"github.com/towgo/towgo/dao/ormDriver/gormDriver" "github.com/towgo/towgo/dao/ormDriver/gormDriver"
"github.com/towgo/towgo/dao/ormDriver/xormDriver" "github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/lib/processmanager"
"github.com/towgo/towgo/lib/system" "github.com/towgo/towgo/lib/system"
"github.com/towgo/towgo/towgo" "github.com/towgo/towgo/towgo"
) )
@ -18,17 +15,18 @@ import (
var appName string = "fushouxian-server" var appName string = "fushouxian-server"
var appVersion string = "1.0.0" var appVersion string = "1.0.0"
var basePath = system.GetPathOfProgram() // var basePath = system.GetPathOfProgram()
var basePath = "E:\\workfile\\FuShouXian-Backend\\apps\\fushouxian-server"
func init() { func init() {
//初始化xorm数据库驱动 //初始化xorm数据库驱动
var dbconfig []xormDriver.DsnConfig var dbconfig []xormDriver.DsnConfig
system.ScanConfigJson(basePath+"/config/dbconfig.json", &dbconfig) system.ScanConfigJson(basePath+"\\config\\dbconfig.json", &dbconfig)
xormDriver.New(dbconfig) xormDriver.New(dbconfig)
//初始化gorm数据库驱动 //初始化gorm数据库驱动
var gormdbconfig []gormDriver.DsnConfig var gormdbconfig []gormDriver.DsnConfig
system.ScanConfigJson(basePath+"/config/dbconfig.json", &gormdbconfig) system.ScanConfigJson(basePath+"\\config\\dbconfig.json", &gormdbconfig)
gormDriver.New(gormdbconfig) gormDriver.New(gormdbconfig)
//设定默认orm引擎 //设定默认orm引擎
@ -39,7 +37,7 @@ func init() {
} }
func main() { func main() {
pm := processmanager.GetManager() /*pm := processmanager.GetManager()
for k, v := range os.Args { for k, v := range os.Args {
switch v { switch v {
case "start": case "start":
@ -83,7 +81,8 @@ func main() {
} }
} }
log.Print("参数传递错误,有效参数如下:\n" + os.Args[0] + " start | stop | reload | stop") log.Print("参数传递错误,有效参数如下:\n" + os.Args[0] + " start | stop | reload | stop")
*/
start()
} }
func start() { func start() {
@ -93,7 +92,7 @@ func start() {
conf := struct { conf := struct {
Serverport string `json:"serverport"` Serverport string `json:"serverport"`
}{} }{}
system.ScanConfigJson(basePath+"/config/config.json", &conf) system.ScanConfigJson(basePath+"\\config\\config.json", &conf)
http.HandleFunc("/jsonrpc", towgo.HttpHandller) http.HandleFunc("/jsonrpc", towgo.HttpHandller)
@ -103,7 +102,7 @@ func start() {
func moduleClientInit() { func moduleClientInit() {
var node towgo.EdgeServerNodeConfig var node towgo.EdgeServerNodeConfig
system.ScanConfigJson(basePath+"config/togocdn.client.config.json", &node) system.ScanConfigJson(basePath+"\\config\\togocdn.client.config.json", &node)
node.Methods = towgo.GetMethods() node.Methods = towgo.GetMethods()
node.ModuleName = appName node.ModuleName = appName
for _, v := range node.ServerUrls { for _, v := range node.ServerUrls {

@ -1,3 +0,0 @@
package init
import _ "src/module/category"

@ -0,0 +1,12 @@
package init
import _ "src/module/category"
import _ "src/module/coupon"
import _ "src/module/goods"
import _ "src/module/service"
import _ "src/module/skuPrice"
import _ "src/module/activity"
import _ "src/module/itemGoodsSkuPrice"
import _ "src/module/good_category_re"
import _ "src/module/sku"
import _ "src/module/address"

@ -0,0 +1,28 @@
package activity
func (Activity) TableName() string {
return "activity"
}
type Activity struct {
ID int `json:"id"` // 活动ID
Title string `json:"title"` // 活动标题
Type string `json:"type"` // 活动类型
RichtextID int `json:"richtext_id"` // 富文本ID
RichtextTitle string `json:"richtext_title"` // 富文本标题
StartTime int64 `json:"starttime"` // 活动开始时间
EndTime int64 `json:"endtime"` // 活动结束时间
Rules Rules `json:"rules" ` // 活动规则
StatusCode string `json:"status_code"` // 活动状态码
}
type Rules struct {
ActivityAutoClose string `json:"activity_auto_close"` // 活动自动关闭
FictitiousNum string `json:"fictitious_num"` // 虚拟号码
IsAlone string `json:"is_alone"` // 是否单独
IsFictitious string `json:"is_fictitious"` // 是否虚拟
LimitBuy string `json:"limit_buy"` // 限购
OrderAutoClose string `json:"order_auto_close"` // 订单自动关闭
TeamCard string `json:"team_card"` // 团购卡
TeamNum string `json:"team_num"` // 团购人数
ValidTime string `json:"valid_time"` // 有效时间
}

@ -0,0 +1,12 @@
package activity
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(Activity))
towgo.NewCRUDJsonrpcAPI("/activity", Activity{}, []Activity{}).RegAPI()
}

@ -0,0 +1,34 @@
package address
func (Address) TableName() string {
return "address"
}
func (Area) TableName() string {
return "area"
}
// Address 表示用户的地址信息
type Address struct {
ID int64 `json:"id"` // 地址的唯一标识符
IsDefault string `json:"is_default"` // 是否为默认地址1表示是0表示否
UserID int64 `json:"user_id"` // 关联用户的ID
Consignee string `json:"consignee"` // 收货人姓名
Phone string `json:"phone"` // 联系电话
ProvinceName string `json:"province_name"` // 省份名称
CityName string `json:"city_name"` // 城市名称
AreaName string `json:"area_name"` // 区域名称
Address string `json:"address"` // 详细地址
ProvinceID int64 `json:"province_id"` // 省份ID
CityID int64 `json:"city_id"` // 城市ID
AreaID int64 `json:"area_id"` // 区域ID
Latitude float64 `json:"latitude"` // 纬度
Longitude float64 `json:"longitude"` // 经度
}
// Area 表示地区信息
type Area struct {
Value int64 `json:"value"` // 地区值
Label string `json:"label"` // 地区标签
PID int64 `json:"pid"` // 上级地区的值
Level int64 `json:"level"` // 地区级别
}

@ -0,0 +1,24 @@
package address
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(Address), new(Area))
towgo.NewCRUDJsonrpcAPI("/address", Address{}, []Address{}).RegAPI()
towgo.NewCRUDJsonrpcAPI("/area", Area{}, []Area{}).RegAPI()
//towgo.SetFunc("/area", AreaInfo)
}
type AreaResult struct {
AreaData [][][]Area `json:"areaData"`
CityData [][]Area `json:"cityData"`
ProvinceData []Area `json:"provinceData"`
}
/*func AreaInfo(rpc towgo.JsonRpcConnection) {
}
*/

@ -10,17 +10,57 @@ func (Category) TableName() string {
type Category struct { type Category struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Type int64 `json:"type"` Image string `json:"image"`
Description string `json:"description"`
Name string `json:"name"` Name string `json:"name"`
ParentId int64 `json:"parent_id"` Type string `json:"type"`
Pid int64 `json:"pid"`
Weigh int64 `json:"weigh"`
Children []Category `json:"children" xorm:"-"` Children []Category `json:"children" xorm:"-"`
} }
func (c *Category) AfterQuery(session basedboperat.DbTransactionSession) { func (c *Category) AfterQuery(session basedboperat.DbTransactionSession) {
var cs []Category
cs = append(cs, Category{
Id: c.Id,
Image: c.Image,
Description: c.Description,
Name: c.Name,
Type: c.Type,
Pid: c.Pid,
Weigh: c.Weigh,
Children: c.Children,
})
children := findChildren(cs, session)
c.Id = children[0].Id
c.Image = children[0].Image
c.Description = children[0].Description
c.Name = children[0].Name
c.Type = children[0].Type
c.Pid = children[0].Pid
c.Weigh = children[0].Weigh
c.Children = children[0].Children
}
// 递归查询子集方法
func findChildren(categories []Category, session basedboperat.DbTransactionSession) []Category {
var result []Category
for _, category := range categories {
var children []Category var children []Category
var list basedboperat.List var list basedboperat.List
list.Limit = -1 list.Limit = -1
session.ListScan(&list, c, &children) list.Where = append(list.Where, basedboperat.Condition{
c.Children = children Field: "pid",
Operator: "=",
Value: category.Id,
})
session.ListScan(&list, &category, &children) // 传递切片的指针
category.Children = findChildren(children, session)
result = append(result, category)
}
return result
} }

@ -8,5 +8,8 @@ import (
func init() { func init() {
xormDriver.Sync2(new(Category)) xormDriver.Sync2(new(Category))
towgo.NewCRUDJsonrpcAPI("/category", Category{}, []Category{}).RegAPI() towgo.NewCRUDJsonrpcAPI("/category", Category{}, []Category{}).RegAPI()
towgo.SetFunc("/category/treeList", TreeList)
}
func TreeList(rpcConn towgo.JsonRpcConnection) {
} }

@ -0,0 +1,31 @@
package comment
import "time"
func (Comment) TableName() string {
return "comment"
}
// Comment 用户评论结构体
type Comment struct {
ID int64 `json:"id"` // 评论ID
GoodsID int64 `json:"goods_id"` // 商品ID
OrderID int64 `json:"order_id"` // 订单ID
OrderItemID int64 `json:"order_item_id"` // 订单项ID
UserID int64 `json:"user_id"` // 用户ID
Level int64 `json:"level"` // 评级
Content string `json:"content"` // 评论内容
Images []string `json:"images"` // 评论图片列表
Status string `json:"status"` // 评论状态
AdminID int64 `json:"admin_id"` // 管理员ID
ReplyContent string `json:"reply_content"` // 回复内容
ReplyTime time.Time `json:"replytime"` // 回复时间
CreateTime int64 `json:"createtime"` // 创建时间
UpdateTime int64 `json:"updatetime"` // 更新时间
DeleteTime int64 `json:"deletetime"` // 删除时间
User struct {
ID int64 `json:"id"` // 用户ID
Nickname string `json:"nickname"` // 用户昵称
Avatar string `json:"avatar"` // 用户头像
} `json:"user" xorm:"-"` // 用户信息
}

@ -0,0 +1,12 @@
package comment
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(Comment))
towgo.NewCRUDJsonrpcAPI("/comment", Comment{}, []Comment{}).RegAPI()
}

@ -0,0 +1,45 @@
package goods
func (Coupon) TableName() string {
return "coupon"
}
// Coupon 结构体表示优惠券信息
type Coupon struct {
ID int64 `json:"id"` // 优惠券ID
Name string `json:"name"` // 优惠券名称
Type string `json:"type"` // 优惠券类型
GoodsIds string `json:"goods_ids"` // 关联商品ID
Amount string `json:"amount"` // 优惠金额
Enough string `json:"enough"` // 满足条件金额
Stock int64 `json:"stock"` // 库存
Limit int64 `json:"limit"` // 领取限制
Usetimestart int64 `json:"usetimestart"` // 可使用时间段开始
Usetimeend int64 `json:"usetimeend"` // 可使用时间段结束
Gettimestart int64 `json:"gettimestart"` // 可领取时间段开始
Gettimeend int64 `json:"gettimeend"` // 可领取时间段结束
Description string `json:"description"` // 优惠券描述
StatusCode string `json:"status_code"` // 优惠券状态代码
StatusName string `json:"status_name"` // 优惠券状态名称
GetTime TimeRange `json:"gettime" xorm:"-"` // 可领取时间段
UseTime TimeRange `json:"usetime" xorm:"-"` // 可使用时间段
UserCoupons []string `json:"user_coupons" xorm:"-"` // 用户优惠券列表
}
type TimeRange struct {
Start int64 `json:"start"` // 开始时间
End int64 `json:"end"` // 结束时间
}
func (coupon *Coupon) AfterQuery() error {
coupon.GetTime = TimeRange{
coupon.Gettimestart,
coupon.Gettimeend,
}
coupon.UseTime = TimeRange{
coupon.Usetimestart,
coupon.Usetimeend,
}
return nil
}

@ -0,0 +1,12 @@
package goods
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(Coupon))
towgo.NewCRUDJsonrpcAPI("/coupon", Coupon{}, []Coupon{}).RegAPI()
}

@ -0,0 +1,12 @@
package good_category_re
func (GoodCategoryRe) TableName() string {
return "good_category_re"
}
// GoodCategoryRe 结构体表示产品信息
type GoodCategoryRe struct {
Id int64 `json:"id"`
GoodsId int64 `json:"goodsId"`
CategoryId int64 `json:"categoryId"`
}

@ -0,0 +1,12 @@
package good_category_re
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(GoodCategoryRe))
towgo.NewCRUDJsonrpcAPI("/goodCategoryRe", GoodCategoryRe{}, []GoodCategoryRe{}).RegAPI()
}

@ -0,0 +1,162 @@
package goods
import (
"github.com/towgo/towgo/dao/basedboperat"
"log"
"src/module/activity"
coupon "src/module/coupon"
"src/module/good_category_re"
service "src/module/service"
"src/module/sku"
skuPrice "src/module/skuPrice"
"strconv"
"strings"
)
func (Goods) TableName() string {
return "goods"
}
// Goods 结构体表示产品信息
type Goods struct {
ID int64 `json:"id"` // 产品ID
Type string `json:"type"` // 产品类型
Title string `json:"title"` // 产品标题
Subtitle string `json:"subtitle"` // 产品副标题
Weigh int64 `json:"weigh"` // 产品权重
CategoryIds string `json:"category_ids" xorm:"-"` // 类别ID
Image string `json:"image"` // 产品图片
Images []string `json:"images"` // 产品图片数组
Params []Param `json:"params"` // 产品参数
Content string `json:"content"` // 产品内容
Price string `json:"price"` // 产品价格
OriginalPrice string `json:"original_price"` // 产品原价
IsSKU int64 `json:"is_sku"` // 是否有SKU
Likes int64 `json:"likes"` // 喜欢数
Views int64 `json:"views"` // 浏览数
Sales int64 `json:"sales"` // 销售数
ShowSales int64 `json:"show_sales"` // 展示销售数
TotalSales int64 `json:"total_sales"` // 总计销售额
ServiceIds string `json:"service_ids"` // 服务ID
DispatchType string `json:"dispatch_type"` // 派送类型
DispatchIds string `json:"dispatch_ids"` // 派送ID
DeleteTime interface{} `json:"deletetime"` // 删除时间
Activity activity.Activity `json:"activity" xorm:"-"` // 活动
ActivityType string `json:"activity_type"` // 活动类型
Buyers []string `json:"buyers" xorm:"-"` // 购买者列表
SKUPrice []skuPrice.SKUPrice `json:"sku_price" xorm:"-"` // SKU价格列表
Stock int64 `json:"stock"` // 库存
ActivityDiscounts []string `json:"activity_discounts"` // 活动折扣列表
ActivityDiscountsTypes string `json:"activity_discounts_types"` // 活动折扣类型
ActivityDiscountsTags []string `json:"activity_discounts_tags"` // 活动折扣标签
Favorite interface{} `json:"favorite"` // 收藏
DispatchTypeArr []string `json:"dispatch_type_arr"` // 派送类型数组
Service []service.Service `json:"service" xorm:"-"` // 服务列表
SKU []sku.SKU `json:"sku" xorm:"-"` // SKU列表
Coupons []coupon.Coupon `json:"coupons" xorm:"-"` // 优惠券列表
GrouponPrice string `json:"groupon_price"` // 团购价
}
type Param struct {
Title string `json:"title"`
Content string `json:"content"`
}
func (good *Goods) AfterQuery(session basedboperat.DbTransactionSession) error {
var skuPrices []skuPrice.SKUPrice
var skuPrice skuPrice.SKUPrice
var list basedboperat.List
list.Limit = -1
list.Where = append(list.Where, basedboperat.Condition{
Field: "goods_id",
Operator: "=",
Value: good.ID,
})
session.ListScan(&list, &skuPrice, &skuPrices) // 传递切片的指针
good.SKUPrice = skuPrices
if len(skuPrices) > 0 {
var a activity.Activity
for _, v := range skuPrices {
if v.ActivityId != 0 {
err := session.Get(&a, nil, "id = ?", v.ActivityId)
if err != nil {
log.Println("@", err)
return err
}
break
}
}
good.Activity = a
}
var serverList []service.Service
sIds := strings.Split(good.ServiceIds, ",")
for _, sId := range sIds {
var s service.Service
err := session.Get(&s, nil, "id = ?", sId)
if err != nil {
return err
}
serverList = append(serverList, s)
}
good.Service = serverList
var gcr good_category_re.GoodCategoryRe
var gcrs []good_category_re.GoodCategoryRe
var list2 basedboperat.List
list2.Limit = -1
list2.Where = append(list.Where, basedboperat.Condition{
Field: "goods_id",
Operator: "=",
Value: good.ID,
})
session.ListScan(&list2, &gcr, &gcrs) // 传递切片的指针
var tempIds []string
for _, v := range gcrs {
tempIds = append(tempIds, strconv.FormatInt(v.CategoryId, 10))
}
result := ""
if len(tempIds) > 1 {
result = strings.Join(tempIds, ",")
} else if len(tempIds) == 1 {
result = tempIds[0]
}
good.CategoryIds = result
var skus []sku.SKU
var skud sku.SKU
var listSku basedboperat.List
listSku.Limit = -1
listSku.Where = append(listSku.Where, basedboperat.Condition{
Field: "goods_id",
Operator: "=",
Value: good.ID,
})
listSku.Where = append(listSku.Where, basedboperat.Condition{
Field: "pid",
Operator: "=",
Value: 0,
})
session.ListScan(&listSku, &skud, &skus)
good.SKU = skus
/* var cs []coupon.Coupon
var c coupon.Coupon
var list2 basedboperat.List
list2.Limit = -1
list2.Where = append(list.Where, basedboperat.Condition{
Field: "goods_ids",
Operator: "like",
Value: "%" + strconv.FormatInt(good.ID, 10) + "%",
})
list2.Or = append(list.Where, basedboperat.Condition{
Field: "goods_ids",
Operator: "like",
Value: "%" + strconv.FormatInt(good.ID, 10) + "%",
})
session.ListScan(&list, &sku, &skus)*/
return nil
}

@ -0,0 +1,108 @@
package goods
import (
"github.com/towgo/towgo/dao/basedboperat"
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
"log"
"src/module/good_category_re"
)
func init() {
xormDriver.Sync2(new(Goods))
towgo.NewCRUDJsonrpcAPI("/goods", Goods{}, []Goods{}).RegAPI()
towgo.SetFunc("/goods/list2", List2)
}
type List2Params struct {
CategoryId interface{} `json:"category_id"`
Keywords string `json:"keywords"`
Page int64 `json:"page"`
}
func List2(rpcConn towgo.JsonRpcConnection) {
var params List2Params
err := rpcConn.ReadParams(&params)
if err != nil {
log.Println(err)
return
}
var good Goods
var goods []Goods
var gcr good_category_re.GoodCategoryRe
var gcrs []good_category_re.GoodCategoryRe
var listGcr basedboperat.List
listGcr.Limit = 10
var listGood basedboperat.List
listGood.Limit = 10
if params.CategoryId != 0 {
listGcr.Where = append(listGcr.Where, basedboperat.Condition{
Field: "category_id",
Operator: "=",
Value: params.CategoryId,
})
}
if params.CategoryId != "0" {
listGcr.Where = append(listGcr.Where, basedboperat.Condition{
Field: "category_id",
Operator: "=",
Value: params.CategoryId,
})
}
if params.Keywords != "" {
listGood.Like = make(map[string][]interface{})
listGood.Like["title"] = []interface{}{"%" + params.Keywords + "%"}
}
basedboperat.ListScan(&listGcr, &gcr, &gcrs)
//basedboperat.ListScan(&listGood, &good, &goods)
sql := "select * from " + good.TableName() + " where title like '%" + params.Keywords + "%'"
err = basedboperat.SqlQueryScan(&goods, sql)
if err != nil {
log.Println(err)
//rpcConn.WriteError(500, err.Error())
//return
}
sql = "select count(id) as `count` from " + good.TableName()
var m []map[string]interface{}
err = basedboperat.SqlQueryScan(&m, sql)
if err != nil {
log.Println(err)
}
count := int64(m[0]["count"].(float64))
mapGcrs := make(map[int64]int64)
for _, v := range gcrs {
mapGcrs[v.GoodsId] = v.CategoryId
}
var resultGoods []Goods
for _, v := range goods {
if mapGcrs[v.ID] != 0 {
resultGoods = append(resultGoods, v)
}
}
type data struct {
ResultGoods []Goods `json:"resultGoods"`
CurrentPage int64 `json:"current_Page"`
LastPage int64 `json:"last_page"`
PerPage int64 `json:"per_page"`
Total int64 `json:"total"`
}
var lastPage int64
if count%10 == 0 {
lastPage = count / 10
} else {
lastPage = count/10 + 1
}
d := data{
ResultGoods: resultGoods,
CurrentPage: params.Page,
LastPage: lastPage,
PerPage: 10,
Total: count,
}
rpcConn.WriteResult(d)
}

@ -0,0 +1,17 @@
package itemGoodsSkuPrice
func (ItemGoodsSkuPrice) TableName() string {
return "item_goods_sku_price"
}
// ItemGoodsSkuPrice 结构体表示商品 SKU 的价格信息中的具体项
type ItemGoodsSkuPrice struct {
ID int64 `json:"id"` // 唯一标识
ActivityID int64 `json:"activity_id"` // 活动的唯一标识
SkuPriceID int64 `json:"sku_price_id"` // SKU 价格的唯一标识
GoodsID int64 `json:"goods_id"` // 商品的唯一标识
Stock int64 `json:"stock"` // 库存
Sales int64 `json:"sales"` // 销量
Price string `json:"price"` // 价格
Status string `json:"status"` // 状态
}

@ -0,0 +1,12 @@
package itemGoodsSkuPrice
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(ItemGoodsSkuPrice))
towgo.NewCRUDJsonrpcAPI("/itemGoodsSkuPrice", ItemGoodsSkuPrice{}, []ItemGoodsSkuPrice{}).RegAPI()
}

@ -0,0 +1,104 @@
package order
func (Order) TableName() string {
return "order"
}
// Order 表示订单信息
type Order struct {
ID int64 `json:"id"` // 订单ID
Type string `json:"type"` // 订单类型
OrderSN string `json:"order_sn"` // 订单编号
UserID int64 `json:"user_id"` // 用户ID
ActivityType string `json:"activity_type"` // 活动类型
GoodsAmount string `json:"goods_amount"` // 商品金额
DispatchAmount string `json:"dispatch_amount"` // 配送费用
Phone string `json:"phone"` // 联系电话
Consignee string `json:"consignee"` // 收货人
ProvinceName string `json:"province_name"` // 省份名称
CityName string `json:"city_name"` // 城市名称
AreaName string `json:"area_name"` // 区域名称
Address string `json:"address"` // 收货地址
ProvinceID int64 `json:"province_id"` // 省份ID
CityID int64 `json:"city_id"` // 城市ID
AreaID int64 `json:"area_id"` // 区域ID
Status int64 `json:"status"` // 订单状态
InvoiceStatus string `json:"invoice_status"` // 发票状态
Memo string `json:"memo"` // 备注
Remark string `json:"remark"` // 备注
TotalAmount string `json:"total_amount"` // 订单总金额
ScoreAmount int64 `json:"score_amount"` // 积分金额
TotalFee string `json:"total_fee"` // 总费用
LastTotalFee string `json:"last_total_fee"` // 最终总费用
DiscountFee string `json:"discount_fee"` // 折扣金额
CouponFee string `json:"coupon_fee"` // 优惠券金额
ActivityDiscountMoney string `json:"activity_discount_money"` // 活动折扣金额
DispatchDiscountMoney string `json:"dispatch_discount_money"` // 配送折扣金额
PayFee string `json:"pay_fee"` // 支付费用
ScoreFee int64 `json:"score_fee"` // 积分费用
GoodsOriginalAmount string `json:"goods_original_amount"` // 商品原始金额
CouponsID int64 `json:"coupons_id"` // 优惠券ID
TransactionID string `json:"transaction_id"` // 交易ID
PaymentJSON string `json:"payment_json"` // 支付信息JSON
PayType string `json:"pay_type"` // 支付类型
Paytime int64 `json:"paytime"` // 支付时间
Ext string `json:"ext"` // 扩展信息
Platform string `json:"platform"` // 平台
Createtime int64 `json:"createtime"` // 创建时间
Item []OrderItem `json:"item"` // 订单项列表
StatusCode string `json:"status_code"` // 状态编码
StatusName string `json:"status_name"` // 状态名称
StatusDesc string `json:"status_desc"` // 状态描述
Btns []string `json:"btns"` // 按钮列表
ExtArr []ExtArr `json:"ext_arr"` // 扩展信息数组
}
type ExtArr struct {
BuyType string `json:"buy_type"`
GrouponId int64 `json:"groupon_id"`
ExpiredTime int64 `json:"expired_time"`
}
// OrderItem 表示订单项信息
type OrderItem struct {
ID int64 `json:"id"` // 订单项ID
UserID int64 `json:"user_id"` // 用户ID
OrderID int64 `json:"order_id"` // 订单ID
GoodsID int64 `json:"goods_id"` // 商品ID
GoodsType string `json:"goods_type"` // 商品类型
GoodsSkuPriceID int64 `json:"goods_sku_price_id"` // 商品SKU价格ID
ActivityID int64 `json:"activity_id"` // 活动ID
ActivityType string `json:"activity_type"` // 活动类型
ItemGoodsSkuPriceID int64 `json:"item_goods_sku_price_id"` // 订单项商品SKU价格ID
GoodsSkuText string `json:"goods_sku_text"` // 商品SKU文本
GoodsTitle string `json:"goods_title"` // 商品标题
GoodsImage string `json:"goods_image"` // 商品图片
GoodsOriginalPrice string `json:"goods_original_price"` // 商品原始价格
DiscountFee string `json:"discount_fee"` // 折扣金额
GoodsPrice string `json:"goods_price"` // 商品价格
GoodsNum int64 `json:"goods_num"` // 商品数量
GoodsWeight int64 `json:"goods_weight"` // 商品重量
PayPrice string `json:"pay_price"` // 支付价格
DispatchStatus int64 `json:"dispatch_status"` // 配送状态
DispatchFee string `json:"dispatch_fee"` // 配送费用
DispatchType string `json:"dispatch_type"` // 配送类型
DispatchID int64 `json:"dispatch_id"` // 配送ID
StoreID int64 `json:"store_id"` // 店铺ID
AftersaleStatus int64 `json:"aftersale_status"` // 售后状态
CommentStatus int64 `json:"comment_status"` // 评论状态
RefundStatus int64 `json:"refund_status"` // 退款状态
RefundFee string `json:"refund_fee"` // 退款费用
RefundMsg string `json:"refund_msg"` // 退款消息
ExpressName string `json:"express_name"` // 快递公司名称
ExpressCode string `json:"express_code"` // 快递公司代码
ExpressNo string `json:"express_no"` // 快递单号
Ext string `json:"ext"` // 扩展信息
Createtime int64 `json:"createtime"` // 创建时间
Updatetime int64 `json:"updatetime"` // 更新时间
StatusCode string `json:"status_code"` // 状态编码
StatusName string `json:"status_name"` // 状态名称
StatusDesc string `json:"status_desc"` // 状态描述
Btns []string `json:"btns"` // 按钮列表
ExtArr []ExtArr `json:"ext_arr"` // 扩展信息数组
StatusText string `json:"status_text"` // 状态文本
}

@ -0,0 +1,13 @@
package goods
func (Service) TableName() string {
return "service"
}
// Service 结构体表示服务信息
type Service struct {
ID int64 `json:"id"` // 服务ID
Name string `json:"name"` // 服务名称
Image string `json:"image"` // 服务图片
Description string `json:"description"` // 服务描述
}

@ -0,0 +1,12 @@
package goods
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(Service))
towgo.NewCRUDJsonrpcAPI("/service", Service{}, []Service{}).RegAPI()
}

@ -0,0 +1,35 @@
package sku
import "github.com/towgo/towgo/dao/basedboperat"
func (SKU) TableName() string {
return "sku"
}
// SKU 表示SKU属性
type SKU struct {
ID int64 `json:"id"` // SKU的唯一标识符
Name string `json:"name"` // SKU的名称
PID int64 `json:"pid"` // 父ID表示SKU属性
GoodsID int64 `json:"goods_id"` // 关联商品的ID
Weigh int64 `json:"weigh"` // SKU的权重
Content []SKU `json:"content" xorm:"-"` // SKU内容列表
}
func (sku *SKU) AfterQuery(session basedboperat.DbTransactionSession) error {
var qSku SKU
var qSkus []SKU
var listSkus basedboperat.List
listSkus.Limit = -1
listSkus.Where = append(listSkus.Where, basedboperat.Condition{
Field: "pid",
Operator: "=",
Value: sku.ID,
})
session.ListScan(&listSkus, &qSku, &qSkus)
sku.Content = qSkus
return nil
}

@ -0,0 +1,12 @@
package sku
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(SKU))
towgo.NewCRUDJsonrpcAPI("/sku", SKU{}, []SKU{}).RegAPI()
}

@ -0,0 +1,48 @@
package goods
import (
"github.com/towgo/towgo/dao/basedboperat"
"src/module/itemGoodsSkuPrice"
"strconv"
)
func (SKUPrice) TableName() string {
return "sku_price"
}
// SKUPrice 结构体表示商品 SKU 的价格信息
type SKUPrice struct {
ID int64 `json:"id"` // SKU 价格的唯一标识
GoodsSkuIds []int64 `json:"goods_sku_ids"` // 商品 SKU 的标识数组
GoodsId int64 `json:"goods_id"` // 商品的唯一标识
Weigh int64 `json:"weigh"` // 权重
Image string `json:"image"` // 图片链接
Stock int64 `json:"stock"` // 库存
StockWarning interface{} `json:"stock_warning"` // 库存预警信息,根据实际情况调整数据类型
Sales int64 `json:"sales"` // 销量
SN string `json:"sn"` // 商品编号
Weight int64 `json:"weight"` // 重量
Price string `json:"price"` // 价格
GoodsSkuText string `json:"goods_sku_text"` // 商品 SKU 文本描述
Status string `json:"status"` // 状态
GrouponPrice string `json:"groupon_price"` // 团购价格
ActivityType string `json:"activity_type"` // 活动类型
ActivityId int64 `json:"activity_id"` // 活动的唯一标识
ItemGoodsSkuPrice itemGoodsSkuPrice.ItemGoodsSkuPrice `json:"item_goods_sku_price" xorm:"-"` // 商品 SKU 价格信息
GoodsSkuIdArr []string `json:"goods_sku_id_arr" xorm:"-"` // 商品 SKU 标识数组
}
func (sku *SKUPrice) AfterQuery(session basedboperat.DbTransactionSession) error {
var item itemGoodsSkuPrice.ItemGoodsSkuPrice
err := session.Get(&item, nil, "sku_price_id = ?", sku.ID)
if err != nil {
return err
}
sku.ItemGoodsSkuPrice = item
for _, id := range sku.GoodsSkuIds {
sku.GoodsSkuIdArr = append(sku.GoodsSkuIdArr, strconv.FormatInt(id, 10))
}
return nil
}

@ -0,0 +1,12 @@
package goods
import (
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
"github.com/towgo/towgo/towgo"
)
func init() {
xormDriver.Sync2(new(SKUPrice))
towgo.NewCRUDJsonrpcAPI("/skuprice", SKUPrice{}, []SKUPrice{}).RegAPI()
}
Loading…
Cancel
Save