冲突
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 {
|
} 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.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为准
|
v.Weight = skuBindInfo.Weight // 以本地信息中的WEIGHT为准
|
||||||
//饿鲜达的订单做一下处理
|
//饿鲜达的订单做一下处理
|
||||||
if strings.Contains(order.StoreName, model.ExdStoreName) {
|
if strings.Contains(order.StoreName, model.ExdStoreName) {
|
||||||
@@ -1314,29 +1342,29 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
|
|||||||
order.StoreID = storeID
|
order.StoreID = storeID
|
||||||
order.StoreName = stores[0].Name
|
order.StoreName = stores[0].Name
|
||||||
order.VendorStoreID = storeMaps[0].VendorStoreID
|
order.VendorStoreID = storeMaps[0].VendorStoreID
|
||||||
//如果是立即达的订单,要判断一下送达时间是否在门店营业时间范围内
|
//如果是立即达的订单,要判断一下下单时间是否在门店营业时间范围内
|
||||||
//若没有,则要把这个订单变成定时达,预计送达时间改为门店的营业时间
|
//若没有,则要把这个订单变成定时达,预计送达时间改为门店的营业时间
|
||||||
//如果门店没有营业时间,则直接报错
|
//如果门店没有营业时间,则直接报错
|
||||||
if order.BusinessType == model.BusinessTypeImmediate {
|
if order.BusinessType == model.BusinessTypeImmediate {
|
||||||
store := stores[0]
|
store := stores[0]
|
||||||
var (
|
var (
|
||||||
opentime1 = jxutils.JxOperationTime2TimeByDate(store.OpenTime1, order.ExpectedDeliveredTime)
|
opentime1 = jxutils.JxOperationTime2TimeByDate(store.OpenTime1, order.OrderCreatedAt)
|
||||||
opentime2 = jxutils.JxOperationTime2TimeByDate(store.OpenTime2, order.ExpectedDeliveredTime)
|
opentime2 = jxutils.JxOperationTime2TimeByDate(store.OpenTime2, order.OrderCreatedAt)
|
||||||
closetime1 = jxutils.JxOperationTime2TimeByDate(store.CloseTime1, order.ExpectedDeliveredTime)
|
closetime1 = jxutils.JxOperationTime2TimeByDate(store.CloseTime1, order.OrderCreatedAt)
|
||||||
closetime2 = jxutils.JxOperationTime2TimeByDate(store.CloseTime2, order.ExpectedDeliveredTime)
|
closetime2 = jxutils.JxOperationTime2TimeByDate(store.CloseTime2, order.OrderCreatedAt)
|
||||||
expectedTime = order.ExpectedDeliveredTime
|
orderCreatedAt = order.OrderCreatedAt
|
||||||
)
|
)
|
||||||
if store.OpenTime1 == 0 || store.CloseTime1 == 0 {
|
if store.OpenTime1 == 0 || store.CloseTime1 == 0 {
|
||||||
return "", fmt.Errorf("该门店没有营业时间,不能接单!门店:[%v]", storeID)
|
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 store.OpenTime2 != 0 && store.CloseTime2 != 0 {
|
||||||
if !(expectedTime.Sub(opentime2) >= 0 && expectedTime.Sub(closetime2) <= 0) {
|
if !(orderCreatedAt.Sub(opentime2) >= 0 && orderCreatedAt.Sub(closetime2) <= 0) {
|
||||||
if expectedTime.Sub(opentime1) < 0 {
|
if orderCreatedAt.Sub(opentime1) < 0 {
|
||||||
order.ExpectedDeliveredTime = opentime1
|
order.ExpectedDeliveredTime = opentime1
|
||||||
order.BusinessType = model.BusinessTypeDingshida
|
order.BusinessType = model.BusinessTypeDingshida
|
||||||
} else {
|
} else {
|
||||||
if expectedTime.Sub(opentime2) < 0 {
|
if orderCreatedAt.Sub(opentime2) < 0 {
|
||||||
order.ExpectedDeliveredTime = opentime2
|
order.ExpectedDeliveredTime = opentime2
|
||||||
} else {
|
} else {
|
||||||
order.ExpectedDeliveredTime = opentime1.AddDate(0, 0, 1)
|
order.ExpectedDeliveredTime = opentime1.AddDate(0, 0, 1)
|
||||||
@@ -1345,7 +1373,7 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if expectedTime.Sub(opentime1) < 0 {
|
if orderCreatedAt.Sub(opentime1) < 0 {
|
||||||
order.ExpectedDeliveredTime = opentime1
|
order.ExpectedDeliveredTime = opentime1
|
||||||
} else {
|
} else {
|
||||||
order.ExpectedDeliveredTime = opentime1.AddDate(0, 0, 1)
|
order.ExpectedDeliveredTime = opentime1.AddDate(0, 0, 1)
|
||||||
@@ -1506,3 +1534,23 @@ func AdjustJdsOrderSimple(ctx *jxcontext.Context, vendorOrderID string, skuID in
|
|||||||
}
|
}
|
||||||
return err
|
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 // 饿百的最少转自配送需要的时间(分钟)
|
minute2Schedule3rdCarrier4Ebai = 30 // 饿百的最少转自配送需要的时间(分钟)
|
||||||
minMinute2Schedule3rdCarrier = 5 // 转三方配送最少等待时间(分钟)
|
minMinute2Schedule3rdCarrier = 5 // 转三方配送最少等待时间(分钟)
|
||||||
|
|
||||||
time2AutoPickupMin = 14 * time.Minute // 自动拣货等待时间,这个只有在没有PickDeadline信息才有用,否则会根据PickDeadline设置
|
time2AutoPickupMin = 14 * time.Minute // 自动拣货等待时间,这个只有在没有PickDeadline信息才有用,否则会根据PickDeadline设置
|
||||||
second2AutoPickupGap = 60 //随机60秒
|
second2AutoPickupGap = 60 //随机60秒
|
||||||
time2AutoPickupAhead = 20 * time.Second // 有最后拣货时间的提前值
|
time2AutoPickupAhead = 120 * time.Second // 有最后拣货时间的提前值
|
||||||
|
|
||||||
switch2SelfDeliverRetryGap = 3 * time.Second // 转自送失败尝试的时间间隙
|
switch2SelfDeliverRetryGap = 3 * time.Second // 转自送失败尝试的时间间隙
|
||||||
switch2SelfDeliverRetryCount = 2 // 转自送失败尝试次数
|
switch2SelfDeliverRetryCount = 2 // 转自送失败尝试次数
|
||||||
@@ -1180,7 +1180,7 @@ func (s *DefScheduler) updateOrderByBill(order *model.GoodsOrder, bill *model.Wa
|
|||||||
if bill.Status == model.WaybillStatusDelivered {
|
if bill.Status == model.WaybillStatusDelivered {
|
||||||
storeDetail, _ := partner.CurOrderManager.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
storeDetail, _ := partner.CurOrderManager.LoadStoreDetail(jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
||||||
if storeDetail != nil {
|
if storeDetail != nil {
|
||||||
jxutils.RefreshOrderEarningPrice2(order, storeDetail.PayPercentage)
|
jxutils.RefreshOrderEarningPrice3(order, storeDetail.PayPercentage, bill)
|
||||||
updateFields = append(updateFields, "NewEarningPrice")
|
updateFields = append(updateFields, "NewEarningPrice")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1057,6 +1057,47 @@ func RefreshPageActs(ctx *jxcontext.Context, vendorIDs []int, createdFrom time.T
|
|||||||
return hint, err
|
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) {
|
func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, actTypes, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
actMap := make(map[int]*model.Act)
|
actMap := make(map[int]*model.Act)
|
||||||
|
|||||||
@@ -672,6 +672,7 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric
|
|||||||
'","eclpID":"', t2.eclp_id,
|
'","eclpID":"', t2.eclp_id,
|
||||||
'","weight":', t2.weight, ',"categoryID":', t2.category_id, ',"nameID":', t2.name_id,
|
'","weight":', t2.weight, ',"categoryID":', t2.category_id, ',"nameID":', t2.name_id,
|
||||||
', "seq":', t2.seq,
|
', "seq":', t2.seq,
|
||||||
|
', "minOrderCount":', t2.min_order_count,
|
||||||
"}")), "]") skus_str,
|
"}")), "]") skus_str,
|
||||||
CONCAT("[", GROUP_CONCAT(DISTINCT t3.place_code), "]") places_str
|
CONCAT("[", GROUP_CONCAT(DISTINCT t3.place_code), "]") places_str
|
||||||
` + sql + `
|
` + sql + `
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cms
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -3399,13 +3400,16 @@ func UpdateStorePricePack(ctx *jxcontext.Context, storeID, vendorID int, pricePa
|
|||||||
}()
|
}()
|
||||||
//证明是门店自己的调价包
|
//证明是门店自己的调价包
|
||||||
if strings.Contains(pricePack, utils.Int2Str(storeID)) {
|
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, "")
|
configList, err := dao.QueryConfigs(db, pricePack, model.ConfigTypePricePack, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err = dao.UpdateEntityLogically(db, configList[0], map[string]interface{}{
|
if _, err = dao.UpdateEntityLogically(db, configList[0], map[string]interface{}{
|
||||||
"Value": value,
|
"Value": string(realValue),
|
||||||
}, ctx.GetUserName(), nil); err != nil {
|
}, ctx.GetUserName(), nil); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -4079,7 +4079,7 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo
|
|||||||
snapshotAt = utils.Time2Date(time.Now())
|
snapshotAt = utils.Time2Date(time.Now())
|
||||||
)
|
)
|
||||||
storeSkuBindHis := &model.StoreSkuBindHistory{
|
storeSkuBindHis := &model.StoreSkuBindHistory{
|
||||||
SnapshotAt: snapshotAt.AddDate(0, 0, -2),
|
SnapshotAt: snapshotAt.AddDate(0, 0, -5),
|
||||||
}
|
}
|
||||||
dao.DeleteEntity(db, storeSkuBindHis, "SnapshotAt")
|
dao.DeleteEntity(db, storeSkuBindHis, "SnapshotAt")
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
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])
|
updateMatters = append(updateMatters, skusMap[c4.EclpID])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("updateMatters", utils.Format4Output(updateMatters, false))
|
|
||||||
case 1:
|
case 1:
|
||||||
if len(deleteMatters) > 0 {
|
if len(deleteMatters) > 0 {
|
||||||
for _, v := range deleteMatters {
|
for _, v := range deleteMatters {
|
||||||
|
|||||||
@@ -1297,6 +1297,9 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
|||||||
ShopInfo, _ := api.MtpsAPI.ShopQuery(strconv.Itoa(storeId))
|
ShopInfo, _ := api.MtpsAPI.ShopQuery(strconv.Itoa(storeId))
|
||||||
if ShopInfo != nil {
|
if ShopInfo != nil {
|
||||||
ShopName = ShopInfo.ShopName
|
ShopName = ShopInfo.ShopName
|
||||||
|
if ShopName == "" {
|
||||||
|
ShopName = StoreLists[0].Name[:len(StoreLists[0].Name)-3]
|
||||||
|
}
|
||||||
StoreInfoList, _ = api.MtpsAPI.GetStoreStatus(ShopName)
|
StoreInfoList, _ = api.MtpsAPI.GetStoreStatus(ShopName)
|
||||||
if StoreInfoList != nil && StoreInfoList.DataList != nil {
|
if StoreInfoList != nil && StoreInfoList.DataList != nil {
|
||||||
goto ifExist
|
goto ifExist
|
||||||
@@ -1354,15 +1357,15 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
|||||||
{
|
{
|
||||||
if StoreInfoList.DataList[0].OuterPoiID != "" {
|
if StoreInfoList.DataList[0].OuterPoiID != "" {
|
||||||
//若存在且名字不为空,就是找到了
|
//若存在且名字不为空,就是找到了
|
||||||
if StoreInfoList.DataList[0].OpenType != courierStatus {
|
// if StoreInfoList.DataList[0].OpenType != courierStatus ||{
|
||||||
sl := make(map[string]interface{})
|
sl := make(map[string]interface{})
|
||||||
sl["vendorStoreID"] = StoreInfoList.DataList[0].OuterPoiID
|
sl["vendorStoreID"] = StoreInfoList.DataList[0].OuterPoiID
|
||||||
sl["status"] = StoreInfoList.DataList[0].OpenType
|
sl["status"] = StoreInfoList.DataList[0].OpenType
|
||||||
sl["vendorStatus"] = StoreInfoList.DataList[0].OpenType
|
sl["vendorStatus"] = StoreInfoList.DataList[0].OpenType
|
||||||
globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
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))
|
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())
|
UpdateStoreCourierMap(ctx, nil, storeId, model.VendorIDMTPS, sl, ctx.GetUserName())
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -165,9 +165,9 @@ func Init() {
|
|||||||
|
|
||||||
ScheduleTimerFunc("doDailyWork2", doDailyWork2, dailyWorkTimeList2)
|
ScheduleTimerFunc("doDailyWork2", doDailyWork2, dailyWorkTimeList2)
|
||||||
|
|
||||||
ScheduleTimerFuncByInterval(func() {
|
// ScheduleTimerFuncByInterval(func() {
|
||||||
orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now())
|
// orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now())
|
||||||
}, 10*time.Second, 10*time.Minute)
|
// }, 10*time.Second, 10*time.Minute)
|
||||||
|
|
||||||
//京东的订单信息解密密钥获取
|
//京东的订单信息解密密钥获取
|
||||||
ScheduleTimerFuncByInterval(func() {
|
ScheduleTimerFuncByInterval(func() {
|
||||||
|
|||||||
@@ -804,6 +804,7 @@ func GetWeeklyStoreScore(storeID, weekIndexParam int) (outWeeklyStoreScoreDataLi
|
|||||||
if weekIndexParam == -1 {
|
if weekIndexParam == -1 {
|
||||||
outWeeklyStoreScoreDataList = weeklyStoreScoreDataList
|
outWeeklyStoreScoreDataList = weeklyStoreScoreDataList
|
||||||
} else {
|
} else {
|
||||||
|
fmt.Println("testss", utils.Format4Output(weeklyStoreScoreDataList, false))
|
||||||
outWeeklyStoreScoreDataList = []*model.WeeklyStoreScore{weeklyStoreScoreDataList[weekIndexParam]}
|
outWeeklyStoreScoreDataList = []*model.WeeklyStoreScore{weeklyStoreScoreDataList[weekIndexParam]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1587,36 +1587,58 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
|
|||||||
// fmt.Println("deleteList2", deleteList)
|
// fmt.Println("deleteList2", deleteList)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeIDs := []int{
|
storeIDs := []int{
|
||||||
667443,
|
667335,
|
||||||
667433,
|
667321,
|
||||||
667389,
|
667319,
|
||||||
666862,
|
667260,
|
||||||
666835,
|
667227,
|
||||||
666830,
|
667167,
|
||||||
666826,
|
667109,
|
||||||
666822,
|
667094,
|
||||||
666800,
|
667050,
|
||||||
666785,
|
666898,
|
||||||
666775,
|
666852,
|
||||||
666772,
|
666815,
|
||||||
103459,
|
666763,
|
||||||
102860,
|
666761,
|
||||||
102859,
|
666760,
|
||||||
102858,
|
666759,
|
||||||
102852,
|
666714,
|
||||||
102847,
|
666708,
|
||||||
102811,
|
666705,
|
||||||
102793,
|
666669,
|
||||||
102780,
|
103437,
|
||||||
101732,
|
103425,
|
||||||
100714,
|
103349,
|
||||||
100712,
|
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 {
|
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 {
|
for _, v := range acts.Data {
|
||||||
var actStoreSkuParam []*act.ActStoreSkuParam
|
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 {
|
for _, actStoreSku := range actStoreSkus {
|
||||||
if actStoreSku.StoreID == storeID {
|
if actStoreSku.StoreID == storeID {
|
||||||
aa := &act.ActStoreSkuParam{
|
aa := &act.ActStoreSkuParam{
|
||||||
|
|||||||
@@ -590,11 +590,24 @@ func RefreshOrderSkuRelated(order *model.GoodsOrder) *model.GoodsOrder {
|
|||||||
|
|
||||||
func RefreshOrderEarningPrice2(order *model.GoodsOrder, payPercentage int) *model.GoodsOrder {
|
func RefreshOrderEarningPrice2(order *model.GoodsOrder, payPercentage int) *model.GoodsOrder {
|
||||||
if order.EarningType == model.EarningTypePoints {
|
if order.EarningType == model.EarningTypePoints {
|
||||||
if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
// if order.VendorID == model.VendorIDJDShop || order.VendorID == model.VendorIDJX {
|
||||||
order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage)) / 100
|
// order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage)) / 100
|
||||||
} else {
|
// } else {
|
||||||
order.NewEarningPrice = order.TotalShopMoney * int64((100 - payPercentage/2)) / 100
|
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 {
|
} else {
|
||||||
order.NewEarningPrice = order.EarningPrice
|
order.NewEarningPrice = order.EarningPrice
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,6 +286,12 @@ type StoreSkuPriceAndWeight struct {
|
|||||||
SkuID int `orm:"column(sku_id)"`
|
SkuID int `orm:"column(sku_id)"`
|
||||||
Weight int
|
Weight int
|
||||||
Price int
|
Price int
|
||||||
|
Prefix string
|
||||||
|
Name string
|
||||||
|
Unit string
|
||||||
|
Comment string
|
||||||
|
SpecQuality float32
|
||||||
|
SpecUnit string
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoreSkuAndName struct {
|
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]))
|
vendorSkuIDField = fmt.Sprintf("t2.%s_id", ConvertDBFieldPrefix(model.VendorNames[vendorID]))
|
||||||
}
|
}
|
||||||
sql := fmt.Sprintf(`
|
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
|
FROM sku t1
|
||||||
JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.deleted_at = ?
|
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 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
|
%s
|
||||||
WHERE %s IN (`+GenQuestionMarks(len(vendorSkuIDs))+`)`, vendorSkuIDField, sqlThingMap, vendorSkuIDField)
|
WHERE %s IN (`+GenQuestionMarks(len(vendorSkuIDs))+`)`, vendorSkuIDField, sqlThingMap, vendorSkuIDField)
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ type Sku struct {
|
|||||||
ExdSkuID string `orm:"column(exd_sku_id)" json:"exdSkuID"` //饿鲜达商品ID
|
ExdSkuID string `orm:"column(exd_sku_id)" json:"exdSkuID"` //饿鲜达商品ID
|
||||||
ExdCategoryThirdID int `orm:"column(exd_category_third_id)" json:"exdCategoryThirdID"`
|
ExdCategoryThirdID int `orm:"column(exd_category_third_id)" json:"exdCategoryThirdID"`
|
||||||
EclpID string `orm:"column(eclp_id)" json:"eclpID"` //eclp物料商品ID
|
EclpID string `orm:"column(eclp_id)" json:"eclpID"` //eclp物料商品ID
|
||||||
|
MinOrderCount int `json:"minOrderCount"` //最少起购份数,美团用
|
||||||
// JdID int64 `orm:"column(jd_id);null;index" json:"jdID"`
|
// JdID int64 `orm:"column(jd_id);null;index" json:"jdID"`
|
||||||
// JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
// 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.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 := ""
|
// storeTel := ""
|
||||||
storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||||
storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||||
if storeDeatail.Tel2 != "" {
|
// if storeDeatail.Tel2 != "" {
|
||||||
storeTel = ",门店电话:" + 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.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.CargoType = dadaapi.CargoTypeFresh
|
||||||
billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
||||||
billParams.CargoNum = order.GoodsCount
|
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),
|
// "goods_pickup_info": fmt.Sprintf("%s第%d号单", model.VendorChineseNames[order.VendorID], order.OrderSeq),
|
||||||
// "poi_seq": fmt.Sprintf("#%d", order.OrderSeq),
|
// "poi_seq": fmt.Sprintf("#%d", order.OrderSeq),
|
||||||
// }
|
// }
|
||||||
storeTel := ""
|
// storeTel := ""
|
||||||
storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||||
storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||||
if storeDeatail.Tel2 != "" {
|
// if storeDeatail.Tel2 != "" {
|
||||||
storeTel = ",门店电话:" + storeDeatail.Tel2
|
// storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||||
}
|
// }
|
||||||
billParams.Note = utils.FilterMb4(order.BuyerComment + ",取货失败请联系平台电话:18048531223" + storeTel)
|
billParams.Note = utils.FilterMb4(order.BuyerComment + ",取货失败或配送遇到问题请联系18048531223,禁止未配送直接完成定单!")
|
||||||
billParams.GoodsDetail = string(utils.MustMarshal(goods))
|
billParams.GoodsDetail = string(utils.MustMarshal(goods))
|
||||||
billParams.GoodsPickupInfo = fmt.Sprintf("%s第%d号单", model.VendorChineseNames[order.VendorID], order.OrderSeq)
|
billParams.GoodsPickupInfo = fmt.Sprintf("%s第%d号单", model.VendorChineseNames[order.VendorID], order.OrderSeq)
|
||||||
billParams.PoiSeq = fmt.Sprintf("#%d", order.OrderSeq)
|
billParams.PoiSeq = fmt.Sprintf("#%d", order.OrderSeq)
|
||||||
|
|||||||
@@ -390,6 +390,7 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
|||||||
phone = model.VendorStoreTel
|
phone = model.VendorStoreTel
|
||||||
}
|
}
|
||||||
params["ivr_phone"] = phone //统一改为这个电话
|
params["ivr_phone"] = phone //统一改为这个电话
|
||||||
|
|
||||||
if store.VendorStoreID != "" {
|
if store.VendorStoreID != "" {
|
||||||
params["baidu_shop_id"] = 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)
|
boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee)
|
||||||
params["package_box_price"] = boxFee
|
params["package_box_price"] = boxFee
|
||||||
|
params["service_phone"] = store.Tel1
|
||||||
params["address"] = store.Address
|
params["address"] = store.Address
|
||||||
// todo 饿百 开店审核通过后不允许修改商户信息
|
// todo 饿百 开店审核通过后不允许修改商户信息
|
||||||
if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreAddress*/) != 0 {
|
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)
|
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)
|
err := partner.CurOrderManager.OnOrderStatusChanged(vendorOrgCode, status)
|
||||||
retVal = jdapi.Err2CallbackResponse(err, status.VendorStatus)
|
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) {
|
func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) {
|
||||||
if globals.EnableJdStoreWrite {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,12 @@ func OnCallbackMsg(msg *jdshopapi.CallBackResult) (err error) {
|
|||||||
})
|
})
|
||||||
case jcqapi.TopicOrderCancel:
|
case jcqapi.TopicOrderCancel:
|
||||||
utils.CallFuncAsync(func() {
|
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:
|
default:
|
||||||
return fmt.Errorf("暂不支持的topic类型!topic: %v", msgType)
|
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) {
|
func SaveJdsOrders(msg *jdshopapi.CallBackResult) (err error) {
|
||||||
order, err := result2Orders(msg)
|
order, err := result2Orders(msg)
|
||||||
|
if err != nil || order == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
order.StoreID = 102919
|
order.StoreID = 102919
|
||||||
order.JxStoreID = 102919
|
order.JxStoreID = 102919
|
||||||
order.StoreName = "商城模板(成都发货)"
|
order.StoreName = "商城模板(成都发货)"
|
||||||
@@ -74,8 +82,8 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
|||||||
OrderCreatedAt: utils.Str2Time(msg.OrderStartTime),
|
OrderCreatedAt: utils.Str2Time(msg.OrderStartTime),
|
||||||
ConsigneeAddress: Decrypt(msg.ConsigneeInfo.FullAddress),
|
ConsigneeAddress: Decrypt(msg.ConsigneeInfo.FullAddress),
|
||||||
ConsigneeName: Decrypt(msg.ConsigneeInfo.Fullname),
|
ConsigneeName: Decrypt(msg.ConsigneeInfo.Fullname),
|
||||||
ConsigneeMobile: Decrypt(msg.ConsigneeInfo.Telephone),
|
ConsigneeMobile: Decrypt(msg.ConsigneeInfo.Mobile),
|
||||||
ConsigneeMobile2: Decrypt(msg.ConsigneeInfo.Mobile),
|
ConsigneeMobile2: Decrypt(msg.ConsigneeInfo.Telephone),
|
||||||
ActualPayPrice: jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)),
|
ActualPayPrice: jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)),
|
||||||
Status: model.OrderStatusNew,
|
Status: model.OrderStatusNew,
|
||||||
TotalShopMoney: utils.Float64TwoInt64(math.Round(float64(jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment))) * jdshopapi.JdsPayPercentage)),
|
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.StoreID = storeList[0].ID
|
||||||
order.StoreName = storeList[0].Name
|
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, "", "")
|
storeMaps, _ := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDJDShop}, []int{order.StoreID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "")
|
||||||
if len(storeMaps) > 0 {
|
if len(storeMaps) > 0 {
|
||||||
order.VendorStoreID = storeMaps[0].VendorStoreID
|
order.VendorStoreID = storeMaps[0].VendorStoreID
|
||||||
@@ -115,6 +124,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
|||||||
order.BusinessType = model.BusinessTypeImmediate
|
order.BusinessType = model.BusinessTypeImmediate
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Warnf("暂不支持的京东商城订单类型!type: %v", msg.OrderState)
|
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) {
|
func Decrypt(p string) (result string) {
|
||||||
|
if p == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
data, _ := base64.StdEncoding.DecodeString(strings.ReplaceAll(p, " ", "+"))
|
data, _ := base64.StdEncoding.DecodeString(strings.ReplaceAll(p, " ", "+"))
|
||||||
key := GetKey(hex.EncodeToString(data)[4:36])
|
key := GetKey(hex.EncodeToString(data)[4:36])
|
||||||
data2, _ := base64.StdEncoding.DecodeString(key)
|
data2, _ := base64.StdEncoding.DecodeString(key)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package jdshop
|
package jdshop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -50,7 +51,9 @@ func (p *PurchaseHandler) GetOrderStatus(vendorOrgCode, vendorOrderID string) (s
|
|||||||
params["orderID"] = vendorOrderID
|
params["orderID"] = vendorOrderID
|
||||||
params["token"] = "JxCaIsHiGetJsdOrderTmpToken_20200731"
|
params["token"] = "JxCaIsHiGetJsdOrderTmpToken_20200731"
|
||||||
result, err := apiToYd("order/GetJdsOrder", params)
|
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) {
|
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 err == nil {
|
||||||
if jsonResult1["code"] != nil {
|
if jsonResult1["code"] != nil {
|
||||||
errLevel = platformapi.ErrLevelGeneralFail
|
if utils.Interface2Int64WithDefault(jsonResult1["code"], 0) != 0 {
|
||||||
err = utils.NewErrorCode(jsonResult1["desc"].(string), jsonResult1["code"].(string))
|
errLevel = platformapi.ErrLevelGeneralFail
|
||||||
baseapi.SugarLogger.Debugf("yd AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
err = utils.NewErrorCode(jsonResult1["desc"].(string), jsonResult1["code"].(string))
|
||||||
|
baseapi.SugarLogger.Debugf("yd AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
retVal = jsonResult1
|
retVal = jsonResult1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
"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.TotalShopMoney += jxOrder.FreightPrice
|
||||||
order.ActualPayPrice = order.TotalShopMoney
|
order.ActualPayPrice = order.TotalShopMoney
|
||||||
|
order.TotalShopMoney = utils.Float64TwoInt64(float64(order.TotalShopMoney) * jdshopapi.JdsPayPercentage)
|
||||||
if jxOrder.FromStoreID != 0 {
|
if jxOrder.FromStoreID != 0 {
|
||||||
order.FromStoreID = jxOrder.FromStoreID
|
order.FromStoreID = jxOrder.FromStoreID
|
||||||
order.DeliveryFlag = model.OrderDeliveryFlagMaskScheduleDisabled
|
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 {
|
if order == nil || order.StoreID != model.MatterStoreID || order.FromStoreID == 0 {
|
||||||
return fmt.Errorf("只允许物料店重发物料订单调用此接口!")
|
return fmt.Errorf("只允许物料店重发物料订单调用此接口!")
|
||||||
}
|
}
|
||||||
queryOrderStatus, err := api.JdEclpAPI.QueryOrderStatus(order.EclpOutID)
|
// queryOrderStatus, err := api.JdEclpAPI.QueryOrderStatus(order.EclpOutID)
|
||||||
if len(queryOrderStatus.OrderStatusList) > 0 {
|
// if len(queryOrderStatus.OrderStatusList) > 0 {
|
||||||
code := queryOrderStatus.OrderStatusList[len(queryOrderStatus.OrderStatusList)-1].SoStatusCode
|
// code := queryOrderStatus.OrderStatusList[len(queryOrderStatus.OrderStatusList)-1].SoStatusCode
|
||||||
if code == jdeclpapi.SoStatusCode10022 || code == jdeclpapi.SoStatusCode10038 { //表示该订单在京东物流为暂停或已经逆向发货完成
|
// if code == jdeclpapi.SoStatusCode10022 || code == jdeclpapi.SoStatusCode10038 { //表示该订单在京东物流为暂停或已经逆向发货完成
|
||||||
if len(order.VendorOrderID) == 14 && order.EclpOutID != "" { //这是不分包的订单
|
if len(order.VendorOrderID) == 14 && order.EclpOutID != "" { //这是不分包的订单
|
||||||
_, err = createMatterOrder(buildJxOrderInfo(order, order.Skus), order, int64(00))
|
_, err = createMatterOrder(buildJxOrderInfo(order, order.Skus), order, int64(01))
|
||||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||||
for _, v := range order.Skus {
|
for _, v := range order.Skus {
|
||||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||||
}
|
}
|
||||||
} else if len(order.VendorOrderID) == 14 && order.EclpOutID == "" { //这是分包的主订单
|
} else if len(order.VendorOrderID) == 14 && order.EclpOutID == "" { //这是分包的主订单
|
||||||
goodsList, err := dao.GetMatterChildOrders(db, order.VendorOrderID)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(goodsList) > 0 {
|
suffix := utils.Str2Int64(cOrder.VendorOrderID[len(cOrder.VendorOrderID)-2:]) + int64(len(goodsList))
|
||||||
for _, v := range goodsList {
|
_, err = createMatterOrder(buildJxOrderInfo(cOrder, cOrder.Skus), cOrder, suffix)
|
||||||
cOrder, err := partner.CurOrderManager.LoadOrder(v.VendorOrderID, model.VendorIDJX)
|
for _, v := range cOrder.Skus {
|
||||||
if err != nil {
|
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
if isNeedUpdatePrice {
|
if isNeedUpdatePrice {
|
||||||
foodData["price"] = jxutils.IntPrice2Standard(storeSku.VendorPrice)
|
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["unit"] = storeSku.Unit
|
||||||
foodData["box_num"] = 1
|
foodData["box_num"] = 1
|
||||||
foodData["box_price"] = jxutils.IntPrice2Standard(storeSku.BoxFee)
|
foodData["box_price"] = jxutils.IntPrice2Standard(storeSku.BoxFee)
|
||||||
|
|||||||
@@ -307,6 +307,27 @@ func (c *ActController) DeleteSkusFromAct() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 将门店从所有活动中删除
|
||||||
|
// @Description 将门店从所有活动中删除
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeIDs query string true "门店ID列表"
|
||||||
|
// @Param vendorID query int true "厂商ID"
|
||||||
|
// @Param types query string false "活动类型列表"
|
||||||
|
// @Param isAsync query bool false "是否异步"
|
||||||
|
// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /DeleteStoresFromAct [delete]
|
||||||
|
func (c *ActController) DeleteStoresFromAct() {
|
||||||
|
c.callDeleteStoresFromAct(func(params *tActDeleteStoresFromActParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
var storeIDs, types []int
|
||||||
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Types, &types); err == nil {
|
||||||
|
retVal, err = act.DeleteStoresFromAct(params.Ctx, params.VendorID, types, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// @Title 强制更新商品平台价
|
// @Title 强制更新商品平台价
|
||||||
// @Description 强制更新商品平台价
|
// @Description 强制更新商品平台价
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -1119,3 +1119,18 @@ func (c *OrderController) AdjustJdsOrderSimple() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 修改订单运费
|
||||||
|
// @Description 修改订单运费
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param vendorOrderID formData string true "订单号"
|
||||||
|
// @Param desiredFee formData int true "运费"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /UpdateWaybillDesiredFee [put]
|
||||||
|
func (c *OrderController) UpdateWaybillDesiredFee() {
|
||||||
|
c.callUpdateWaybillDesiredFee(func(params *tOrderUpdateWaybillDesiredFeeParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
err = orderman.UpdateWaybillDesiredFee(params.Ctx, params.VendorOrderID, params.DesiredFee)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,6 +43,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "DeleteStoresFromAct",
|
||||||
|
Router: `/DeleteStoresFromAct`,
|
||||||
|
AllowHTTPMethods: []string{"delete"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "ForceUpdateVendorPrice",
|
Method: "ForceUpdateVendorPrice",
|
||||||
@@ -1314,6 +1323,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "UpdateWaybillDesiredFee",
|
||||||
|
Router: `/UpdateWaybillDesiredFee`,
|
||||||
|
AllowHTTPMethods: []string{"put"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AutoFocusStoreSkus",
|
Method: "AutoFocusStoreSkus",
|
||||||
|
|||||||
Reference in New Issue
Block a user