冲突
This commit is contained in:
@@ -194,6 +194,33 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
|
||||
}
|
||||
}
|
||||
}
|
||||
//更新订单new_earning_price
|
||||
if order.EarningType == model.EarningTypePoints {
|
||||
waybill, _ := c.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID)
|
||||
store, _ := c.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
||||
if waybill == nil {
|
||||
// if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
||||
// if order.NewEarningPrice == 0 || order.NewEarningPrice != order.TotalShopMoney*int64(100-store.PayPercentage)/int64(100) {
|
||||
// order.NewEarningPrice = order.TotalShopMoney * int64(100-store.PayPercentage) / int64(100)
|
||||
// }
|
||||
// } else {
|
||||
if order.NewEarningPrice == 0 || order.NewEarningPrice != order.TotalShopMoney*int64(100-store.PayPercentage/2)/int64(100) {
|
||||
order.NewEarningPrice = order.TotalShopMoney * int64(100-store.PayPercentage/2) / int64(100)
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
// if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
||||
// if order.NewEarningPrice == 0 || order.NewEarningPrice != (order.TotalShopMoney-waybill.DesiredFee)*int64(100-store.PayPercentage)/int64(100) {
|
||||
// order.NewEarningPrice = (order.TotalShopMoney - waybill.DesiredFee) * int64(100-store.PayPercentage) / int64(100)
|
||||
// }
|
||||
// } else {
|
||||
if order.NewEarningPrice == 0 || order.NewEarningPrice != (order.TotalShopMoney-waybill.DesiredFee)*int64(100-store.PayPercentage/2)/int64(100) {
|
||||
order.NewEarningPrice = (order.TotalShopMoney - waybill.DesiredFee) * int64(100-store.PayPercentage/2) / int64(100)
|
||||
}
|
||||
// }
|
||||
}
|
||||
dao.UpdateEntity(db, order, "NewEarningPrice")
|
||||
}
|
||||
}
|
||||
} else if orderStatus.Status == model.OrderStatusCanceled {
|
||||
//如果取消订单则要把库存加回去
|
||||
@@ -437,6 +464,7 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
v.ShopPrice = v.SalePrice * 70 / 100
|
||||
}
|
||||
}
|
||||
v.SkuName = jxutils.ComposeSkuNameOriginal(skuBindInfo.Prefix, skuBindInfo.Name, skuBindInfo.Comment, skuBindInfo.Unit, skuBindInfo.SpecQuality, skuBindInfo.SpecUnit, 0)
|
||||
v.Weight = skuBindInfo.Weight // 以本地信息中的WEIGHT为准
|
||||
//饿鲜达的订单做一下处理
|
||||
if strings.Contains(order.StoreName, model.ExdStoreName) {
|
||||
@@ -1314,29 +1342,29 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
|
||||
order.StoreID = storeID
|
||||
order.StoreName = stores[0].Name
|
||||
order.VendorStoreID = storeMaps[0].VendorStoreID
|
||||
//如果是立即达的订单,要判断一下送达时间是否在门店营业时间范围内
|
||||
//如果是立即达的订单,要判断一下下单时间是否在门店营业时间范围内
|
||||
//若没有,则要把这个订单变成定时达,预计送达时间改为门店的营业时间
|
||||
//如果门店没有营业时间,则直接报错
|
||||
if order.BusinessType == model.BusinessTypeImmediate {
|
||||
store := stores[0]
|
||||
var (
|
||||
opentime1 = jxutils.JxOperationTime2TimeByDate(store.OpenTime1, order.ExpectedDeliveredTime)
|
||||
opentime2 = jxutils.JxOperationTime2TimeByDate(store.OpenTime2, order.ExpectedDeliveredTime)
|
||||
closetime1 = jxutils.JxOperationTime2TimeByDate(store.CloseTime1, order.ExpectedDeliveredTime)
|
||||
closetime2 = jxutils.JxOperationTime2TimeByDate(store.CloseTime2, order.ExpectedDeliveredTime)
|
||||
expectedTime = order.ExpectedDeliveredTime
|
||||
opentime1 = jxutils.JxOperationTime2TimeByDate(store.OpenTime1, order.OrderCreatedAt)
|
||||
opentime2 = jxutils.JxOperationTime2TimeByDate(store.OpenTime2, order.OrderCreatedAt)
|
||||
closetime1 = jxutils.JxOperationTime2TimeByDate(store.CloseTime1, order.OrderCreatedAt)
|
||||
closetime2 = jxutils.JxOperationTime2TimeByDate(store.CloseTime2, order.OrderCreatedAt)
|
||||
orderCreatedAt = order.OrderCreatedAt
|
||||
)
|
||||
if store.OpenTime1 == 0 || store.CloseTime1 == 0 {
|
||||
return "", fmt.Errorf("该门店没有营业时间,不能接单!门店:[%v]", storeID)
|
||||
}
|
||||
if !(expectedTime.Sub(opentime1) >= 0 && expectedTime.Sub(closetime1) <= 0) {
|
||||
if !(orderCreatedAt.Sub(opentime1) >= 0 && orderCreatedAt.Sub(closetime1) <= 0) {
|
||||
if store.OpenTime2 != 0 && store.CloseTime2 != 0 {
|
||||
if !(expectedTime.Sub(opentime2) >= 0 && expectedTime.Sub(closetime2) <= 0) {
|
||||
if expectedTime.Sub(opentime1) < 0 {
|
||||
if !(orderCreatedAt.Sub(opentime2) >= 0 && orderCreatedAt.Sub(closetime2) <= 0) {
|
||||
if orderCreatedAt.Sub(opentime1) < 0 {
|
||||
order.ExpectedDeliveredTime = opentime1
|
||||
order.BusinessType = model.BusinessTypeDingshida
|
||||
} else {
|
||||
if expectedTime.Sub(opentime2) < 0 {
|
||||
if orderCreatedAt.Sub(opentime2) < 0 {
|
||||
order.ExpectedDeliveredTime = opentime2
|
||||
} else {
|
||||
order.ExpectedDeliveredTime = opentime1.AddDate(0, 0, 1)
|
||||
@@ -1345,7 +1373,7 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if expectedTime.Sub(opentime1) < 0 {
|
||||
if orderCreatedAt.Sub(opentime1) < 0 {
|
||||
order.ExpectedDeliveredTime = opentime1
|
||||
} else {
|
||||
order.ExpectedDeliveredTime = opentime1.AddDate(0, 0, 1)
|
||||
@@ -1506,3 +1534,23 @@ func AdjustJdsOrderSimple(ctx *jxcontext.Context, vendorOrderID string, skuID in
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateWaybillDesiredFee(ctx *jxcontext.Context, vendorOrderID string, desiredFee int) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
order, _ := dao.GetSimpleOrder(db, vendorOrderID)
|
||||
if order == nil {
|
||||
return fmt.Errorf("未找到该订单!orderID: %v", vendorOrderID)
|
||||
}
|
||||
bill, err := partner.CurOrderManager.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if bill == nil {
|
||||
return fmt.Errorf("未找到此订单对应的运单!orderID: %v", vendorOrderID)
|
||||
}
|
||||
bill.DesiredFee = int64(desiredFee)
|
||||
_, err = dao.UpdateEntity(db, bill, "DesiredFee")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ const (
|
||||
minute2Schedule3rdCarrier4Ebai = 30 // 饿百的最少转自配送需要的时间(分钟)
|
||||
minMinute2Schedule3rdCarrier = 5 // 转三方配送最少等待时间(分钟)
|
||||
|
||||
time2AutoPickupMin = 14 * time.Minute // 自动拣货等待时间,这个只有在没有PickDeadline信息才有用,否则会根据PickDeadline设置
|
||||
second2AutoPickupGap = 60 //随机60秒
|
||||
time2AutoPickupAhead = 20 * time.Second // 有最后拣货时间的提前值
|
||||
time2AutoPickupMin = 14 * time.Minute // 自动拣货等待时间,这个只有在没有PickDeadline信息才有用,否则会根据PickDeadline设置
|
||||
second2AutoPickupGap = 60 //随机60秒
|
||||
time2AutoPickupAhead = 120 * time.Second // 有最后拣货时间的提前值
|
||||
|
||||
switch2SelfDeliverRetryGap = 3 * time.Second // 转自送失败尝试的时间间隙
|
||||
switch2SelfDeliverRetryCount = 2 // 转自送失败尝试次数
|
||||
@@ -1180,7 +1180,7 @@ func (s *DefScheduler) updateOrderByBill(order *model.GoodsOrder, bill *model.Wa
|
||||
if bill.Status == model.WaybillStatusDelivered {
|
||||
storeDetail, _ := partner.CurOrderManager.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
||||
if storeDetail != nil {
|
||||
jxutils.RefreshOrderEarningPrice2(order, storeDetail.PayPercentage)
|
||||
jxutils.RefreshOrderEarningPrice3(order, storeDetail.PayPercentage, bill)
|
||||
updateFields = append(updateFields, "NewEarningPrice")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,6 +1057,47 @@ func RefreshPageActs(ctx *jxcontext.Context, vendorIDs []int, createdFrom time.T
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func DeleteStoresFromAct(ctx *jxcontext.Context, vendorID int, actTypes, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
task := tasksch.NewParallelTask("将SKU从所有活动中删除", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeID := batchItemList[0].(int)
|
||||
acts, _ := dao.QueryActs(db, 0, 0, 50, 0, "", vendorID, []int{1}, actTypes, nil, storeID, nil, 0, utils.ZeroTimeValue, utils.ZeroTimeValue, time.Now().AddDate(0, -3, 0), time.Now())
|
||||
for _, v := range acts.Data {
|
||||
var actStoreSkuParam []*ActStoreSkuParam
|
||||
_, actStoreSkus, _ := dao.GetActStoreSkuVendorList(db, v.ID, []int{vendorID}, nil, nil, "", 0, 99999)
|
||||
for _, actStoreSku := range actStoreSkus {
|
||||
if actStoreSku.StoreID == storeID {
|
||||
aa := &ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
StoreID: storeID,
|
||||
SkuID: actStoreSku.SkuID,
|
||||
ActID: v.ID,
|
||||
},
|
||||
}
|
||||
actStoreSkuParam = append(actStoreSkuParam, aa)
|
||||
}
|
||||
}
|
||||
_, err = DeleteActStoreSkuBind(ctx, db, v.ID, actStoreSkuParam)
|
||||
if err == nil {
|
||||
_, err = SyncAct(ctx, nil, v.ID, nil, true)
|
||||
}
|
||||
}
|
||||
|
||||
return retVal, err
|
||||
}, storeIDs)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if err = err2; err == nil {
|
||||
hint = utils.Int2Str(len(resultList))
|
||||
}
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, actTypes, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
actMap := make(map[int]*model.Act)
|
||||
|
||||
@@ -672,6 +672,7 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric
|
||||
'","eclpID":"', t2.eclp_id,
|
||||
'","weight":', t2.weight, ',"categoryID":', t2.category_id, ',"nameID":', t2.name_id,
|
||||
', "seq":', t2.seq,
|
||||
', "minOrderCount":', t2.min_order_count,
|
||||
"}")), "]") skus_str,
|
||||
CONCAT("[", GROUP_CONCAT(DISTINCT t3.place_code), "]") places_str
|
||||
` + sql + `
|
||||
|
||||
@@ -2,6 +2,7 @@ package cms
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -3399,13 +3400,16 @@ func UpdateStorePricePack(ctx *jxcontext.Context, storeID, vendorID int, pricePa
|
||||
}()
|
||||
//证明是门店自己的调价包
|
||||
if strings.Contains(pricePack, utils.Int2Str(storeID)) {
|
||||
obj := dao.PricePercentagePack2Obj(value)
|
||||
realValue, _ := json.Marshal(obj)
|
||||
// _, err = UpdateConfig(ctx, pricePack, model.ConfigTypePricePack, string(realValue))
|
||||
configList, err := dao.QueryConfigs(db, pricePack, model.ConfigTypePricePack, "")
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
if _, err = dao.UpdateEntityLogically(db, configList[0], map[string]interface{}{
|
||||
"Value": value,
|
||||
"Value": string(realValue),
|
||||
}, ctx.GetUserName(), nil); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
|
||||
@@ -4079,7 +4079,7 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo
|
||||
snapshotAt = utils.Time2Date(time.Now())
|
||||
)
|
||||
storeSkuBindHis := &model.StoreSkuBindHistory{
|
||||
SnapshotAt: snapshotAt.AddDate(0, 0, -2),
|
||||
SnapshotAt: snapshotAt.AddDate(0, 0, -5),
|
||||
}
|
||||
dao.DeleteEntity(db, storeSkuBindHis, "SnapshotAt")
|
||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
||||
@@ -4397,7 +4397,6 @@ func SyncMatterC4ToGy(ctx *jxcontext.Context, isContinueWhenError, isAsync bool)
|
||||
updateMatters = append(updateMatters, skusMap[c4.EclpID])
|
||||
}
|
||||
}
|
||||
fmt.Println("updateMatters", utils.Format4Output(updateMatters, false))
|
||||
case 1:
|
||||
if len(deleteMatters) > 0 {
|
||||
for _, v := range deleteMatters {
|
||||
|
||||
@@ -1297,6 +1297,9 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
ShopInfo, _ := api.MtpsAPI.ShopQuery(strconv.Itoa(storeId))
|
||||
if ShopInfo != nil {
|
||||
ShopName = ShopInfo.ShopName
|
||||
if ShopName == "" {
|
||||
ShopName = StoreLists[0].Name[:len(StoreLists[0].Name)-3]
|
||||
}
|
||||
StoreInfoList, _ = api.MtpsAPI.GetStoreStatus(ShopName)
|
||||
if StoreInfoList != nil && StoreInfoList.DataList != nil {
|
||||
goto ifExist
|
||||
@@ -1354,15 +1357,15 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
||||
{
|
||||
if StoreInfoList.DataList[0].OuterPoiID != "" {
|
||||
//若存在且名字不为空,就是找到了
|
||||
if StoreInfoList.DataList[0].OpenType != courierStatus {
|
||||
sl := make(map[string]interface{})
|
||||
sl["vendorStoreID"] = StoreInfoList.DataList[0].OuterPoiID
|
||||
sl["status"] = StoreInfoList.DataList[0].OpenType
|
||||
sl["vendorStatus"] = StoreInfoList.DataList[0].OpenType
|
||||
globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
||||
StoreInfoList.DataList[0].OuterPoiID, StoreInfoList.DataList[0].PoiName, strconv.Itoa(StoreInfoList.DataList[0].OpenType), strconv.Itoa(StoreLists[0].Status))
|
||||
UpdateStoreCourierMap(ctx, nil, storeId, model.VendorIDMTPS, sl, ctx.GetUserName())
|
||||
}
|
||||
// if StoreInfoList.DataList[0].OpenType != courierStatus ||{
|
||||
sl := make(map[string]interface{})
|
||||
sl["vendorStoreID"] = StoreInfoList.DataList[0].OuterPoiID
|
||||
sl["status"] = StoreInfoList.DataList[0].OpenType
|
||||
sl["vendorStatus"] = StoreInfoList.DataList[0].OpenType
|
||||
globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
||||
StoreInfoList.DataList[0].OuterPoiID, StoreInfoList.DataList[0].PoiName, strconv.Itoa(StoreInfoList.DataList[0].OpenType), strconv.Itoa(StoreLists[0].Status))
|
||||
UpdateStoreCourierMap(ctx, nil, storeId, model.VendorIDMTPS, sl, ctx.GetUserName())
|
||||
// }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -165,9 +165,9 @@ func Init() {
|
||||
|
||||
ScheduleTimerFunc("doDailyWork2", doDailyWork2, dailyWorkTimeList2)
|
||||
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now())
|
||||
}, 10*time.Second, 10*time.Minute)
|
||||
// ScheduleTimerFuncByInterval(func() {
|
||||
// orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now())
|
||||
// }, 10*time.Second, 10*time.Minute)
|
||||
|
||||
//京东的订单信息解密密钥获取
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
|
||||
@@ -804,6 +804,7 @@ func GetWeeklyStoreScore(storeID, weekIndexParam int) (outWeeklyStoreScoreDataLi
|
||||
if weekIndexParam == -1 {
|
||||
outWeeklyStoreScoreDataList = weeklyStoreScoreDataList
|
||||
} else {
|
||||
fmt.Println("testss", utils.Format4Output(weeklyStoreScoreDataList, false))
|
||||
outWeeklyStoreScoreDataList = []*model.WeeklyStoreScore{weeklyStoreScoreDataList[weekIndexParam]}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1587,36 +1587,58 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
|
||||
// fmt.Println("deleteList2", deleteList)
|
||||
db := dao.GetDB()
|
||||
storeIDs := []int{
|
||||
667443,
|
||||
667433,
|
||||
667389,
|
||||
666862,
|
||||
666835,
|
||||
666830,
|
||||
666826,
|
||||
666822,
|
||||
666800,
|
||||
666785,
|
||||
666775,
|
||||
666772,
|
||||
103459,
|
||||
102860,
|
||||
102859,
|
||||
102858,
|
||||
102852,
|
||||
102847,
|
||||
102811,
|
||||
102793,
|
||||
102780,
|
||||
101732,
|
||||
100714,
|
||||
100712,
|
||||
667335,
|
||||
667321,
|
||||
667319,
|
||||
667260,
|
||||
667227,
|
||||
667167,
|
||||
667109,
|
||||
667094,
|
||||
667050,
|
||||
666898,
|
||||
666852,
|
||||
666815,
|
||||
666763,
|
||||
666761,
|
||||
666760,
|
||||
666759,
|
||||
666714,
|
||||
666708,
|
||||
666705,
|
||||
666669,
|
||||
103437,
|
||||
103425,
|
||||
103349,
|
||||
103123,
|
||||
103116,
|
||||
103107,
|
||||
103069,
|
||||
103019,
|
||||
102940,
|
||||
102890,
|
||||
102831,
|
||||
102772,
|
||||
102751,
|
||||
101870,
|
||||
101755,
|
||||
101176,
|
||||
100767,
|
||||
100754,
|
||||
100726,
|
||||
100699,
|
||||
100476,
|
||||
100369,
|
||||
100366,
|
||||
100361,
|
||||
100351,
|
||||
100350,
|
||||
}
|
||||
for _, storeID := range storeIDs {
|
||||
acts, _ := dao.QueryActs(db, 0, 0, 50, -1, "", -1, []int{1}, []int{0, 3, 4}, nil, storeID, nil, 0, utils.ZeroTimeValue, utils.ZeroTimeValue, utils.Str2Time("2020-05-30 00:00:00"), utils.Str2Time("2020-07-30 00:00:00"))
|
||||
acts, _ := dao.QueryActs(db, 0, 0, 50, 0, "", -1, []int{1}, []int{0, 3, 4}, nil, storeID, nil, 0, utils.ZeroTimeValue, utils.ZeroTimeValue, utils.Str2Time("2020-05-30 00:00:00"), utils.Str2Time("2020-07-30 00:00:00"))
|
||||
for _, v := range acts.Data {
|
||||
var actStoreSkuParam []*act.ActStoreSkuParam
|
||||
_, actStoreSkus, _ := dao.GetActStoreSkuVendorList(db, v.ID, nil, nil, nil, "", 0, 99999)
|
||||
_, actStoreSkus, _ := dao.GetActStoreSkuVendorList(db, v.ID, []int{0}, nil, nil, "", 0, 99999)
|
||||
for _, actStoreSku := range actStoreSkus {
|
||||
if actStoreSku.StoreID == storeID {
|
||||
aa := &act.ActStoreSkuParam{
|
||||
|
||||
@@ -590,11 +590,24 @@ func RefreshOrderSkuRelated(order *model.GoodsOrder) *model.GoodsOrder {
|
||||
|
||||
func RefreshOrderEarningPrice2(order *model.GoodsOrder, payPercentage int) *model.GoodsOrder {
|
||||
if order.EarningType == model.EarningTypePoints {
|
||||
if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
||||
order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage)) / 100
|
||||
} else {
|
||||
order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage/2)) / 100
|
||||
}
|
||||
// if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
||||
// order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage)) / 100
|
||||
// } else {
|
||||
order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage/2)) / 100
|
||||
// }
|
||||
} else {
|
||||
order.NewEarningPrice = order.EarningPrice
|
||||
}
|
||||
return order
|
||||
}
|
||||
|
||||
func RefreshOrderEarningPrice3(order *model.GoodsOrder, payPercentage int, bill *model.Waybill) *model.GoodsOrder {
|
||||
if order.EarningType == model.EarningTypePoints {
|
||||
// if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
||||
// order.NewEarningPrice = (order.TotalShopMoney - bill.DesiredFee) * int64((100 - payPercentage)) / 100
|
||||
// } else {
|
||||
order.NewEarningPrice = (order.TotalShopMoney - bill.DesiredFee) * int64((100 - payPercentage/2)) / 100
|
||||
// }
|
||||
} else {
|
||||
order.NewEarningPrice = order.EarningPrice
|
||||
}
|
||||
|
||||
@@ -286,6 +286,12 @@ type StoreSkuPriceAndWeight struct {
|
||||
SkuID int `orm:"column(sku_id)"`
|
||||
Weight int
|
||||
Price int
|
||||
Prefix string
|
||||
Name string
|
||||
Unit string
|
||||
Comment string
|
||||
SpecQuality float32
|
||||
SpecUnit string
|
||||
}
|
||||
|
||||
type StoreSkuAndName struct {
|
||||
@@ -621,10 +627,12 @@ func GetStoreSkuPriceAndWeight(db *DaoDB, vendorStoreID string, vendorID int, ve
|
||||
vendorSkuIDField = fmt.Sprintf("t2.%s_id", ConvertDBFieldPrefix(model.VendorNames[vendorID]))
|
||||
}
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT %s vendor_sku_id, t1.id sku_id, t2.price, t1.weight
|
||||
SELECT %s vendor_sku_id, t1.id sku_id, t2.price, t1.weight,
|
||||
t5.prefix, t5.name, t1.comment, t5.unit, t1.spec_quality, t1.spec_unit
|
||||
FROM sku t1
|
||||
JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.deleted_at = ?
|
||||
JOIN store_map t3 ON t3.store_id = t2.store_id AND t3.vendor_id = ? AND t3.vendor_store_id = ? AND t3.deleted_at = ?
|
||||
JOIN sku_name t5 ON t5.id = t1.name_id
|
||||
%s
|
||||
WHERE %s IN (`+GenQuestionMarks(len(vendorSkuIDs))+`)`, vendorSkuIDField, sqlThingMap, vendorSkuIDField)
|
||||
sqlParams := []interface{}{
|
||||
|
||||
@@ -226,6 +226,7 @@ type Sku struct {
|
||||
ExdSkuID string `orm:"column(exd_sku_id)" json:"exdSkuID"` //饿鲜达商品ID
|
||||
ExdCategoryThirdID int `orm:"column(exd_category_third_id)" json:"exdCategoryThirdID"`
|
||||
EclpID string `orm:"column(eclp_id)" json:"eclpID"` //eclp物料商品ID
|
||||
MinOrderCount int `json:"minOrderCount"` //最少起购份数,美团用
|
||||
// JdID int64 `orm:"column(jd_id);null;index" json:"jdID"`
|
||||
// JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
||||
|
||||
|
||||
@@ -228,14 +228,14 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder)
|
||||
}
|
||||
if billParams.ShopNo, err = c.getDadaShopID(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
|
||||
}
|
||||
// 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.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4(order.BuyerComment+"取货失败请联系平台电话:18048531223"+storeTel))
|
||||
billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4(order.BuyerComment+"取货失败或配送遇到问题请联系18048531223,禁止未配送直接完成定单!"))
|
||||
billParams.CargoType = dadaapi.CargoTypeFresh
|
||||
billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
||||
billParams.CargoNum = order.GoodsCount
|
||||
|
||||
@@ -238,13 +238,13 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
||||
// "goods_pickup_info": fmt.Sprintf("%s第%d号单", model.VendorChineseNames[order.VendorID], order.OrderSeq),
|
||||
// "poi_seq": fmt.Sprintf("#%d", order.OrderSeq),
|
||||
// }
|
||||
storeTel := ""
|
||||
storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
if storeDeatail.Tel2 != "" {
|
||||
storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
}
|
||||
billParams.Note = utils.FilterMb4(order.BuyerComment + ",取货失败请联系平台电话:18048531223" + storeTel)
|
||||
// storeTel := ""
|
||||
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
// if storeDeatail.Tel2 != "" {
|
||||
// storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
// }
|
||||
billParams.Note = utils.FilterMb4(order.BuyerComment + ",取货失败或配送遇到问题请联系18048531223,禁止未配送直接完成定单!")
|
||||
billParams.GoodsDetail = string(utils.MustMarshal(goods))
|
||||
billParams.GoodsPickupInfo = fmt.Sprintf("%s第%d号单", model.VendorChineseNames[order.VendorID], order.OrderSeq)
|
||||
billParams.PoiSeq = fmt.Sprintf("#%d", order.OrderSeq)
|
||||
|
||||
@@ -390,6 +390,7 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||
phone = model.VendorStoreTel
|
||||
}
|
||||
params["ivr_phone"] = phone //统一改为这个电话
|
||||
|
||||
if store.VendorStoreID != "" {
|
||||
params["baidu_shop_id"] = store.VendorStoreID
|
||||
}
|
||||
@@ -402,7 +403,7 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||
}
|
||||
boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee)
|
||||
params["package_box_price"] = boxFee
|
||||
|
||||
params["service_phone"] = store.Tel1
|
||||
params["address"] = store.Address
|
||||
// todo 饿百 开店审核通过后不允许修改商户信息
|
||||
if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreAddress*/) != 0 {
|
||||
|
||||
@@ -109,6 +109,16 @@ func (c *PurchaseHandler) onOrderMsg(vendorOrgCode string, msg *jdapi.CallbackOr
|
||||
c.onOrderComment2(a, msg)
|
||||
})
|
||||
}
|
||||
// if msg.StatusID == jdapi.OrderStatusVenderAgreeCancel {
|
||||
// order := &model.GoodsOrder{
|
||||
// VendorOrgCode: vendorOrgCode,
|
||||
// VendorOrderID: msg.BillID,
|
||||
// }
|
||||
// err2 := c.PickupGoods(order, false, jxcontext.AdminCtx.GetUserName())
|
||||
// if err2 != nil {
|
||||
// globals.SugarLogger.Warnf("京东取消拣货:%v", err2)
|
||||
// }
|
||||
// }
|
||||
err := partner.CurOrderManager.OnOrderStatusChanged(vendorOrgCode, status)
|
||||
retVal = jdapi.Err2CallbackResponse(err, status.VendorStatus)
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ func (c *PurchaseHandler) RefundOrder(ctx *jxcontext.Context, order *model.Goods
|
||||
// 发起部分退款
|
||||
func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) {
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = getAPI(order.VendorOrgCode).AfsSubmit(order.VendorOrderID, ctx.GetUserName(), utils.Int2Str(jdapi.AfsReasonWrongPurchase), reason, "", order.ConsigneeName, order.ConsigneeMobile, order.ConsigneeAddress, orderSkus2AfsSkus(refundSkuList))
|
||||
_, err = getAPI(order.VendorOrgCode).AfsSubmit(order.VendorOrderID, ctx.GetUserName(), utils.Int2Str(jdapi.AfsReasonTypeWrongGoods), reason, "", order.ConsigneeName, order.ConsigneeMobile, order.ConsigneeAddress, orderSkus2AfsSkus(refundSkuList))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -34,7 +34,12 @@ func OnCallbackMsg(msg *jdshopapi.CallBackResult) (err error) {
|
||||
})
|
||||
case jcqapi.TopicOrderCancel:
|
||||
utils.CallFuncAsync(func() {
|
||||
CurPurchaseHandler.CancelOrder(jxcontext.AdminCtx, getRealOrderID(msg.OrderID), "系统取消")
|
||||
order := getRealOrderID(msg.OrderID)
|
||||
if order != nil {
|
||||
if order.Status != model.OrderStatusCanceled {
|
||||
CurPurchaseHandler.CancelOrder(jxcontext.AdminCtx, order, "系统取消")
|
||||
}
|
||||
}
|
||||
})
|
||||
default:
|
||||
return fmt.Errorf("暂不支持的topic类型!topic: %v", msgType)
|
||||
@@ -44,6 +49,9 @@ func OnCallbackMsg(msg *jdshopapi.CallBackResult) (err error) {
|
||||
|
||||
func SaveJdsOrders(msg *jdshopapi.CallBackResult) (err error) {
|
||||
order, err := result2Orders(msg)
|
||||
if err != nil || order == nil {
|
||||
return err
|
||||
}
|
||||
order.StoreID = 102919
|
||||
order.JxStoreID = 102919
|
||||
order.StoreName = "商城模板(成都发货)"
|
||||
@@ -74,8 +82,8 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
OrderCreatedAt: utils.Str2Time(msg.OrderStartTime),
|
||||
ConsigneeAddress: Decrypt(msg.ConsigneeInfo.FullAddress),
|
||||
ConsigneeName: Decrypt(msg.ConsigneeInfo.Fullname),
|
||||
ConsigneeMobile: Decrypt(msg.ConsigneeInfo.Telephone),
|
||||
ConsigneeMobile2: Decrypt(msg.ConsigneeInfo.Mobile),
|
||||
ConsigneeMobile: Decrypt(msg.ConsigneeInfo.Mobile),
|
||||
ConsigneeMobile2: Decrypt(msg.ConsigneeInfo.Telephone),
|
||||
ActualPayPrice: jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)),
|
||||
Status: model.OrderStatusNew,
|
||||
TotalShopMoney: utils.Float64TwoInt64(math.Round(float64(jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment))) * jdshopapi.JdsPayPercentage)),
|
||||
@@ -99,6 +107,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
}
|
||||
order.StoreID = storeList[0].ID
|
||||
order.StoreName = storeList[0].Name
|
||||
globals.SugarLogger.Debugf("jds GetStoreListByLocation, orderID: %v storeID :%v", order.VendorOrderID, order.StoreID)
|
||||
storeMaps, _ := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDJDShop}, []int{order.StoreID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "")
|
||||
if len(storeMaps) > 0 {
|
||||
order.VendorStoreID = storeMaps[0].VendorStoreID
|
||||
@@ -115,6 +124,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
order.BusinessType = model.BusinessTypeImmediate
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("暂不支持的京东商城订单类型!type: %v", msg.OrderState)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//结算类型
|
||||
@@ -162,6 +172,9 @@ func setJdsOrderSeq(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
func Decrypt(p string) (result string) {
|
||||
if p == "" {
|
||||
return ""
|
||||
}
|
||||
data, _ := base64.StdEncoding.DecodeString(strings.ReplaceAll(p, " ", "+"))
|
||||
key := GetKey(hex.EncodeToString(data)[4:36])
|
||||
data2, _ := base64.StdEncoding.DecodeString(key)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jdshop
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -50,7 +51,9 @@ func (p *PurchaseHandler) GetOrderStatus(vendorOrgCode, vendorOrderID string) (s
|
||||
params["orderID"] = vendorOrderID
|
||||
params["token"] = "JxCaIsHiGetJsdOrderTmpToken_20200731"
|
||||
result, err := apiToYd("order/GetJdsOrder", params)
|
||||
return status2Jxstatus(result["orderState"].(string)), err
|
||||
jdsOrder := &jdshopapi.GetOrderResult{}
|
||||
json.Unmarshal([]byte(strings.ReplaceAll(result["data"].(string), "\\", "")), &jdsOrder)
|
||||
return status2Jxstatus(jdsOrder.OrderState), err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
@@ -193,9 +196,11 @@ func apiToYd(url string, params map[string]interface{}) (retVal map[string]inter
|
||||
}
|
||||
if err == nil {
|
||||
if jsonResult1["code"] != nil {
|
||||
errLevel = platformapi.ErrLevelGeneralFail
|
||||
err = utils.NewErrorCode(jsonResult1["desc"].(string), jsonResult1["code"].(string))
|
||||
baseapi.SugarLogger.Debugf("yd AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
if utils.Interface2Int64WithDefault(jsonResult1["code"], 0) != 0 {
|
||||
errLevel = platformapi.ErrLevelGeneralFail
|
||||
err = utils.NewErrorCode(jsonResult1["desc"].(string), jsonResult1["code"].(string))
|
||||
baseapi.SugarLogger.Debugf("yd AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
}
|
||||
}
|
||||
retVal = jsonResult1
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||
@@ -847,6 +849,7 @@ func jxOrder2GoodsOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, deliveryAd
|
||||
}
|
||||
order.TotalShopMoney += jxOrder.FreightPrice
|
||||
order.ActualPayPrice = order.TotalShopMoney
|
||||
order.TotalShopMoney = utils.Float64TwoInt64(float64(order.TotalShopMoney) * jdshopapi.JdsPayPercentage)
|
||||
if jxOrder.FromStoreID != 0 {
|
||||
order.FromStoreID = jxOrder.FromStoreID
|
||||
order.DeliveryFlag = model.OrderDeliveryFlagMaskScheduleDisabled
|
||||
@@ -1709,44 +1712,44 @@ func SendFailedMatterOrder(ctx *jxcontext.Context, vendorOrderID string) (err er
|
||||
if order == nil || order.StoreID != model.MatterStoreID || order.FromStoreID == 0 {
|
||||
return fmt.Errorf("只允许物料店重发物料订单调用此接口!")
|
||||
}
|
||||
queryOrderStatus, err := api.JdEclpAPI.QueryOrderStatus(order.EclpOutID)
|
||||
if len(queryOrderStatus.OrderStatusList) > 0 {
|
||||
code := queryOrderStatus.OrderStatusList[len(queryOrderStatus.OrderStatusList)-1].SoStatusCode
|
||||
if code == jdeclpapi.SoStatusCode10022 || code == jdeclpapi.SoStatusCode10038 { //表示该订单在京东物流为暂停或已经逆向发货完成
|
||||
if len(order.VendorOrderID) == 14 && order.EclpOutID != "" { //这是不分包的订单
|
||||
_, err = createMatterOrder(buildJxOrderInfo(order, order.Skus), order, int64(00))
|
||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||
for _, v := range order.Skus {
|
||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||
}
|
||||
} else if len(order.VendorOrderID) == 14 && order.EclpOutID == "" { //这是分包的主订单
|
||||
goodsList, err := dao.GetMatterChildOrders(db, order.VendorOrderID)
|
||||
// queryOrderStatus, err := api.JdEclpAPI.QueryOrderStatus(order.EclpOutID)
|
||||
// if len(queryOrderStatus.OrderStatusList) > 0 {
|
||||
// code := queryOrderStatus.OrderStatusList[len(queryOrderStatus.OrderStatusList)-1].SoStatusCode
|
||||
// if code == jdeclpapi.SoStatusCode10022 || code == jdeclpapi.SoStatusCode10038 { //表示该订单在京东物流为暂停或已经逆向发货完成
|
||||
if len(order.VendorOrderID) == 14 && order.EclpOutID != "" { //这是不分包的订单
|
||||
_, err = createMatterOrder(buildJxOrderInfo(order, order.Skus), order, int64(01))
|
||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||
for _, v := range order.Skus {
|
||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||
}
|
||||
} else if len(order.VendorOrderID) == 14 && order.EclpOutID == "" { //这是分包的主订单
|
||||
goodsList, err := dao.GetMatterChildOrders(db, order.VendorOrderID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(goodsList) > 0 {
|
||||
for _, v := range goodsList {
|
||||
cOrder, err := partner.CurOrderManager.LoadOrder(v.VendorOrderID, model.VendorIDJX)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(goodsList) > 0 {
|
||||
for _, v := range goodsList {
|
||||
cOrder, err := partner.CurOrderManager.LoadOrder(v.VendorOrderID, model.VendorIDJX)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
suffix := utils.Str2Int64(cOrder.VendorOrderID[len(cOrder.VendorOrderID)-2:]) + int64(len(goodsList))
|
||||
_, err = createMatterOrder(buildJxOrderInfo(cOrder, cOrder.Skus), cOrder, suffix)
|
||||
for _, v := range cOrder.Skus {
|
||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||
}
|
||||
}
|
||||
suffix := utils.Str2Int64(cOrder.VendorOrderID[len(cOrder.VendorOrderID)-2:]) + int64(len(goodsList))
|
||||
_, err = createMatterOrder(buildJxOrderInfo(cOrder, cOrder.Skus), cOrder, suffix)
|
||||
for _, v := range cOrder.Skus {
|
||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||
}
|
||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||
} else if len(order.VendorOrderID) == 16 && order.EclpOutID != "" { // 这是分包的子订单
|
||||
return fmt.Errorf("请重发主订单!主订单号:[%v]", order.VendorOrderID[len(order.VendorOrderID)-2:])
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("只允许物流订单为暂停或逆向完成才能调用此接口!")
|
||||
}
|
||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||
} else if len(order.VendorOrderID) == 16 && order.EclpOutID != "" { // 这是分包的子订单
|
||||
return fmt.Errorf("请重发主订单!主订单号:[%v]", order.VendorOrderID[len(order.VendorOrderID)-2:])
|
||||
}
|
||||
// } else {
|
||||
// return fmt.Errorf("只允许物流订单为暂停或逆向完成才能调用此接口!")
|
||||
// }
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
if isNeedUpdatePrice {
|
||||
foodData["price"] = jxutils.IntPrice2Standard(storeSku.VendorPrice)
|
||||
}
|
||||
foodData["min_order_count"] = 1
|
||||
if storeSku.MinOrderCount != 0 {
|
||||
foodData["min_order_count"] = storeSku.MinOrderCount
|
||||
} else {
|
||||
foodData["min_order_count"] = 1
|
||||
}
|
||||
foodData["unit"] = storeSku.Unit
|
||||
foodData["box_num"] = 1
|
||||
foodData["box_price"] = jxutils.IntPrice2Standard(storeSku.BoxFee)
|
||||
|
||||
Reference in New Issue
Block a user