Beispiel #1
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
}