Browse Source

fix:bug

token_replace
黄梓健 4 years ago
parent
commit
3eed0107be
  1. 2
      controllers/client/good.go
  2. 2
      controllers/client/order_entry.go
  3. 18
      controllers/pc/order_draw.go
  4. 18
      models/customer_goods.go
  5. 10
      models/customer_order.go
  6. 13
      models/customer_order_sub.go

2
controllers/client/good.go

@ -109,7 +109,7 @@ func (t *GoodCtl) ListOrder() {
for index, order := range orders { for index, order := range orders {
order.ServicePhone = option.MainServicePhone order.ServicePhone = option.MainServicePhone
for _, sub := range subs { for _, sub := range subs {
if fmt.Sprint(order.Id) == sub["order_id"] {
if order.Id == sub.OrderId {
orders[index].SubOrders = append(orders[index].SubOrders, sub) orders[index].SubOrders = append(orders[index].SubOrders, sub)
} }
} }

2
controllers/client/order_entry.go

@ -521,7 +521,7 @@ func (t *OrderEntryCtl) EntryOrders() {
for i := range list { for i := range list {
s := make([]interface{}, 0) s := make([]interface{}, 0)
for _, sub := range subs { for _, sub := range subs {
if sub["order_id"] == fmt.Sprint(list[i].OrderId) {
if sub.OrderId == list[i].OrderId {
s = append(s, sub) s = append(s, sub)
} }
} }

18
controllers/pc/order_draw.go

@ -492,14 +492,14 @@ type OrdersResult struct {
// 获取所有订单 // 获取所有订单
type SpecialOrdersResult struct { type SpecialOrdersResult struct {
Id int `json:"id"`
UserId int `json:"user_id"`
AreaName string `json:"area_name"`
EntryPersonName string `json:"entry_person_name"`
Username string `json:"username"`
Phone string `json:"phone"`
Address string `json:"address"`
Goods []map[string]string `json:"goods"`
Id int `json:"id"`
UserId int `json:"user_id"`
AreaName string `json:"area_name"`
EntryPersonName string `json:"entry_person_name"`
Username string `json:"username"`
Phone string `json:"phone"`
Address string `json:"address"`
Goods []*models.SubOrderResult `json:"goods"`
} }
func (t *OrderDrawCtl) Orders() { func (t *OrderDrawCtl) Orders() {
@ -534,7 +534,7 @@ func (t *OrderDrawCtl) Orders() {
t.CheckErr(err) t.CheckErr(err)
for i := range orders { for i := range orders {
for j := range subs { for j := range subs {
if fmt.Sprint(orders[i].Id) == subs[j]["order_id"] {
if orders[i].Id == subs[j].OrderId {
orders[i].Goods = append(orders[i].Goods, subs[j]) orders[i].Goods = append(orders[i].Goods, subs[j])
} }
} }

18
models/customer_goods.go

@ -14,15 +14,15 @@ type CustomerGoods struct {
CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"` CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"` UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
AreaId int `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
GoodsPicUrl interface{} `json:"goods_pic_url" xorm:"json comment('商品图片')"`
IsForceAdded int `json:"is_force_added" xorm:"not null default 0 comment('是否强制上架0不强制1强制') TINYINT(1)"`
FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"`
Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"`
Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"`
Price float64 `json:"price" xorm:"not null default 0.00 comment('商品单价') DECIMAL(18,2)"`
Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
AreaId int `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
GoodsPicUrl []interface{} `json:"goods_pic_url" xorm:"json comment('商品图片')"`
IsForceAdded int `json:"is_force_added" xorm:"not null default 0 comment('是否强制上架0不强制1强制') TINYINT(1)"`
FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"`
Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"`
Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"`
Price float64 `json:"price" xorm:"not null default 0.00 comment('商品单价') DECIMAL(18,2)"`
Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
//// 无关变量 //// 无关变量
GoodType int `json:"good_type" xorm:"-"` GoodType int `json:"good_type" xorm:"-"`

10
models/customer_order.go

@ -48,11 +48,11 @@ type CustomerOrder struct {
GoodsNum int `json:"goods_num" xorm:"not null default 0 comment('商品数量') INT(11)"` GoodsNum int `json:"goods_num" xorm:"not null default 0 comment('商品数量') INT(11)"`
// 无关变量 // 无关变量
OrderTime string `json:"order_time,omitempty" xorm:"-"`
Good *CustomerGoods `json:"good,omitempty" xorm:"-"`
User *User `json:"user,omitempty" xorm:"-"`
ServicePhone string `json:"service_phone" xorm:"-"`
SubOrders []map[string]string `json:"sub_orders,omitempty" xorm:"-"`
OrderTime string `json:"order_time,omitempty" xorm:"-"`
Good *CustomerGoods `json:"good,omitempty" xorm:"-"`
User *User `json:"user,omitempty" xorm:"-"`
ServicePhone string `json:"service_phone" xorm:"-"`
SubOrders []*SubOrderResult `json:"sub_orders,omitempty" xorm:"-"`
} }
func (t *CustomerOrder) TableName() string { func (t *CustomerOrder) TableName() string {

13
models/customer_order_sub.go

@ -22,7 +22,7 @@ type CustomerOrderSub struct {
GoodPrice float64 `json:"good_price" xorm:"not null default 0.00 comment('商品价格') DECIMAL(18,2)"` GoodPrice float64 `json:"good_price" xorm:"not null default 0.00 comment('商品价格') DECIMAL(18,2)"`
// 无关变量 // 无关变量
GoodsPicUrl string `json:"goods_pic_url" xorm:"extends"`
GoodsPicUrl interface{} `json:"goods_pic_url" xorm:"extends"`
} }
func (t *CustomerOrderSub) TableName() string { func (t *CustomerOrderSub) TableName() string {
@ -33,7 +33,16 @@ func (t *CustomerOrderSub) Alias(n string) string {
return fmt.Sprintf("%s as %s", t.TableName(), n) return fmt.Sprintf("%s as %s", t.TableName(), n)
} }
func GetCustomerOrderSubsByOrderIds(orderIds interface{}) (subs []map[string]string, err error) {
type SubOrderResult struct {
OrderId int `json:"order_id"`
GoodsId int `json:"goods_id"`
GoodsNum int `json:"goods_num"`
GoodName string `json:"good_name"`
GoodPrice float64 `json:"good_price"`
GoodsPicUrl []interface{} `json:"goods_pic_url"`
}
func GetCustomerOrderSubsByOrderIds(orderIds interface{}) (subs []*SubOrderResult, err error) {
err = core.GetXormAuto().Table(new(CustomerOrderSub)).Alias("s"). err = core.GetXormAuto().Table(new(CustomerOrderSub)).Alias("s").
Select("s.order_id, s.goods_id, s.goods_num, s.good_name, s.good_price, g.goods_pic_url"). Select("s.order_id, s.goods_id, s.goods_num, s.good_name, s.good_price, g.goods_pic_url").
Join("left", new(CustomerGoods).Alias("g"), "g.id=s.goods_id"). Join("left", new(CustomerGoods).Alias("g"), "g.id=s.goods_id").

Loading…
Cancel
Save