Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -192,7 +192,7 @@ func setFakeOrderFlag(db *dao.DaoDB, order *model.GoodsOrder) {
|
|||||||
isMatch := false
|
isMatch := false
|
||||||
mobileList := strings.Split(configList[0].Value, ",")
|
mobileList := strings.Split(configList[0].Value, ",")
|
||||||
for _, v := range mobileList {
|
for _, v := range mobileList {
|
||||||
if v == realMobile {
|
if jxutils.TrimDecorationChar(v) == realMobile {
|
||||||
isMatch = true
|
isMatch = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,13 +223,13 @@ func init() {
|
|||||||
TimeoutGap: 0,
|
TimeoutGap: 0,
|
||||||
},
|
},
|
||||||
TimeoutAction: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (err error) {
|
TimeoutAction: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (err error) {
|
||||||
if savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore { // 自配送商家使用
|
if savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore && savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake { // 自配送商家使用
|
||||||
return sch.createWaybillOn3rdProviders(savedOrderInfo, 0, nil)
|
return sch.createWaybillOn3rdProviders(savedOrderInfo, 0, nil)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
ShouldSetTimer: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) bool {
|
ShouldSetTimer: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) bool {
|
||||||
return savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore
|
return savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore && savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -245,7 +245,8 @@ func init() {
|
|||||||
if savedOrderInfo.isDeliveryCompetition &&
|
if savedOrderInfo.isDeliveryCompetition &&
|
||||||
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
||||||
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
||||||
savedOrderInfo.order.VendorID != model.VendorIDEBAI { // 非自配送商家使用
|
savedOrderInfo.order.VendorID != model.VendorIDEBAI &&
|
||||||
|
savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake { // 非自配送商家使用
|
||||||
return sch.createWaybillOn3rdProviders(savedOrderInfo, 0, nil)
|
return sch.createWaybillOn3rdProviders(savedOrderInfo, 0, nil)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -254,7 +255,8 @@ func init() {
|
|||||||
return savedOrderInfo.isDeliveryCompetition &&
|
return savedOrderInfo.isDeliveryCompetition &&
|
||||||
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
||||||
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
||||||
savedOrderInfo.order.VendorID != model.VendorIDEBAI
|
savedOrderInfo.order.VendorID != model.VendorIDEBAI &&
|
||||||
|
savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//*
|
//*
|
||||||
@@ -269,7 +271,8 @@ func init() {
|
|||||||
savedOrderInfo.isDeliveryCompetition &&
|
savedOrderInfo.isDeliveryCompetition &&
|
||||||
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
||||||
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
||||||
order.VendorID == model.VendorIDEBAI { // 非自配送商家使用
|
order.VendorID == model.VendorIDEBAI &&
|
||||||
|
savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake { // 非自配送商家使用
|
||||||
return sch.createWaybillOn3rdProviders(savedOrderInfo, ebaiCancelWaybillMaxFee, nil)
|
return sch.createWaybillOn3rdProviders(savedOrderInfo, ebaiCancelWaybillMaxFee, nil)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -280,7 +283,8 @@ func init() {
|
|||||||
savedOrderInfo.isDeliveryCompetition &&
|
savedOrderInfo.isDeliveryCompetition &&
|
||||||
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
||||||
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore &&
|
||||||
order.VendorID == model.VendorIDEBAI
|
order.VendorID == model.VendorIDEBAI &&
|
||||||
|
savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//*/
|
//*/
|
||||||
@@ -1101,12 +1105,14 @@ func OnDefSchConfChanged(key, value string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *DefScheduler) notifyNewOrder(order *model.GoodsOrder) {
|
func (s *DefScheduler) notifyNewOrder(order *model.GoodsOrder) {
|
||||||
|
if order.Flag&model.OrderFlagMaskFake == 0 {
|
||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order)
|
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order)
|
||||||
weixinmsg.NotifyNewOrder(order)
|
weixinmsg.NotifyNewOrder(order)
|
||||||
smsmsg.NotifyNewOrder(order)
|
smsmsg.NotifyNewOrder(order)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DefScheduler) notifyUserApplyCancel(order *model.GoodsOrder, cancelReason string) {
|
func (s *DefScheduler) notifyUserApplyCancel(order *model.GoodsOrder, cancelReason string) {
|
||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
@@ -1115,7 +1121,9 @@ func (s *DefScheduler) notifyUserApplyCancel(order *model.GoodsOrder, cancelReas
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *DefScheduler) notify3rdPartyWaybill(order *model.GoodsOrder, bill *model.Waybill, isBillAlreadyCandidate bool) {
|
func (s *DefScheduler) notify3rdPartyWaybill(order *model.GoodsOrder, bill *model.Waybill, isBillAlreadyCandidate bool) {
|
||||||
|
if order.Flag&model.OrderFlagMaskFake == 0 {
|
||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
weixinmsg.NotifyWaybillStatus(bill, order, isBillAlreadyCandidate)
|
weixinmsg.NotifyWaybillStatus(bill, order, isBillAlreadyCandidate)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkConfig(configType, key, value string) (err error) {
|
func checkConfig(opFlag int, configType, key, value string) (err error) {
|
||||||
switch configType {
|
switch configType {
|
||||||
case model.ConfigTypePricePack:
|
case model.ConfigTypePricePack:
|
||||||
if value != "" {
|
if value != "" {
|
||||||
@@ -221,7 +221,9 @@ func checkConfig(configType, key, value string) (err error) {
|
|||||||
}
|
}
|
||||||
case model.ConfigTypeRole:
|
case model.ConfigTypeRole:
|
||||||
case model.ConfigTypeSys:
|
case model.ConfigTypeSys:
|
||||||
|
if opFlag&(model.SyncFlagNewMask|model.SyncFlagDeletedMask) != 0 {
|
||||||
err = fmt.Errorf("系统参数只支持修改,不支持自由添加")
|
err = fmt.Errorf("系统参数只支持修改,不支持自由添加")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType)
|
err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType)
|
||||||
}
|
}
|
||||||
@@ -229,7 +231,7 @@ func checkConfig(configType, key, value string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error) {
|
func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error) {
|
||||||
if err = checkConfig(configType, key, value); err != nil {
|
if err = checkConfig(model.SyncFlagNewMask, configType, key, value); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +246,7 @@ func AddConfig(ctx *jxcontext.Context, key, configType, value string) (err error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
||||||
if err = checkConfig(configType, key, ""); err != nil {
|
if err = checkConfig(model.SyncFlagDeletedMask, configType, key, ""); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
@@ -299,7 +301,7 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (err er
|
|||||||
if key == "" {
|
if key == "" {
|
||||||
return fmt.Errorf("修改配置必须给定key")
|
return fmt.Errorf("修改配置必须给定key")
|
||||||
}
|
}
|
||||||
if err = checkConfig(configType, key, value); err != nil {
|
if err = checkConfig(model.SyncFlagModifiedMask, configType, key, value); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/netspider"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -107,6 +109,10 @@ func Init() {
|
|||||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||||
}, autoSaleStoreSkuTimeList)
|
}, autoSaleStoreSkuTimeList)
|
||||||
|
|
||||||
|
if beego.BConfig.RunMode == "beta" {
|
||||||
|
netspider.GetAndStoreCitiesShops(jxcontext.AdminCtx, nil, nil, 0, 0, false, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doDailyWork() {
|
func doDailyWork() {
|
||||||
|
|||||||
@@ -63,15 +63,16 @@ func UpdateEntityByKV(db *DaoDB, item interface{}, kvs map[string]interface{}, c
|
|||||||
|
|
||||||
func BatchUpdateEntityByKV(db *DaoDB, items []*KVUpdateItem) (num int64, err error) {
|
func BatchUpdateEntityByKV(db *DaoDB, items []*KVUpdateItem) (num int64, err error) {
|
||||||
if len(items) > 0 {
|
if len(items) > 0 {
|
||||||
Begin(db)
|
// 不用事务应该是OK的吧,用事务经常会导致死锁(不同平台在同步同一条数据)
|
||||||
defer func() {
|
// Begin(db)
|
||||||
if r := recover(); r != nil || err != nil {
|
// defer func() {
|
||||||
Rollback(db)
|
// if r := recover(); r != nil || err != nil {
|
||||||
if r != nil {
|
// Rollback(db)
|
||||||
panic(r)
|
// if r != nil {
|
||||||
}
|
// panic(r)
|
||||||
}
|
// }
|
||||||
}()
|
// }
|
||||||
|
// }()
|
||||||
for _, v := range items {
|
for _, v := range items {
|
||||||
num2, err2 := UpdateEntityByKV(db, v.Item, v.KVs, nil)
|
num2, err2 := UpdateEntityByKV(db, v.Item, v.KVs, nil)
|
||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
@@ -79,7 +80,7 @@ func BatchUpdateEntityByKV(db *DaoDB, items []*KVUpdateItem) (num int64, err err
|
|||||||
}
|
}
|
||||||
num += num2
|
num += num2
|
||||||
}
|
}
|
||||||
Commit(db)
|
// Commit(db)
|
||||||
}
|
}
|
||||||
return num, nil
|
return num, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ func QueryPageStores(db *DaoDB, pageSize, offset int, keyword string, vendorStor
|
|||||||
}
|
}
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
keywordLike := "%" + keyword + "%"
|
keywordLike := "%" + keyword + "%"
|
||||||
sql += " AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.org_code LIKE ? OR t1.address LIKE ? OR t2.name LIKE ? OR t3.name LIKE ?"
|
sql += " AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.org_code LIKE ? OR t1.address LIKE ? OR t2.name LIKE ? OR t3.name LIKE ? OR t1.licence_code LIKE ?"
|
||||||
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||||
sql += ")"
|
sql += ")"
|
||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
StoreStatusName = map[int]string{
|
StoreStatusName = map[int]string{
|
||||||
StoreStatusDisabled: "禁用",
|
StoreStatusDisabled: "禁用",
|
||||||
StoreStatusClosed: "长期休息",
|
StoreStatusClosed: "休息",
|
||||||
StoreStatusHaveRest: "临时休息",
|
StoreStatusHaveRest: "临时休息",
|
||||||
StoreStatusOpened: "营业中",
|
StoreStatusOpened: "营业中",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ func getStorePageInfo(ctx *jxcontext.Context, handler partner.IPurchasePlatformN
|
|||||||
if !(storePageInfo.Lng != 0 && storePageInfo.Lat != 0) {
|
if !(storePageInfo.Lng != 0 && storePageInfo.Lat != 0) {
|
||||||
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode))
|
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode))
|
||||||
if storePageInfo.DistrictCode == 0 && cityCode != 0 {
|
if storePageInfo.DistrictCode == 0 && cityCode != 0 {
|
||||||
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, "")
|
if place, err := dao.GetPlaceByCode(dao.GetDB(), cityCode); err == nil {
|
||||||
|
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(place.ParentCode))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if storePageInfo.DistrictCode == 0 {
|
} else if storePageInfo.DistrictCode == 0 {
|
||||||
storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat)
|
storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat)
|
||||||
@@ -140,6 +142,31 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
|
|||||||
rand.Shuffle(len(cityCodeList), func(i, j int) {
|
rand.Shuffle(len(cityCodeList), func(i, j int) {
|
||||||
cityCodeList[i], cityCodeList[j] = cityCodeList[j], cityCodeList[i]
|
cityCodeList[i], cityCodeList[j] = cityCodeList[j], cityCodeList[i]
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM page_shop t1
|
||||||
|
ORDER BY t1.id DESC
|
||||||
|
LIMIT 1`
|
||||||
|
var lastShop *model.PageShop
|
||||||
|
if dao.GetRow(db, &lastShop, sql) == nil {
|
||||||
|
index := -1
|
||||||
|
for k, v := range cityCodeList {
|
||||||
|
if v == lastShop.CityCode {
|
||||||
|
index = k + 1
|
||||||
|
if index >= len(cityCodeList) {
|
||||||
|
index = -1
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if index > 0 {
|
||||||
|
var cityCodeList2 []int
|
||||||
|
cityCodeList2 = append(cityCodeList2, cityCodeList[index:]...)
|
||||||
|
cityCodeList2 = append(cityCodeList2, cityCodeList[:index]...)
|
||||||
|
cityCodeList = cityCodeList2
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(vendorIDs) == 0 {
|
if len(vendorIDs) == 0 {
|
||||||
vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI}
|
vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI}
|
||||||
@@ -165,9 +192,11 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
for _, v := range shopList {
|
for _, v := range shopList {
|
||||||
|
if v.DistrictCode > 0 {
|
||||||
tmpShop := *v
|
tmpShop := *v
|
||||||
dao.DeleteEntity(db, &tmpShop, model.FieldVendorStoreID, model.FieldVendorID)
|
dao.DeleteEntity(db, &tmpShop, model.FieldVendorStoreID, model.FieldVendorID)
|
||||||
if err = dao.CreateEntity(db, v); err != nil {
|
}
|
||||||
|
if err = dao.CreateEntity(db, v); err != nil && !dao.IsDuplicateError(err) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -891,15 +891,6 @@ 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: "GetStoreOrderCountInfo2",
|
|
||||||
Router: `/GetStoreOrderCountInfo2`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoresOrderSaleInfo",
|
Method: "GetStoresOrderSaleInfo",
|
||||||
|
|||||||
Reference in New Issue
Block a user