diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 844895e77..858a62124 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -73,13 +73,13 @@ func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, l lastHours = defLastHours } //权限 - if permission.IsRoled(ctx) { - if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil { - if storeIDsMap[storeID] == 0 { - storeID = -1 - } - } - } + //if permission.IsRoled(ctx) { + // if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil { + // if storeIDsMap[storeID] == 0 { + // storeID = -1 + // } + // } + //} db := dao.GetDB() sql := ` SELECT t1.lock_status, t1.status, COUNT(*) count diff --git a/business/jxcallback/scheduler/basesch/basesch_ext.go b/business/jxcallback/scheduler/basesch/basesch_ext.go index d2559c9dd..f7d01fead 100644 --- a/business/jxcallback/scheduler/basesch/basesch_ext.go +++ b/business/jxcallback/scheduler/basesch/basesch_ext.go @@ -35,6 +35,7 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order * excludeCourierVendorIDMap := jxutils.IntList2Map(excludeCourierVendorIDs) errList := errlist.New() + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) for _, storeCourier := range storeCourierList { switch storeCourier.Status { case model.YES: @@ -45,8 +46,12 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order * // 创建运单 bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee) if err = err2; err == nil { - bill.DesiredFee += model.WayBillDeliveryMarkUp - bill.ActualFee += model.WayBillDeliveryMarkUp + // 其实这个bill没啥用,运单的创建是通过回调产生的 + bill.DesiredFee += int64(model.WayBillDeliveryMarkUp + store.FreightMarkup) + if bill.WaybillVendorID == model.VendorIDFengNiao { + bill.DesiredFee += model.WayBillDeliveryMarkUp + } + bill.DesiredFee += int64(store.FreightMarkup) bills = append(bills, bill) if createOnlyOne { break diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index eb265e669..517342e93 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -884,7 +884,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf if err = s.canOrderCreateWaybillNormally(order, savedOrderInfo); err == nil { if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 { if savedOrderInfo.retryCount <= maxWaybillRetryCount { - var waybillVendorIDs = []int{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao, model.VendorIDUUPT} + var waybillVendorIDs = []int{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao, model.VendorIDUUPT, model.VendorIDSFPS} savedOrderInfo.isNeedCreate3rdWaybill = true excludeVendorIDs := savedOrderInfo.GetWaybillVendorIDs() //TODO 取消京西不自动发美团 2020-06-02 @@ -922,11 +922,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf //TODO 2020-07-21 发单时间要在门店的营业时间内 var storeDetail *dao.StoreDetail - //if savedOrderInfo.storeDetail != nil { - // storeDetail = savedOrderInfo.storeDetail - //} else { storeDetail, err = dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "") - //} if storeDetail != nil { if storeDetail.OpenTime1 != 0 && storeDetail.CloseTime1 != 0 { time1 := jxutils.JxOperationTime2TimeByDate(storeDetail.OpenTime1, time.Now()) @@ -947,12 +943,47 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf //1表示为门店发单,需要验证门店账户余额情况 _, err2 := s.CheckStoreBalance(jxcontext.AdminCtx, order, waybillVendorIDs) - //TODO 2021-02-19 增加品牌配送开关 - //TODO 2021-08-31 修改为每个平台的开关 - //if storeDetail.BrandIsOpen == model.YES { - // err = fmt.Errorf("此品牌已关闭配送! [%v]", storeDetail.BrandName) - //} if err == nil && err2 == nil { + // 1.检查门店三方配送配置,达达>蜂鸟>美团>顺丰>uu + // excludeVendorIDs 包括上面已经发送的平台id + storeCourierList, err := dao.GetStoreCourierList2(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, model.StoreStatusOpened, []int{model.StoreAuditStatusOnline, model.StoreAuditStatusUpdated}) + excludeVendorIDsMap := make(map[int]int, 0) // 被排除的配送 + for _, v := range excludeVendorIDs { + excludeVendorIDsMap[v] = model.YES + } + + vendorID := 0 + for _, v := range storeCourierList { + if excludeVendorIDsMap[v.VendorID] == model.YES { + continue + } + if v.VendorID == model.VendorIDDada { + excludeVendorIDs = []int{model.VendorIDFengNiao, model.VendorIDMTPS, model.VendorIDUUPT, model.VendorIDSFPS} + vendorID = v.VendorID + break + } + if v.VendorID == model.VendorIDFengNiao { + excludeVendorIDs = []int{model.VendorIDDada, model.VendorIDMTPS, model.VendorIDUUPT, model.VendorIDSFPS} + vendorID = v.VendorID + break + } + if v.VendorID == model.VendorIDMTPS { + excludeVendorIDs = []int{model.VendorIDDada, model.VendorIDFengNiao, model.VendorIDUUPT, model.VendorIDSFPS} + vendorID = v.VendorID + break + } + if v.VendorID == model.VendorIDUUPT { + excludeVendorIDs = []int{model.VendorIDDada, model.VendorIDMTPS, model.VendorIDFengNiao, model.VendorIDSFPS} + vendorID = v.VendorID + break + } + if v.VendorID == model.VendorIDSFPS { + excludeVendorIDs = []int{model.VendorIDDada, model.VendorIDMTPS, model.VendorIDUUPT, model.VendorIDFengNiao} + vendorID = v.VendorID + break + } + } + partner.CurOrderManager.OnOrderMsg(order, fmt.Sprintf("发起自动创建三方运单,目标创建运单平台[%s],排除平台[%s]", jxutils.GetVendorName(vendorID), utils.Format4Output(excludeVendorIDs, false)), "") if _, err = s.CreateWaybillOnProviders4SavedOrder(jxcontext.AdminCtx, savedOrderInfo, nil, excludeVendorIDs, false, maxDeliveryFee); err == nil { savedOrderInfo.retryCount++ } diff --git a/business/jxcallback/scheduler/defsch/defsch_ext.go b/business/jxcallback/scheduler/defsch/defsch_ext.go index a3b3017f6..5a427fe26 100644 --- a/business/jxcallback/scheduler/defsch/defsch_ext.go +++ b/business/jxcallback/scheduler/defsch/defsch_ext.go @@ -477,6 +477,8 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor if savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, false); savedOrderInfo != nil { timeoutSecond = savedOrderInfo.GetCreateWaybillTimeout() } + + store, _ := dao.GetStoreDetail(db, order.JxStoreID, order.VendorID, order.VendorOrgCode) for _, storeCourier := range storeCourierList { var feeInfo *partner.WaybillFeeInfo if waybillMap[storeCourier.VendorID] != nil { @@ -503,6 +505,7 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor if storeCourier.VendorID == model.VendorIDFengNiao { feeInfo.DeliveryFee += model.WayBillDeliveryMarkUp // 蜂鸟加 } + feeInfo.DeliveryFee += int64(store.FreightMarkup) feeInfo.TimeoutSecond = timeoutSecond } } else { diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 880aec838..0521ca795 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -909,6 +909,16 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa } } + if payload["packageSetting"] != nil { + valid["packageSetting"], _ = payload["packageSetting"].(json.Number).Int64() + } + if payload["packageSwitch"] != nil { + valid["packageSwitch"], _ = payload["packageSwitch"].(json.Number).Int64() + } + if payload["freightMarkup"] != nil { + valid["freightMarkup"], _ = payload["freightMarkup"].(json.Number).Int64() + } + if valid["originalName"] != nil { delete(valid, "originalName") } diff --git a/business/model/order.go b/business/model/order.go index caaa0e7ff..c144a0699 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -93,77 +93,76 @@ type ModelTimeInfo struct { } type GoodsOrder struct { - ID int64 `orm:"column(id)" json:"id"` - VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` - VendorOrderID2 string `orm:"column(vendor_order_id2);size(200);index" json:"vendorOrderID2"` - VendorID int `orm:"column(vendor_id)" json:"vendorID"` - VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` - StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid - JxStoreID int `orm:"column(jx_store_id)" json:"jxStoreID"` // 根据VendorStoreID在本地系统里查询出来的 jxstoreid - StoreName string `orm:"size(64)" json:"storeName"` - ShopPrice int64 `json:"shopPrice"` // 京西价 - VendorPrice int64 `json:"vendorPrice"` // 平台价 - SalePrice int64 `json:"salePrice"` // 售卖价 - ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 - TotalShopMoney int64 `json:"totalShopMoney"` // 应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除) - DiscountMoney int64 `json:"discountMoney"` // 订单总优惠金额 - PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+ - JxSubsidyMoney int64 `json:"jxSubsidyMoney"` // 京西我们自己填的订单补贴金额 - BaseFreightMoney int64 `json:"baseFreightMoney"` // 商户承担的配送费(不包括DistanceFreightMoney) - DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) - WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 - EarningPrice int64 `json:"earningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费) - NewEarningPrice int64 `json:"newEarningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费)(新规则) - Weight int `json:"weight"` // 单位为克 - VendorUserID string `orm:"column(vendor_user_id);size(48)" json:"vendorUserID"` - UserID string `orm:"column(user_id);size(48);index" json:"userID"` - ConsigneeName string `orm:"size(32)" json:"consigneeName"` - ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"` // 订单中的收货手机号 - ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"` // 收货人真实手机号 - ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"` - CoordinateType int `json:"coordinateType"` - ConsigneeLng int `json:"consigneeLng"` // 坐标 * (10的六次方) - ConsigneeLat int `json:"consigneeLat"` // 坐标 * (10的六次方) - SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里) - GoodsCount int `json:"goodsCount"` // 商品个数 - Status int `json:"status"` // 参见OrderStatus*相关的常量定义 - VendorStatus string `orm:"size(255)" json:"vendorStatus"` - LockStatus int `json:"lockStatus"` // 当前只支持单一锁定 - LockStatusTime time.Time `orm:"type(datetime);null" json:"lockStatusTime"` // last lock status time - OrderSeq int `json:"orderSeq"` // 门店订单序号 - BuyerComment string `orm:"size(255)" json:"buyerComment"` - BusinessType int `json:"businessType"` - ExpectedDeliveredTime time.Time `orm:"type(datetime)" json:"expectedDeliveredTime"` // 预期送达时间 - CancelApplyReason string `orm:"size(255)" json:"-"` // ""表示没有申请,不为null表示用户正在取消申请 - DeliveryType string `orm:"size(32)" json:"deliveryType"` // 订单配送方式,缺省是平台配送 - CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单 - - VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` - WaybillVendorID int `orm:"column(waybill_vendor_id)" json:"waybillVendorID"` // 表示当前承运商,-1表示还没有安排 - AdjustCount int8 `json:"adjustCount"` // 调整单(次数) - DeliveryFlag int8 `json:"deliveryFlag"` // 第1位为1表示禁止调度器调度三方配送 - DuplicatedCount int `json:"-"` // 重复新订单消息数,这个一般不是由于消息重发造成的(消息重发由OrderStatus过滤),一般是业务逻辑造成的 - OrderCreatedAt time.Time `orm:"type(datetime);index" json:"orderCreatedAt"` // 这里记录的是订单生效时间,即用户支付完成(货到付款即为下单时间) - OrderFinishedAt time.Time `orm:"type(datetime)" json:"orderFinishedAt"` - StatusTime time.Time `orm:"type(datetime)" json:"statusTime"` // last status time - PickDeadline time.Time `orm:"type(datetime);null" json:"pickDeadline"` - DeliveryFeeFrom *time.Time `orm:"type(datetime);null" json:"deliveryFeeFrom,omitempty"` // 三方配置费计算的开始基准时间 - ModelTimeInfo `json:"-"` // 1 - Flag int `json:"flag"` // 非运单调整相关的其它状态 - InvoiceTitle string `orm:"size(64)" json:"invoiceTitle"` // 发票抬头 - InvoiceTaxerID string `orm:"size(32);column(invoice_taxer_id)" json:"invoiceTaxerID"` // 发票纳税人识别码 - InvoiceEmail string `orm:"size(64)" json:"invoiceEmail"` // 发票邮箱 - VendorOrgCode string `orm:"size(64)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 - FromStoreID int `orm:"column(from_store_id)" json:"fromStoreID"` // 物料配送门店 - EclpOutID string `orm:"column(eclp_out_id)" json:"eclpOutID"` // 物料配送的出库单号 - AddressID int64 `orm:"column(address_id)" json:"addressID"` // 配送地址ID - EarningType int `json:"earningType"` // 订单结算方式,2为扣点,1为报价 - OrderType int `json:"orderType"` // 订单类型,0为普通订单,1为物料订单,2为进货订单 - OrderPayPercentage int `json:"orderPayPercentage"` // 调价包? - CouponIDs string `orm:"column(coupon_ids)" json:"couponIDs"` // 优惠券IDs(京西商城) - NotifyType int `json:"notifyType"` // 0表示没有通知,1表示发的短信,2表示发的语音 - PhoneAscription string `orm:"column(phone_ascription)" json:"phoneAscription"` // 电话号码归属地,{代表抖音号码归宿地[yes-四川成都]} - + ModelTimeInfo `json:"-"` // 1 + ID int64 `orm:"column(id)" json:"id"` + VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` + VendorOrderID2 string `orm:"column(vendor_order_id2);size(200);index" json:"vendorOrderID2"` + VendorID int `orm:"column(vendor_id)" json:"vendorID"` + VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` + StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid + JxStoreID int `orm:"column(jx_store_id)" json:"jxStoreID"` // 根据VendorStoreID在本地系统里查询出来的 jxstoreid + StoreName string `orm:"size(64)" json:"storeName"` + ShopPrice int64 `json:"shopPrice"` // 京西价 + VendorPrice int64 `json:"vendorPrice"` // 平台价 + SalePrice int64 `json:"salePrice"` // 售卖价 + ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 + TotalShopMoney int64 `json:"totalShopMoney"` // 应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除) + DiscountMoney int64 `json:"discountMoney"` // 订单总优惠金额 + PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+ + JxSubsidyMoney int64 `json:"jxSubsidyMoney"` // 京西我们自己填的订单补贴金额 + BaseFreightMoney int64 `json:"baseFreightMoney"` // 商户承担的配送费(不包括DistanceFreightMoney) + DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) + WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 + EarningPrice int64 `json:"earningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费) + NewEarningPrice int64 `json:"newEarningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费)(新规则) + Weight int `json:"weight"` // 单位为克 + VendorUserID string `orm:"column(vendor_user_id);size(48)" json:"vendorUserID"` // 平台用户id + UserID string `orm:"column(user_id);size(48);index" json:"userID"` // 用户id + ConsigneeName string `orm:"size(32)" json:"consigneeName"` // 收货人名称 + ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"` // 订单中的收货手机号 + ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"` // 收货人真实手机号 + ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"` // 收货地址 + CoordinateType int `json:"coordinateType"` // 坐标类型 + ConsigneeLng int `json:"consigneeLng"` // 坐标 * (10的六次方) + ConsigneeLat int `json:"consigneeLat"` // 坐标 * (10的六次方) + SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里) + GoodsCount int `json:"goodsCount"` // 商品个数 + Status int `json:"status"` // 参见OrderStatus*相关的常量定义 + VendorStatus string `orm:"size(255)" json:"vendorStatus"` // 平台状态 + LockStatus int `json:"lockStatus"` // 当前只支持单一锁定 + LockStatusTime time.Time `orm:"type(datetime);null" json:"lockStatusTime"` // last lock status time + OrderSeq int `json:"orderSeq"` // 门店订单序号 + BuyerComment string `orm:"size(255)" json:"buyerComment"` + BusinessType int `json:"businessType"` + ExpectedDeliveredTime time.Time `orm:"type(datetime)" json:"expectedDeliveredTime"` // 预期送达时间 + CancelApplyReason string `orm:"size(255)" json:"-"` // ""表示没有申请,不为null表示用户正在取消申请 + DeliveryType string `orm:"size(32)" json:"deliveryType"` // 订单配送方式,缺省是平台配送 + CreateDeliveryType int `orm:"default(0)" json:"createDeliveryType"` //默认0系统发单,1为门店发单 + VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` // 运单id + WaybillVendorID int `orm:"column(waybill_vendor_id)" json:"waybillVendorID"` // 表示当前承运商,-1表示还没有安排 + AdjustCount int8 `json:"adjustCount"` // 调整单(次数) + DeliveryFlag int8 `json:"deliveryFlag"` // 第1位为1表示禁止调度器调度三方配送 + DuplicatedCount int `json:"-"` // 重复新订单消息数,这个一般不是由于消息重发造成的(消息重发由OrderStatus过滤),一般是业务逻辑造成的 + OrderCreatedAt time.Time `orm:"type(datetime);index" json:"orderCreatedAt"` // 这里记录的是订单生效时间,即用户支付完成(货到付款即为下单时间) + OrderFinishedAt time.Time `orm:"type(datetime)" json:"orderFinishedAt"` + StatusTime time.Time `orm:"type(datetime)" json:"statusTime"` // last status time + PickDeadline time.Time `orm:"type(datetime);null" json:"pickDeadline"` + DeliveryFeeFrom *time.Time `orm:"type(datetime);null" json:"deliveryFeeFrom,omitempty"` // 三方配置费计算的开始基准时间 + Flag int `json:"flag"` // 非运单调整相关的其它状态 + InvoiceTitle string `orm:"size(64)" json:"invoiceTitle"` // 发票抬头 + InvoiceTaxerID string `orm:"size(32);column(invoice_taxer_id)" json:"invoiceTaxerID"` // 发票纳税人识别码 + InvoiceEmail string `orm:"size(64)" json:"invoiceEmail"` // 发票邮箱 + VendorOrgCode string `orm:"size(64)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 + FromStoreID int `orm:"column(from_store_id)" json:"fromStoreID"` // 物料配送门店 + EclpOutID string `orm:"column(eclp_out_id)" json:"eclpOutID"` // 物料配送的出库单号 + AddressID int64 `orm:"column(address_id)" json:"addressID"` // 配送地址ID + EarningType int `json:"earningType"` // 订单结算方式,2为扣点,1为报价 + OrderType int `json:"orderType"` // 订单类型,0为普通订单,1为物料订单,2为进货订单 + OrderPayPercentage int `json:"orderPayPercentage"` // 调价包? + CouponIDs string `orm:"column(coupon_ids)" json:"couponIDs"` // 优惠券IDs(京西商城) + NotifyType int `json:"notifyType"` // 0表示没有通知,1表示发的短信,2表示发的语音 + PhoneAscription string `orm:"column(phone_ascription)" json:"phoneAscription"` // 电话号码归属地,{代表抖音号码归宿地[yes-四川成都]} + PackagePrice int `orm:"size(8);column(package_price);default(0)" json:"packagePrice"` // 门店包装袋金额 // 以下只是用于传递数据 OriginalData string `orm:"-" json:"-"` Skus []*OrderSku `orm:"-" json:"-"` diff --git a/business/model/store.go b/business/model/store.go index 77042d4ff..6198daaa0 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -393,14 +393,17 @@ type Store struct { OperatorPhone3 string `orm:"size(16)" json:"operatorPhone3"` // 饿百运营人电话 OperatorRole3 string `orm:"size(32)" json:"operatorRole3"` // 饿百运营人组(角色) - PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告) - IsBoughtMatter int `json:"isBoughtMatter"` //这周是否申请过物料 - SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例 - Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图 - BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID - IsPrintCancelOrder int `orm:"column(is_print_cancel_order)" json:"isPrintCancelOrder"` //是否打印取消订单1是/-1否 - IsPrintRefundOrder int `orm:"column(is_print_refund_order)" json:"isPrintRefundOrder"` //是否打印退款订单1是/-1否 - IDCardHandBack string `orm:"size(255);column(id_card_hand_back)" json:"idCardHandBack"` // 手持身份证背面 + PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告) + IsBoughtMatter int `json:"isBoughtMatter"` //这周是否申请过物料 + SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例 + Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图 + BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID + IsPrintCancelOrder int `orm:"column(is_print_cancel_order)" json:"isPrintCancelOrder"` //是否打印取消订单1是/-1否 + IsPrintRefundOrder int `orm:"column(is_print_refund_order)" json:"isPrintRefundOrder"` //是否打印退款订单1是/-1否 + IDCardHandBack string `orm:"size(255);column(id_card_hand_back)" json:"idCardHandBack"` //手持身份证背面 + PackageSetting int `orm:"size(8);column(package_setting);default(0)" json:"packageSetting"` //门店包装袋扣费设置 + PackageSwitch int `orm:"size(8);column(package_switch);default(0)" json:"packageSwitch"` //物料购物单门店购买袋子开关[0打开/1关闭] + FreightMarkup int `orm:"size(8);column(freight_markup);default(0)" json:"freightMarkup"` //门店为三方运单时,设置的运营加价 } func (*Store) TableUnique() [][]string { diff --git a/business/partner/delivery/dada/waybill.go b/business/partner/delivery/dada/waybill.go index 54e099ce6..884dbc3d3 100644 --- a/business/partner/delivery/dada/waybill.go +++ b/business/partner/delivery/dada/waybill.go @@ -80,13 +80,14 @@ func (c *DeliveryHandler) OnWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap } func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaapi.CallbackResponse) { - order := c.callbackMsg2Waybill(msg) + order, goodsOrder := c.callbackMsg2Waybill(msg) + store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode) switch msg.OrderStatus { case dadaapi.OrderStatusWaitingForAccept: dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID) if err == nil { order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee) - order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup) } order.Status = model.WaybillStatusNew case dadaapi.OrderStatusAccepted: @@ -94,7 +95,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap order.Remark = order.CourierName + "," + order.CourierMobile if dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID); err == nil { order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee) - order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup) } case dadaapi.OrderStatusReturningInOrder: order.Status = model.WaybillStatusCourierArrived @@ -161,7 +162,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap return err } -func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill) { +func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill, goods *model.GoodsOrder) { retVal = &model.Waybill{ VendorWaybillID: msg.ClientID, WaybillVendorID: model.VendorIDDada, @@ -179,12 +180,11 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal retVal.StatusTime = utils.Timestamp2Time(updateTime) retVal.VendorOrderID, retVal.OrderVendorID = jxutils.SplitUniversalOrderID(msg.OrderID) - var good *model.GoodsOrder sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0` sqlParams := []interface{}{msg.OrderID} - dao.GetRow(dao.GetDB(), &good, sql, sqlParams) - retVal.OrderVendorID = good.VendorID - return retVal + dao.GetRow(dao.GetDB(), &goods, sql, sqlParams) + retVal.OrderVendorID = goods.VendorID + return retVal, goods } func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) { diff --git a/business/partner/delivery/fn/store.go b/business/partner/delivery/fn/store.go index 52f41bb10..36b7d70e8 100644 --- a/business/partner/delivery/fn/store.go +++ b/business/partner/delivery/fn/store.go @@ -148,7 +148,7 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S // 蜂鸟门店状态改变 func OnStoreStatus(msg *fnpsapi.ChainstoreStatusNotify) (retVal *fnpsapi.CallbackResponse) { - return curDeliveryHandler.OnStoreStatus(msg) + return CurDeliveryHandler.OnStoreStatus(msg) } // 修改本地门店审核状态 diff --git a/business/partner/delivery/fn/waybill.go b/business/partner/delivery/fn/waybill.go index ad0727bb7..56a76c93c 100644 --- a/business/partner/delivery/fn/waybill.go +++ b/business/partner/delivery/fn/waybill.go @@ -5,6 +5,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/mtpsapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "strings" "time" @@ -35,7 +36,7 @@ const ( ) var ( - curDeliveryHandler *DeliveryHandler + CurDeliveryHandler *DeliveryHandler complaintReson2FnResonMap = map[int]int{ model.ComplaintReasons1: ComplaintReasonsFn160, model.ComplaintReasons2: ComplaintReasonsFn130, @@ -53,10 +54,8 @@ type DeliveryHandler struct { } func init() { - if api.FnAPI != nil { - curDeliveryHandler = new(DeliveryHandler) - partner.RegisterDeliveryPlatform(curDeliveryHandler, true) - } + CurDeliveryHandler = new(DeliveryHandler) + partner.RegisterDeliveryPlatform(CurDeliveryHandler, true) } func (c *DeliveryHandler) GetVendorID() int { @@ -249,14 +248,17 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta } order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(cc.PartnerOrderCode) order.OrderVendorID = good.VendorID + store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode) orderStatus := utils.Str2Int64(order.VendorStatus) switch orderStatus { case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 0 创建订单 order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID) - order.Status = model.WaybillStatusNew //5 带调度 + order.DesiredFee += int64(store.FreightMarkup) // 运营加价 + order.Status = model.WaybillStatusNew //5 带调度 case fnpsapi.OrderStatusAssigned: //20分配骑手 - //order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID) + order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID) + order.DesiredFee += int64(store.FreightMarkup) order.Status = model.WaybillStatusCourierAssigned //12 order.Remark = order.CourierName + "," + order.CourierMobile case fnpsapi.OrderStatusArrived: // 80 到店 @@ -323,7 +325,7 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta // 异常报备 func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) { - return curDeliveryHandler.OnWaybillExcept(msg) + return CurDeliveryHandler.OnWaybillExcept(msg) } func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) { @@ -487,3 +489,31 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId } return vendorPrice, nil } + +func (c *DeliveryHandler) GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error) { + order, err := api.FnAPI.GetKnightInfo(&fnpsapi.GetOrderDetailReq{ + PartnerOrderCode: vendorOrderID, + }) + if err == nil { + lng = utils.Str2Float64WithDefault(order.CarrierDriverLongitude, 0) + lat = utils.Str2Float64WithDefault(order.CarrierDriverLatitude, 0) + } + return lng, lat, err +} + +func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) { + return api.FnAPI.AddTip(&fnpsapi.AddTipRes{ + OrderId: "", + PartnerOrderCode: vendorOrderID, + AddTipAmountCent: tipFee, + ThirdIndexId: time.Now().Unix(), + }) +} + +func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) { + order, err := api.FnAPI.QueryOrder(vendorOrderID) + if err == nil { + tipFee = order.OrderTipAmountCent + } + return tipFee, err +} diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index bdd90496b..254da65da 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -85,7 +85,7 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg } func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) { - order := c.callbackMsg2Waybill(msg) + order, goodsOrder := c.callbackMsg2Waybill(msg) // 多次取消,只处理第一次 if msg.Status == mtpsapi.OrderStatusCanceled { orderStatus, _ := orderman.FixedOrderManager.GetWayBillStatusList(msg.OrderID, msg.MtPeisongID, model.VendorIDMTPS) @@ -96,6 +96,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m } } + store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode) switch msg.Status { case mtpsapi.OrderStatusWaitingForSchedule: data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID) @@ -104,6 +105,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m } order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100) order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100) + order.DesiredFee += int64(store.FreightMarkup) order.Status = model.WaybillStatusNew case mtpsapi.OrderStatusAccepted: // 已接单 data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID) @@ -112,6 +114,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m } order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100) order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100) + order.DesiredFee += int64(store.FreightMarkup) order.Status = model.WaybillStatusCourierAssigned order.Remark = order.CourierName + "," + order.CourierMobile case mtpsapi.OrderStatusPickedUp: // 已取货 @@ -230,7 +233,7 @@ func signParams(params url.Values) string { return fmt.Sprintf("%x", sha1.Sum([]byte(finalStr))) } -func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill) { +func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill, good2 *model.GoodsOrder) { retVal = &model.Waybill{ VendorWaybillID: msg.MtPeisongID, VendorWaybillID2: utils.Int64ToStr(msg.DeliveryID), @@ -250,7 +253,7 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (re } else { retVal.OrderVendorID = good.VendorID } - return retVal + return retVal, good } // 老方法是自己计算 @@ -548,3 +551,13 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId } return 0, err } + +func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) { + // 无法获取已经添加的小费金额 + return fmt.Errorf("美团暂不支持添加小费") + //return api.MtpsAPI.AddTip(vendorOrderID, vendorWaybillID, tipFee) +} + +func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) { + return tipFee, err +} diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index 3f69c94f3..cd97e8d4d 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -140,9 +140,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i return nil, err } - //+0.2 + // 系统加价 desiredFee := utils.Float64TwoInt(sfTotalPrice) + utils.WayBillDeliveryMarkUp - + // 运营加价 + desiredFee += store.FreightMarkup bill = &model.Waybill{ VendorOrderID: order.VendorOrderID, OrderVendorID: order.VendorID, @@ -222,8 +223,6 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo } deliveryFeeInfo = &partner.WaybillFeeInfo{} price, err := api.SfPsAPI.PreCreateOrder(param) - //+0.2 - //deliveryFee := utils.Float64TwoInt(price) + utils.WayBillDeliveryMarkUp deliveryFeeInfo.DeliveryFee = utils.Float64TwoInt64(price) globals.SugarLogger.Debugf("GetWaybillFee deliveryFeeInfo.DeliveryFee=%d", deliveryFeeInfo.DeliveryFee) return deliveryFeeInfo, err @@ -343,8 +342,7 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons order.CourierMobile = sfOrder.RiderPhone } - //+0.2 - sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) + utils.WayBillDeliveryMarkUp + sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) sfActualPrice := utils.Float64TwoInt64(sfOrder.RealPayMoney) globals.SugarLogger.Debugf("SFPS OnWaybillMsg,sfTotalPrice=%d,sfActualPrice=%d", sfTotalPrice, sfActualPrice) @@ -354,6 +352,9 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons dao.GetRow(dao.GetDB(), &good, sql, sqlParams) order.OrderVendorID = good.VendorID + store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode) + sfTotalPrice += store.FreightMarkup + orderStatus := utils.Str2Int64(order.VendorStatus) switch orderStatus { case sfps2.OrderStatusNewOrder: //1:订单创建 diff --git a/business/partner/delivery/uupt/waybill.go b/business/partner/delivery/uupt/waybill.go index 00ee86d7b..ab8604855 100644 --- a/business/partner/delivery/uupt/waybill.go +++ b/business/partner/delivery/uupt/waybill.go @@ -341,6 +341,10 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp } else { reallyPrice = int64(utils.Str2Float64(uuPrice.OrderPrice) * 100) } + + store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode) + reallyPrice += int64(store.FreightMarkup) + actualFee := int64((utils.Str2Float64(uuPrice.OrderPrice)-utils.Str2Float64(uuPrice.PriceOff))*100) - int64(utils.WayBillDeliveryMarkUp) switch req.State { case uuptapi.StateConfirmSuccess: diff --git a/business/partner/partner_order.go b/business/partner/partner_order.go index 8eaf6bc3e..552130339 100644 --- a/business/partner/partner_order.go +++ b/business/partner/partner_order.go @@ -95,7 +95,9 @@ type IPurchasePlatformOrderHandler interface { } type IAddWaybillTip interface { + // GetWaybillTip 获取添加小费 GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) + // UpdateWaybillTip 添加小费 UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) } diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index c92ddb899..80ae20fe0 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -310,6 +310,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo giftSkus, discountMoney := getZengSkus(vendorOrderID, orderData) order.DiscountMoney = discountMoney order.Skus = append(order.Skus, giftSkus...) + + // 包装袋金额设置 + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) + order.PackagePrice = store.PackageSetting jxutils.RefreshOrderSkuRelated(order) return order } diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index 52546659b..124aacdf7 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -350,6 +350,9 @@ func Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) { } order.Skus = append(order.Skus, sku) } + // 包装袋金额设置 + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) + order.PackagePrice = store.PackageSetting jxutils.RefreshOrderSkuRelated(order) return order } diff --git a/business/partner/purchase/jdshop/callback.go b/business/partner/purchase/jdshop/callback.go index 696fb067d..b4181b328 100644 --- a/business/partner/purchase/jdshop/callback.go +++ b/business/partner/purchase/jdshop/callback.go @@ -323,7 +323,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err if order.ExpectedDeliveredTime.Sub(order.OrderCreatedAt) <= time.Hour+time.Minute { order.BusinessType = model.BusinessTypeImmediate } - // buildOrderTo102919(order) + order.PackagePrice = store.PackageSetting return order, err } diff --git a/business/partner/purchase/jx/localjx/kuaishou_pay.go b/business/partner/purchase/jx/localjx/kuaishou_pay.go index e4ca64930..31fa0a3c6 100644 --- a/business/partner/purchase/jx/localjx/kuaishou_pay.go +++ b/business/partner/purchase/jx/localjx/kuaishou_pay.go @@ -92,7 +92,7 @@ func OnKSPayCallback(msg *kuaishou_mini.CallBackDetail, refund *kuaishou_mini.Re func onKSPayFinished(msg *kuaishou_mini.CallBackDetail) (err error) { orderPay := &model.OrderPay{ PayOrderID: msg.OutOrderNo, - PayType: model.PayTypeTicTok, + PayType: model.PayTypeKuaiShou, } orderPay.DeletedAt = utils.DefaultTimeValue db := dao.GetDB() @@ -162,7 +162,7 @@ func RefundOrderByKS(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID OutRefundNo: refundID, Reason: refundDesc, Attach: "", - NotifyUrl: "http://callback.jxc4.com/kuaishou/kuaiShouCallback", + NotifyUrl: "https://callback.jxc4.com/kuaishou/kuaiShouCallback", RefundAmount: int64(orderPay.TotalFee), Sign: "", MultiCopiesGoodsInfo: "", diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index ce0742a09..e007f652a 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -1228,6 +1228,9 @@ func jxOrder2GoodsOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, deliveryAd if IsDeliverySelf { order.DeliveryType = model.OrderDeliveryTypeSelfTake } + + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) + order.PackagePrice = store.PackageSetting return order, err } diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 3bf5a11ad..1843fdae7 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -245,10 +245,8 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo } } ignoreSkuMap := make(map[int]int) - // detail := result["detail"].([]interface{}) multiSkuMap := make(map[int]int) for _, product := range detail { - // product := product2.(map[string]interface{}) skuName := product["food_name"].(string) skuID := utils.Interface2String(product["sku_id"]) sku := &model.OrderSku{ @@ -296,9 +294,6 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo if sku.SalePrice < 0 { sku.SalePrice = jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"])) } - // if product["isGift"].(bool) { - // sku.SkuType = 1 - // } order.Skus = append(order.Skus, sku) multiSkuMap[sku.SkuID]++ } @@ -308,6 +303,9 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo } } + // 包装袋金额设置 + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) + order.PackagePrice = store.PackageSetting jxutils.RefreshOrderSkuRelated(order) return order } diff --git a/business/partner/purchase/mtwm/order_afs.go b/business/partner/purchase/mtwm/order_afs.go index 5f07c1831..e7ff38001 100644 --- a/business/partner/purchase/mtwm/order_afs.go +++ b/business/partner/purchase/mtwm/order_afs.go @@ -107,11 +107,11 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma for _, sku := range refundData.FoodList { orderSku := &model.OrderSkuFinancial{ // VendorID: model.VendorIDMTWM, - // AfsOrderID: afsOrder.AfsOrderID, + AfsOrderID: afsOrder.AfsOrderID, // VendorOrderID: afsOrder.VendorOrderID, // VendorStoreID: afsOrder.VendorStoreID, // StoreID: afsOrder.StoreID, - // IsAfsOrder: 1, + IsAfsOrder: 1, Count: sku.Count, // ConfirmTime: afsOrder.AfsCreateAt, @@ -120,6 +120,10 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma Name: sku.FoodName, UserMoney: jxutils.StandardPrice2Int(sku.RefundPrice)*int64(sku.Count) + jxutils.StandardPrice2Int(sku.BoxPrice)*int64(sku.BoxNum), } + if orderSku.VendorSkuID == "" || orderSku.VendorSkuID == "0" { + orderSku.VendorSkuID = sku.AppFoodCode + } + afsOrder.SkuUserMoney += orderSku.UserMoney afsOrder.Skus = append(afsOrder.Skus, orderSku) } diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index e9d78fc8a..a5045bfb9 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -174,9 +174,7 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s salePrice += sku.SalePrice } } - //order.TotalShopMoney = utils.Float64TwoInt64(float64(salePrice) * 0.95) // 抖音平台扣点金额0.05 - //order.DeliveryType = model.OrderDeliveryTypeStoreSelf autoTransport, err := GetStoreAutoCallRiderInfo(vendorOrgCode, []int64{utils.Str2Int64(vendorStoreIdRelly)}) if err != nil || len(autoTransport) == 0 { order.DeliveryType = model.OrderDeliveryTypePlatform @@ -195,20 +193,6 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s 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 { - // order.BusinessType = model.BusinessTypeImmediate - //} else { - // order.BusinessType = model.BusinessTypeDingshida - //} - if result.EarlyArrival { // 立即达 order.BusinessType = model.BusinessTypeImmediate order.ExpectedDeliveredTime = getTimeFromTimestamp(result.TargetArrivalTime + 30*60) // 预计最晚送达时间 @@ -239,7 +223,6 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s // 抖音订单手机号和收货地址是否同城 order.PhoneAscription = "" - //ascription, err := phonedata.Find(order.ConsigneeMobile) ascription, err := ascription_place.Find(order.ConsigneeMobile) if err != nil { order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + err.Error() @@ -250,7 +233,8 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s order.PhoneAscription = model.PhoneAscriptionAddressNo + "-" + "归属信息不匹配:" + ascription.Province + ascription.City } } - + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) + order.PackagePrice = store.PackageSetting jxutils.RefreshOrderSkuRelated(order) return order, orderMap, nil } @@ -310,15 +294,6 @@ func (c *PurchaseHandler) onOrderMsg(msgId, orderId string, msg interface{}) (re return tiktokShop.Err2CallbackResponse(nil, "") } - // 取消订单:可能未支付取消订单,不做处理 - //if msgId == tiktokShop.CallbackCancelOrderMsgTagId { - // if _, err := partner.CurOrderManager.LoadOrder(orderId, model.VendorIDDD); err != nil && strings.Contains(err.Error(), "找不到相应订单") { - // return tiktokShop.Err2CallbackResponse(nil, "") - // } else { - // return tiktokShop.Err2CallbackResponse(err, "") - // } - //} - // 组装订单状态变化 status, appOrgCode := c.callbackMsg2Status(msgId, orderId, msg) // 校验重复消息 diff --git a/controllers/jd_callback.go b/controllers/jd_callback.go index 97c0d493c..165b6817f 100644 --- a/controllers/jd_callback.go +++ b/controllers/jd_callback.go @@ -110,9 +110,8 @@ func (c *DjswController) OrderCommentPush() { func (c *DjswController) Token() { urlValues, err := utils.HTTPBody2Values(c.Ctx.Input.RequestBody, false) - if err == nil { - globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false)) - } + globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false)) + globals.SugarLogger.Info(utils.Format4Output(utils.Format4Output(err, false), false)) jd.OnTokenChange(urlValues) c.Data["json"] = c.transferResponse("Token", nil) c.ServeJSON() diff --git a/controllers/kuaishou_callback.go b/controllers/kuaishou_callback.go index 2e4e0b17b..6416b59bc 100644 --- a/controllers/kuaishou_callback.go +++ b/controllers/kuaishou_callback.go @@ -2,9 +2,7 @@ package controllers import ( "git.rosy.net.cn/baseapi/platformapi/kuaishou_mini" - "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" ) @@ -16,10 +14,6 @@ type KuaiShouController struct { // KuaiShouCallBack 快手回调 func (c *KuaiShouController) KuaiShouCallback() { payOrder, refundOrder, payType, msgId, err := api.KuaiShouApi.KauiShouCallback(c.Ctx.Request) - globals.SugarLogger.Debugf("KuaiShouCallBack payOrder =: %s", utils.Format4Output(payOrder, false)) - globals.SugarLogger.Debugf("KuaiShouCallBack refundOrder=: %s", refundOrder) - globals.SugarLogger.Debugf("KuaiShouCallBack payType=: %s", payType) - globals.SugarLogger.Debugf("KuaiShouCallBack err=: %s", utils.Format4Output(err, false)) if err != nil { c.Data["json"] = CallBackFail(msgId) c.ServeJSON()