Exemplo n.º 1
0
func (this *ReqRedisModule) fill_material(ad *context.AdInfo, material *jesgoo_protocol.Material) (err error) {

	if ad.Adid != int64(*material.Id) {
		err = errors.New("id is not equal")
		return
	}

	/*	switch *material.Type {
		case jesgoo_protocol.Material_TEXT:
			if ad.AdType != context.TEXT {
				str := fmt.Sprintf("adid[%d] is not TEXT in bs", ad.Adid)
				err = errors.New(str)
				return
			}
		case jesgoo_protocol.Material_IMAGE:
			if ad.AdType != context.IMAGE {
				str := fmt.Sprintf("adid[%d] is not IMAGE in bs", ad.Adid)
				err = errors.New(str)
				return
			}
		case jesgoo_protocol.Material_ICON_TEXT:
			if ad.AdType != context.TEXT_ICON {
				str := fmt.Sprintf("adid[%d] is not ICON_TEXT in bs", ad.Adid)
				err = errors.New(str)
				return
			}
		default:
			str := fmt.Sprintf("adid[%d] is UNKNOWN is bs", ad.Adid)
			err = errors.New(str)
			return
		}
	*/
	if material.Title != nil {
		ad.Title = *material.Title
	}
	if material.Description != nil {
		ad.Description1 = *material.Description
	}
	if material.Image != nil {
		ad.ImageUrl = *material.Image.Url
	}
	if material.TargetUrl != nil {
		ad.ClickUrl = *material.TargetUrl
	}
	if material.App != nil {
		ad.Appname = *material.App.Name
		ad.Package = *material.App.PackageName
		ad.LogoUrl = *material.App.Logo.Url
		if material.App.PackageSize != nil {
			ad.PackageSize = (*material.App.PackageSize) >> 20
		}
	}
	if material.LongDescription != nil {
		ad.Description2 = *material.LongDescription
	}
	ad.MaterialReady = true
	return
}
Exemplo n.º 2
0
func (this *ReqJesgooModule) parse_resp(ret_ads *[]context.AdInfo, bs_resp *ui2bs.BSResponse, adtype AdType) {
	if bs_resp.Ads == nil {
		return
	}
	var ad_num int
	ad_num = len(bs_resp.Ads)
	utils.DebugLog.Write("get jesgoo ad num [%d]", ad_num)
	for i := 0; i < ad_num; i++ {
		var tmpad context.AdInfo
		tmpad.MaterialReady = false
		this.convert_resp_ad(&tmpad, bs_resp.Ads[i], adtype)
		*ret_ads = append(*ret_ads, tmpad)
	}

}
Exemplo n.º 3
0
func (this *ReqQiushiModule) parse_resp(response *mobads_api.BidResponse, adtype AdType, inner_ads *[]context.AdInfo, bd_appsid string) (err error) {
	utils.DebugLog.Write("baidu_response [%s]", response.String())
	if response.ErrorCode != nil {
		utils.WarningLog.Write("request qiushi fail . error_code is %u", *response.ErrorCode)
		errstr := fmt.Sprintf("request qiushi fail . errcode[%d]", *response.ErrorCode)
		err = errors.New(errstr)
		return
	}
	for i := 0; i < len(response.Ads); i++ {
		var inner_ad context.AdInfo
		inner_ad.MaterialReady = true
		err = this.convert_ad(&inner_ad, adtype, response.Ads[i], bd_appsid)
		if err != nil {
			continue
		}
		*inner_ads = append(*inner_ads, inner_ad)
	}
	return
}
Exemplo n.º 4
0
func (this *ReqQiushiModule) convert_ad(inad *context.AdInfo, adtype AdType, bsad *mobads_api.Ad, bd_appsid string) (err error) {
	if bsad.AdId != nil {
		inad.Adid = int64(*bsad.AdId)
	}
	//	inad.Groupid = bsad.Groupid
	//	inad.Planid = bsad.Groupid
	//	inad.Userid = bsad.Userid
	admeta := bsad.MaterialMeta
	if admeta != nil {

		inad.AdSrc = context.AdSrc_BAIDU

		if admeta.CreativeType != nil {
			switch *admeta.CreativeType {
			case mobads_api.CreativeType_TEXT:
				inad.AdType = context.TEXT
			case mobads_api.CreativeType_IMAGE:
				inad.AdType = context.IMAGE
			case mobads_api.CreativeType_HTML:
				inad.AdType = context.HTML
			case mobads_api.CreativeType_VIDEO:
				inad.AdType = context.VIDEO
			case mobads_api.CreativeType_TEXT_ICON:
				inad.AdType = context.TEXT_ICON
			}
		}
		if admeta.InteractionType != nil {
			switch *admeta.InteractionType {
			case mobads_api.InteractionType_SURFING:
				inad.InteractionType = context.SURFING
			case mobads_api.InteractionType_DOWNLOAD:
				inad.InteractionType = context.DOWNLOAD
			case mobads_api.InteractionType_DIALING:
				inad.InteractionType = context.DIALING
			case mobads_api.InteractionType_MESSAGE:
				inad.InteractionType = context.MESSAGE
			case mobads_api.InteractionType_MAIL:
				inad.InteractionType = context.MAIL
			default:
				inad.InteractionType = context.NO_INTERACT

			}
		}

		switch adtype {
		case Banner:
			inad.AdSlotType = context.AdSlotType_BANNER
		case Insert:
			inad.AdSlotType = context.AdSlotType_INSERT
		case Initlization:
			inad.AdSlotType = context.AdSlotType_INITIALIZATION
		default:
			inad.AdSlotType = context.AdSlotType_BANNER
		}

		if admeta.Title != nil {
			inad.Title = *admeta.Title
		}
		if admeta.Description1 != nil {
			inad.Description1 = *admeta.Description1
		}
		if admeta.Description2 != nil {
			inad.Description2 = *admeta.Description2
		}
		if admeta.MediaUrl != nil {
			switch inad.AdType {
			case context.TEXT_ICON:
				inad.LogoUrl = *admeta.MediaUrl
			case context.IMAGE:
				inad.ImageUrl = *admeta.MediaUrl
			default:
				inad.ImageUrl = *admeta.MediaUrl
			}
		}
		for i := 0; i < len(admeta.WinNoticeUrl); i++ {
			inad.ImpressionUrl = append(inad.ImpressionUrl, admeta.WinNoticeUrl[i])
		}
		if admeta.ClickUrl != nil {
			inad.ClickUrl = *admeta.ClickUrl
		}
	}
	inad.DspMediaid = bd_appsid
	inad.DspChannelid = ""
	inad.Bid = 0
	inad.Price = 0
	inad.Ctr = 0
	inad.Cpm = 0
	//	inad.Wuliao_type = bsad.WuliaoType
	//	inad.LogoUrl = bsad.AppLogo
	return
}
Exemplo n.º 5
0
func (this *ReqJesgooModule) convert_resp_ad(inad *context.AdInfo, bsad *ui2bs.Ad, adtype AdType) {
	inad.AdSrc = context.AdSrc_JESGOO
	switch bsad.Adtype {
	case ui2bs.AdType_TEXT:
		inad.AdType = context.TEXT
	case ui2bs.AdType_IMAGE:
		inad.AdType = context.IMAGE
	case ui2bs.AdType_HTML:
		inad.AdType = context.HTML
	case ui2bs.AdType_VIDEO:
		inad.AdType = context.VIDEO
	case ui2bs.AdType_TEXT_ICON:
		inad.AdType = context.TEXT_ICON
	}
	switch bsad.InteractionType {
	case ui2bs.Interaction_SURFING:
		inad.InteractionType = context.SURFING
	case ui2bs.Interaction_DOWNLOAD:
		inad.InteractionType = context.DOWNLOAD
	case ui2bs.Interaction_DIALING:
		inad.InteractionType = context.DIALING
	case ui2bs.Interaction_MESSAGE:
		inad.InteractionType = context.MESSAGE
	case ui2bs.Interaction_MAIL:
		inad.InteractionType = context.MAIL
	}

	switch adtype {
	case Banner:
		inad.AdSlotType = context.AdSlotType_BANNER
	case Initlization:
		inad.AdSlotType = context.AdSlotType_INITIALIZATION
	case Insert:
		inad.AdSlotType = context.AdSlotType_INSERT
	case OfferWall:
		inad.AdSlotType = context.AdSlotType_OFFERWALL
	case Recommed:
		inad.AdSlotType = context.AdSlotType_RECOMMEND
	default:
		inad.AdSlotType = context.AdSlotType_BANNER
	}

	inad.Adid = bsad.Adid
	inad.Groupid = bsad.Groupid
	inad.Planid = bsad.Planid
	inad.Userid = bsad.Userid
	inad.Bid = bsad.Bid
	inad.Price = 0
	inad.Ctr = 0
	inad.Cpm = 0

}