From c6088a7dd4a4f2a01a766db2b646b2d6fbfaab2c Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 3 Jul 2018 15:35:02 +0800 Subject: [PATCH] - more fields on elemeorder. --- business/elm/controller/order.go | 9 ++++++++- business/elm/models/order.go | 14 ++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/business/elm/controller/order.go b/business/elm/controller/order.go index 69a6b764c..4e2c2274b 100644 --- a/business/elm/controller/order.go +++ b/business/elm/controller/order.go @@ -1,6 +1,8 @@ package controller import ( + "strings" + "git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/platformapi/elmapi" "git.rosy.net.cn/baseapi/utils" @@ -77,7 +79,12 @@ func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string, user retVal = errResponseCallELMAPIError } else { rec.Data = string(utils.MustMarshal(result)) - num, err := db.Update(rec, "Data") + rec.Consignee = result["consignee"].(string) + rec.Mobile = userMobile + if createdAt, ok := result["createdAt"].(string); ok { + rec.OrderCreatedAt = strings.Replace(createdAt, "T", " ", 1) + } + num, err := db.Update(rec, "Data", "Consignee", "Mobile", "OrderCreatedAt") if err != nil || num != 1 { globals.SugarLogger.Warnf("error in updating order data:%v, error:%v, num:%d", msg, err, num) retVal = errResponseDataError diff --git a/business/elm/models/order.go b/business/elm/models/order.go index bb82b8f47..d06c0e6eb 100644 --- a/business/elm/models/order.go +++ b/business/elm/models/order.go @@ -1,10 +1,16 @@ package models type ELMOrder struct { - Id int - OrderId string `orm:"size(50);unique;null;column(orderid)"` - Data string `orm:"type(text);null"` - Type int `orm:"null"` + Id int + OrderId string `orm:"size(50);unique;null;column(orderid)"` + Consignee string `orm:"size(8)"` + Mobile string `orm:"size(16)"` + Data string `orm:"type(text);null"` + Type int `orm:"null"` + OrderCreatedAt string `orm:"size(50);index"` + // CreatedAt time.Time `orm:"auto_now_add;type(datetime);null"` + // UpdatedAt time.Time `orm:"auto_now;type(datetime);null"` + // StatusTime string `orm:"size(50)"` } func (e *ELMOrder) TableName() string {