Sfoglia il codice sorgente

Merge branch '14.7.2_fix' into debug

zwxi 10 mesi fa
parent
commit
b7d1a89568
2 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  1. 8 0
      models/company/company_product.go
  2. 11 1
      services/cygx/admin_power.go

+ 8 - 0
models/company/company_product.go

@@ -683,3 +683,11 @@ func GetCompanyProductRaiForeverCount(companyId int) (count int, err error) {
 	err = o.Raw(sqlCount, companyId).QueryRow(&count)
 	return
 }
+
+// 根据共享销售id查被共享的公司销售id
+func GetCompanyProductSellerIdByShareSellerId(shareSellerId int) (sellerId int, err error) {
+	sqlCount := ` SELECT seller_id FROM company_product WHERE share_seller_id = ? AND product_id = 2 `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, shareSellerId).QueryRow(&sellerId)
+	return
+}

+ 11 - 1
services/cygx/admin_power.go

@@ -12,13 +12,23 @@ import (
 
 // 获取这个销售所能查看的手机号权限
 func GetAdminLookUserMobile(adminInfo *system.Admin) (mapMobile map[string]string, err error) {
+
+	sellerId, e := company.GetCompanyProductSellerIdByShareSellerId(adminInfo.AdminId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyProductSellerIdByShareSellerId 根据共享销售id查被共享的公司销售id, Err: " + e.Error())
+		return
+	}
 	var conditionMobile string
 	if adminInfo.RoleTypeCode == "rai_group" {
 		//组长查看本组所有组员
 		conditionMobile = ` SELECT mobile FROM user_seller_relation WHERE seller_id IN (SELECT  admin_id FROM admin WHERE group_id = (SELECT group_id FROM admin WHERE admin_id = ` + strconv.Itoa(adminInfo.AdminId) + ` )) `
 	} else {
 		//组员查看自己
-		conditionMobile = ` SELECT mobile FROM user_seller_relation WHERE seller_id  = ` + strconv.Itoa(adminInfo.AdminId)
+		if sellerId != 0 {
+			conditionMobile = ` SELECT mobile FROM user_seller_relation WHERE seller_id  IN ( ` + strconv.Itoa(adminInfo.AdminId) + `,` + strconv.Itoa(sellerId) + ` ) `
+		} else {
+			conditionMobile = ` SELECT mobile FROM user_seller_relation WHERE seller_id  IN ( ` + strconv.Itoa(adminInfo.AdminId) + ` ) `
+		}
 	}
 	mobileList, e := cygx.GetSellerUserMobile(conditionMobile)
 	if e != nil {