- more fields on elemeorder.

This commit is contained in:
gazebo
2018-07-03 15:35:02 +08:00
parent 339da74d44
commit c6088a7dd4
2 changed files with 18 additions and 5 deletions

View File

@@ -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

View File

@@ -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 {