Merge remote-tracking branch 'origin/mark' into don

This commit is contained in:
Rosy-zhudan
2019-10-09 08:45:50 +08:00
20 changed files with 221 additions and 68 deletions

View File

@@ -74,7 +74,6 @@ func init() {
func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Act, vendorIDs []int, actStoreSku []*ActStoreSkuParam) (validVendorIDs []int, actStoreSkuList []*model.ActStoreSku, actStoreSkuMapList []*model.ActStoreSkuMap, err error) {
wholeValidVendorMap := make(map[int]int)
wholeValidVendorMap[model.VendorIDJX] = 1
if len(actStoreSku) > 0 {
storeIDMap := make(map[int]int)
skuIDMap := make(map[int]int)
@@ -715,7 +714,7 @@ func SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actID int, vendor
task := tasksch.NewParallelTask("SyncAct", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
vendorID := batchItemList[0].(int)
if handler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformActHandler); handler != nil {
if handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformActHandler); handler != nil {
tmpActMap := &model.ActMap{}
tmpActMap.ID = actMap[vendorID].MapID
if err = handler.SyncAct(ctx, nil, actMap[vendorID], nil, actStoreSkuMap[vendorID]); err == nil {
@@ -725,6 +724,8 @@ func SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actID int, vendor
}
// 保存最后一次同步错误信息
dao.UpdateEntity(db, tmpActMap, "Remark")
} else {
globals.SugarLogger.Warnf("SyncAct strange actID:%d, vendorID:%d", actID, vendorID)
}
return retVal, err
}, vendorIDs)

View File

@@ -315,3 +315,17 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (err er
func QueryConfigs(key, configType, keyword string) (configList []*model.NewConfig, err error) {
return dao.QueryConfigs(dao.GetDB(), key, configType, keyword)
}
func GetCityBankBranches(ctx *jxcontext.Context, cityCode int, bankCode string) (info map[int]map[string][]string, err error) {
list, err := dao.GetCityBankBranches(dao.GetDB(), cityCode, bankCode)
if err == nil && len(list) > 0 {
info = make(map[int]map[string][]string)
for _, v := range list {
if info[v.CityCode] == nil {
info[v.CityCode] = make(map[string][]string)
}
info[v.CityCode][v.PayeeBankCode] = append(info[v.CityCode][v.PayeeBankCode], v.PayeeBankBranchName)
}
}
return info, err
}

View File

@@ -42,6 +42,7 @@ type StoreExt struct {
MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名
OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名
OperatorName2 string `orm:"size(8)" json:"operatorName2"` // 非京东运营人姓名
FloatLng float64 `json:"lng"`
FloatLat float64 `json:"lat"`
@@ -120,6 +121,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
*/
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = t1.market_man_phone AND mm.deleted_at = ?
LEFT JOIN user om ON om.mobile <> '' AND om.mobile = t1.operator_phone AND om.deleted_at = ?
LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = t1.operator_phone2 AND om2.deleted_at = ?
`
sqlFromParams = []interface{}{
utils.DefaultTimeValue,
@@ -128,6 +130,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
// utils.DefaultTimeValue,
utils.DefaultTimeValue,
utils.DefaultTimeValue,
utils.DefaultTimeValue,
}
sqlWhere := `
WHERE t1.deleted_at = ?
@@ -174,20 +177,22 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
}
if keyword != "" {
keywordLike := "%" + keyword + "%"
sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.market_man_phone LIKE ?
sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.operator_phone2 LIKE ? OR t1.market_man_phone LIKE ?
OR t1.last_operator LIKE ? OR city.name LIKE ? OR t1.address LIKE ? OR t1.printer_sn LIKE ? OR t1.licence_code LIKE ? OR t1.id_code LIKE ?`
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike,
keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
// if !globals.DisableWXAuth1 && jxutils.IsLegalMobileNumber(keywordInt64) {
// sql += `
// LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.parentid = -1 AND wx1.tel = ?
// LEFT JOIN weixins wx2 ON t1.id = wx2.jxstoreid AND wx2.parentid = -1
// LEFT JOIN weixins wx3 ON wx3.parentid = wx2.id AND wx3.tel = ?
// `
// sqlParams = append(sqlParams, keywordInt64, keywordInt64)
// sqlWhere += " OR wx1.id IS NOT NULL OR wx3.id IS NOT NULL"
// }
if true { // jxutils.IsLegalMobileNumber(keywordInt64) {
sqlWhere += ` OR (
SELECT COUNT(*)
FROM casbin_rule t11
JOIN user t12 ON t12.user_id = t11.v0 AND t12.mobile LIKE ?
WHERE t11.v1 <> '' AND (t11.v1 = CONCAT(?, t1.id) OR t11.v1 = CONCAT(?, t1.market_man_role) OR t11.v1 = CONCAT(?, t1.operator_role) OR t11.v1 = CONCAT(?, t1.operator_role2))
) > 0`
prefix := autils.NewRole("", 0).GetFullName()
sqlWhereParams = append(sqlWhereParams, keyword+"%", autils.NewStoreBossRole(-1).GetFullName(), prefix, prefix, prefix) // 必须要前缀,不然不能用过些会很慢
}
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?"
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64)
if jxutils.GuessVendorIDFromVendorStoreID(keywordInt64) != model.VendorIDUnknown {
@@ -195,7 +200,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
OR (SELECT COUNT(*) FROM store_map tsm WHERE t1.id = tsm.store_id AND tsm.deleted_at = ? AND tsm.vendor_store_id = ?) > 0
OR (SELECT COUNT(*) FROM store_courier_map tsm WHERE t1.id = tsm.store_id AND tsm.deleted_at = ? AND tsm.vendor_store_id = ?) > 0
`
sqlWhereParams = append(sqlWhereParams, utils.DefaultTimeValue, keywordInt64, utils.DefaultTimeValue, keywordInt64)
sqlWhereParams = append(sqlWhereParams, utils.DefaultTimeValue, keyword, utils.DefaultTimeValue, keyword)
}
}
sqlWhere += ")"
@@ -308,6 +313,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
IF(mm.name <> '', mm.name, mm.user_id2) market_man_name,
bank.value payee_bank_name,
IF(om.name <> '', om.name, om.user_id2) operator_name,
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2,
province.code province_code,
province.name province_name,
city.name city_name,
@@ -323,6 +329,9 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
offset = jxutils.FormalizePageOffset(offset)
pageSize = jxutils.FormalizePageSize(pageSize)
mapLimit := false
// globals.SugarLogger.Debug(sql)
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil {
// 地图区域限制过滤
if mapLongitude2, ok := params["mapLongitude"].(string); ok {
@@ -1546,7 +1555,7 @@ func getAllUsers4Store(ctx *jxcontext.Context, db *dao.DaoDB, store *model.Store
}
// 直接电话信息相关人员
for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone} {
for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone, store.OperatorPhone2} {
if mobile != "" {
if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
if userMap[user.GetID()] == 0 {

View File

@@ -1145,6 +1145,8 @@ func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBind
skuBind.Status = model.StoreSkuBindStatusNormal
}
kvs := map[string]interface{}{
model.FieldLastOperator: ctx.GetUserName(),
model.FieldUpdatedAt: time.Now(),
model.FieldStatus: skuBind.Status,
model.FieldJdSyncStatus: skuBind.JdSyncStatus | model.SyncFlagSaleMask,
model.FieldEbaiSyncStatus: skuBind.EbaiSyncStatus | model.SyncFlagSaleMask,

View File

@@ -112,7 +112,11 @@ func Init() {
}, autoSaleStoreSkuTimeList)
if beego.BConfig.RunMode == "beta" {
netspider.GetAndStoreCitiesShops(jxcontext.AdminCtx, nil, nil, 0, 0, false, true)
ScheduleTimerFunc("GetAndStoreCitiesShops", func() {
netspider.GetAndStoreCitiesShops(jxcontext.AdminCtx, nil, nil, 0, 0, false, false)
}, []string{
"04:05:06",
})
}
}