Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2024-01-17 10:22:27 +08:00
19 changed files with 158 additions and 69 deletions

View File

@@ -876,7 +876,11 @@ func (c *OrderManager) GetStoresOrderSaleInfo(ctx *jxcontext.Context, storeIDLis
return c.GetStoresOrderSaleInfoNew(ctx, storeIDList, fromTime, toTime, statusList) return c.GetStoresOrderSaleInfoNew(ctx, storeIDList, fromTime, toTime, statusList)
} }
func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int, brandId, vendorId []int) (map[string]interface{}, error) { func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime time.Time, toTime time.Time, storeId int, brandId, vendorId, storeList []int, mapStoreData map[int]int) (map[string]interface{}, error) {
var (
db = dao.GetDB()
)
year, month, day := time.Now().Date() year, month, day := time.Now().Date()
if fromTime.IsZero() { if fromTime.IsZero() {
fromTime = time.Date(year, month, day, 0, 0, 0, 0, time.Local) fromTime = time.Date(year, month, day, 0, 0, 0, 0, time.Local)
@@ -885,21 +889,20 @@ func (c *OrderManager) GetStoresOrderSaleInfo2(ctx *jxcontext.Context, fromTime
toTime = time.Date(year, month, day, 23, 59, 59, 0, time.Local) toTime = time.Date(year, month, day, 23, 59, 59, 0, time.Local)
} }
db := dao.GetDB()
// 门店统计 // 门店统计
storeStatus, err := dao.StatisticsStoreInfo(db, brandId, vendorId) storeStatus, err := dao.StatisticsStoreInfo(db, brandId, vendorId, storeList)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// 订单统计 // 订单统计
orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId) orderStatus, err := dao.StatisticsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId, storeList)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// 售后单统计 // 售后单统计
afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId) afsOrderStatus, err := dao.StatisticsAfsOrderInfo(db, fromTime, toTime, storeId, brandId, vendorId, storeList)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -3525,6 +3525,9 @@ func UpdateJdStoreNameAll(ctx *jxcontext.Context) (err error) {
` `
if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, v); err == nil { if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, v); err == nil {
for _, store := range stores { for _, store := range stores {
if store.Status == model.StoreStatusDisabled {
continue
}
a := jd.GetAPI(store.VendorOrgCode) a := jd.GetAPI(store.VendorOrgCode)
storeParams := &jdapi.OpStoreParams{ storeParams := &jdapi.OpStoreParams{
StationNo: store.VendorStoreID, StationNo: store.VendorStoreID,
@@ -5677,8 +5680,9 @@ func RefreshStoreIsOnline(ctx *jxcontext.Context) (err error) {
storeMap.IsOnline = 1 storeMap.IsOnline = 1
} else { } else {
storeMap.IsOnline = -1 storeMap.IsOnline = -1
storeMap.Status = model.StoreStatusClosed
} }
dao.UpdateEntity(db, storeMap, "IsOnline") dao.UpdateEntity(db, storeMap, "IsOnline", "Status")
store := fmt.Sprintf("门店id:%d,门店名称:%s,第三方门店状态:%d,本地门店修改后状态:%d,第三方平台Id(美团,饿了么...):%d", store.Store.ID, store.Store.Name, store.Store.Status, storeMap.IsOnline, storeMap.VendorID) store := fmt.Sprintf("门店id:%d,门店名称:%s,第三方门店状态:%d,本地门店修改后状态:%d,第三方平台Id(美团,饿了么...):%d", store.Store.ID, store.Store.Name, store.Store.Status, storeMap.IsOnline, storeMap.VendorID)
event.AddOperateEvent(ctx, ctx.GetTrackInfo(), store, "", "", 10, "UpdateStore") event.AddOperateEvent(ctx, ctx.GetTrackInfo(), store, "", "", 10, "UpdateStore")
} }

View File

@@ -6692,11 +6692,6 @@ func BatchSetRestockingPrice(ctx *jxcontext.Context, preData map[string][]mtwmap
} }
// BatchSetMTBoxPrice 批量修改美团包装费为0 // BatchSetMTBoxPrice 批量修改美团包装费为0
func BatchSetMTBoxPrice(ctx *jxcontext.Context, jxStoreId []int) error { func BatchSetMTBoxPrice(ctx *jxcontext.Context, skuList []*mtwm.SetBoxPrice) error {
var db = dao.GetDB() return mtwm.UpdateBoxPrice(ctx, dao.GetDB(), skuList)
for _, v := range jxStoreId {
mtwm.UpdateBoxPrice(ctx, db, v)
}
return nil
} }

View File

@@ -426,6 +426,7 @@ func Init() {
dao.SetStoresMapSyncStatus(dao.GetDB(), nil, nil, model.SyncFlagStoreStatus) dao.SetStoresMapSyncStatus(dao.GetDB(), nil, nil, model.SyncFlagStoreStatus)
cms.CurVendorSync.SyncStore2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI, model.VendorIDDD}, nil, true, true) cms.CurVendorSync.SyncStore2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI, model.VendorIDDD}, nil, true, true)
// 刷新门店平台商品
syncStoreSku() syncStoreSku()
InitEx() InitEx()
cms.SyncStoresCourierInfo(jxcontext.AdminCtx, nil, false, true) cms.SyncStoresCourierInfo(jxcontext.AdminCtx, nil, false, true)
@@ -566,12 +567,9 @@ func Init() {
func syncStoreSku() { func syncStoreSku() {
syncFlag := 0 syncFlag := 0
if beego.BConfig.RunMode == "jxgy" { if beego.BConfig.RunMode == "jxgy" {
//syncFlag = model.SyncFlagPriceMask syncFlag |= model.SyncFlagPriceMask // SyncFlagSaleMask
if true {
syncFlag |= model.SyncFlagSaleMask
}
} else { } else {
syncFlag |= model.SyncFlagSaleMask syncFlag |= model.SyncFlagPriceMask // SyncFlagSaleMask
} }
task := tasksch.NewParallelTask("同步京西与平台数据", nil, jxcontext.AdminCtx, task := tasksch.NewParallelTask("同步京西与平台数据", nil, jxcontext.AdminCtx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
@@ -592,7 +590,7 @@ func syncStoreSku() {
}) })
errList.AddErr(err) errList.AddErr(err)
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{0}, nil, false, nil, []int{27379}, syncFlag, true, true) _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, nil, nil, false, nil, []int{27379}, syncFlag, true, true)
//_, err = cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, db, partner.GetMultiStoreVendorIDs(), nil, false, []int{27379}, true, true) //_, err = cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, db, partner.GetMultiStoreVendorIDs(), nil, false, []int{27379}, true, true)
errList.AddErr(err) errList.AddErr(err)
} }

View File

@@ -82,6 +82,11 @@ const (
) )
const BrandIdChengShan = 142 // 成山农场品牌id const BrandIdChengShan = 142 // 成山农场品牌id
const (
DefMaxDeliveryFee = 1500 // 创建运单最高价
AlarmFee = 1500 // 配送费报警阈值
)
type VendorInfo struct { type VendorInfo struct {
Name string `json:"name"` Name string `json:"name"`

View File

@@ -106,11 +106,13 @@ func InsertItemFreight(tem *model.FreightTemplate) error {
sqlParams = append(sqlParams, tem.TradeLimitID) sqlParams = append(sqlParams, tem.TradeLimitID)
sqlStr = append(sqlStr, tradeLimitIDSql) sqlStr = append(sqlStr, tradeLimitIDSql)
} }
if len(sqlStr) == model.NO {
return nil
}
tStr = "WHERE a.store_id = ? AND a.vendor_store_id = ?" tStr = "WHERE a.store_id = ? AND a.vendor_store_id = ?"
sqlParams = append(sqlParams, tem.StoreID, tem.VendorStoreID) sqlParams = append(sqlParams, tem.StoreID, tem.VendorStoreID)
tStr2 := sql + strings.Join(sqlStr, ",") + tStr tStr2 := sql + strings.Join(sqlStr, ",") + tStr
_, err := ExecuteSQL(GetDB(), tStr2, sqlParams...) _, err := ExecuteSQL(GetDB(), tStr2, sqlParams...)
fmt.Println(tStr2)
return err return err
} }

View File

@@ -1698,7 +1698,7 @@ type StatisticsStore struct {
} }
// StatisticsStoreInfo 统计所有的门店信息 // StatisticsStoreInfo 统计所有的门店信息
func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*StatisticsStore, error) { func StatisticsStoreInfo(db *DaoDB, brandId, vendorId, storeList []int) ([]*StatisticsStore, error) {
statistics := make([]*StatisticsStore, 0, 0) statistics := make([]*StatisticsStore, 0, 0)
sql := ` SELECT count(s.status) count, s.status FROM store s ` sql := ` SELECT count(s.status) count, s.status FROM store s `
@@ -1708,6 +1708,12 @@ func StatisticsStoreInfo(db *DaoDB, brandId []int, vendorId []int) ([]*Statistic
param = append(param, vendorId) param = append(param, vendorId)
} }
sql += ` WHERE 1=1 ` sql += ` WHERE 1=1 `
if len(storeList) > model.NO {
sql += ` AND s.id IN (` + GenQuestionMarks(len(storeList)) + `)`
param = append(param, storeList)
}
if len(brandId) > model.NO { if len(brandId) > model.NO {
sql += ` AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)` sql += ` AND s.brand_id IN (` + GenQuestionMarks(len(brandId)) + `)`
param = append(param, brandId) param = append(param, brandId)
@@ -1727,7 +1733,7 @@ type StatisticsOrder struct {
} }
// StatisticsOrderInfo 统计订单信息 // StatisticsOrderInfo 统计订单信息
func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) { func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId, storeList []int) ([]*StatisticsOrder, error) {
parma := []interface{}{} parma := []interface{}{}
sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g ` sql := ` SELECT count(g.vendor_order_id) count,g.status status ,sum(g.total_shop_money) total_shop_money FROM goods_order g `
@@ -1741,21 +1747,25 @@ func StatisticsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, b
if storeId != model.NO { if storeId != model.NO {
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) = ?` sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) = ?`
parma = append(parma, storeId) parma = append(parma, storeId)
} else if len(storeList) != model.NO {
sql += ` AND IF(g.store_id <> 0,g.store_id,g.jx_store_id) IN (` + GenQuestionMarks(len(storeList)) + `)`
parma = append(parma, storeList)
} }
if len(vendorId) > model.NO { if len(vendorId) > model.NO {
sql += ` AND g.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)` sql += ` AND g.vendor_id IN (` + GenQuestionMarks(len(vendorId)) + `)`
parma = append(parma, vendorId) parma = append(parma, vendorId)
} }
sql += ` GROUP BY g.status ` sql += ` GROUP BY g.status `
orderStatistics := make([]*StatisticsOrder, 0, 0) orderStatistics := make([]*StatisticsOrder, 0, 0)
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil { if err := GetRows(db, &orderStatistics, sql, parma...); err != nil {
return nil, err return nil, err
} }
return orderStatistics, nil return orderStatistics, nil
} }
// StatisticsAfsOrderInfo 售后单信息统计 // StatisticsAfsOrderInfo 售后单信息统计
func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId []int) ([]*StatisticsOrder, error) { func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int, brandId, vendorId, storeList []int) ([]*StatisticsOrder, error) {
parma := []interface{}{} parma := []interface{}{}
sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a ` sql := `SELECT count(a.vendor_order_id) count,a.status status ,sum(a.afs_total_shop_money) total_shop_money FROM afs_order a `
@@ -1769,6 +1779,9 @@ func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int
if storeId != model.NO { if storeId != model.NO {
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = ?` sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) = ?`
parma = append(parma, storeId) parma = append(parma, storeId)
} else if len(storeList) != model.NO {
sql += ` AND IF(a.store_id <> 0,a.store_id,a.jx_store_id) IN (` + GenQuestionMarks(len(storeList)) + `)`
parma = append(parma, storeList)
} }
if len(vendorId) > 0 { if len(vendorId) > 0 {
@@ -1778,7 +1791,7 @@ func StatisticsAfsOrderInfo(db *DaoDB, startTime, endTime time.Time, storeId int
sql += ` GROUP BY a.status` sql += ` GROUP BY a.status`
orderStatistics := make([]*StatisticsOrder, 0, 0) orderStatistics := make([]*StatisticsOrder, 0, 0)
if err := GetRows(GetDB(), &orderStatistics, sql, parma...); err != nil { if err := GetRows(db, &orderStatistics, sql, parma...); err != nil {
return nil, err return nil, err
} }
return orderStatistics, nil return orderStatistics, nil

View File

@@ -323,12 +323,6 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder)
} }
if billParams.ShopNo, err = c.getDadaShopID(order, db); err == nil { if billParams.ShopNo, err = c.getDadaShopID(order, db); err == nil {
if billParams.CityCode, err = c.getDataCityCodeFromOrder(order, db); err == nil { if billParams.CityCode, err = c.getDataCityCodeFromOrder(order, db); err == nil {
// storeTel := ""
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
// if storeDeatail.Tel2 != "" {
// storeTel = ",门店电话:" + storeDeatail.Tel2
// }
billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType) billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题可联系18048531223取消配送单。")) billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题可联系18048531223取消配送单。"))
billParams.CargoType = dadaapi.CargoTypeFresh billParams.CargoType = dadaapi.CargoTypeFresh
@@ -339,7 +333,7 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder)
return billParams, err return billParams, err
} }
// IDeliveryPlatformHandler // CreateWaybill IDeliveryPlatformHandler
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) { func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
db := dao.GetDB() db := dao.GetDB()

View File

@@ -18,13 +18,11 @@ const (
warningWeight = 50 * 1000 // 克 warningWeight = 50 * 1000 // 克
// maxDiffFee2Mtps = 200 // 与美团配送最多差价 // maxDiffFee2Mtps = 200 // 与美团配送最多差价
// maxAddFee = 200 // 最大增加费用,单位为分,超过不发三方配送了 // maxAddFee = 200 // 最大增加费用,单位为分,超过不发三方配送了
defMaxDeliveryFee = 10000 // 创建运单最高价
alarmFee = 1500 // 配送费报警阈值
) )
func CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee int64, order *model.GoodsOrder, waybillVendorID int) (err error) { func CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee int64, order *model.GoodsOrder, waybillVendorID int) (err error) {
if maxDeliveryFee <= 0 || maxDeliveryFee > defMaxDeliveryFee { if maxDeliveryFee <= 0 || maxDeliveryFee > model.DefMaxDeliveryFee {
maxDeliveryFee = defMaxDeliveryFee maxDeliveryFee = model.DefMaxDeliveryFee
} }
if deliveryFee > maxDeliveryFee { if deliveryFee > maxDeliveryFee {
errStr := fmt.Sprintf("超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(maxDeliveryFee)) errStr := fmt.Sprintf("超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(maxDeliveryFee))
@@ -139,8 +137,8 @@ func CalculateBillDeliveryFee(bill *model.Waybill) (deliveryFee, addFee int64) {
// 日志提示检查订单运费 // 日志提示检查订单运费
func OnWaybillCreated(waybill *model.Waybill) { func OnWaybillCreated(waybill *model.Waybill) {
deliveryFee := int64(math.Max(float64(waybill.DesiredFee), float64(waybill.ActualFee))) deliveryFee := int64(math.Max(float64(waybill.DesiredFee), float64(waybill.ActualFee)))
if deliveryFee > alarmFee { if deliveryFee > model.AlarmFee {
globals.SugarLogger.Infof("[运营]%s订单, orderID:%s, 成功创建%s运单:%s, 配送费:%s太高(大于%s),请知悉!", model.VendorChineseNames[waybill.OrderVendorID], waybill.VendorOrderID, globals.SugarLogger.Infof("[运营]%s订单, orderID:%s, 成功创建%s运单:%s, 配送费:%s太高(大于%s),请知悉!", model.VendorChineseNames[waybill.OrderVendorID], waybill.VendorOrderID,
model.VendorChineseNames[waybill.WaybillVendorID], waybill.VendorWaybillID, jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(alarmFee)) model.VendorChineseNames[waybill.WaybillVendorID], waybill.VendorWaybillID, jxutils.IntPrice2StandardCurrencyString(deliveryFee), jxutils.IntPrice2StandardCurrencyString(model.AlarmFee))
} }
} }

View File

@@ -100,6 +100,17 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment) return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
} }
if maxDeliveryFee == model.NO {
// 获取配送费
fee, err := c.GetWaybillFee(order)
if err != nil {
return nil, err
}
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
return nil, fmt.Errorf("蜂鸟超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
}
}
// 蜂鸟入参结构体 // 蜂鸟入参结构体
parameter := &fnpsapi.CreateOrderReqParam{ parameter := &fnpsapi.CreateOrderReqParam{
PartnerOrderCode: order.VendorOrderID, PartnerOrderCode: order.VendorOrderID,

View File

@@ -323,7 +323,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) { func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
db := dao.GetDB() db := dao.GetDB()
// 检查配送平台是否被禁用 // 检查配送平台是否被禁用
vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDFengNiao, "", model.VendorOrgTypeDelivery) vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDMTPS, "", model.VendorOrgTypeDelivery)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -331,6 +331,17 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment) return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
} }
globals.SugarLogger.Debugf("===================maxDeliveryFee := %d", maxDeliveryFee)
if maxDeliveryFee == model.NO {
fee, err := c.GetWaybillFee(order)
if err != nil {
return nil, err
}
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
return nil, fmt.Errorf("美团配送超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
}
}
// 忽略坐标转换错误,即使是转换出错,也只能当成转换成功来处理,底层会有错误日志输出 // 忽略坐标转换错误,即使是转换出错,也只能当成转换成功来处理,底层会有错误日志输出
lngFloat, latFloat, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType) lngFloat, latFloat, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
billParams := &mtpsapi.CreateOrderByShopParam{ billParams := &mtpsapi.CreateOrderByShopParam{

View File

@@ -89,6 +89,16 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment) return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
} }
if maxDeliveryFee == model.NO {
fee, err := d.GetWaybillFee(order)
if err != nil {
return nil, err
}
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
return nil, fmt.Errorf("顺丰超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
}
}
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "") store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -139,6 +139,16 @@ func (d DeliveryHandler) IsErrStoreExist(err error) bool {
} }
func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) { func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
if maxDeliveryFee == model.NO {
fee, err := d.GetWaybillFee(order)
if err != nil {
return nil, err
}
if fee.DeliveryFee >= model.DefMaxDeliveryFee {
return nil, fmt.Errorf("顺丰超最高限价, 所需运费:%s, 最高限价:%s", jxutils.IntPrice2StandardCurrencyString(fee.DeliveryFee), jxutils.IntPrice2StandardCurrencyString(model.DefMaxDeliveryFee))
}
}
//获取门店老板详情 //获取门店老板详情
storeOwner, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "") storeOwner, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
if err != nil { if err != nil {

View File

@@ -397,10 +397,12 @@ func (c *PrinterHandler) UnregisterPrinter(ctx *jxcontext.Context, machineCode,
func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) { func (c *PrinterHandler) BindPrinter(ctx *jxcontext.Context, mapData map[string]interface{}) (bindResult *partner.BindPrinterResult, err error) {
machineCode := utils.Interface2String(mapData["machineCode"]) machineCode := utils.Interface2String(mapData["machineCode"])
qrKey := utils.Interface2String(mapData["qrKey"]) qrKey := utils.Interface2String(mapData["qrKey"])
if machineCode == "" || qrKey == "" { msign := utils.Interface2String(mapData["msign"])
if machineCode == "" || (qrKey == "" && msign == "") {
return nil, fmt.Errorf("易联云扫描数据格式不正确") return nil, fmt.Errorf("易联云扫描数据格式不正确")
} }
tokenInfo, err := api.YilianyunAPI2.GetPrinterToken(machineCode, qrKey)
tokenInfo, err := api.YilianyunAPI2.GetPrinterToken(machineCode, qrKey, msign)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -2,6 +2,8 @@ package jd
import ( import (
"git.rosy.net.cn/baseapi/platformapi/jdapi" "git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
) )
func OnOrderMsg(msg *jdapi.CallbackOrderMsg, a *jdapi.API) (retVal *jdapi.CallbackResponse) { func OnOrderMsg(msg *jdapi.CallbackOrderMsg, a *jdapi.API) (retVal *jdapi.CallbackResponse) {
@@ -21,6 +23,7 @@ func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackR
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) { func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
if CurPurchaseHandler != nil { if CurPurchaseHandler != nil {
retVal = CurPurchaseHandler.OnStoreMsg(AppKey2OrgCode(msg.AppKey), msg) retVal = CurPurchaseHandler.OnStoreMsg(AppKey2OrgCode(msg.AppKey), msg)
globals.SugarLogger.Debugf("retVal========= %s", utils.Format4Output(retVal, false))
} }
return retVal return retVal
} }

View File

@@ -142,12 +142,10 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, utils.DefaultTimeValue, storeID); err == nil { if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, utils.DefaultTimeValue, storeID); err == nil {
for _, store := range stores { for _, store := range stores {
a := getAPI(store.VendorOrgCode) a := getAPI(store.VendorOrgCode)
// phone := "" if store.Status == model.StoreStatusDisabled {
// if store.MarketManPhone != "" { continue
// phone = store.MarketManPhone }
// } else {
// phone = model.VendorStoreTel
// }
storeParams := &jdapi.OpStoreParams{ storeParams := &jdapi.OpStoreParams{
StationNo: store.VendorStoreID, StationNo: store.VendorStoreID,
Operator: userName, Operator: userName,
@@ -339,6 +337,7 @@ func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode s
// 当前京东的storeCrud消息不会在门店状态改变时发送所以意义不大先放在这里 // 当前京东的storeCrud消息不会在门店状态改变时发送所以意义不大先放在这里
func (c *PurchaseHandler) OnStoreMsg(vendorOrgCode string, msg *jdapi.CallbackOrderMsg) (response *jdapi.CallbackResponse) { func (c *PurchaseHandler) OnStoreMsg(vendorOrgCode string, msg *jdapi.CallbackOrderMsg) (response *jdapi.CallbackResponse) {
globals.SugarLogger.Debugf("OnStoreMsg========= %s", utils.Format4Output(msg, false))
var err error var err error
if msg.StatusID == jdapi.StatusIDUpdateStore { if msg.StatusID == jdapi.StatusIDUpdateStore {
var storeStatus int var storeStatus int

View File

@@ -900,31 +900,34 @@ func (p *PurchaseHandler) GetSkuCategoryIdByName(vendorOrgCode, skuName string)
return "", err return "", err
} }
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, storeId int) error { type SetBoxPrice struct {
storeDetail, err := dao.GetStoreDetail(db, storeId, model.VendorIDMTWM, "") StoreId int `json:"store_id"` // 门店id
SkuId int `json:"sku_id"` // 商品id
BoxPrice float64 `json:"box_price"` // 打包价格
}
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []*SetBoxPrice) error {
storeDetail, err := dao.GetStoreDetail(db, list[0].StoreId, model.VendorIDMTWM, "")
if err != nil { if err != nil {
return err return err
} }
storeSkuList, err := dao.GetStoresSkusInfo(db, []int{storeId}, nil) //storeSkuList, err := dao.GetStoresSkusInfo(db, []int{list[0].StoreId}, nil)
if err != nil { //if err != nil {
return err // return err
} //}
api := getAPI(storeDetail.VendorOrgCode, storeId, storeDetail.VendorStoreID) api := getAPI(storeDetail.VendorOrgCode, list[0].StoreId, storeDetail.VendorStoreID)
foodDataList := make([]map[string]interface{}, 0) foodDataList := make([]map[string]interface{}, 0)
for _, v := range storeSkuList { for _, v := range list {
if v.MtwmID != model.NO {
continue
}
foodDataList = append(foodDataList, map[string]interface{}{ foodDataList = append(foodDataList, map[string]interface{}{
"app_spu_code": utils.Int2Str(v.SkuID), "app_spu_code": utils.Int2Str(v.SkuId),
"skus": []map[string]interface{}{ "skus": []map[string]interface{}{
{ {
"sku_id": utils.Int2Str(v.SkuID), "sku_id": utils.Int2Str(v.SkuId),
"ladder_box_num": "0", "ladder_box_num": "1",
"ladder_box_price": "0", "ladder_box_price": utils.Float64ToStr(v.BoxPrice),
}, },
}, },
}) })

View File

@@ -888,17 +888,17 @@ func (c *SkuController) BatchSetRestockingPrice() {
// @Title 批量设置美团商品打包费为零 // @Title 批量设置美团商品打包费为零
// @Description 批量设置美团商品打包费为零 // @Description 批量设置美团商品打包费为零
// @Param token header string true "认证token" // @Param token header string true "认证token"
// @Param storeIds formData string true "门店id列表" // @Param payload formData string true "json数据SpuData对象()"
// @Success 200 {object} controllers.CallResult // @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult
// @router /BatchSetBoxPrice [post] // @router /BatchSetBoxPrice [post]
func (c *SkuController) BatchSetBoxPrice() { func (c *SkuController) BatchSetBoxPrice() {
c.callBatchSetBoxPrice(func(params *tSkuBatchSetBoxPriceParams) (retVal interface{}, errCode string, err error) { c.callBatchSetBoxPrice(func(params *tSkuBatchSetBoxPriceParams) (retVal interface{}, errCode string, err error) {
var stores []int payload := make([]*mtwm.SetBoxPrice, 0, 0)
if err = jxutils.Strings2Objs(params.StoreIds, &stores); err != nil { if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err != nil {
return retVal, "", err return nil, "", err
} }
err = cms.BatchSetMTBoxPrice(params.Ctx, stores) err = cms.BatchSetMTBoxPrice(params.Ctx, payload)
return retVal, "", err return retVal, "", err
}) })
} }

View File

@@ -4,7 +4,9 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/bidding" "git.rosy.net.cn/jx-callback/business/bidding"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/partner/delivery" "git.rosy.net.cn/jx-callback/business/partner/delivery"
"strings" "strings"
"time" "time"
@@ -496,12 +498,38 @@ func (c *OrderController) StaleIndexInfo() {
if err != nil { if err != nil {
return nil, "", err return nil, "", err
} }
ctx := params.Ctx
if !auth2.IsV2Token(ctx.GetToken()) {
return nil, model.ErrCodeTokenIsInvalid, model.ErrTokenIsInvalid
}
mobile, userID := ctx.GetMobileAndUserID()
if mobile == "" || userID == "" || userID == "null" || userID == "NULL" {
return nil, "", fmt.Errorf("不能得到用户手机号,%s,%s", userID, mobile)
}
var storeList []*dao.StoreWithCityName
dataList := make([]int, 0, len(storeList))
mapDataList := make(map[int]int, len(storeList))
if storeList, err = cms.GetStoreList4User(ctx, mobile, userID); err == nil && len(storeList) > 0 {
// todo应该用通用方法
for _, v := range storeList {
dataList = append(dataList, v.Store.ID)
mapDataList[v.Store.ID] = model.YES
}
} else {
return retVal, "", err
}
if params.StoreID != 0 && mapDataList[params.StoreID] != model.YES {
return retVal, "", fmt.Errorf("此门店%d,不归属于该用户%s", params.StoreID, ctx.GetUserName())
}
var vendors []int var vendors []int
var brandIds []int var brandIds []int
if err := jxutils.Strings2Objs(params.VendorIds, &vendors, params.BrandIds, &brandIds); err != nil { if err := jxutils.Strings2Objs(params.VendorIds, &vendors, params.BrandIds, &brandIds); err != nil {
return nil, "", err return retVal, "", err
} }
retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo2(params.Ctx, timeList[0], timeList[1], params.StoreID, brandIds, vendors) retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo2(params.Ctx, timeList[0], timeList[1], params.StoreID, brandIds, vendors, dataList, mapDataList)
return retVal, "", err return retVal, "", err
}) })
} }