wangchuanjin 1 éve
szülő
commit
1f95ca49b4
3 módosított fájl, 21 hozzáadás és 17 törlés
  1. 18 14
      openPower/openPower.go
  2. 2 2
      public/service/power.go
  3. 1 1
      public/service/power_test.go

+ 18 - 14
openPower/openPower.go

@@ -85,7 +85,7 @@ func main() {
 	dayCount := flag.Int("c", 0, "自定义设置需要开通权益的天数,包含今天")
 	entName := flag.String("n", "", "企业名称")
 	isCheck := flag.Int("b", 1, "是否前置校验和后置处理")
-	openWay := flag.Int("a", 0, "开通权益方式;0:只开一个身份 1:开全部身份 2:只开到企业上")
+	powerWay := flag.Int("a", 0, "权益开通/取消方式;0:一个身份 1:全部身份 2:仅仅企业上")
 	flag.Parse()
 	if *phone == "" {
 		log.Fatalln("-p 参数无效")
@@ -145,13 +145,13 @@ func main() {
 	for _, v := range *ur {
 		id := Int64All(v["base_user_id"])
 		for _, identity := range middleground.UserCenter.IdentityList(id) {
-			if *openWay == 0 {
+			if *powerWay == 0 {
 				if *entName == "" && identity.PositionType == 1 {
 					continue
 				} else if *entName != "" && (identity.PositionType == 0 || *entName != identity.Name) {
 					continue
 				}
-			} else if *openWay == 2 {
+			} else if *powerWay == 2 {
 				if *entName == "" {
 					continue
 				} else if identity.PositionType == 0 || *entName != identity.Name {
@@ -208,7 +208,7 @@ func main() {
 					Type:        1,
 					EndTime:     endTime,
 				}
-				if *openWay == 2 {
+				if *powerWay == 2 {
 					powerReq.EntAccountId = identity.EntAccountId
 					powerReq.EntId = identity.EntId
 				} else {
@@ -226,16 +226,20 @@ func main() {
 					log.Println(msg, powerType, "开通失败!")
 				}
 			} else if *m == 3 {
-				r, err := c.PowerHandle(context.Background(), &pb.PowerReq{
-					Appid:        appid,
-					GoodsCode:    goodsCode,
-					GoodsSpecId:  goodsSpecId,
-					EntId:        identity.EntId,
-					AccountId:    identity.AccountId,
-					BuyNum:       1,
-					Type:         -1,
-					EntAccountId: identity.EntAccountId,
-				})
+				powerReq := &pb.PowerReq{
+					Appid:       appid,
+					GoodsCode:   goodsCode,
+					GoodsSpecId: goodsSpecId,
+					BuyNum:      1,
+					Type:        -1,
+				}
+				if *powerWay == 2 {
+					powerReq.EntAccountId = identity.EntAccountId
+					powerReq.EntId = identity.EntId
+				} else {
+					powerReq.AccountId = identity.AccountId
+				}
+				r, err := c.PowerHandle(context.Background(), powerReq)
 				if err != nil {
 					log.Println(msg, powerType, "取消失败!", err)
 				} else if r.Status == 1 {

+ 2 - 2
public/service/power.go

@@ -62,8 +62,8 @@ func CancelPower(appid, goods_code string, goods_spec_id, account_id, ent_accoun
 		return false, errors.New("无效的参数appid")
 	} else if goods_code == "" {
 		return false, errors.New("无效的参数goods_code")
-	} else if account_id == 0 {
-		return false, errors.New("无效的参数account_id")
+	} else if account_id == 0 && ent_account_id == 0 {
+		return false, errors.New("无效的参数account_id、ent_account_id")
 	}
 	return Base_power.CancelPower(appid, goods_code, goods_spec_id, account_id, ent_account_id), nil
 }

+ 1 - 1
public/service/power_test.go

@@ -20,7 +20,7 @@ func TestCancelPower(t *testing.T) {
 	//信息发布
 	//b, err := CancelPower("10000", "xxfb_gyxx", 4, 11686)
 	//医疗领域化
-	b, err := CancelPower("10000", "lyh", 13, 13485)
+	b, err := CancelPower("10000", "lyh", 13, 13485, 0)
 	assert.Nil(t, err)
 	assert.True(t, b)
 }