- record order ok.
This commit is contained in:
@@ -2,8 +2,10 @@ package elm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/elmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -15,10 +17,6 @@ type OrderController struct {
|
||||
controller.OrderController
|
||||
}
|
||||
|
||||
var (
|
||||
api *elmapi.API
|
||||
)
|
||||
|
||||
func (c *OrderController) OnOrderStatusMsg(msg *elmapi.CallbackOrderStatusMsg) (retVal *elmapi.CallbackResponse) {
|
||||
controller.RoutinePool.CallFun(func() {
|
||||
retVal = c.onOrderStatusMsg(msg)
|
||||
@@ -94,37 +92,41 @@ func (c *OrderController) onOrderCancelRefundMsg(msg *elmapi.CallbackOrderCancel
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (c *OrderController) getOrderInfo(msg *elmapi.CallbackOrderStatusMsg) (order *model.Order, orderSkus []*model.OrderSku, err error) {
|
||||
result, err := api.GetOrder(msg.OrderID)
|
||||
func (c *OrderController) getOrderInfo(msg *elmapi.CallbackOrderStatusMsg) (order *model.GoodsOrder, orderSkus []*model.OrderSku, err error) {
|
||||
result, err := api.ElmAPI.GetOrder(msg.OrderID)
|
||||
if err == nil {
|
||||
phoneList := result["phoneList"].([]interface{})
|
||||
consigneeMobile := ""
|
||||
if len(phoneList) > 0 {
|
||||
consigneeMobile = phoneList[0].(string)
|
||||
}
|
||||
order = &model.Order{
|
||||
// globals.SugarLogger.Debug(result)
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: msg.OrderID,
|
||||
VendorID: controller.VendorIDELM,
|
||||
VendorStoreID: result["shopId"].(string),
|
||||
StoreID: int(utils.Str2Int64(result["openId"].(string))),
|
||||
VendorStoreID: utils.Int64ToStr(utils.MustInterface2Int64(result["shopId"])),
|
||||
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(result["openId"]), 0)),
|
||||
StoreName: result["shopName"].(string),
|
||||
ConsigneeName: result["consignee"].(string),
|
||||
ConsigneeMobile: consigneeMobile,
|
||||
VendorStatus: msg.State,
|
||||
OrderCreatedAt: utils.Str2Time(result["createdAt"].(string)),
|
||||
OriginalData: string(utils.MustMarshal(result)),
|
||||
}
|
||||
|
||||
orderSkus = []*model.OrderSku{}
|
||||
for _, group := range result["groups"].([]map[string]interface{}) {
|
||||
for _, product := range group["items"].([]map[string]interface{}) {
|
||||
for _, group2 := range result["groups"].([]interface{}) {
|
||||
group := group2.(map[string]interface{})
|
||||
for _, product2 := range group["items"].([]interface{}) {
|
||||
product := product2.(map[string]interface{})
|
||||
sku := &model.OrderSku{
|
||||
VendorOrderID: msg.OrderID,
|
||||
VendorID: controller.VendorIDJD,
|
||||
Count: int(utils.MustInterface2Int64(product["quantity"])),
|
||||
SkuID: int(utils.Str2Int64(product["extendCode"].(string))),
|
||||
VendorSkuID: product["skuId"].(string),
|
||||
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(product["extendCode"]), 0)),
|
||||
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(product["skuId"])),
|
||||
SkuName: product["name"].(string),
|
||||
SalePrice: utils.MustInterface2Int64(product["userPrice"]),
|
||||
SalePrice: int64(math.Round(utils.MustInterface2Float64(product["userPrice"]) * 100)),
|
||||
OrderCreatedAt: order.OrderCreatedAt,
|
||||
}
|
||||
orderSkus = append(orderSkus, sku)
|
||||
@@ -202,10 +204,10 @@ func (c *OrderController) onOrderOtherCancelRefundStatus(msg *elmapi.CallbackOrd
|
||||
}
|
||||
|
||||
// PurchasePlatformHandler
|
||||
func (c *OrderController) AcceptOrRefuseOrder(order *model.Order, isAcceptIt bool) {
|
||||
func (c *OrderController) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool) {
|
||||
if isAcceptIt {
|
||||
api.ConfirmOrder(order.VendorOrderID)
|
||||
api.ElmAPI.ConfirmOrder(order.VendorOrderID)
|
||||
} else {
|
||||
api.CancelOrder(order.VendorOrderID, elmapi.CancelOrderTypeOthers, "")
|
||||
api.ElmAPI.CancelOrder(order.VendorOrderID, elmapi.CancelOrderTypeOthers, "")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user