예제 #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
}
예제 #2
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
}