aa
This commit is contained in:
@@ -752,12 +752,12 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric
|
|||||||
return skuNamesInfo, err
|
return skuNamesInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckHasSensitiveWord(word string) (bool, error) {
|
func CheckHasSensitiveWord(word string) (bool, string) {
|
||||||
if hasSensitiveWord, sensitiveWord := IsSensitiveWordInList(word); hasSensitiveWord {
|
if hasSensitiveWord, sensitiveWord := IsSensitiveWordInList(word); hasSensitiveWord {
|
||||||
return true, errors.New(fmt.Sprintf("不能包含敏感词:[%s]", sensitiveWord))
|
return true, sensitiveWord
|
||||||
}
|
}
|
||||||
|
|
||||||
return false, nil
|
return false, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsSensitiveWordInList(str string) (bool, string) {
|
func IsSensitiveWordInList(str string) (bool, string) {
|
||||||
@@ -802,8 +802,8 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
|||||||
}
|
}
|
||||||
|
|
||||||
skuNameExt.Name = utils.TrimBlankChar(skuNameExt.Name)
|
skuNameExt.Name = utils.TrimBlankChar(skuNameExt.Name)
|
||||||
if hasSensitiveWord, err := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord {
|
if hasSensitiveWord, word := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord {
|
||||||
return nil, err
|
skuNameExt.Name = strings.ReplaceAll(skuNameExt.Name, word, "")
|
||||||
}
|
}
|
||||||
upc := utils.Pointer2String(skuNameExt.Upc)
|
upc := utils.Pointer2String(skuNameExt.Upc)
|
||||||
if upc == "" {
|
if upc == "" {
|
||||||
@@ -946,10 +946,11 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
var beforSkuName = *skuName
|
var beforSkuName = *skuName
|
||||||
if payload["name"] != nil {
|
if payload["name"] != nil {
|
||||||
newSkuName := utils.TrimBlankChar(utils.Interface2String(payload["name"]))
|
newSkuName := utils.TrimBlankChar(utils.Interface2String(payload["name"]))
|
||||||
if hasSensitiveWord, err := CheckHasSensitiveWord(newSkuName); hasSensitiveWord {
|
if hasSensitiveWord, word := CheckHasSensitiveWord(newSkuName); hasSensitiveWord {
|
||||||
return 0, err
|
payload["name"] = strings.ReplaceAll(payload["name"].(string), word, "")
|
||||||
|
} else {
|
||||||
|
payload["name"] = newSkuName
|
||||||
}
|
}
|
||||||
payload["name"] = newSkuName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(payload, "isSpu")
|
delete(payload, "isSpu")
|
||||||
|
|||||||
@@ -231,6 +231,6 @@ func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius
|
|||||||
return storeList, err
|
return storeList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetVendorOrgCode(ctx *jxcontext.Context, vendorID int, vendorOrgCode string) (vendorOrgs []*model.VendorOrgCode, err error) {
|
func GetVendorOrgCode(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorType string) (vendorOrgs []*model.VendorOrgCode, err error) {
|
||||||
return dao.GetVendorOrgCode(dao.GetDB(), vendorID, vendorOrgCode)
|
return dao.GetVendorOrgCode(dao.GetDB(), vendorID, vendorOrgCode, vendorType)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ func GetNeedUploadDataResource(db *DaoDB) (dataResList []*model.DataResource, er
|
|||||||
return dataResList, err
|
return dataResList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode string) (vendorOrgs []*model.VendorOrgCode, err error) {
|
func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode, vendorType string) (vendorOrgs []*model.VendorOrgCode, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT vendor_id, vendor_org_code, comment, is_jx_cat
|
SELECT vendor_id, vendor_org_code, comment, is_jx_cat, is_open
|
||||||
FROM vendor_org_code
|
FROM vendor_org_code
|
||||||
WHERE deleted_at = ?
|
WHERE deleted_at = ?
|
||||||
`
|
`
|
||||||
@@ -47,6 +47,10 @@ func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode string) (vendorOrgs
|
|||||||
sql += " AND vendor_org_code = ?"
|
sql += " AND vendor_org_code = ?"
|
||||||
sqlParams = append(sqlParams, vendorOrgCode)
|
sqlParams = append(sqlParams, vendorOrgCode)
|
||||||
}
|
}
|
||||||
|
if vendorType != "" {
|
||||||
|
sql += " AND vendor_type = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorType)
|
||||||
|
}
|
||||||
err = GetRows(db, &vendorOrgs, sql, sqlParams)
|
err = GetRows(db, &vendorOrgs, sql, sqlParams)
|
||||||
return vendorOrgs, err
|
return vendorOrgs, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ func GetMenu(db *DaoDB, name string, level int, userID string) (menus []*model.M
|
|||||||
sql += " AND a.level = ?"
|
sql += " AND a.level = ?"
|
||||||
sqlParams = append(sqlParams, level)
|
sqlParams = append(sqlParams, level)
|
||||||
}
|
}
|
||||||
|
sql += " ORDER BY a.id"
|
||||||
err = GetRows(db, &menus, sql, sqlParams)
|
err = GetRows(db, &menus, sql, sqlParams)
|
||||||
return menus, err
|
return menus, err
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,7 @@ func GetMenuWithUser(db *DaoDB, name string, level int, userID string) (menus []
|
|||||||
JOIN role_menu c ON c.menu_id = a.id AND c.role_id = b.role_id AND c.deleted_at = ?
|
JOIN role_menu c ON c.menu_id = a.id AND c.role_id = b.role_id AND c.deleted_at = ?
|
||||||
WHERE a.deleted_at = ?)a
|
WHERE a.deleted_at = ?)a
|
||||||
JOIN menu b ON (b.id = a.id OR b.id = a.parent_id)
|
JOIN menu b ON (b.id = a.id OR b.id = a.parent_id)
|
||||||
|
ORDER BY b.id
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{userID, utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue}
|
sqlParams := []interface{}{userID, utils.DefaultTimeValue, utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||||
err = GetRows(db, &menus, sql, sqlParams)
|
err = GetRows(db, &menus, sql, sqlParams)
|
||||||
|
|||||||
@@ -108,12 +108,13 @@ func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int, eclpIDs []string
|
|||||||
}
|
}
|
||||||
if len(catIDs) > 0 {
|
if len(catIDs) > 0 {
|
||||||
sql += `
|
sql += `
|
||||||
JOIN sku_category t3 ON t3.id = t2.category_id
|
JOIN sku_category t3 ON t3.id = t2.category_id AND t3.is_exd_spec = ?
|
||||||
LEFT JOIN sku_category t3p ON t3p.id = t3.parent_id
|
LEFT JOIN sku_category t3p ON t3p.id = t3.parent_id AND t3p.is_exd_spec = ?
|
||||||
`
|
`
|
||||||
sqlWhere += " AND (t3.id IN (" + GenQuestionMarks(len(catIDs)) + ")"
|
sqlWhere += " AND (t3.id IN (" + GenQuestionMarks(len(catIDs)) + ")"
|
||||||
sqlWhere += " OR t3p.id IN (" + GenQuestionMarks(len(catIDs)) + ") )"
|
sqlWhere += " OR t3p.id IN (" + GenQuestionMarks(len(catIDs)) + ") )"
|
||||||
sqlParams = append(sqlParams, catIDs, catIDs)
|
sqlWhere += " AND t1.exd_sku_id = ''"
|
||||||
|
sqlParams = append(sqlParams, model.NO, model.NO, catIDs, catIDs)
|
||||||
}
|
}
|
||||||
if len(eclpIDs) > 0 {
|
if len(eclpIDs) > 0 {
|
||||||
sqlWhere += " AND t1.eclp_id IN (" + GenQuestionMarks(len(eclpIDs)) + ")"
|
sqlWhere += " AND t1.eclp_id IN (" + GenQuestionMarks(len(eclpIDs)) + ")"
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
const (
|
||||||
|
VendorOrgTypePlatform = "platform" //外卖平台
|
||||||
|
VendorOrgTypeDelivery = "delivery" //配送平台
|
||||||
|
)
|
||||||
|
|
||||||
type VendorOrgCode struct {
|
type VendorOrgCode struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
|
||||||
@@ -7,6 +12,8 @@ type VendorOrgCode struct {
|
|||||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
Comment string `json:"comment"` //备注
|
Comment string `json:"comment"` //备注
|
||||||
//appkey,secret token等
|
//appkey,secret token等
|
||||||
Type string `json:"type"` //platform 普通平台, delivery 三方配送平台
|
|
||||||
IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用
|
VendorType string `json:"vendorType"` //platform 普通平台, delivery 三方配送平台
|
||||||
|
IsJxCat int `json:"isJxCat"` //是否使用京西分类,0默认使用
|
||||||
|
IsOpen int `json:"isOpen"` //主要三方配送用,是否配送,默认0表示打开,1表示关
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,6 +248,15 @@ func (c *DeliveryHandler) getBillParams(db *dao.DaoDB, order *model.GoodsOrder)
|
|||||||
// IDeliveryPlatformHandler
|
// IDeliveryPlatformHandler
|
||||||
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
|
if vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDDada, "", model.VendorOrgTypeDelivery); err == nil {
|
||||||
|
if len(vendorOrgCode) > 0 {
|
||||||
|
if vendorOrgCode[0].IsOpen == model.YES {
|
||||||
|
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
billParams, err := c.getBillParams(db, order)
|
billParams, err := c.getBillParams(db, order)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if globals.EnableStoreWrite {
|
if globals.EnableStoreWrite {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package fn
|
package fn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -66,6 +67,15 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
|
|||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
|
if vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDFengNiao, "", model.VendorOrgTypeDelivery); err == nil {
|
||||||
|
if len(vendorOrgCode) > 0 {
|
||||||
|
if vendorOrgCode[0].IsOpen == model.YES {
|
||||||
|
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
storeDetail, err := dao.GetStoreDetail(db, order.StoreID, order.VendorID, order.VendorOrgCode)
|
storeDetail, err := dao.GetStoreDetail(db, order.StoreID, order.VendorID, order.VendorOrgCode)
|
||||||
deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db)
|
deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -191,6 +191,15 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
|
|||||||
// IDeliveryPlatformHandler
|
// IDeliveryPlatformHandler
|
||||||
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
|
if vendorOrgCode, err := dao.GetVendorOrgCode(db, model.VendorIDMTPS, "", model.VendorOrgTypeDelivery); err == nil {
|
||||||
|
if len(vendorOrgCode) > 0 {
|
||||||
|
if vendorOrgCode[0].IsOpen == model.YES {
|
||||||
|
return nil, fmt.Errorf("此平台配送已被系统关闭,暂不发配送 [%v]", vendorOrgCode[0].Comment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db)
|
deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err = delivery.CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee, order, model.VendorIDMTPS); err != nil {
|
if err = delivery.CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee, order, model.VendorIDMTPS); err != nil {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type tEbaiStoreInfo struct {
|
|||||||
CityID int `orm:"column(city_id)"`
|
CityID int `orm:"column(city_id)"`
|
||||||
DistrictID int `orm:"column(district_id)"`
|
DistrictID int `orm:"column(district_id)"`
|
||||||
VendorStoreName string
|
VendorStoreName string
|
||||||
|
BrandName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||||
@@ -151,9 +152,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
SELECT
|
SELECT
|
||||||
t1.*,
|
t1.*,
|
||||||
t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code,
|
t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code,
|
||||||
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status, t2.vendor_store_name
|
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status, t2.vendor_store_name,
|
||||||
|
t3.name brand_name
|
||||||
FROM store t1
|
FROM store t1
|
||||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
||||||
|
LEFT JOIN brand t3 ON t3.id = t1.brand_id
|
||||||
WHERE t1.id = ?
|
WHERE t1.id = ?
|
||||||
ORDER BY t2.updated_at
|
ORDER BY t2.updated_at
|
||||||
`
|
`
|
||||||
@@ -398,7 +401,11 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
|||||||
if store.VendorStoreName != "" {
|
if store.VendorStoreName != "" {
|
||||||
params["name"] = store.VendorStoreName
|
params["name"] = store.VendorStoreName
|
||||||
} else {
|
} else {
|
||||||
params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI)
|
if store.BrandID != 1 {
|
||||||
|
params["name"] = store.Name
|
||||||
|
} else {
|
||||||
|
params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee)
|
boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ type tJdStoreInfo struct {
|
|||||||
RealLastOperator string
|
RealLastOperator string
|
||||||
SyncStatus int
|
SyncStatus int
|
||||||
VendorStoreName string
|
VendorStoreName string
|
||||||
|
BrandName string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -127,9 +128,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
|
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
|
||||||
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator,
|
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator,
|
||||||
t2.last_operator) real_last_operator,
|
t2.last_operator) real_last_operator,
|
||||||
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name
|
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name,
|
||||||
|
t3.name brand_name
|
||||||
FROM store t1
|
FROM store t1
|
||||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
||||||
|
LEFT JOIN brand t3 ON t3.id = t1.brand_id
|
||||||
LEFT JOIN place city ON t1.city_code = city.code
|
LEFT JOIN place city ON t1.city_code = city.code
|
||||||
LEFT JOIN place district ON t1.district_code = district.code
|
LEFT JOIN place district ON t1.district_code = district.code
|
||||||
WHERE t1.id = ?
|
WHERE t1.id = ?
|
||||||
@@ -159,7 +162,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
if store.VendorStoreName != "" {
|
if store.VendorStoreName != "" {
|
||||||
storeParams.StationName = store.VendorStoreName
|
storeParams.StationName = store.VendorStoreName
|
||||||
} else {
|
} else {
|
||||||
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
if store.BrandID != 1 {
|
||||||
|
storeParams.StationName = store.Name
|
||||||
|
} else {
|
||||||
|
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen)
|
storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ func (c *SysController) GetEbaiRTFDetail() {
|
|||||||
// @router /GetVendorOrgCode [get]
|
// @router /GetVendorOrgCode [get]
|
||||||
func (c *SysController) GetVendorOrgCode() {
|
func (c *SysController) GetVendorOrgCode() {
|
||||||
c.callGetVendorOrgCode(func(params *tSysGetVendorOrgCodeParams) (retVal interface{}, errCode string, err error) {
|
c.callGetVendorOrgCode(func(params *tSysGetVendorOrgCodeParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = common.GetVendorOrgCode(params.Ctx, params.VendorID, params.VendorOrgCode)
|
retVal, err = common.GetVendorOrgCode(params.Ctx, params.VendorID, params.VendorOrgCode, model.VendorOrgTypePlatform)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user