|
@@ -34,10 +34,7 @@ var (
|
|
|
all map[string]string
|
|
|
powerType string
|
|
|
middleground *Middleground
|
|
|
- allEntity = map[string]Entity{
|
|
|
- "yxy": &Yxy{},
|
|
|
- }
|
|
|
- c *Config
|
|
|
+ c *Config
|
|
|
)
|
|
|
|
|
|
type Config struct {
|
|
@@ -88,8 +85,9 @@ func main() {
|
|
|
filterSpec[v] = true
|
|
|
}
|
|
|
MysqlMain.Init()
|
|
|
- allEntity := map[int64]*Common{}
|
|
|
- allT := ""
|
|
|
+ allEntity := map[int64]Entity{}
|
|
|
+ allEntity[-1] = &Yxy{}
|
|
|
+ allT := "-1:医械通"
|
|
|
for _, v := range *MysqlMain.SelectBySql(`select a.id,c.code,c.name,a.goods_code,a.name as spec_name from base_service.base_goods_spec a
|
|
|
inner join base_service.base_goods_spec_power b on (a.id=b.spec_id)
|
|
|
inner join base_service.base_function c on (b.function_code=c.code) order by a.id`) {
|
|
@@ -114,7 +112,7 @@ func main() {
|
|
|
All: map[string]string{name: code},
|
|
|
}
|
|
|
} else {
|
|
|
- allEntity[id].All[name] = code
|
|
|
+ (allEntity[id].(*Common)).All[name] = code
|
|
|
}
|
|
|
}
|
|
|
phone := flag.String("p", "", "手机号")
|
|
@@ -211,54 +209,85 @@ func main() {
|
|
|
if *isCheck == 1 && !entity.beforeOpen(phone, identity) {
|
|
|
return
|
|
|
}
|
|
|
- for _, v := range all {
|
|
|
- wed, err := resClient.WaitEmpowerDetail(context.Background(), &pb.WaitEmpowerDetailReq{
|
|
|
- Appid: "10000",
|
|
|
- EntId: identity.EntId,
|
|
|
- FunctionCode: v,
|
|
|
+ endTime := ""
|
|
|
+ if *dayCount > 0 {
|
|
|
+ now := time.Now()
|
|
|
+ end_time := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
|
|
|
+ end_time = end_time.AddDate(0, 0, *dayCount-1)
|
|
|
+ endTime = date.FormatDate(&end_time, date.Date_Full_Layout)
|
|
|
+ }
|
|
|
+ isEmpower := false
|
|
|
+ if identity.EntId > 0 {
|
|
|
+ resp, err := resClient.WaitEmpowerDetailBySpecId(context.Background(), &pb.WaitEmpowerDetailBySpecIdReq{
|
|
|
+ Appid: "10000",
|
|
|
+ EntId: identity.EntId,
|
|
|
+ SpecId: goodsSpecId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
log.Println(msg, powerType, "开通失败!", err)
|
|
|
- } else if wed.Id == 0 {
|
|
|
- endTime := ""
|
|
|
- if *dayCount > 0 {
|
|
|
- now := time.Now()
|
|
|
- end_time := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
|
|
|
- end_time = end_time.AddDate(0, 0, *dayCount-1)
|
|
|
- endTime = date.FormatDate(&end_time, date.Date_Full_Layout)
|
|
|
- }
|
|
|
- powerReq := &pb.PowerReq{
|
|
|
- Appid: appid,
|
|
|
- GoodsCode: goodsCode,
|
|
|
- GoodsSpecId: goodsSpecId,
|
|
|
- BuyNum: 0,
|
|
|
- Type: 1,
|
|
|
- EndTime: endTime,
|
|
|
- }
|
|
|
- if *powerWay == 2 {
|
|
|
- powerReq.EntAccountId = identity.EntAccountId
|
|
|
- powerReq.EntId = identity.EntId
|
|
|
- } else {
|
|
|
- powerReq.AccountId = identity.AccountId
|
|
|
- }
|
|
|
- r, err := resClient.PowerHandle(context.Background(), powerReq)
|
|
|
- if err != nil {
|
|
|
- log.Println(msg, powerType, "开通失败!", err)
|
|
|
- } else if r.Status == 1 {
|
|
|
- if *isCheck == 1 {
|
|
|
- entity.afterOpen(phone, identity)
|
|
|
- }
|
|
|
- log.Println(msg, powerType, "已开通!")
|
|
|
- } else {
|
|
|
- log.Println(msg, powerType, "开通失败!")
|
|
|
+ } else if len(resp.WaitEmpowerDetails) > 0 {
|
|
|
+ if *powerWay < 2 {
|
|
|
+ isEmpower = true
|
|
|
+ } else if *powerWay == 2 {
|
|
|
+ log.Fatalln(msg, powerType, "权益已存在!")
|
|
|
}
|
|
|
}
|
|
|
- resClient.Empower(context.Background(), &pb.EmpowerReq{
|
|
|
- Appid: "10000",
|
|
|
- FunctionCode: v,
|
|
|
- EntId: identity.EntId,
|
|
|
- EntUserId: []int64{identity.EntUserId},
|
|
|
- })
|
|
|
+ // for _, v := range all {
|
|
|
+ // resp, err := resClient.WaitEmpowerDetail(context.Background(), &pb.WaitEmpowerDetailReq{
|
|
|
+ // Appid: "10000",
|
|
|
+ // EntId: identity.EntId,
|
|
|
+ // FunctionCode: v,
|
|
|
+ // })
|
|
|
+ // log.Println(v, resp.Id)
|
|
|
+ // if err != nil {
|
|
|
+ // log.Println(msg, powerType, "开通失败!", err)
|
|
|
+ // } else if resp.Id > 0 {
|
|
|
+ // if *powerWay < 2 {
|
|
|
+ // isEmpower = true
|
|
|
+ // } else if *powerWay == 2 {
|
|
|
+ // log.Fatalln(msg, powerType, "权益已存在!")
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ var r *pb.Resp
|
|
|
+ var err error
|
|
|
+ if isEmpower {
|
|
|
+ for _, v := range all {
|
|
|
+ r, err = resClient.Empower(context.Background(), &pb.EmpowerReq{
|
|
|
+ Appid: "10000",
|
|
|
+ FunctionCode: v,
|
|
|
+ EntId: identity.EntId,
|
|
|
+ EntUserId: []int64{identity.EntUserId},
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ powerReq := &pb.PowerReq{
|
|
|
+ Appid: appid,
|
|
|
+ GoodsCode: goodsCode,
|
|
|
+ GoodsSpecId: goodsSpecId,
|
|
|
+ BuyNum: 1,
|
|
|
+ Type: 1,
|
|
|
+ EndTime: endTime,
|
|
|
+ }
|
|
|
+ if *powerWay == 2 {
|
|
|
+ powerReq.EntAccountId = identity.EntAccountId
|
|
|
+ powerReq.EntId = identity.EntId
|
|
|
+ } else {
|
|
|
+ powerReq.AccountId = identity.AccountId
|
|
|
+ }
|
|
|
+ r, err = resClient.PowerHandle(context.Background(), powerReq)
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ log.Println(msg, powerType, "开通失败!", err)
|
|
|
+ } else if r.Status == 1 {
|
|
|
+ if *isCheck == 1 {
|
|
|
+ entity.afterOpen(phone, identity)
|
|
|
+ }
|
|
|
+ log.Println(msg, powerType, "已开通!")
|
|
|
+ } else {
|
|
|
+ log.Println(msg, powerType, "开通失败!")
|
|
|
}
|
|
|
} else if *m == 3 {
|
|
|
powerReq := &pb.PowerReq{
|