- fixed a bug in defsch.init, replace LoadOrder with GetOrder.

- dynamic table name for legacy order related table.
This commit is contained in:
gazebo
2018-07-23 17:30:22 +08:00
parent 96d8e7b2fa
commit 479ce46200
18 changed files with 253 additions and 80 deletions

View File

@@ -132,30 +132,32 @@ func (c *OrderController) legacyWriteJxOrder(order *model.GoodsOrder, db orm.Orm
db.Begin()
if isDelFirst {
db.Raw("DELETE FROM jxorder2 WHERE order_id = ?", utils.Str2Int64(order.VendorOrderID))
db.Raw("DELETE FROM jxordersku2 WHERE order_id = ?", utils.Str2Int64(order.VendorOrderID))
db.Raw("DELETE FROM "+globals.JxorderTableName+" WHERE order_id = ?", utils.Str2Int64(order.VendorOrderID))
db.Raw("DELETE FROM "+globals.JxorderskuTableName+" WHERE order_id = ?", utils.Str2Int64(order.VendorOrderID))
}
jxorder := &legacyorder.Jxorder2{
VenderId: int8(order.VendorID),
OrderId: utils.Str2Int64(order.VendorOrderID),
JxStoreId: utils.Int2Str(jxutils.GetJxStoreIDFromOrder(order)),
JxStoreName: order.StoreName,
OrderNum: order.OrderSeq,
OrderStatus: legacyMapOrderStatus(order.Status),
OrderStatusTime: utils.Time2Str(order.StatusTime),
BusinessTag: businessTags,
SkuCount: order.SkuCount,
OrderBuyerRemark: order.BuyerComment,
BuyerFullName: order.ConsigneeName,
BuyerFullAddress: order.ConsigneeAddress,
BuyerMobile: order.ConsigneeMobile,
BuyerCoordType: legacyMapCoordinateType(order.CoordinateType),
BuyerLng: jxutils.IntCoordinate2Standard(order.ConsigneeLng),
BuyerLat: jxutils.IntCoordinate2Standard(order.ConsigneeLat),
CityName: "all",
OrderStartTime: utils.Time2Str(order.StatusTime),
JdStoreId: order.VendorStoreID,
VenderId: int8(order.VendorID),
OrderId: utils.Str2Int64(order.VendorOrderID),
JxStoreId: utils.Int2Str(jxutils.GetJxStoreIDFromOrder(order)),
JxStoreName: order.StoreName,
OrderNum: order.OrderSeq,
OrderStatus: legacyMapOrderStatus(order.Status),
OrderStatusTime: utils.Time2Str(order.StatusTime),
BusinessTag: businessTags,
SkuCount: order.SkuCount,
OrderBuyerRemark: order.BuyerComment,
BuyerFullName: order.ConsigneeName,
BuyerFullAddress: order.ConsigneeAddress,
BuyerMobile: order.ConsigneeMobile,
BuyerCoordType: legacyMapCoordinateType(order.CoordinateType),
BuyerLng: jxutils.IntCoordinate2Standard(order.ConsigneeLng),
BuyerLat: jxutils.IntCoordinate2Standard(order.ConsigneeLat),
CityName: "all",
OrderStartTime: utils.Time2Str(order.StatusTime),
JdStoreId: order.VendorStoreID,
OrderTotalMoney: int(order.SalePrice),
OrderDiscountMoney: int(order.SalePrice - order.ActualPayPrice),
// DeliveryPackageWeight: float64(order.Weight) / 1000,
}
@@ -169,7 +171,7 @@ func (c *OrderController) legacyWriteJxOrder(order *model.GoodsOrder, db orm.Orm
globals.SugarLogger.Infof("insert jxorder:%v error:%v", jxorder, err)
return err
}
sql := "INSERT INTO jxordersku2(vender_id, order_id, jx_sku_id, sku_name, jx_store_id, sku_price, sku_count, is_gift, promotion_type, sku_plat_discount, sku_vender_discount, sku_img) VALUES"
sql := "INSERT INTO " + globals.JxorderskuTableName + "(vender_id, order_id, jx_sku_id, sku_name, jx_store_id, sku_price, sku_count, is_gift, promotion_type, sku_plat_discount, sku_vender_discount, sku_img) VALUES"
params := []interface{}{}
for _, sku := range order.Skus {
sql += "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),"
@@ -184,7 +186,7 @@ func (c *OrderController) legacyWriteJxOrder(order *model.GoodsOrder, db orm.Orm
vendorOrderID := utils.Str2Int64(order.VendorOrderID)
utils.CallFuncLogError(func() error {
_, err = db.Raw(`
UPDATE jxorder2 t1
UPDATE `+globals.JxorderTableName+` t1
JOIN jxstore t2 ON t2.storeid = t1.jx_store_id
SET t1.store_lng = t2.lng,
t1.store_lat = t2.lat
@@ -195,7 +197,7 @@ func (c *OrderController) legacyWriteJxOrder(order *model.GoodsOrder, db orm.Orm
utils.CallFuncLogError(func() error {
_, err = db.Raw(`
UPDATE jxordersku2 t1
UPDATE `+globals.JxorderskuTableName+` t1
JOIN jx_sku t2 ON t2.id = t1.jx_sku_id
JOIN jx_sku_name t3 ON t3.id = t2.nameid
SET t1.sku_img = t3.img
@@ -227,6 +229,15 @@ func (c *OrderController) legacyJxOrderStatusChanged(status *model.OrderStatus,
updateFields = append(updateFields, "DeliveryFinishTime")
}
_, err = db.Update(jxorder, updateFields...)
db.Raw(`
UPDATE `+globals.JxorderTableName+` t1
JOIN waybill t2 ON t2.vendor_order_id = t1.order_id AND t2.status = 105
SET t1.delivery_price = IF(t2.waybill_vendor_id = 102, t2.desired_fee/100, t1.delivery_price),
t1.delivery_price1 = IF(t2.waybill_vendor_id = 101, t2.desired_fee/100, t1.delivery_price1)
WHERE t1.order_id = ?
`, jxorder.OrderId).Exec()
return err
}, "legacyJxOrderStatusChanged")
} else {