aa
This commit is contained in:
@@ -4062,8 +4062,8 @@ type GetBrandsResult struct {
|
||||
Balance int `json:"balance"`
|
||||
}
|
||||
|
||||
func GetBrands(ctx *jxcontext.Context, name string, brandID int) (getBrandsResult []*GetBrandsResult, err error) {
|
||||
brands, _ := dao.GetBrands(dao.GetDB(), name, brandID, "")
|
||||
func GetBrands(ctx *jxcontext.Context, name string, brandID int, isManage bool) (getBrandsResult []*GetBrandsResult, err error) {
|
||||
brands, _ := dao.GetBrands(dao.GetDB(), name, brandID, "", isManage, ctx.GetUserID())
|
||||
for _, v := range brands {
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(v.ID)
|
||||
result := &GetBrandsResult{
|
||||
@@ -4138,7 +4138,7 @@ func CreateVendorStore(ctx *jxcontext.Context, storeID, vendorID int, payload ma
|
||||
return fmt.Errorf("请选择平台账号!")
|
||||
}
|
||||
if vendorID == model.VendorIDMTWM {
|
||||
if brands, err := dao.GetBrands(db, "", storeDetail.BrandID, ""); err == nil {
|
||||
if brands, err := dao.GetBrands(db, "", storeDetail.BrandID, "", false, ""); err == nil {
|
||||
if len(brands) > 0 {
|
||||
if strings.Contains(brands[0].Name, "无品牌") {
|
||||
return fmt.Errorf("无品牌店铺不允许创建美团门店!")
|
||||
|
||||
@@ -1400,7 +1400,7 @@ func GetUserInfo(ctx *jxcontext.Context) (userInfo *UserInfo, err error) {
|
||||
if err = dao.GetRow(db, &userInfo, sql, sqlParams); err == nil && userInfo != nil {
|
||||
if brandUsers, _ := dao.GetBrandUser(db, 0, ctx.GetUserID()); len(brandUsers) > 0 {
|
||||
for _, v := range brandUsers {
|
||||
brands, _ := dao.GetBrands(db, "", v.BrandID, "")
|
||||
brands, _ := dao.GetBrands(db, "", v.BrandID, "", false, "")
|
||||
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(v.BrandID)
|
||||
brandMap := &BrandMap{
|
||||
BrandID: v.BrandID,
|
||||
|
||||
@@ -263,7 +263,7 @@ func CallbackBrandBill(res *SecretNumberMsgRes) (err error) {
|
||||
db = dao.GetDB()
|
||||
errLists = errlist.New()
|
||||
)
|
||||
if brands, _ := dao.GetBrands(db, "", 0, res.PoolKey); len(brands) > 0 {
|
||||
if brands, _ := dao.GetBrands(db, "", 0, res.PoolKey, false, ""); len(brands) > 0 {
|
||||
if brandID := brands[0].ID; brandID != 0 {
|
||||
price := utils.Float64TwoInt(utils.Str2Time(res.ReleaseTime).Sub(utils.Str2Time(res.StartTime)).Minutes()+1) * 6
|
||||
if err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, brandID, price, model.BrandBillTypeExpend, model.BrandBillFeeTypeSecretNumber, ""); err == nil {
|
||||
|
||||
@@ -990,25 +990,30 @@ func GetStoreAuditPage(db *DaoDB, statuss []int, keyword string, applyTimeStart,
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
func GetBrands(db *DaoDB, name string, brandID int, poolKey string) (brands []*model.Brand, err error) {
|
||||
func GetBrands(db *DaoDB, name string, brandID int, poolKey string, isManage bool, userID string) (brands []*model.Brand, err error) {
|
||||
sqlParams := []interface{}{}
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM brand
|
||||
WHERE deleted_at = ?
|
||||
SELECT a.*
|
||||
FROM brand a
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
if isManage {
|
||||
sql += ` JOIN brand_user b ON a.id = b.brand_id AND b.user_id = ?`
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
sql += `
|
||||
WHERE a.deleted_at = ?
|
||||
`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
if name != "" {
|
||||
sql += " AND name LIKE ?"
|
||||
sql += " AND a.name LIKE ?"
|
||||
sqlParams = append(sqlParams, "%"+name+"%")
|
||||
}
|
||||
if brandID != 0 {
|
||||
sql += " AND id = ?"
|
||||
sql += " AND a.id = ?"
|
||||
sqlParams = append(sqlParams, brandID)
|
||||
}
|
||||
if poolKey != "" {
|
||||
sql += " AND secret_number_pool_key = ?"
|
||||
sql += " AND a.secret_number_pool_key = ?"
|
||||
sqlParams = append(sqlParams, poolKey)
|
||||
}
|
||||
err = GetRows(db, &brands, sql, sqlParams)
|
||||
|
||||
@@ -963,15 +963,16 @@ func (c *StoreController) GetJddjStoreInfo() {
|
||||
|
||||
// @Title 查询品牌
|
||||
// @Description 查询品牌
|
||||
// @Param token header string false "认证token"
|
||||
// @Param brandID query int false "品牌ID"
|
||||
// @Param name query string false "品牌名"
|
||||
// @Param token header string false "认证token"
|
||||
// @Param brandID query int false "品牌ID"
|
||||
// @Param name query string false "品牌名"
|
||||
// @Param isManage query bool false "是否是查自己管理的品牌"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetBrands [get]
|
||||
func (c *StoreController) GetBrands() {
|
||||
c.callGetBrands(func(params *tStoreGetBrandsParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetBrands(params.Ctx, params.Name, params.BrandID)
|
||||
retVal, err = cms.GetBrands(params.Ctx, params.Name, params.BrandID, params.IsManage)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user