+ OrderSkuFinancial.StoreSubID, StoreSubName

This commit is contained in:
gazebo
2019-08-13 10:27:29 +08:00
parent 91efe965d1
commit 37b931abe5
4 changed files with 33 additions and 3 deletions

View File

@@ -332,10 +332,12 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
// }
// } else
if actStoreSkuMap != nil {
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 /*&& v.StoreSubName != ""*/ {
if actStoreSku := actStoreSkuMap.GetActStoreSku(jxStoreID, skuID, order.VendorID); actStoreSku != nil && v.StoreSubName != "" {
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
if actStoreSku := actStoreSkuMap.GetActStoreSku(jxStoreID, skuID, order.VendorID); actStoreSku != nil {
v.EarningPrice = actStoreSku.EarningPrice
v.StoreSubID = actStoreSku.ActID
if v.StoreSubName != "" {
v.StoreSubID = actStoreSku.ActID
}
}
}
}

View File

@@ -236,11 +236,16 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
}
orderSkus := order.Skus
vendorSkuIDs := make([]int64, 0)
skuIDMap := make(map[int]int)
for _, v := range orderSkus {
intVendorSkuID := utils.Str2Int64WithDefault(v.VendorSkuID, 0)
if intVendorSkuID != 0 {
vendorSkuIDs = append(vendorSkuIDs, intVendorSkuID)
}
if skuID := jxutils.GetSkuIDFromOrderSkuFinancial(v); skuID > 0 {
skuIDMap[skuID] = 1
}
}
if len(vendorSkuIDs) > 0 {
tableName := "t2"
@@ -263,6 +268,17 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
for _, v := range skuInfos {
skumapper[v.VendorSkuID] = v
}
var actStoreSkuMap *jxutils.ActStoreSkuMap
if len(skuIDMap) > 0 {
if order2, err2 := c.LoadOrder(order.VendorOrderID, order.VendorID); err2 == nil {
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt)
if err != nil {
globals.SugarLogger.Errorf("updateAfsOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
return err
}
actStoreSkuMap = jxutils.NewActStoreSkuMap(actStoreSkuList, false)
}
}
for _, v := range orderSkus {
v.AfsOrderID = order.AfsOrderID
v.VendorID = order.VendorID
@@ -281,6 +297,13 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af
v.JxSkuID = skuBindInfo.SkuID
}
}
if actStoreSkuMap != nil {
if skuID := jxutils.GetSkuIDFromOrderSkuFinancial(v); skuID > 0 && v.StoreSubName != "" {
if actStoreSku := actStoreSkuMap.GetActStoreSku(jxStoreID, skuID, order.VendorID); actStoreSku != nil {
v.StoreSubID = actStoreSku.ActID
}
}
}
}
}
return nil

View File

@@ -151,6 +151,8 @@ type OrderSkuFinancial struct {
// CreatedAt time.Time `orm:"type(datetime);index" json:"createdAt"` // 订单创建时间
// JxSkuMoney int64 `json:"jxSkuMoney"` // 京西补贴金额,现阶段是平台扣京西多少钱,京西扣商家多少钱,暂不考虑撤回京西补贴
// SkuType int `json:"-"` // 当前如果为gift就为1否则缺省为0
StoreSubID int `orm:"column(store_sub_id)" json:"storeSubID"` // 当前这个字段被当成活动ID用
StoreSubName string `orm:"size(64)" json:"storeSubName"` // 当前这个字段被用作vendorActType
}
func (o *OrderSkuFinancial) TableIndex() [][]string {

View File

@@ -162,6 +162,9 @@ func (c *PurchaseHandler) buildAfsOrder(afsInfo *jdapi.AfsServiceResponse) (afsO
UserMoney: x.AfsMoney,
PmSkuSubsidyMoney: x.PlatPayMoney,
}
if x.PromotionType != 0 && x.PromotionType != jdapi.PromotionTypeNormal {
orderSku.StoreSubName = utils.Int2Str(x.PromotionType)
}
afsOrder.PmSkuSubsidyMoney += orderSku.PmSkuSubsidyMoney
orderSku.PmSubsidyMoney += orderSku.PmSkuSubsidyMoney