diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 3079a8908..535c8cd89 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -210,6 +210,15 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m } } } + + // 目前存在当订单为平台自配送时,本地储存新订单的结算信息是包含了配送费的!所以结算信息不对! + // 修改为订单完成时更新订单的结算信息 + settlementAmount, err3 := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).GetOrderSettleAccounts(order) + if err3 == nil && settlementAmount != model.NO { + order.TotalShopMoney = settlementAmount + dao.UpdateEntity(db, order, "TotalShopMoney") + } + //更新订单new_earning_price if order.EarningType == model.EarningTypePoints { waybill, _ := c.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID) @@ -239,6 +248,9 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m } } } + // 刷新订单结束时间 + order.OrderFinishedAt = time.Now() + dao.UpdateEntity(db, order, "OrderFinishedAt") } else if orderStatus.Status == model.OrderStatusCanceled { //如果取消订单则要把库存加回去 if order, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == nil { @@ -2509,7 +2521,20 @@ func UpdateTiktokShopTotalMoney() { } nextStartIndex = next v.TotalShopMoney = totalShopMoney - if _, err := dao.UpdateEntity(db, v, "TotalShopMoney"); err != nil { + if v.EarningType == model.EarningTypePoints { + waybill, _ := partner.CurOrderManager.LoadWaybill(v.VendorWaybillID, v.WaybillVendorID) + // store, _ := c.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID) + if waybill == nil { + if (v.NewEarningPrice == 0 || v.NewEarningPrice != v.TotalShopMoney*int64(100-v.OrderPayPercentage/2)/int64(100)) && v.OrderPayPercentage <= 50 { + v.NewEarningPrice = v.TotalShopMoney * int64(100-v.OrderPayPercentage/2) / int64(100) + } + } else { + if (v.NewEarningPrice == 0 || v.NewEarningPrice != (v.TotalShopMoney-waybill.DesiredFee)*int64(100-v.OrderPayPercentage/2)/int64(100)) && v.OrderPayPercentage <= 50 { + v.NewEarningPrice = v.TotalShopMoney*int64(100-v.OrderPayPercentage/2)/int64(100) - waybill.DesiredFee + } + } + } + if _, err := dao.UpdateEntity(db, v, "TotalShopMoney", "NewEarningPrice"); err != nil { globals.SugarLogger.Errorf("更新本地订单结算信息错误 : %s", err) continue } diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 224f2f734..b5ba39178 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -882,9 +882,27 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID if toTime.Sub(fromTime).Hours() > 24 { isLongTime = true } + + if len(storeIDList) >= 2 { + globals.SugarLogger.Errorf("GetStoresOrderSaleInfoNew err : [%v]", storeIDList) + } + + // 获取门店绑定美团的详情,是否为服务商. + // 如果是服务商将不再统计美团的订单!其他平台正常统计! + storeMapList, err := dao.GetStoresMapList2(db, []int{model.VendorIDMTWM}, storeIDList, nil, model.StoreStatusAll, 0, "", "", "", false) + if err != nil { + return nil, err + } + isService := 0 + if len(storeMapList) > 0 { + for _, v := range storeMapList { + isService = v.IsService + } + } + orderIDMap := make(map[string]struct{}) var vendorOrderIDs []string - orderSkuList, err := dao.GetStoreOrderSkuList(db, storeIDList, fromTime, toTime, statusList, true) + orderSkuList, err := dao.GetStoreOrderSkuList(db, storeIDList, fromTime, toTime, statusList, true, isService) if err != nil { return nil, err } @@ -900,13 +918,7 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID afsSkuList, err = dao.GetStoreAfsOrderSkuList2(db, vendorOrderIDs) orderSkuList4Afs, err = dao.GetStoreOrderSkuList4Afs2(db, vendorOrderIDs) } - //afsSkuList, err := dao.GetStoreAfsOrderSkuList(db, storeIDList, fromTime, toTime, []int{model.AfsOrderStatusFinished}, true) - //if err != nil { - // return nil, err - //} - //if err != nil { - // return nil, err - //} + orderSkuHandler := func(skuList []*dao.OrderSkuWithActualPayPrice) (orderMap map[string]*model.GoodsOrder, orderSkuMap map[string]*dao.OrderSkuWithActualPayPrice, saleInfoMap map[int64]*dao.StoresOrderSaleInfo) { orderMap = make(map[string]*model.GoodsOrder) orderSkuMap = make(map[string]*dao.OrderSkuWithActualPayPrice) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index b0e06ba64..128b0f34b 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -799,7 +799,8 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo // } // 将订单修改为完成状态 order.Status = model.OrderStatusFinished - partner.CurOrderManager.UpdateOrderFields(order, []string{"status"}) + order.OrderFinishedAt = time.Now() + partner.CurOrderManager.UpdateOrderFields(order, []string{"status", "OrderFinishedAt"}) default: s.resetTimer(savedOrderInfo, bill, isPending) } diff --git a/business/jxstore/cms/sync2.go b/business/jxstore/cms/sync2.go index 331a34ee7..800ca15cf 100644 --- a/business/jxstore/cms/sync2.go +++ b/business/jxstore/cms/sync2.go @@ -38,8 +38,6 @@ func getMultiStoreVendorInfoList() (list []*MultiStoreVendorInfo) { }) } } - globals.SugarLogger.Debugf("======vendorIDs======= %s", utils.Format4Output(vendorIDs, false)) - globals.SugarLogger.Debugf("======list======= %s", utils.Format4Output(list, false)) return list } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index b81e30658..b62ac023c 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -581,7 +581,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag // 修改商品信息时不改价(以免活动引起的失败),而用单独的改价来改 if (model.IsSyncStatusUpdate(sku.SkuSyncStatus) || (model.IsSyncStatusSeq(sku.SkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil { if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB && vendorID != model.VendorIDDD { - globals.SugarLogger.Warnf("syncStoreSkuNew 修改门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID) + globals.SugarLogger.Warnf("syncStoreSkuNew 修改门店:%d商品:%d平台:%d,但没有平台分类ID", storeID, sku.SkuID, sku.VendorID) } else { isAdded2Update = true updateList = append(updateList, calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage))) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 7c85a0fcb..f24f72715 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -205,6 +205,11 @@ func Init() { delivery.UpdateFakeWayBillToTiktok() }, 10*time.Second, 5*time.Second) + // 抖音自动刷单 + ScheduleTimerFuncByInterval(func() { + delivery.AutoSettingFakeDelivery() + }, 10*time.Second, 5*time.Second) + // 定时任务更新负责人信息 ScheduleTimerFunc("RefreshStoreOperator", func() { cms.UpdateStoreOperatorConfig() diff --git a/business/jxutils/enterprise_msg/enterprise_send_msg.go b/business/jxutils/enterprise_msg/enterprise_send_msg.go index adf659e61..9e7da1b83 100644 --- a/business/jxutils/enterprise_msg/enterprise_send_msg.go +++ b/business/jxutils/enterprise_msg/enterprise_send_msg.go @@ -1,7 +1,6 @@ package enterprise_msg import ( - "fmt" enterprise "git.rosy.net.cn/baseapi/platformapi/enterprise_wechat" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" @@ -42,21 +41,21 @@ func SendUserMessage(phone, title, description, url string) error { return err } for _, v := range userList { - if v.Mobile == "" { - api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{ - Touser: "ShiFeng", - Msgtype: enterprise.MsgTypeText, - Agentid: enterprise.EnterpriseAgentid, - Text: struct { - Content string `json:"content"` - }{Content: fmt.Sprintf("用户[%s]未添加企业微信联系电话,请联系添加电话号码[企业微信联系电话与京西系统保持一致!]", v.Name)}, - Safe: 0, - EnableIdTrans: 0, - EnableDuplicateCheck: 0, - DuplicateCheckInterval: 0, - }) - continue - } + //if v.Mobile == "" { + // api.EnterpriseChatMin.SendMsgToUserTypeText(&enterprise.SendTextMsgReq{ + // Touser: "ShiFeng", + // Msgtype: enterprise.MsgTypeText, + // Agentid: enterprise.EnterpriseAgentid, + // Text: struct { + // Content string `json:"content"` + // }{Content: fmt.Sprintf("用户[%s]未添加企业微信联系电话,请联系添加电话号码[企业微信联系电话与京西系统保持一致!]", v.Name)}, + // Safe: 0, + // EnableIdTrans: 0, + // EnableDuplicateCheck: 0, + // DuplicateCheckInterval: 0, + // }) + // continue + //} if v.Mobile == phone { enterpriseUserId = v.Userid } diff --git a/business/jxutils/tasksch/task.go b/business/jxutils/tasksch/task.go index 98b9dd598..ae2df0469 100644 --- a/business/jxutils/tasksch/task.go +++ b/business/jxutils/tasksch/task.go @@ -511,7 +511,6 @@ func SendMessage(t *BaseTask) { } if err := ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content); err != nil { - globals.SugarLogger.Errorf("==============errr ddd %v", err) err2 := enterprise_msg.SendUserMessage(authInfo.Mobile, "异步任务完成", "", content) globals.SugarLogger.Errorf("==============errr ddd %v", err2) } diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index b31e44f3c..80901c0f8 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -376,8 +376,7 @@ func GetAfsOrderSkuInfo(db *DaoDB, vendorOrderID, afsOrderID string, vendorID in return skus, err } -func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAtEnd time.Time, statusList []int, isFinish bool) (skuList []*OrderSkuWithActualPayPrice, err error) { - // order_finished_at +func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAtEnd time.Time, statusList []int, isFinish bool, isService int) (skuList []*OrderSkuWithActualPayPrice, err error) { sql := ` SELECT t1.*, IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id, t2.status, t2.actual_pay_price, t2.distance_freight_money, t2.waybill_tip_money, t2.new_earning_price, @@ -403,6 +402,11 @@ func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAt sql += " AND t2.status IN (" + GenQuestionMarks(len(statusList)) + ")" sqlParams = append(sqlParams, statusList) } + if isService == model.YES { + sql += "AND t2.vendor_id <> ?" + sqlParams = append(sqlParams, model.VendorIDMTWM) + } + err = GetRows(db, &skuList, sql, sqlParams...) return skuList, err } @@ -1814,3 +1818,45 @@ func GetOrderStoreIDs(db *DaoDB, beginAt, endAt time.Time, vendorID int) (storeI } return storeIDs, err } + +// GetOrderListByStoreList 根据门店id获取正在刷单的门店商品 +func GetOrderListByStoreList(db *DaoDB, storeId []int64) (order []*model.GoodsOrder, err error) { + sql := `SELECT * FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? g.vendor_store_id IN (` + GenQuestionMarks(len(storeId)) + `)` + `AND g.vendor_id = ? AND g.status < ?` + sqlParam := []interface{}{time.Now().AddDate(0, 0, -7), time.Now(), storeId, model.VendorIDDD, model.OrderStatusDelivering} + + if err := GetRows(db, &order, sql, sqlParam...); err != nil { + return nil, err + } + + return order, nil +} + +type CourierInfo struct { + CourierName string `json:"courier_name"` + CourierMobile string `json:"courier_mobile"` +} + +// 获取同区域的骑手信息 +func GetAddressRiderInfo(db *DaoDB, address string, randNumber int64) (*CourierInfo, error) { + sql := ` + SELECT w.courier_name,w.courier_mobile FROM goods_order s + LEFT JOIN waybill w ON s.vendor_order_id = w.vendor_order_id AND w.courier_name <>"" AND w.courier_mobile <>"" + WHERE s.order_created_at >= ? AND s.status = ? AND s.delivery_type = ? AND s.consignee_address LIKE ? + LIMIT ?,? ` + param := []interface{}{time.Now().AddDate(0, -3, 0), model.OrderStatusFinished, model.OrderDeliveryTypePlatform, "%" + fmt.Sprintf("%s", address) + "%", randNumber, 1} + + courier := &CourierInfo{} + if err := GetRow(db, courier, sql, param); err != nil { + return nil, err + } + + if courier.CourierName == "" || courier.CourierMobile == "" { + info, err := GetAddressRiderInfo(db, address, randNumber+1) + if err != nil { + return nil, err + } + return info, err + } + + return courier, nil +} diff --git a/business/model/dao/dao_order_test.go b/business/model/dao/dao_order_test.go index 4159d38cd..d5871641c 100644 --- a/business/model/dao/dao_order_test.go +++ b/business/model/dao/dao_order_test.go @@ -24,13 +24,13 @@ func TestGetAfsOrderSkuInfo(t *testing.T) { } func TestGetStoreOrderSkuList(t *testing.T) { - skuList, err := GetStoreOrderSkuList(GetDB(), []int{100118}, time.Now().Add(-30*time.Hour), time.Now(), nil, false) + skuList, err := GetStoreOrderSkuList(GetDB(), []int{100118}, time.Now().Add(-30*time.Hour), time.Now(), nil, false, 1) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(skuList, false)) - afsSkuList, err := GetStoreOrderSkuList(GetDB(), []int{100118}, time.Now().Add(-30*time.Hour), time.Now(), nil, false) + afsSkuList, err := GetStoreOrderSkuList(GetDB(), []int{100118}, time.Now().Add(-30*time.Hour), time.Now(), nil, false, 1) if err != nil { t.Fatal(err) } diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 649908a28..9ae29652c 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -7,8 +7,6 @@ import ( "strings" "time" - "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" @@ -207,7 +205,6 @@ func GetStoreDetailByVendorStoreID(db *DaoDB, vendorStoreID string, vendorID int if storeDetail, err = getStoreDetail(db, int(utils.Str2Int64WithDefault(vendorStoreID, 0)), vendorID, "", vendorOrgCode); err == nil { storeDetail.VendorStoreID = vendorStoreID } - globals.SugarLogger.Debugf("GetStoreDetailByVendorStoreID storeDetail ====%s", utils.Format4Output(storeDetail, false)) return storeDetail, err } diff --git a/business/model/dao/thing_map.go b/business/model/dao/thing_map.go index 2eafc33c1..24bf0b549 100644 --- a/business/model/dao/thing_map.go +++ b/business/model/dao/thing_map.go @@ -83,7 +83,7 @@ func GetThingToTiktokMapList(db *DaoDB, vendorId int, thingId int64, vendorOrgCo // DeleteThingToTiktokMapList 删除同步关联关系 func DeleteThingToTiktokMapList(vendorId int, vendorThingId string, skuId int) error { - sql := ` DELETE FROM thing_map t1 WHERE vendor_thing_id = ? AND vendor_id = ? AND thing_id = ? ` + sql := ` DELETE FROM thing_map WHERE vendor_thing_id = ? AND vendor_id = ? AND thing_id = ? ` param := []interface{}{vendorThingId, vendorId, skuId} _, err := ExecuteSQL(GetDB(), sql, param...) return err diff --git a/business/model/store.go b/business/model/store.go index f0b292cff..d7f665eb0 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -492,6 +492,7 @@ type StoreMap struct { DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //在vendorID=14,存储打包费 DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争 CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单 + IsService int `orm:"default(0)" json:"isService"` // 默认0非服务商,1服务商 SyncStatus int8 `orm:"default(2)" json:"syncStatus"` IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步 diff --git a/business/partner/delivery/rider.go b/business/partner/delivery/rider.go index c5f276195..be90ae39d 100644 --- a/business/partner/delivery/rider.go +++ b/business/partner/delivery/rider.go @@ -3,7 +3,11 @@ package delivery import ( "crypto/rand" "fmt" + "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" + "git.rosy.net.cn/jx-callback/business/jxutils" + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "math/big" + "strings" "time" "git.rosy.net.cn/baseapi/platformapi/mtpsapi" @@ -322,3 +326,44 @@ func UpdateFakeWayBillToTiktok() { } } + +// AutoSettingFakeDelivery 自动设置骑手, 推送假订单 +func AutoSettingFakeDelivery() { + db := dao.GetDB() + // 查询需要刷单的门店 + configList, err := dao.QueryConfigs(db, "storeIdList", "AutoDelivery", "") + if err != nil { + globals.SugarLogger.Errorf("抖音自动刷单获取刷单门店列表错误:%v", err) + return + } + if len(configList) != model.YES { + globals.SugarLogger.Errorf("newConfig 刷单门店设置异常") + return + } + + // 获取刷单门店订单 + orderList, err := dao.GetOrderListByStoreList(db, utils.StringSlice2Int64(strings.Split(configList[0].Value, ","))) + if err != nil { + globals.SugarLogger.Errorf("获取门店刷单记录错误") + return + } + + for _, v := range orderList { + jxutils.CallMsgHandler(func() { + // 1.根据订单客户地址获取骑手列表 + randNumber, _ := rand.Int(rand.Reader, big.NewInt(200)) + randTime := randNumber.Int64() + riderInfo, err := dao.GetAddressRiderInfo(db, strings.Split(v.ConsigneeAddress, "市")[0], randTime) + if err != nil { + globals.SugarLogger.Errorf("自动获取骑手信息错误:[%v]", err) + return + } + // 自动发单 + if err := defsch.FixedScheduler.SelfDeliveringAndUpdateStatus(jxcontext.AdminCtx, v.VendorOrderID, v.VendorID, jxcontext.AdminCtx.GetUserName(), riderInfo.CourierName, riderInfo.CourierMobile); err != nil { + globals.SugarLogger.Errorf("自动发货错误:[%v]", err) + return + } + }, jxutils.ComposeUniversalOrderID(v.VendorOrderID, model.VendorIDDD)) + } + +} diff --git a/business/partner/partner_order.go b/business/partner/partner_order.go index dbf11572f..8eaf6bc3e 100644 --- a/business/partner/partner_order.go +++ b/business/partner/partner_order.go @@ -89,6 +89,9 @@ type IPurchasePlatformOrderHandler interface { ComplaintRider(vendorOrderId string, resonID int, resonContent string) (err error) //推送订单骑手信息 GetOrderRider(vendorOrgCode, vendorStoreID string, param map[string]interface{}) (err error) + + // 获取各个平台订单的结算信息 + GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) } type IAddWaybillTip interface { diff --git a/business/partner/printer/feie/feie.go b/business/partner/printer/feie/feie.go index 7452468c8..f23ed0437 100644 --- a/business/partner/printer/feie/feie.go +++ b/business/partner/printer/feie/feie.go @@ -350,7 +350,7 @@ func (c *PrinterHandler) PrintOrder(ctx *jxcontext.Context, store *model.Store, return } content := "" - if store.PrinterFontSize == partner.PrinterFontSizeBig { + if store.PrinterFontSize == partner.PrinterFontSizeBig || store.PrinterFontSize == partner.PrinterFontSizeBig2 { content = c.getOrderContentBig(order, store.Tel1, storeDetail) } else { content = c.getOrderContent(order, store.Tel1, storeDetail) diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 5eea2f695..b488a10f4 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -786,3 +786,14 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + orderInfo, err := api.EbaiAPI.OrderGet(order.VendorOrderID) + if err != nil { + return 0, err + } + orderMap := orderInfo["order"].(map[string]interface{}) + + return utils.ForceInterface2Int64(orderMap["shop_fee"]), nil +} diff --git a/business/partner/purchase/elm/order.go b/business/partner/purchase/elm/order.go index becd7c62e..598e3872f 100644 --- a/business/partner/purchase/elm/order.go +++ b/business/partner/purchase/elm/order.go @@ -344,3 +344,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index b53a21d67..bfac7e806 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -660,3 +660,12 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(goods *model.GoodsOrder) (int64, error) { + settlement, err := getAPI(goods.VendorOrgCode).OrderShoudSettlementService2(goods.VendorOrderID) + if err != nil { + return 0, err + } + return settlement.SettlementAmount, nil +} diff --git a/business/partner/purchase/jdshop/order.go b/business/partner/purchase/jdshop/order.go index e424e12ca..cd16bac49 100644 --- a/business/partner/purchase/jdshop/order.go +++ b/business/partner/purchase/jdshop/order.go @@ -328,3 +328,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/jx/order.go b/business/partner/purchase/jx/order.go index 71af88f8e..ec82bfbcd 100644 --- a/business/partner/purchase/jx/order.go +++ b/business/partner/purchase/jx/order.go @@ -155,3 +155,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 9418ab187..21e5bcbd7 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -849,3 +849,20 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + oderDetail, err := getAPI(order.VendorOrgCode, 0, order.VendorStoreID).OrderGetOrderDetail(utils.Str2Int64(order.VendorOrderID), true) + if err != nil { + return 0, err + } + + if poiReceiveDetailStr := utils.Interface2String(oderDetail["poi_receive_detail"]); poiReceiveDetailStr != "" { + var poiReceiveDetail *mtwmapi.PoiReceiveDetailInfo + utils.UnmarshalUseNumber([]byte(poiReceiveDetailStr), &poiReceiveDetail) + if poiReceiveDetail != nil { + return poiReceiveDetail.WmPoiReceiveCent, nil + } + } + return 0, nil +} diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 1b95a38fc..f5946f3eb 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -2,9 +2,6 @@ package mtwm import ( "encoding/json" - "regexp" - "strings" - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" @@ -15,6 +12,8 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" + "regexp" + "strings" ) const ( @@ -163,30 +162,19 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in storeCat.CatSyncStatus |= model.SyncFlagNewMask err = p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat) } + + // 门店内存在重复的分类:【柑桔柚类】 【底料】,请先删除重复分类后再操作。 if err != nil && strings.Contains(err.Error(), "门店内存在重复的分类:") { - globals.SugarLogger.Debugf("==========err %s", err.Error()) - storeCategoryList, err2 := api.RetailCatList(vendorStoreID) - globals.SugarLogger.Debugf("==========err2 %v", err2) - globals.SugarLogger.Debugf("==========err %s", utils.Format4Output(storeCategoryList, false)) - if err2 != nil { - err = err2 - } else { - for _, v := range storeCategoryList { - globals.SugarLogger.Debugf("storeCategoryList==========err %s", err.Error()) - if len(v.Children) > 0 { - for _, c := range v.Children { - if strings.Contains(c.Name, err.Error()) { - api.RetailCatDelete(vendorStoreID, "", c.Name) - } - } - } - if strings.Contains(v.Name, err.Error()) { - api.RetailCatDelete(vendorStoreID, "", v.Name) + for _, v := range deleteRepeatCat(err.Error()) { + if len(v) > 0 { + if err2 := api.RetailCatDelete(vendorStoreID, "", v, model.YES); err != nil { + globals.SugarLogger.Errorf("RetailCatDelete delete err : [%v]", err2) } } } } } + if err == nil { // storeCat.VendorCatID = utils.FilterEmoji(storeCat.Name) storeCat.VendorCatID = utils.Int2Str(storeCat.ID) @@ -194,6 +182,40 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in return err } +// deleteRepeatCat 门店内存在重复的分类:【柑桔柚类】 【底料】 【火锅】,请先删除重复分类后再操作。 +func deleteRepeatCat(param string) []string { + firstIndex := strings.Index(param, "【") + lastIndex := strings.LastIndex(param, "】") + newParam := param[firstIndex:lastIndex] + deleteCat := make([]string, 0, 0) + for _, v := range strings.Split(newParam, "【") { + if strings.TrimSpace(v) == "" { + continue + } else if strings.Contains(v, "【") { + for _, v2 := range strings.Split(v, "【") { + if strings.TrimSpace(v) == "" { + continue + } + if strings.TrimSpace(v2) != "" { + deleteCat = append(deleteCat, v2) + } + } + } else if strings.Contains(v, "】") { + for _, v3 := range strings.Split(v, "】") { + if strings.TrimSpace(v3) == "" { + continue + } + if strings.TrimSpace(v3) != "" { + deleteCat = append(deleteCat, v3) + } + } + } else { + deleteCat = append(deleteCat, v) + } + } + return deleteCat +} + func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { return p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat) } @@ -201,7 +223,7 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) { if false { if globals.EnableMtwmStoreWrite { - err = getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID).RetailCatDelete(vendorStoreID, tryCatName2Code(vendorCatID), vendorCatID) + err = getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID).RetailCatDelete(vendorStoreID, tryCatName2Code(vendorCatID), vendorCatID, model.NO) } } else { var catCodes []string diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index 0edff175d..7ee79a71e 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -27,7 +27,6 @@ const ( // OnOrderMsg 抖音 func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackResponse) { - globals.SugarLogger.Debugf("guoyuan %s,%s", msgId, utils.Format4Output(msg, false)) if CurPurchaseHandler != nil { orderId, shopId, _ := api.TiktokStore.GetCallbackOrderId(msgId, msg) globals.SugarLogger.Debugf("order_id %s,%d", orderId, shopId) diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index 4d2e649d3..1f0c436ca 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -87,25 +87,24 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s } orderMap = result order = &model.GoodsOrder{ - VendorOrderID: result.OrderId, - VendorID: model.VendorIDDD, - VendorStoreID: "", - StoreID: 0, - CoordinateType: model.CoordinateTypeMars, - BuyerComment: result.BuyerWords, - ExpectedDeliveredTime: getTimeFromTimestamp(result.EarliestReceiptTime + 30*60), // 预计最晚送达时间 - PickDeadline: utils.DefaultTimeValue, - VendorStatus: utils.Int64ToStr(result.OrderStatus), //1待支付/103部分支付/105已支付/2备货中/101部分发货/3已发货/4取消/完成/21发货前退款完成/22发货后退款/39收货后退款 - OrderSeq: 0, - StatusTime: getTimeFromTimestamp(result.CreateTime), - OrderCreatedAt: getTimeFromTimestamp(result.CreateTime), - OriginalData: string(utils.MustMarshal(result)), - ActualPayPrice: result.PayAmount, - BaseFreightMoney: result.PostAmount, - InvoiceTitle: "", - InvoiceTaxerID: "", - InvoiceEmail: "", - VendorOrgCode: vendorOrgCode, + VendorOrderID: result.OrderId, + VendorID: model.VendorIDDD, + VendorStoreID: "", + StoreID: 0, + CoordinateType: model.CoordinateTypeMars, + BuyerComment: result.BuyerWords, + PickDeadline: utils.DefaultTimeValue, + VendorStatus: utils.Int64ToStr(result.OrderStatus), //1待支付/103部分支付/105已支付/2备货中/101部分发货/3已发货/4取消/完成/21发货前退款完成/22发货后退款/39收货后退款 + OrderSeq: 0, + StatusTime: getTimeFromTimestamp(result.CreateTime), + OrderCreatedAt: getTimeFromTimestamp(result.CreateTime), + OriginalData: string(utils.MustMarshal(result)), + ActualPayPrice: result.PayAmount, + BaseFreightMoney: result.PostAmount, + InvoiceTitle: "", + InvoiceTaxerID: "", + InvoiceEmail: "", + VendorOrgCode: vendorOrgCode, } if result.FinishTime != 0 { @@ -195,18 +194,27 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s globals.SugarLogger.Debugf("平台门店未绑定到京西系统 %s", err.Error()) return nil, nil, err } - // 订单不在门店营业时间来的订单, - openTime := localStore.OpenTime1 // 门店开始营业时间 - closeTime := localStore.CloseTime1 // 门店结束营业时间 - if localStore.CloseTime2 != 0 { - closeTime = localStore.CloseTime2 - } - h, m, _ := order.ExpectedDeliveredTime.Clock() - if order.ExpectedDeliveredTime.Day() == time.Now().Day() && utils.Str2Int16(fmt.Sprintf("%d%d", h, m)) >= openTime && utils.Str2Int16(fmt.Sprintf("%d%d", h, m)) < closeTime && localStore.Status == model.StoreStatusOpened { + // 订单不在门店营业时间来的订单, + //openTime := localStore.OpenTime1 // 门店开始营业时间 + //closeTime := localStore.CloseTime1 // 门店结束营业时间 + //if localStore.CloseTime2 != 0 { + // closeTime = localStore.CloseTime2 + //} + // + //h, m, _ := order.ExpectedDeliveredTime.Clock() + //if order.ExpectedDeliveredTime.Day() == time.Now().Day() && utils.Str2Int16(fmt.Sprintf("%d%d", h, m)) >= openTime && utils.Str2Int16(fmt.Sprintf("%d%d", h, m)) < closeTime && localStore.Status == model.StoreStatusOpened { + // order.BusinessType = model.BusinessTypeImmediate + //} else { + // order.BusinessType = model.BusinessTypeDingshida + //} + + if result.EarlyArrival { // 立即达 order.BusinessType = model.BusinessTypeImmediate - } else { + order.ExpectedDeliveredTime = getTimeFromTimestamp(result.TargetArrivalTime + 30*60) // 预计最晚送达时间 + } else { // 定时达 order.BusinessType = model.BusinessTypeDingshida + order.ExpectedDeliveredTime = getTimeFromTimestamp(result.EarliestReceiptTime + 30*60) // 预计最晚送达时间 } // 用户保密信息脱敏 @@ -1030,3 +1038,8 @@ func GetOrderTotalShopMoney(appOrgCode string, orderIds string, nextStartIndex s func GetOrderDetail(appOrgCode, vendorOrderID string) (*order_orderDetail_response.ShopOrderDetail, error) { return getAPI(appOrgCode, 0, "").GetTiktokOrderDetail(vendorOrderID) } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 138433a29..57ca83921 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -152,21 +152,25 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if len(localThing) == 0 { if err := dao.CreateThingMap(int64(storeSku.SkuID), utils.Int64ToStr(time.Now().Unix()), storeDetail.VendorOrgCode, "本地不存在,线上也不存在", model.ThingTypeSku, model.ThingTypeSyncing); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 continue } param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType) if len(failedList2) != 0 { + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 failedList = append(failedList, failedList2...) continue } tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 if err != nil { dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } if err := dao.UpdateThingMap(db, model.ThingTypeSyncSuccess, utils.Int64ToStr(tiktokResult.ProductId), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode); err != nil { + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } @@ -190,12 +194,14 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品 if err != nil { + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode) failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } if err := dao.UpdateThingMap(db, model.ThingTypeSyncSuccess, utils.Int64ToStr(tiktokResult.ProductId), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode); err != nil { + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } @@ -214,6 +220,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if time.Now().Unix()-localThing[0].CreatedAt.Unix() > 300 { dao.DeleteThingToTiktokMapList(model.VendorIDDD, localThing[0].VendorThingID, storeSku.SkuID) } + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 + failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("商品同步中或同步错误"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } else if localThing[0].SyncStatus == model.ThingTypeSyncSuccess { // 主商品存在,直接同步子商品 @@ -249,15 +257,16 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI updateParam.Pic = param.Pic updateParam.Description = param.Description updateParam.WeightUnit = tiktokShop.WeightUint_G - updateParam.StandardBrandId, err = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, updateParam.CategoryLeafId) updateParam.ProductId = mainOrderDetail.ProductId updateParam.MainProductId = mainProductId updateParam.SpecPrices = param.SpecPrices + updateParam.StandardBrandId = param.StandardBrandId if err2 := api.EditStoreCommodity(updateParam); err2 != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err2, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) } + storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做 failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改主品,主品审核中/失败,子商品未创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue } @@ -368,8 +377,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } // 获取商品的属性 - if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" { - param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) + if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" || storeSku.UpcTiktokBrandId == "" { + param.ProductFormatNew, param.StandardBrandId, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId) if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) continue @@ -378,7 +387,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI param.ProductFormatNew = storeSku.TiktokAttribute } // 获取品牌 - param.StandardBrandId = 789194134 // 默认品牌京西菜市 + if param.StandardBrandId == 0 { + param.StandardBrandId, _ = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId) + } + if param.StandardBrandId == 0 { + param.StandardBrandId = 596120136 // 无品牌 + } // 修改商品 param.ProductId = mainIdInt @@ -454,22 +468,22 @@ func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreS // spec_prices param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku) // 获取商品的属性 - if storeSku.TiktokAttribute != "" && storeSku.TiktokAttribute != "{}" { - param.ProductFormatNew = storeSku.TiktokAttribute - } else if storeSku.VendorSkuAttrId != "" && storeSku.VendorSkuAttrId != "{}" { + if storeSku.TiktokAttribute != "" && storeSku.TiktokAttribute != "{}" && storeSku.UpcTiktokBrandId != "" { param.ProductFormatNew = storeSku.TiktokAttribute } else { - param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) + param.ProductFormatNew, param.StandardBrandId, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId) + //param.ProductFormatNew, err = MakeProductFormatNew(api, int64(storeSku.NameID), param.CategoryLeafId) if err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) return } } - param.StandardBrandId, err = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId) - if err != nil { - failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) - return + if param.StandardBrandId == 0 { + param.StandardBrandId, _ = getTiktokBrandId(api, db, storeSku.Upc, storeSku.UpcBrandName, storeSku.UpcTiktokBrandId, param.CategoryLeafId) + } + if param.StandardBrandId == 0 { + param.StandardBrandId = 596120136 } param.FreightId, param.SaleLimitId, err = getFreightIdAndSaleLimitId(api, db, storeDetail, vendorStoreID) @@ -481,12 +495,23 @@ func makeMainProductSku(db *dao.DaoDB, api *tiktokShop.API, storeSku *dao.StoreS } func getTiktokBrandId(api *tiktokShop.API, db *dao.DaoDB, upc, upcBrandName, upcTiktokBrandId string, categoryLeafId int64) (int64, error) { + globals.SugarLogger.Debugf("upc:%s,upcBrandName:%s,upcTiktokBrandId:%s,categoryLeafId:%d", upc, upcBrandName, upcTiktokBrandId, categoryLeafId) if upc == "" { // 默认品牌京西菜市 596120136 return 596120136, nil } else if upc != "" && upcBrandName != "" && upcTiktokBrandId != "" { return utils.Str2Int64(upcTiktokBrandId), nil } else if upc != "" && upcBrandName != "" && upcTiktokBrandId == "" { - standardBrandId, err := api.GetSkuBrand(categoryLeafId, upcBrandName) + brandName := upcBrandName + if strings.Contains(brandName, "/") { + brandName = strings.Split(brandName, "/")[0] + } + if strings.Contains(brandName, "(") { + brandName = strings.Split(brandName, "(")[0] + } + if strings.Contains(brandName, "(") { + brandName = strings.Split(brandName, "(")[0] + } + standardBrandId, err := api.GetSkuBrand(categoryLeafId, brandName) if err != nil { return 0, err } @@ -497,6 +522,15 @@ func getTiktokBrandId(api *tiktokShop.API, db *dao.DaoDB, upc, upcBrandName, upc if err != nil { return 0, err } + if strings.Contains(brandName, "/") || strings.Contains(brandName, "(") || strings.Contains(brandName, "(") { + brandName = strings.Split(brandName, "/")[0] + } + if strings.Contains(brandName, "(") { + brandName = strings.Split(brandName, "(")[0] + } + if strings.Contains(brandName, "(") { + brandName = strings.Split(brandName, "(")[0] + } standardBrandId, err := api.GetSkuBrand(categoryLeafId, brandName) if err != nil { return 0, err @@ -907,19 +941,21 @@ func GetTiktokImgList(api *tiktokShop.API, storeId, appOrgCode string, detailImg return strings.Join(tiktokImg, "|"), detailTiktok, nil } -func MakeProductFormatNew(api *tiktokShop.API, skuNameId int64, categoryLeafId int64) (string, error) { +func MakeProductFormatNew(api *tiktokShop.API, skuNameId int64, categoryLeafId int64, upcCode, upcBrandName, upcTiktokBrandId string) (string, int64, error) { + db := dao.GetDB() categoryList, err := api.GetCatePropertyV2(categoryLeafId) if err != nil { - return "", err + return "", 0, err } categoryMap := make(map[string][]map[string]interface{}) + tiktokBrandId, _ := getTiktokBrandId(api, db, upcCode, upcBrandName, upcTiktokBrandId, categoryLeafId) for _, v := range categoryList.Data.Data { if v.Required != model.YES { continue } options := make([]map[string]interface{}, 0) if v.PropertyName == "品牌" { - options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 789194134, "diy_type": v.DiyType}) + options = append(options, map[string]interface{}{"name": v.PropertyName, "value": tiktokBrandId, "diy_type": v.DiyType}) categoryMap[utils.Int64ToStr(v.PropertyId)] = options } else if v.PropertyName == "产地" { options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 13850, "diy_type": v.DiyType}) @@ -934,7 +970,7 @@ func MakeProductFormatNew(api *tiktokShop.API, skuNameId int64, categoryLeafId i } productFormatNew := utils.Format4Output(categoryMap, false) dao.UpdateSkuNameTiktokAttr(dao.GetDB(), skuNameId, productFormatNew) - return utils.Format4Output(categoryMap, false), nil + return utils.Format4Output(categoryMap, false), tiktokBrandId, nil } // GetSpecPrices 解析属性和规格参数 diff --git a/business/partner/purchase/weimob/wsc/order.go b/business/partner/purchase/weimob/wsc/order.go index ff960af92..787c3a925 100644 --- a/business/partner/purchase/weimob/wsc/order.go +++ b/business/partner/purchase/weimob/wsc/order.go @@ -313,3 +313,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/business/partner/purchase/yb/order.go b/business/partner/purchase/yb/order.go index e973e72fa..594f0f808 100644 --- a/business/partner/purchase/yb/order.go +++ b/business/partner/purchase/yb/order.go @@ -106,3 +106,8 @@ func (c *PurchaseHandler) CancelLogisticsByWmOrderId(order *model.GoodsOrder, re func (c *PurchaseHandler) OrderLogisticsStatus(orderId int64) (int64, error) { return 0, nil } + +// GetOrderSettleAccounts 获取订单结算信息 +func (c *PurchaseHandler) GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error) { + return 0, nil +} diff --git a/controllers/tiktok_order.go b/controllers/tiktok_order.go index 358e1dbc8..290f909ce 100644 --- a/controllers/tiktok_order.go +++ b/controllers/tiktok_order.go @@ -2,9 +2,7 @@ package controllers import ( "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" "strings" @@ -32,7 +30,6 @@ func (t *TiktokController) CallbackTiktokOrderMsg() { // 2.参数解析 orderStatus, resp := api.TiktokStore.CreateOrderCallback(byteList) - globals.SugarLogger.Debugf("orderStatus %s,%s", utils.Format4Output(orderStatus, false), utils.Format4Output(resp, false)) if resp.Code != 0 { t.Data["json"] = resp t.ServeJSON()