diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 1b695b5a3..6911d861e 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -1515,7 +1515,7 @@ func (s *DefScheduler) updateBillsInfo(savedOrderInfo *WatchOrderInfo, bill *mod func (s *DefScheduler) autoPickupGood(savedOrderInfo *WatchOrderInfo) (err error) { order := savedOrderInfo.order flag := model.IsOrderDeliveryByStore(order) || model.IsOrderDeliveryBySelf(order) - if err = s.PickupGoods(order, flag, ""); err == nil { + if err = s.PickupGoods(order, flag, "autoPickup"); err == nil { order.DeliveryFlag |= model.OrderDeliveryFlagMaskAutoPickup partner.CurOrderManager.UpdateOrderFields(order, []string{"DeliveryFlag"}) } else if err == scheduler.ErrOrderStatusAlreadySatisfyCurOperation { diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 9f013b070..37f51c855 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -634,8 +634,8 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, upcs []strin keywordInt64, keywordInt64, model.ThingTypeSku, utils.DefaultTimeValue, keywordInt64) if isFocus { - sql += " OR t4.ebai_id = ? OR t4.mtwm_id = ? OR t4.dd_id = ?" - sqlParams = append(sqlParams, keywordInt64, keywordInt64, keywordInt64) + sql += " OR t4.ebai_id = ? OR t4.mtwm_id = ? OR t4.dd_id = ? OR t4.tao_id = ?" + sqlParams = append(sqlParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64) } } sql += ")" @@ -900,8 +900,8 @@ func getGetStoresSkusBaseSQL2(db *dao.DaoDB, storeIDs, skuIDs []int, upcs []stri keywordInt64, keywordInt64, model.ThingTypeSku, utils.DefaultTimeValue, keywordInt64) if isFocus { - sql += " OR t4.ebai_id = ? OR t4.mtwm_id = ? OR t4.dd_id = ?" - sqlParams = append(sqlParams, keywordInt64, keywordInt64, keywordInt64) + sql += " OR t4.ebai_id = ? OR t4.mtwm_id = ? OR t4.dd_id = ? OR t4.tao_id = ?" + sqlParams = append(sqlParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64) } } sql += ")" @@ -1165,10 +1165,10 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []str t2.comment, t2.category_id sku_category_id, t2.status sku_status, t2.eclp_id, t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at, t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at, - t4.ebai_id, t4.mtwm_id,t4.dd_id, t4.yb_id, CONCAT(smm.yb_store_prefix,t1.yb_name_suffix) yb_sku_name, t4.jds_id, t4.jds_ware_id, - t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status,t4.dd_sync_status, t4.yb_sync_status, t4.jds_sync_status, - t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.jx_price, t4.dd_price, t4.yb_price, t4.jds_price, - t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time, t4.dd_lock_time, t4.jx_lock_time, t4.yb_lock_time, t4.jds_lock_time, + t4.ebai_id, t4.mtwm_id, t4.tao_id,t4.dd_id, t4.yb_id, CONCAT(smm.yb_store_prefix,t1.yb_name_suffix) yb_sku_name, t4.jds_id, t4.jds_ware_id, + t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status,t4.tao_sync_status , t4.dd_sync_status, t4.yb_sync_status, t4.jds_sync_status, + t4.jd_price, t4.ebai_price, t4.mtwm_price,t4.tao_price, t4.jx_price, t4.dd_price, t4.yb_price, t4.jds_price, + t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time,t4.tao_lock_time, t4.dd_lock_time, t4.jx_lock_time, t4.yb_lock_time, t4.jds_lock_time, t4.status_sale_begin, t4.status_sale_end, t4.stock, t4.mt_ladder_box_price, t6.mid_unit_price real_mid_unit_price, t7.unit_price audit_unit_price @@ -1333,10 +1333,10 @@ func GetStoresSkusNew2(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []st t2.comment, t2.category_id sku_category_id, t2.status sku_status, t2.eclp_id, t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at, t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at, - t4.ebai_id, t4.mtwm_id,t4.dd_id, t4.yb_id, CONCAT(smm.yb_store_prefix,t1.yb_name_suffix) yb_sku_name, t4.jds_id, t4.jds_ware_id, - t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status, t4.dd_sync_status, t4.yb_sync_status, t4.jds_sync_status, - t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.dd_price, t4.jx_price, t4.yb_price, t4.jds_price, - t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time, t4.dd_lock_time, t4.jx_lock_time, t4.yb_lock_time, t4.jds_lock_time, + t4.ebai_id, t4.mtwm_id,t4.dd_id,t4.tao_id, t4.yb_id, CONCAT(smm.yb_store_prefix,t1.yb_name_suffix) yb_sku_name, t4.jds_id, t4.jds_ware_id, + t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status, t4.tao_sync_status, t4.dd_sync_status, t4.yb_sync_status, t4.jds_sync_status, + t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.tao_price, t4.dd_price, t4.jx_price, t4.yb_price, t4.jds_price, + t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time,t4.tao_lock_time, t4.dd_lock_time, t4.jx_lock_time, t4.yb_lock_time, t4.jds_lock_time, t4.status_sale_begin, t4.status_sale_end, t4.stock, t4.mt_ladder_box_price, t6.mid_unit_price real_mid_unit_price, t7.unit_price audit_unit_price,t8.name categoryName @@ -3492,10 +3492,10 @@ func GetLocalStoreSkusByStoreID(storeID int) (tmp []*tGetStoresSkusInfoContainCa t2.comment, t2.category_id sku_category_id, t2.status sku_status, t2.eclp_id, t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at, t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at, - t4.ebai_id, t4.mtwm_id,t4.dd_id, t4.yb_id, CONCAT(smm.yb_store_prefix,t1.yb_name_suffix) yb_sku_name, t4.jds_id, t4.jds_ware_id, - t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status, t4.dd_sync_status,t4.yb_sync_status, t4.jds_sync_status, - t4.jd_price, t4.ebai_price, t4.mtwm_price,t4.dd_price, t4.jx_price, t4.yb_price, t4.jds_price, - t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time,t4.dd_lock_time, t4.jx_lock_time, t4.yb_lock_time, t4.jds_lock_time, + t4.ebai_id, t4.mtwm_id,t4.tao_id,t4.dd_id, t4.yb_id, CONCAT(smm.yb_store_prefix,t1.yb_name_suffix) yb_sku_name, t4.jds_id, t4.jds_ware_id, + t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status, t4.tao_sync_status, t4.dd_sync_status,t4.yb_sync_status, t4.jds_sync_status, + t4.jd_price, t4.ebai_price, t4.mtwm_price,t4.dd_price, t4.jx_price, t4.yb_price, t4.jds_price,t4.tao_price, + t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time,t4.dd_lock_time, t4.jx_lock_time, t4.yb_lock_time, t4.jds_lock_time,t4.tao_lock_time, t4.status_sale_begin, t4.status_sale_end, t4.stock, t4.mt_ladder_box_price, t6.mid_unit_price real_mid_unit_price, t7.unit_price audit_unit_price, diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 622edb56a..5ce233747 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -148,11 +148,10 @@ func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo task.AddFailedList(failedList) } if err == nil { - if vendorID == model.VendorIDMTWM { + switch vendorID { + case model.VendorIDMTWM, model.VendorIDDD, model.VendorIDTaoVegetable: refutil.SetObjFieldByName(storeCatMap, idFieldName, catInfo.VendorCatID) - } else if vendorID == model.VendorIDDD { - refutil.SetObjFieldByName(storeCatMap, idFieldName, catInfo.VendorCatID) - } else { + default: refutil.SetObjFieldByName(storeCatMap, idFieldName, utils.Str2Int64WithDefault(catInfo.VendorCatID, 0)) } _, err = dao.UpdateEntity(db, storeCatMap, updateFields...) @@ -556,7 +555,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag } } else { if sku.MergedStatus == model.SkuStatusNormal { - if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB && vendorID != model.VendorIDDD || vendorID != model.VendorIDJDShop { + if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB && vendorID != model.VendorIDDD && vendorID != model.VendorIDJDShop { globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID) } else if dao.IsVendorThingIDEmpty(utils.Int64ToStr(sku.VendorVendorCatID)) && vendorID == model.VendorIDJDShop { globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有映射的平台ID", storeID, sku.SkuID) @@ -755,15 +754,12 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag task.AddFailedList(failedList) } if err != nil { - //handle error for sensitive words, if find, then insert to table sensitive_words if sensitiveWord := GetSensitiveWord(singleStoreHandler, err.Error()); sensitiveWord != "" { dao.InsertSensitiveWord(sensitiveWord, vendorID, ctx.GetUserName()) - // words, _ := dao.GetSensitiveWordList(vendorID) - // word := words[0] - // word.Word = word.Word + "," + sensitiveWord - // dao.UpdateSensitiveWord(word, vendorID, 0, ctx.GetUserName()) } } + globals.SugarLogger.Debugf("batchedStoreSkuList := %s", utils.Format4Output(batchedStoreSkuList, false)) + globals.SugarLogger.Debugf("failedList := %s", utils.Format4Output(failedList, false)) successList := putils.UnselectStoreSkuSyncListByVendorSkuIDs(batchedStoreSkuList, GetVendorSkuIDList(failedList)) if len(successList) > 0 { _, err := updateStoreSku(dao.GetDB(), vendorID, successList, model.SyncFlagNewMask) diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index b30b9ecdc..15a1b91d8 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -686,6 +686,8 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" + globals.SugarLogger.Debugf("sql :============ %s", sql) + globals.SugarLogger.Debugf("sql :============ %s", utils.Format4Output(sqlParams, false)) if err = GetRows(db, &skus, sql, sqlParams...); err != nil { return nil, err } @@ -1242,9 +1244,9 @@ func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (storeSkuNameExt []*StoreSk sql2 := ` SELECT a.id sku_id,a.*,t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at, t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at, - t4.ebai_id, t4.mtwm_id,t4.dd_id, - t4.ebai_sync_status, t4.mtwm_sync_status,t4.dd_sync_status, - t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.jx_price, t4.stock, + t4.ebai_id, t4.mtwm_id,t4.dd_id,t4.tao_id, + t4.ebai_sync_status, t4.mtwm_sync_status,t4.dd_sync_status,t4.tao_sync_status, + t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.jx_price, t4.tao_price, t4.stock, a.spec_quality sku_spec_quality, a.spec_unit sku_spec_unit FROM sku a JOIN sku_name t1 ON a.name_id = t1.id AND t1.deleted_at = ? diff --git a/business/model/order.go b/business/model/order.go index c144a0699..8997a5041 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -192,26 +192,27 @@ func (o *GoodsOrderOriginal) TableUnique() [][]string { } type OrderSku struct { - ID int64 `orm:"column(id)" json:"id"` - VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` - VendorID int `orm:"column(vendor_id)" json:"vendorID"` - StoreSubID int `orm:"column(store_sub_id)" json:"storeSubID"` // EarningActID,当前这个字段被当成结算活动ID用 - StoreSubName string `orm:"size(64)" json:"storeSubName"` // 当前这个字段被用作vendorActType - Count int `json:"count"` - VendorSkuID string `orm:"column(vendor_sku_id);size(48)" json:"vendorSkuID"` - SkuID int `orm:"column(sku_id)" json:"skuID"` // 外部系统里记录的 jxskuid - JxSkuID int `orm:"column(jx_sku_id)" json:"jxSkuID"` // 根据VendorSkuID在本地系统里查询出来的 jxskuid - SkuName string `orm:"size(255)" json:"skuName"` - ShopPrice int64 `json:"shopPrice"` // 京西价 - VendorPrice int64 `json:"vendorPrice"` // 平台价 - SalePrice int64 `json:"salePrice"` // 售卖价 - EarningPrice int64 `json:"earningPrice"` // 活动商品设置,结算给门店老板的钱,如果结算活动ID为0,是按结算比例算的,否则就是结算表中的值 - Weight int `json:"weight"` // 单位为克 - SkuType int `json:"skuType"` // 当前如果为gift就为1,否则缺省为0 - PromotionType int `json:"promotionType"` // todo 当前是用于记录京东的PromotionType(生成jxorder用),没有做转换 - OrderCreatedAt time.Time `orm:"type(datetime);index" json:"-"` // 分区考虑 - IsVendorAct int `json:"isVendorAct"` - Upc string `json:"upc"` //upc码 + ID int64 `orm:"column(id)" json:"id"` + VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` + VendorSubOrderID string `orm:"column(vendor_sub_order_id);size(48)" json:"vendorSubOrderID"` // 子订单id + VendorID int `orm:"column(vendor_id)" json:"vendorID"` + StoreSubID int `orm:"column(store_sub_id)" json:"storeSubID"` // EarningActID,当前这个字段被当成结算活动ID用 + StoreSubName string `orm:"size(64)" json:"storeSubName"` // 当前这个字段被用作vendorActType + Count int `json:"count"` + VendorSkuID string `orm:"column(vendor_sku_id);size(48)" json:"vendorSkuID"` + SkuID int `orm:"column(sku_id)" json:"skuID"` // 外部系统里记录的 jxskuid + JxSkuID int `orm:"column(jx_sku_id)" json:"jxSkuID"` // 根据VendorSkuID在本地系统里查询出来的 jxskuid + SkuName string `orm:"size(255)" json:"skuName"` + ShopPrice int64 `json:"shopPrice"` // 京西价 + VendorPrice int64 `json:"vendorPrice"` // 平台价 + SalePrice int64 `json:"salePrice"` // 售卖价 + EarningPrice int64 `json:"earningPrice"` // 活动商品设置,结算给门店老板的钱,如果结算活动ID为0,是按结算比例算的,否则就是结算表中的值 + Weight int `json:"weight"` // 单位为克 + SkuType int `json:"skuType"` // 当前如果为gift就为1,否则缺省为0 + PromotionType int `json:"promotionType"` // todo 当前是用于记录京东的PromotionType(生成jxorder用),没有做转换 + OrderCreatedAt time.Time `orm:"type(datetime);index" json:"-"` // 分区考虑 + IsVendorAct int `json:"isVendorAct"` + Upc string `json:"upc"` //upc码 } // 同样商品在一个订单中可能重复出现(比如搞活动时,相同商品价格不一样,第一个有优惠) diff --git a/business/partner/purchase/tao_vegetable/financial.go b/business/partner/purchase/tao_vegetable/financial.go index 62bb2988b..c31d6510b 100644 --- a/business/partner/purchase/tao_vegetable/financial.go +++ b/business/partner/purchase/tao_vegetable/financial.go @@ -164,9 +164,9 @@ func (p *PurchaseHandler) OrderDetail2Financial(result *domain591.AlibabaAelophy VendorStoreID: *result.StoreId, StoreID: 0, JxStoreID: jxStoreID, - VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(x.SkuCode)), + VendorSkuID: *x.SkuCode, SkuID: utils.Str2Int(*x.SkuCode), - Name: utils.Interface2String(x.SkuName), + Name: *x.SkuName, SalePrice: *x.Price, Count: utils.Float64TwoInt(*x.BuySaleQuantity), SkuBoxMoney: 0, @@ -177,24 +177,26 @@ func (p *PurchaseHandler) OrderDetail2Financial(result *domain591.AlibabaAelophy orderFinancial.SkuBoxMoney += orderSkuFinancial.SkuBoxMoney // 活动 - for _, v := range *x.Activitys { - activity := &model.OrderDiscountFinancial{ - VendorID: orderFinancial.VendorID, - VendorOrderID: orderFinancial.VendorOrderID, + if x.Activitys != nil { + for _, v := range *x.Activitys { + activity := &model.OrderDiscountFinancial{ + VendorID: orderFinancial.VendorID, + VendorOrderID: orderFinancial.VendorOrderID, + } + if v.ChannelActivityId != nil { + activity.VendorActivityID = *v.ChannelActivityId + activity.Type = tao_vegetable.ActivityTypeChannel + } + if v.BizActivityId != nil { + activity.VendorActivityID = *v.BizActivityId + activity.Type = tao_vegetable.ActivityTypeBiz + } + if v.MerchantActivityId != nil { + activity.VendorActivityID = *v.MerchantActivityId + activity.Type = tao_vegetable.ActivityTypeMerchant + } + orderFinancial.Discounts = append(orderFinancial.Discounts, activity) } - if v.ChannelActivityId != nil { - activity.VendorActivityID = *v.ChannelActivityId - activity.Type = tao_vegetable.ActivityTypeChannel - } - if v.BizActivityId != nil { - activity.VendorActivityID = *v.BizActivityId - activity.Type = tao_vegetable.ActivityTypeBiz - } - if v.MerchantActivityId != nil { - activity.VendorActivityID = *v.MerchantActivityId - activity.Type = tao_vegetable.ActivityTypeMerchant - } - orderFinancial.Discounts = append(orderFinancial.Discounts, activity) } } @@ -208,5 +210,6 @@ func (p *PurchaseHandler) OrderDetail2Financial(result *domain591.AlibabaAelophy orderFinancial.SelfDeliveryDiscountMoney = *result.SkuDiscountPlatformFee // 平台承担运费补贴(商家自送)+ orderFinancial.DistanceFreightMoney = 0 + globals.SugarLogger.Debugf("orderFinancial===============: %s", utils.Format4Output(orderFinancial, false)) return orderFinancial } diff --git a/business/partner/purchase/tao_vegetable/order.go b/business/partner/purchase/tao_vegetable/order.go index 7f28a761b..fbea60828 100644 --- a/business/partner/purchase/tao_vegetable/order.go +++ b/business/partner/purchase/tao_vegetable/order.go @@ -14,7 +14,6 @@ import ( domain591 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability591/domain" request591 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability591/request" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util" - "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/ascription_place" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -31,7 +30,8 @@ var ( var ( VendorStatus2StatusMap = map[string]int{ - tao_vegetable.OrderStatusNew: model.OrderStatusNew, // 商户接单 + tao_vegetable.OrderStatusPayFinsh: model.OrderStatusNew, // 商户接单 + tao_vegetable.OrderStatusNew: model.OrderStatusAccepted, // 商户接单 tao_vegetable.OrderStatusPickedUp: model.OrderStatusFinishedPickup, // 拣货完成 tao_vegetable.OrderStatusCallRider: model.OrderStatusFinishedPickup, // 打包出库(呼叫骑手,骑手到店,骑手取货) tao_vegetable.OrderStatusDelivery: model.OrderStatusDelivering, // 配送中 @@ -55,8 +55,8 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve StoreId: utils.String2Pointer(vendorStoreID), BizOrderId: utils.Int64ToPointer(vendorOrderID), }} + orderDetail, err := getAPI(vendorOrgCode, 0, vendorStoreID).QueryOrderDetail(requestParam) - globals.SugarLogger.Debugf("orderDetail := %s", utils.Format4Output(orderDetail, false)) if err != nil { return nil, nil, err } @@ -95,32 +95,34 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve order.ConsigneeLat = jxutils.StandardCoordinate2Int(utils.Str2Float64(originalList[1])) order.DiscountMoney = *orderDetail.DiscountFee - var salePrice int64 = 0 + //var salePrice int64 = 0 + //var weight int = 0 order.PmSubsidyMoney = *orderDetail.SkuDiscountPlatformFee // 平台承担优惠 // 添加需要赠送的东西(暂时没有赠品套餐直接商品) multiSkuMap := make(map[int]int) if len(*orderDetail.SubOrderResponseList) > 0 { for _, extra := range *orderDetail.SubOrderResponseList { sku := &model.OrderSku{ - VendorOrderID: order.VendorOrderID, - VendorID: model.VendorIDTaoVegetable, - StoreSubID: 0, - StoreSubName: "", - Count: utils.Float64TwoInt(*extra.BuySaleQuantity), - VendorSkuID: *extra.SkuCode, - SkuID: utils.Str2Int(*extra.SkuCode), - JxSkuID: utils.Str2Int(*extra.SkuCode), - SkuName: *extra.SkuName, - ShopPrice: *extra.Price, - VendorPrice: *extra.OriginalFee / utils.Float64TwoInt64(*extra.BuySaleQuantity), - SalePrice: *extra.OriginalFee, - EarningPrice: 0, - Weight: int(*extra.Weight), - SkuType: 0, - PromotionType: 0, - OrderCreatedAt: order.OrderCreatedAt, - IsVendorAct: 0, - Upc: *extra.Barcode, + VendorOrderID: order.VendorOrderID, + VendorID: model.VendorIDTaoVegetable, + StoreSubID: 0, + StoreSubName: "", + Count: utils.Float64TwoInt(*extra.BuySaleQuantity), + VendorSkuID: *extra.SkuCode, + SkuID: utils.Str2Int(*extra.SkuCode), + JxSkuID: utils.Str2Int(*extra.SkuCode), + SkuName: *extra.SkuName, + ShopPrice: *extra.Price, + VendorPrice: *extra.OriginalFee / utils.Float64TwoInt64(*extra.BuySaleQuantity), + SalePrice: *extra.OriginalFee / utils.Float64TwoInt64(*extra.BuySaleQuantity), + EarningPrice: 0, + Weight: int(*extra.Weight / utils.Float64TwoInt64(*extra.BuySaleQuantity)), + SkuType: 0, + PromotionType: 0, + OrderCreatedAt: order.OrderCreatedAt, + IsVendorAct: 0, + Upc: *extra.Barcode, + VendorSubOrderID: utils.Int64ToStr(*extra.BizSubOrderId), } activityId := make([]int64, 0) @@ -154,9 +156,15 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve } multiSkuMap[sku.SkuID]++ order.Skus = append(order.Skus, sku) - salePrice += sku.SalePrice + //salePrice += sku.SalePrice + //weight += sku.Weight + globals.SugarLogger.Debugf("=====skuPrice := %d", sku.SalePrice) } } + //order.SalePrice = salePrice + //order.Weight = weight + //globals.SugarLogger.Debugf("=====skuPrice := %d", salePrice) + // 淘宝默认自配送 if *orderDetail.DeliveryType == tao_vegetable.OrderDeliveryTypeTime { order.DeliveryType = model.OrderDeliveryTypePlatform @@ -185,18 +193,19 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve v.IsVendorAct = model.YES } } - // 抖音订单手机号和收货地址是否同城 - order.PhoneAscription = "" - ascription, err := ascription_place.Find(order.ConsigneeMobile) - if err != nil { - order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + err.Error() - } else { - if strings.Contains(order.ConsigneeAddress, ascription.Province) && strings.Contains(order.ConsigneeAddress, ascription.City) { - order.PhoneAscription = model.PhoneAscriptionAddressYes + "-" + ascription.Province + ascription.City - } else { - order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + "归属信息不匹配:" + ascription.Province + ascription.City - } - } + // 抖音订单手机号和收货地址是否同城(虚拟号,无法获取到正确地址) + order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + "归属信息不匹配:" + "虚拟电话号码" + //ascription, err := ascription_place.Find(order.ConsigneeMobile) + //if err != nil { + // order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + err.Error() + // err = nil + //} else { + // if strings.Contains(order.ConsigneeAddress, ascription.Province) && strings.Contains(order.ConsigneeAddress, ascription.City) { + // order.PhoneAscription = model.PhoneAscriptionAddressYes + "-" + ascription.Province + ascription.City + // } else { + // order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + "归属信息不匹配:" + ascription.Province + ascription.City + // } + //} // 本地获取订单记录 orderSeq, _ := dao.GetVendorOrderNumber(dao.GetDB(), model.VendorIDTaoVegetable, order.VendorStoreID) @@ -211,6 +220,7 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve } order.StoreName = store.Name // 真实门店名称 + globals.SugarLogger.Debugf("=====order : %s", utils.Format4Output(order, false)) return order, orderMap, err } @@ -333,7 +343,7 @@ func (c *PurchaseHandler) onOrderMsg(orderStatus, orderId string, orderCallback // 商户接单/支付完成代表新订单 if msg.OrderStatus == tao_vegetable.OrderStatusNew || msg.OrderStatus == tao_vegetable.OrderStatusPayFinsh { - order, orderMap, err2 := c.getOrder(msg.MerchantCode, msg.BizOrderId, msg.StoreId) + order, orderMap, err2 := c.getOrder("", msg.BizOrderId, msg.StoreId) if err = err2; err == nil { err = partner.CurOrderManager.OnOrderNew(order, status) if err == nil { @@ -402,9 +412,12 @@ func (c *PurchaseHandler) callbackOrderMsg2Status(msg *tao_vegetable.CallbackOrd } switch msg.OrderStatus { - case tao_vegetable.OrderStatusNew: // 商户接单 + case tao_vegetable.OrderStatusPayFinsh: // 新订单 orderStatus.Status = model.OrderStatusNew orderStatus.Remark = "新订单" + case tao_vegetable.OrderStatusNew: // 商户接单 + orderStatus.Status = model.OrderStatusAccepted + orderStatus.Remark = "商户接单" case tao_vegetable.OrderStatusPickedUp: // 拣货完成 orderStatus.Status = model.OrderStatusFinishedPickup orderStatus.Remark = "拣货完成" @@ -481,7 +494,8 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI // PickupGoods 拣货 func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) { - if !isSelfDelivery { + globals.SugarLogger.Debugf("PickupGoods 自动拣货:%s, %s", utils.Format4Output(isSelfDelivery, false), utils.Format4Output(order, false)) + if isSelfDelivery { param, err := orderStatusChangeNotice(order, tao_vegetable.OrderStatusPickedUp) if err != nil { return err @@ -534,8 +548,22 @@ func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName // SelfDeliverDelivering 自配送订单配送中 func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) { - param := OrderStatusChangeDelivery(order, tao_vegetable.OrderStatusDelivery) - return getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").DeliveryFinish(param) + api := getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "") + // 出库 + param, err := orderStatusChangeNotice(order, tao_vegetable.OrderStatusCallRider) + if err != nil { + return err + } + if err = api.DeliveryFinish(param); err == nil { + paramDelivery, err := orderStatusChangeNotice(order, tao_vegetable.OrderStatusDelivery) + if err != nil { + return err + } + // 开始配送 + return api.DeliveryFinish(paramDelivery) + } + + return err } // SelfDeliverDelivered 自配送订单送达 diff --git a/business/partner/purchase/tao_vegetable/order_utils.go b/business/partner/purchase/tao_vegetable/order_utils.go index 94a8ce631..88fd9f5e7 100644 --- a/business/partner/purchase/tao_vegetable/order_utils.go +++ b/business/partner/purchase/tao_vegetable/order_utils.go @@ -33,10 +33,10 @@ func orderStatusChangeNotice(order *model.GoodsOrder, orderStatus string) (*requ } for _, v := range skuList { workCallbackSubOrderInfo := domain591.AlibabaAelophyOrderWorkCallbackWorkCallbackSubOrderInfo{ - BizSubOrderId: nil, + BizSubOrderId: utils.Int64ToPointer(utils.Str2Int64(v.VendorSubOrderID)), SkuCode: utils.String2Pointer(v.VendorSkuID), PickSaleQuantity: utils.String2Pointer(utils.Int2Str(v.Count)), - PickStockQuantity: utils.String2Pointer(fmt.Sprintf("%.2f", float64(v.Weight)/float64(1000)*float64(v.Count))), + PickStockQuantity: utils.String2Pointer(utils.Int2Str(v.Count)), } workCallbackSubOrderInfoList = append(workCallbackSubOrderInfoList, workCallbackSubOrderInfo) } @@ -56,8 +56,17 @@ func OrderStatusChangeDelivery(order *model.GoodsOrder, orderStatus string) *req Status: utils.String2Pointer(orderStatus), } bill, _ := partner.CurOrderManager.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID) - param.WorkCallbackRequest.DelivererName = utils.String2Pointer(bill.CourierName) - param.WorkCallbackRequest.DelivererPhone = utils.String2Pointer(bill.CourierMobile) + if bill != nil { + if bill.CourierName == "" && bill.CourierMobile == "" { + storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, model.VendorIDTaoVegetable, "") + param.WorkCallbackRequest.DelivererName = utils.String2Pointer("门店老板") + param.WorkCallbackRequest.DelivererPhone = utils.String2Pointer(storeDetail.Tel1) + } else { + param.WorkCallbackRequest.DelivererName = utils.String2Pointer(bill.CourierName) + param.WorkCallbackRequest.DelivererPhone = utils.String2Pointer(bill.CourierMobile) + } + } + if param.WorkCallbackRequest.DelivererName == nil || param.WorkCallbackRequest.DelivererPhone == nil { param.WorkCallbackRequest.DelivererName = utils.String2Pointer("暂无") param.WorkCallbackRequest.DelivererPhone = utils.String2Pointer("暂无") diff --git a/business/partner/purchase/tao_vegetable/store_sku2.go b/business/partner/purchase/tao_vegetable/store_sku2.go index ed93f6fb6..40b744074 100644 --- a/business/partner/purchase/tao_vegetable/store_sku2.go +++ b/business/partner/purchase/tao_vegetable/store_sku2.go @@ -65,6 +65,13 @@ func getStoreVendorOrgCode(storeID int) (vendorOrgCode string) { return vendorOrgCode } +func getStoreVendorOrgCodeByVendorStoreID(vendorStoreID string) (vendorOrgCode string) { + if storeMap, _ := dao.GetStoreDetailForDD(dao.GetDB(), 0, model.VendorIDTaoVegetable, vendorStoreID, ""); storeMap != nil { + return storeMap.VendorOrgCode + } + return vendorOrgCode +} + // 门店分类 func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID int, vendorStoreID string) (cats []*partner.BareCategoryInfo, err error) { remoteCats, err := getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID).GetStoreAllCategory() @@ -124,7 +131,8 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in Leaf: utils.Bool2Point(false), }} if storeCat.ParentID != model.NO { - createCategory.Param.ParentCode = utils.String2Pointer(utils.Int2Str(storeCat.ParentID)) + createCategory.Param.ParentCode = utils.String2Pointer(storeCat.ParentVendorCatID) + createCategory.Param.Leaf = utils.Bool2Point(true) } skuCode, err := api.AddStoreCategoryInfo(createCategory) @@ -143,7 +151,8 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in Leaf: utils.Bool2Point(false), }} if storeCat.ParentID != model.NO { - createCategoryParam.Param.ParentCode = utils.String2Pointer(utils.Int2Str(storeCat.ParentID)) + createCategoryParam.Param.ParentCode = utils.String2Pointer(storeCat.ParentVendorCatID) + createCategoryParam.Param.Leaf = utils.Bool2Point(true) } skuCode, err := api.AddStoreCategoryInfo(createCategoryParam) @@ -183,6 +192,7 @@ func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID in } func (p *PurchaseHandler) IsErrSkuExist(err error) (isExist bool) { + return false } @@ -216,10 +226,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI api := getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID) if isCreate { failedList, err = createTaoVegetable(api, storeSkuList, vendorStoreID, storeID, syncType) - globals.SugarLogger.Debugf("创建淘鲜达商品异常:%s", err.Error()) + globals.SugarLogger.Debugf("创建淘鲜达商品异常:%v", err) } else { failedList, err = UpdateTaoVegetable(api, storeSkuList, vendorStoreID, storeID, syncType) - globals.SugarLogger.Debugf("更新淘鲜达商品异常:%s", err.Error()) + globals.SugarLogger.Debugf("更新淘鲜达商品异常:%v", err) } globals.SugarLogger.Debugf("createOrUpdateStoreSkus=====err := %v", err) globals.SugarLogger.Debugf("createOrUpdateStoreSkus=====err := %v", failedList) @@ -233,13 +243,13 @@ func UpdateTaoVegetable(api *tao_vegetable.API, storeSkuList []*dao.StoreSkuSync totalCount := len(storeSkuList) for index, v := range storeSkuList { updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{ - OuCode: utils.String2Pointer(vendorStoreID), - SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), - SkuName: utils.String2Pointer(v.SkuName), - MemberPrice: utils.String2Pointer("45"), - SkuPrice: utils.String2Pointer("45"), - CategoryCode: utils.String2Pointer(utils.Int2Str(v.CategoryID)), - BackCatCode: utils.String2Pointer(v.SkuVendorCatID), + OuCode: utils.String2Pointer(vendorStoreID), + SkuCode: utils.String2Pointer(utils.Int2Str(v.SkuID)), + SkuName: utils.String2Pointer(v.SkuName), + MemberPrice: utils.String2Pointer(utils.Float64ToStr(float64(v.UnitPrice) / float64(100))), + SkuPrice: utils.String2Pointer(utils.Float64ToStr(float64(v.UnitPrice) / float64(100))), // 优先使用skuPrice 靠后SalePrice + CategoryCode: utils.String2Pointer(utils.Int2Str(v.CategoryID)), + MerchantCatCode: utils.String2Pointer(v.VendorCatID), // 优先使用 靠后 category_code } if v.MinOrderCount <= model.YES { updateSku.PurchaseQuantity = utils.Int64ToPointer(model.YES) // 起购单位 @@ -276,46 +286,49 @@ func createTaoVegetable(api *tao_vegetable.API, storeSkuList []*dao.StoreSkuSync for index, storeSku := range storeSkuList { sku := domain585.AlibabaWdkSkuAddSkuDo{ - Barcodes: utils.String2Pointer(utils.Int2Str(storeSku.SkuID)), - BrandName: utils.String2Pointer(tao_vegetable.CreateSkuBrandName), - OuCode: utils.String2Pointer(vendorStoreID), - InventoryUnit: utils.String2Pointer(storeSku.Unit), - ProducerPlace: utils.String2Pointer(tao_vegetable.CreateSkuProducerPlace), - SkuCode: utils.String2Pointer(utils.Int2Str(storeSku.SkuID)), - SkuName: utils.String2Pointer(storeSku.SkuName), - StorageType: utils.Int64ToPointer(tao_vegetable.CreateSkuStorageType), - SuggestedPrice: utils.String2Pointer(utils.Float64ToStr(utils.Int64ToFloat64(storeSku.UnitPrice) / utils.Int64ToFloat64(100))), - Weight: utils.String2Pointer(utils.Float32ToStr(storeSku.SpecQuality)), - ShelfLife: utils.Int64ToPointer(tao_vegetable.CreateShelfLife), - NetContent: utils.String2Pointer(utils.Float32ToStr(storeSku.SpecQuality)), - SaleUnit: utils.String2Pointer(storeSku.SpecUnit), - LifeStatus: utils.String2Pointer(tao_vegetable.CreateSkuLeafStatus), - SaleSpec: utils.String2Pointer(fmt.Sprintf("%f*1%s", storeSku.SpecQuality, storeSku.Unit)), - StepQuantity: utils.Int64ToPointer(model.YES), // 每次购买至少增加一个购买单位 - SubTitle: utils.String2Pointer("同城包邮"), - SubTitle1: utils.String2Pointer("一小时速达"), - OnlineSaleFlag: utils.Int64ToPointer(tao_vegetable.CreateOnlineSaleFlag), // 门店控制是否可见 - DeliveryUnit: utils.String2Pointer(storeSku.Unit), + Barcodes: utils.String2Pointer(utils.Int2Str(storeSku.SkuID)), + BrandName: utils.String2Pointer(tao_vegetable.CreateSkuBrandName), + OuCode: utils.String2Pointer(vendorStoreID), + //InventoryUnit: utils.String2Pointer(storeSku.Unit), + InventoryUnit: utils.String2Pointer("份"), + ProducerPlace: utils.String2Pointer(tao_vegetable.CreateSkuProducerPlace), + SkuCode: utils.String2Pointer(utils.Int2Str(storeSku.SkuID)), + SkuName: utils.String2Pointer(storeSku.SkuName), + StorageType: utils.Int64ToPointer(tao_vegetable.CreateSkuStorageType), + SuggestedPrice: utils.String2Pointer(utils.Float64ToStr(utils.Int64ToFloat64(storeSku.UnitPrice) / utils.Int64ToFloat64(100))), + Weight: utils.String2Pointer(utils.Float32ToStr(storeSku.SpecQuality)), + ShelfLife: utils.Int64ToPointer(tao_vegetable.CreateShelfLife), + NetContent: utils.String2Pointer(utils.Float32ToStr(storeSku.SpecQuality)), + SaleUnit: utils.String2Pointer("份"), + LifeStatus: utils.String2Pointer(tao_vegetable.CreateSkuLeafStatus), + SaleSpec: utils.String2Pointer(fmt.Sprintf("%.2f*1%s", storeSku.SpecQuality, storeSku.Unit)), + StepQuantity: utils.Int64ToPointer(model.YES), // 每次购买至少增加一个购买单位 + SubTitle: utils.String2Pointer("同城包邮"), + SubTitle1: utils.String2Pointer("一小时速达"), + OnlineSaleFlag: utils.Int64ToPointer(tao_vegetable.CreateOnlineSaleFlag), // 门店控制是否可见 + //DeliveryUnit: utils.String2Pointer(storeSku.Unit), + DeliveryUnit: utils.String2Pointer("份"), DeliverySpec: utils.String2Pointer(utils.Int2Str(model.YES)), MemberPrice: utils.String2Pointer(utils.Float64ToStr(float64(storeSku.UnitPrice) / float64(100))), Storage: utils.String2Pointer(tao_vegetable.CreateStorage), - PickFloatRate: utils.String2Pointer(utils.Int2Str(model.NO)), // ? 0 - ForbidReceiveDays: utils.Int64ToPointer(tao_vegetable.CreateShelfLife), // ? 7 - ForbidSalesDays: utils.Int64ToPointer(model.NO), // ? 0 - OverloadRate: utils.String2Pointer(utils.Int2Str(model.NO)), // ? 0 - WarnDays: utils.Int64ToPointer(model.NO), // ? 0 - FixedFlag: utils.Int64ToPointer(model.NO), // ? 0 - PurchaseSpec: utils.String2Pointer(utils.Int2Str(model.YES)), // ? 1 - PurchaseUnit: utils.String2Pointer(storeSku.Unit), // ? 同上 - LabelStyleType: utils.String2Pointer(tao_vegetable.CreateLabelStyleType), // 库存单位 - ItemTypeNew: utils.Int64ToPointer(tao_vegetable.CreateItemTypeNewVegetable), - SkuPrice: utils.String2Pointer(utils.Float64ToStr(float64(storeSku.UnitPrice) / float64(100))), // 优先使用skuPrice 靠后SalePrice - Period: utils.Int64ToPointer(tao_vegetable.CreateShelfLife), // 优先使用period 靠后shelf_life - MerchantCatCode: utils.String2Pointer(utils.Int2Str(storeSku.NameCategoryID)), // 优先使用 靠后 category_code - FragileFlag: utils.Int64ToPointer(model.YES), - DeliveryStorage: utils.String2Pointer(tao_vegetable.CreateItemDeliveryStorage), - TemporaryFlag: utils.Int64ToPointer(model.NO), - IsOnline: utils.Int64ToPointer(tao_vegetable.CreateIsOnline), + PickFloatRate: utils.String2Pointer(utils.Int2Str(model.NO)), // ? 0 + ForbidReceiveDays: utils.Int64ToPointer(tao_vegetable.CreateShelfLife), // ? 7 + ForbidSalesDays: utils.Int64ToPointer(model.NO), // ? 0 + OverloadRate: utils.String2Pointer(utils.Int2Str(model.NO)), // ? 0 + WarnDays: utils.Int64ToPointer(model.NO), // ? 0 + FixedFlag: utils.Int64ToPointer(model.NO), // ? 0 + PurchaseSpec: utils.String2Pointer(utils.Int2Str(model.YES)), // ? 1 + //PurchaseUnit: utils.String2Pointer(storeSku.Unit), // ? 同上 + PurchaseUnit: utils.String2Pointer("份"), // ? 同上 + LabelStyleType: utils.String2Pointer(tao_vegetable.CreateLabelStyleType), // 库存单位 + ItemTypeNew: utils.Int64ToPointer(tao_vegetable.CreateItemTypeNewVegetable), + SkuPrice: utils.String2Pointer(utils.Float64ToStr(float64(storeSku.UnitPrice) / float64(100))), // 优先使用skuPrice 靠后SalePrice + Period: utils.Int64ToPointer(tao_vegetable.CreateShelfLife), // 优先使用period 靠后shelf_life + FragileFlag: utils.Int64ToPointer(model.YES), + DeliveryStorage: utils.String2Pointer(tao_vegetable.CreateItemDeliveryStorage), + TemporaryFlag: utils.Int64ToPointer(model.NO), + IsOnline: utils.Int64ToPointer(tao_vegetable.CreateIsOnline), + MerchantCatCode: utils.String2Pointer(storeSku.VendorCatID), // 优先使用 靠后 category_code } sku.SkuPicUrls = uploadImg(api, []string{storeSku.ImgOrigin, storeSku.Img, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5, storeSku.DescImg}) if storeSku.MinOrderCount <= model.YES { @@ -324,21 +337,22 @@ func createTaoVegetable(api *tao_vegetable.API, storeSkuList []*dao.StoreSkuSync sku.PurchaseQuantity = utils.Int64ToPointer(int64(storeSku.MinOrderCount)) // 起购单位 } sku.WeightFlag = utils.Int64ToPointer(tao_vegetable.CreateSkuWeightFlagNo) - sku.AvgWeight = utils.String2Pointer("1") // (重量) - if storeSku.Upc == "" { - //sku.WeightFlag = utils.Int64ToPointer(tao_vegetable.CreateSkuWeightFlagYes) - if storeSku.SpecUnit == "g" || storeSku.SpecUnit == "ml" || storeSku.SpecUnit == "G" || storeSku.SpecUnit == "ML" { - sku.PreMinusWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality) / float64(1000))) // 一个售卖单位按多少库存单位扣款(钱) - //sku.AvgWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality) / float64(1000))) // (重量) - } - if storeSku.SpecUnit == "kg" || storeSku.SpecUnit == "l" || storeSku.SpecUnit == "KG" || storeSku.SpecUnit == "L" { - sku.PreMinusWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality))) // 每个购买单位重量,预扣重量 - //sku.AvgWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality) / float64(1000))) // (重量) - } - } else { - //sku.WeightFlag = utils.Int64ToPointer(tao_vegetable.CreateSkuWeightFlagNo) - sku.PreMinusWeight = utils.String2Pointer("1") // 每个购买单位重量,预扣重量 - } + sku.AvgWeight = utils.String2Pointer("1") // (重量) + sku.PreMinusWeight = utils.String2Pointer("1") // 每个购买单位重量,预扣重量 + //if storeSku.Upc == "" { + // //sku.WeightFlag = utils.Int64ToPointer(tao_vegetable.CreateSkuWeightFlagYes) + // if storeSku.SpecUnit == "g" || storeSku.SpecUnit == "ml" || storeSku.SpecUnit == "G" || storeSku.SpecUnit == "ML" { + // sku.PreMinusWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality) / float64(1000))) // 一个售卖单位按多少库存单位扣款(钱) + // //sku.AvgWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality) / float64(1000))) // (重量) + // } + // if storeSku.SpecUnit == "kg" || storeSku.SpecUnit == "l" || storeSku.SpecUnit == "KG" || storeSku.SpecUnit == "L" { + // sku.PreMinusWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality))) // 每个购买单位重量,预扣重量 + // //sku.AvgWeight = utils.String2Pointer(utils.Float64ToStr(float64(storeSku.SpecQuality) / float64(1000))) // (重量) + // } + //} else { + // //sku.WeightFlag = utils.Int64ToPointer(tao_vegetable.CreateSkuWeightFlagNo) + // sku.PreMinusWeight = utils.String2Pointer("1") // 每个购买单位重量,预扣重量 + //} sku.SkuSuppliers = &[]domain585.AlibabaWdkSkuAddSkuSupplierDo{ domain585.AlibabaWdkSkuAddSkuSupplierDo{ ReturnFlag: utils.Int64ToPointer(model.NO), @@ -361,21 +375,25 @@ func createTaoVegetable(api *tao_vegetable.API, storeSkuList []*dao.StoreSkuSync if (index+model.YES)%tao_vegetable.MAXHandleCount == model.NO || index+model.YES == totalCount { createPram.ParamList = ¶m result, err := api.AddStoreSku(createPram) + globals.SugarLogger.Debugf("创建淘鲜达商品异常 result :%s", utils.Format4Output(result, false)) + if err != nil { globals.SugarLogger.Debugf("创建淘鲜达商品异常:%s", err.Error()) - //failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDTaoVegetable], syncType) } // 记录失败的同步数据 - createFailedList, successMap := SelectStoreSkuListByFoodList(storeSkuList, *result, storeID, model.VendorChineseNames[model.VendorIDTaoVegetable], syncType) - failedList = append(failedList, createFailedList...) - // 记录同步成功的数据 - for k, v := range successMap { - vendorSkuIdMap[k] = v - } + failedList, vendorSkuIdMap = SelectStoreSkuListByFoodList(storeSkuList, *result, storeID, model.VendorChineseNames[model.VendorIDTaoVegetable], syncType) createPram.ParamList = nil param = make([]domain585.AlibabaWdkSkuAddSkuDo, 0, 0) } } + globals.SugarLogger.Debugf("vendorSkuIdMap=====err := %v", utils.Format4Output(vendorSkuIdMap, false)) + for _, v := range storeSkuList { + if k, ok := vendorSkuIdMap[utils.Int2Str(v.SkuID)]; ok { + v.VendorSkuID = k + } + } + globals.SugarLogger.Debugf("storeSkuList=====err := %s", utils.Format4Output(storeSkuList, false)) + globals.SugarLogger.Debugf("createTaoVegetable=====err := %v", err) globals.SugarLogger.Debugf("createTaoVegetable=====err := %v", failedList) return failedList, nil @@ -685,12 +703,12 @@ func (p *PurchaseHandler) GetSensitiveWordRegexp() *regexp.Regexp { // SelectStoreSkuListByFoodList 淘宝批量返回 func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []tao_vegetable.VegetableResultList, storeID int, vendorName, syncType string) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr, successMap map[string]string) { - foodMap := make(map[string]string) + foodMap := make(map[string]string, len(foodList)) + successMap = make(map[string]string) if len(foodList) > 0 { for _, v := range foodList { - if v.ProductID == "" { - foodMap[v.SkuID] = v.ErrMsg - } else { + foodMap[v.SkuID] = v.ErrMsg + if v.ProductID != "" { successMap[v.SkuID] = v.ProductID } } diff --git a/business/partner/purchase/tao_vegetable/tao.go b/business/partner/purchase/tao_vegetable/tao.go index 4252ad6b5..77a5278f8 100644 --- a/business/partner/purchase/tao_vegetable/tao.go +++ b/business/partner/purchase/tao_vegetable/tao.go @@ -213,6 +213,14 @@ func getAPI(appOrgCode string, storeID int, vendorStoreID string) (apiObj *tao_v if appOrgCode == "" { globals.SugarLogger.Debugf("getAPI appOrgCode is empty") } - apiObj = partner.CurAPIManager.GetAPI(model.VendorIDTaoVegetable, appOrgCode).(*tao_vegetable.API) + if appOrgCode != "" { + apiObj = partner.CurAPIManager.GetAPI(model.VendorIDTaoVegetable, appOrgCode).(*tao_vegetable.API) + } else if appOrgCode == "" && vendorStoreID != "" { + apiObj = partner.CurAPIManager.GetAPI(model.VendorIDTaoVegetable, getStoreVendorOrgCodeByVendorStoreID(vendorStoreID)).(*tao_vegetable.API) + } else if appOrgCode == "" && storeID != 0 { + apiObj = partner.CurAPIManager.GetAPI(model.VendorIDTaoVegetable, getStoreVendorOrgCode(storeID)).(*tao_vegetable.API) + } else { + apiObj = nil + } return apiObj } diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index 67d7542ff..82a0d6653 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -227,6 +227,7 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s ascription, err := ascription_place.Find(order.ConsigneeMobile) if err != nil { order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + err.Error() + err = nil } else { if strings.Contains(order.ConsigneeAddress, ascription.Province) && strings.Contains(order.ConsigneeAddress, ascription.City) { order.PhoneAscription = model.PhoneAscriptionAddressYes + "-" + ascription.Province + ascription.City