fuwencai 4 år sedan
förälder
incheckning
f21a092d32

+ 15 - 1
api/activity.api

@@ -13,7 +13,7 @@ type Request {
 }
 
 type LotteryOperation {
-	LotteryIdArr     string `form:"lotteryIdArr,optional"`     //奖券标识集合
+	LotteryIdArr     string  `form:"lotteryIdArr,optional"`     //奖券标识集合
 	UserLotteryIdArr []int64 `form:"userLotteryIdArr,optional"` //用户奖券标识集合
 	UserId           string  `form:"userId"`                    //用户标识
 	AppId            string  `form:"appId"`                     //身份标识
@@ -60,6 +60,7 @@ type LotteryJson {
 	ValidityTimeType int64         `form:"validityTimeType"`                                  //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
 	PrizeType        int64         `xorm:"prizeType" form:"prizeType" json:"prizeType"`       //0未使用1已使用2已过期3待使用
 	LotteryType      int64         `xorm:"lotteryType" form:"lotteryType" json:"lotteryType"` //0、满减1折扣券2、实物
+	IsUser           bool          `form:"IsUser"`                                            //是否使用true使用false未使用
 }
 type ActivityJson {
 	ActivityName      string `form:"activityName"`      //活动名字
@@ -82,6 +83,12 @@ type LotteryResp {
 	Message string      `form:"message"`  //响应消息
 	Data    LotteryJson `form:"Activity"` //活动信息
 }
+type AdvertisingReq {
+	UserID         string `form:"userID"`         //用户id
+	Client         string `form:"client"`         //用户端
+	AdvertisingID  string `form:"advertisingID"`  //广告id
+	AdvertisingUrl string `form:"advertisingUrl"` //广告位置
+}
 service activity-api {
 	//查询活动下的奖券
 	@handler activityLotteryCheckHandler // TODO: set handler name and delete this comment
@@ -101,4 +108,11 @@ service activity-api {
 	//奖券详情
 	@handler lotteryInfoCheckHandler // TODO: set handler name and delete this comment
 	get /lotteryInfo (Request) returns(LotteryResp)
+	// 广告联盟
+	// 广告点击
+	@handler advertisingClickHandler // TODO: set handler name and delete this comment
+	post /advertisingClick (AdvertisingReq) returns(Response)
+	// 广告曝光
+	@handler advertisingExposureHandler // TODO: set handler name and delete this comment
+	post /advertisingExposure (AdvertisingReq) returns(Response)
 }

+ 29 - 0
api/internal/handler/advertisingclickhandler.go

@@ -0,0 +1,29 @@
+package handler
+
+import (
+	"net/http"
+
+	"app.yhyue.com/moapp/jyMarketing/api/internal/logic"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/types"
+
+	"github.com/tal-tech/go-zero/rest/httpx"
+)
+
+func advertisingClickHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.AdvertisingReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewAdvertisingClickLogic(r.Context(), ctx)
+		resp, err := l.AdvertisingClick(req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 29 - 0
api/internal/handler/advertisingexposurehandler.go

@@ -0,0 +1,29 @@
+package handler
+
+import (
+	"net/http"
+
+	"app.yhyue.com/moapp/jyMarketing/api/internal/logic"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/types"
+
+	"github.com/tal-tech/go-zero/rest/httpx"
+)
+
+func advertisingExposureHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.AdvertisingReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewAdvertisingExposureLogic(r.Context(), ctx)
+		resp, err := l.AdvertisingExposure(req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 10 - 0
api/internal/handler/routes.go

@@ -42,6 +42,16 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/lotteryInfo",
 				Handler: lotteryInfoCheckHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/advertisingClick",
+				Handler: advertisingClickHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/advertisingExposure",
+				Handler: advertisingExposureHandler(serverCtx),
+			},
 		},
 	)
 }

+ 30 - 0
api/internal/logic/advertisingclicklogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/api/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/types"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type AdvertisingClickLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAdvertisingClickLogic(ctx context.Context, svcCtx *svc.ServiceContext) AdvertisingClickLogic {
+	return AdvertisingClickLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AdvertisingClickLogic) AdvertisingClick(req types.AdvertisingReq) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+
+	return &types.Response{}, nil
+}

+ 42 - 0
api/internal/logic/advertisingexposurelogic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/api/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/types"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type AdvertisingExposureLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAdvertisingExposureLogic(ctx context.Context, svcCtx *svc.ServiceContext) AdvertisingExposureLogic {
+	return AdvertisingExposureLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AdvertisingExposureLogic) AdvertisingExposure(req types.AdvertisingReq) (*types.Response, error) {
+	// todo: add your logic here and delete this line
+	result := &types.Response{}
+	resp, err :=l.svcCtx.Activity.AdvertisingExposure(l.ctx,&activity.AdvertisingReq{
+		UserID: req.UserID,
+		Client: req.Client,
+		AdvertisingID: req.AdvertisingID,
+		AdvertisingUrl: req.AdvertisingUrl,
+	})
+	if err != nil {
+		return nil, err
+	}
+	result.Code = resp.Code
+	result.Message = resp.Message
+	return result, nil
+}

+ 9 - 2
api/internal/types/types.go

@@ -14,7 +14,7 @@ type Request struct {
 }
 
 type LotteryOperation struct {
-	LotteryIdArr     string `form:"lotteryIdArr,optional"`     //奖券标识集合
+	LotteryIdArr     string  `form:"lotteryIdArr,optional"`     //奖券标识集合
 	UserLotteryIdArr []int64 `form:"userLotteryIdArr,optional"` //用户奖券标识集合
 	UserId           string  `form:"userId"`                    //用户标识
 	AppId            string  `form:"appId"`                     //身份标识
@@ -64,7 +64,7 @@ type LotteryJson struct {
 	ValidityTimeType int64         `form:"validityTimeType"`                                  //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
 	PrizeType        int64         `xorm:"prizeType" form:"prizeType" json:"prizeType"`       //0未使用1已使用2已过期3待使用
 	LotteryType      int64         `xorm:"lotteryType" form:"lotteryType" json:"lotteryType"` //0、满减1折扣券2、实物
-	IsUser			 bool          `form:"IsUser"`                                         //是否使用true使用false未使用
+	IsUser           bool          `form:"IsUser"`                                            //是否使用true使用false未使用
 }
 
 type ActivityJson struct {
@@ -89,3 +89,10 @@ type LotteryResp struct {
 	Message string      `form:"message"`  //响应消息
 	Data    LotteryJson `form:"Activity"` //活动信息
 }
+
+type AdvertisingReq struct {
+	UserID         string `form:"userID"`         //用户id
+	Client         string `form:"client"`         //用户端
+	AdvertisingID  string `form:"advertisingID"`  //广告id
+	AdvertisingUrl string `form:"advertisingUrl"` //广告位置
+}

+ 12 - 0
entity/advertising.go

@@ -0,0 +1,12 @@
+package entity
+
+import "time"
+
+// 广告访问明细记录
+type Exposure struct {
+	UserID         string    `xorm:"userID" form:"userID" json:"userID"`                         //用户id
+	Client         string    `xorm:"client" form:"client" json:"client"`                         //用户端
+	AdvertisingID  string    `xorm:"advertisingID" form:"advertisingID" json:"advertisingID"`    //广告id
+	AdvertisingUrl string    `xorm:"advertisingUrl" form:"advertisingUrl" json:"advertisingUrl"` //广告位置
+	CreateTime     time.Time `xorm:"createTime" form:"createTime" json:"2006-01-02 15:04:05"`    //时间
+}

+ 12 - 0
rpc/activity.proto

@@ -85,6 +85,14 @@ message LotteryResp {
   string    message=2;          //响应消息
   LotteryJson data=3; //奖券信息
 }
+
+//--------------广告联盟-----------------
+message AdvertisingReq {
+  string  userID=1;         //用户ID
+  string  client=2;         //用户端
+  string  advertisingID=3;  //广告ID
+  string  advertisingUrl=4; //广告位置
+}
 service Activity {
   //查询活动下的奖券
   rpc activityLottery(Request) returns(activityLotteryResp);
@@ -98,4 +106,8 @@ service Activity {
   rpc userLottery(Request) returns(activityLotteryResp);
    //奖券信息
   rpc lotteryInfo(Request) returns(LotteryResp);
+  //广告联盟-点击
+  rpc advertisingClick(AdvertisingReq) returns(Response);
+  //广告联盟-曝光
+  rpc advertisingExposure(AdvertisingReq) returns(Response);
 }

+ 219 - 37
rpc/activity/activity.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
 // 	protoc-gen-go v1.25.0
-// 	protoc        v3.15.3
+// 	protoc        v3.15.1
 // source: activity.proto
 
 package activity
@@ -870,6 +870,78 @@ func (x *LotteryResp) GetData() *LotteryJson {
 	return nil
 }
 
+//--------------广告联盟-----------------
+type AdvertisingReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	UserID         string `protobuf:"bytes,1,opt,name=userID,proto3" json:"userID,omitempty"`                 //用户ID
+	Client         string `protobuf:"bytes,2,opt,name=client,proto3" json:"client,omitempty"`                 //用户端
+	AdvertisingID  string `protobuf:"bytes,3,opt,name=advertisingID,proto3" json:"advertisingID,omitempty"`   //广告ID
+	AdvertisingUrl string `protobuf:"bytes,4,opt,name=advertisingUrl,proto3" json:"advertisingUrl,omitempty"` //广告位置
+}
+
+func (x *AdvertisingReq) Reset() {
+	*x = AdvertisingReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_activity_proto_msgTypes[9]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *AdvertisingReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AdvertisingReq) ProtoMessage() {}
+
+func (x *AdvertisingReq) ProtoReflect() protoreflect.Message {
+	mi := &file_activity_proto_msgTypes[9]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use AdvertisingReq.ProtoReflect.Descriptor instead.
+func (*AdvertisingReq) Descriptor() ([]byte, []int) {
+	return file_activity_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *AdvertisingReq) GetUserID() string {
+	if x != nil {
+		return x.UserID
+	}
+	return ""
+}
+
+func (x *AdvertisingReq) GetClient() string {
+	if x != nil {
+		return x.Client
+	}
+	return ""
+}
+
+func (x *AdvertisingReq) GetAdvertisingID() string {
+	if x != nil {
+		return x.AdvertisingID
+	}
+	return ""
+}
+
+func (x *AdvertisingReq) GetAdvertisingUrl() string {
+	if x != nil {
+		return x.AdvertisingUrl
+	}
+	return ""
+}
+
 var File_activity_proto protoreflect.FileDescriptor
 
 var file_activity_proto_rawDesc = []byte{
@@ -1002,33 +1074,50 @@ var file_activity_proto_rawDesc = []byte{
 	0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
 	0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
 	0x32, 0x15, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x6f, 0x74, 0x74,
-	0x65, 0x72, 0x79, 0x4a, 0x73, 0x6f, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x8e, 0x03,
-	0x0a, 0x08, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x0f, 0x61, 0x63,
-	0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x12, 0x11, 0x2e,
-	0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
-	0x1a, 0x1d, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x63, 0x74, 0x69,
-	0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12,
-	0x40, 0x0a, 0x0e, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76,
-	0x65, 0x12, 0x1a, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x6f, 0x74,
-	0x74, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x12, 0x2e,
+	0x65, 0x72, 0x79, 0x4a, 0x73, 0x6f, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x8e, 0x01,
+	0x0a, 0x0e, 0x41, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71,
+	0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6c, 0x69, 0x65,
+	0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
+	0x12, 0x24, 0x0a, 0x0d, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67, 0x49,
+	0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69,
+	0x73, 0x69, 0x6e, 0x67, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74,
+	0x69, 0x73, 0x69, 0x6e, 0x67, 0x55, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e,
+	0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67, 0x55, 0x72, 0x6c, 0x32, 0x95,
+	0x04, 0x0a, 0x08, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x0f, 0x61,
+	0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x12, 0x11,
+	0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+	0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x61, 0x63, 0x74,
+	0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x40, 0x0a, 0x0e, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69,
+	0x76, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x6f,
+	0x74, 0x74, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x12,
+	0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+	0x73, 0x65, 0x12, 0x42, 0x0a, 0x12, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61,
+	0x74, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x18, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
+	0x65, 0x71, 0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65,
+	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69,
+	0x74, 0x79, 0x55, 0x73, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
+	0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
+	0x6e, 0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73,
+	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x74,
+	0x74, 0x65, 0x72, 0x79, 0x12, 0x11, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e,
+	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69,
+	0x74, 0x79, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65,
+	0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x0b, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72,
+	0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x11, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
+	0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x40, 0x0a, 0x10, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67, 0x43, 0x6c,
+	0x69, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x41,
+	0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e,
 	0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
-	0x65, 0x12, 0x42, 0x0a, 0x12, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74,
-	0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x18, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69,
-	0x74, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65,
-	0x71, 0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73,
-	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
-	0x79, 0x55, 0x73, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e,
-	0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
-	0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x70,
-	0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x74, 0x74,
-	0x65, 0x72, 0x79, 0x12, 0x11, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52,
-	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
-	0x79, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72,
-	0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x0b, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79,
-	0x49, 0x6e, 0x66, 0x6f, 0x12, 0x11, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e,
-	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69,
-	0x74, 0x79, 0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x62, 0x06,
-	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x65, 0x12, 0x43, 0x0a, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67,
+	0x45, 0x78, 0x70, 0x6f, 0x73, 0x75, 0x72, 0x65, 0x12, 0x18, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x2e, 0x41, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x69, 0x6e, 0x67, 0x52,
+	0x65, 0x71, 0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65,
+	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -1043,7 +1132,7 @@ func file_activity_proto_rawDescGZIP() []byte {
 	return file_activity_proto_rawDescData
 }
 
-var file_activity_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
+var file_activity_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
 var file_activity_proto_goTypes = []interface{}{
 	(*Request)(nil),             // 0: activity.Request
 	(*LotteryOperation)(nil),    // 1: activity.LotteryOperation
@@ -1054,6 +1143,7 @@ var file_activity_proto_goTypes = []interface{}{
 	(*ActivityJson)(nil),        // 6: activity.ActivityJson
 	(*ProductJson)(nil),         // 7: activity.ProductJson
 	(*LotteryResp)(nil),         // 8: activity.LotteryResp
+	(*AdvertisingReq)(nil),      // 9: activity.AdvertisingReq
 }
 var file_activity_proto_depIdxs = []int32{
 	5,  // 0: activity.activityLotteryResp.data:type_name -> activity.LotteryJson
@@ -1066,14 +1156,18 @@ var file_activity_proto_depIdxs = []int32{
 	1,  // 7: activity.Activity.activityUse:input_type -> activity.LotteryOperation
 	0,  // 8: activity.Activity.userLottery:input_type -> activity.Request
 	0,  // 9: activity.Activity.lotteryInfo:input_type -> activity.Request
-	4,  // 10: activity.Activity.activityLottery:output_type -> activity.activityLotteryResp
-	3,  // 11: activity.Activity.lotteryReceive:output_type -> activity.Response
-	3,  // 12: activity.Activity.lotteryStateChange:output_type -> activity.Response
-	3,  // 13: activity.Activity.activityUse:output_type -> activity.Response
-	4,  // 14: activity.Activity.userLottery:output_type -> activity.activityLotteryResp
-	8,  // 15: activity.Activity.lotteryInfo:output_type -> activity.LotteryResp
-	10, // [10:16] is the sub-list for method output_type
-	4,  // [4:10] is the sub-list for method input_type
+	9,  // 10: activity.Activity.advertisingClick:input_type -> activity.AdvertisingReq
+	9,  // 11: activity.Activity.advertisingExposure:input_type -> activity.AdvertisingReq
+	4,  // 12: activity.Activity.activityLottery:output_type -> activity.activityLotteryResp
+	3,  // 13: activity.Activity.lotteryReceive:output_type -> activity.Response
+	3,  // 14: activity.Activity.lotteryStateChange:output_type -> activity.Response
+	3,  // 15: activity.Activity.activityUse:output_type -> activity.Response
+	4,  // 16: activity.Activity.userLottery:output_type -> activity.activityLotteryResp
+	8,  // 17: activity.Activity.lotteryInfo:output_type -> activity.LotteryResp
+	3,  // 18: activity.Activity.advertisingClick:output_type -> activity.Response
+	3,  // 19: activity.Activity.advertisingExposure:output_type -> activity.Response
+	12, // [12:20] is the sub-list for method output_type
+	4,  // [4:12] is the sub-list for method input_type
 	4,  // [4:4] is the sub-list for extension type_name
 	4,  // [4:4] is the sub-list for extension extendee
 	0,  // [0:4] is the sub-list for field type_name
@@ -1193,6 +1287,18 @@ func file_activity_proto_init() {
 				return nil
 			}
 		}
+		file_activity_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*AdvertisingReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -1200,7 +1306,7 @@ func file_activity_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_activity_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   9,
+			NumMessages:   10,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
@@ -1238,6 +1344,10 @@ type ActivityClient interface {
 	UserLottery(ctx context.Context, in *Request, opts ...grpc.CallOption) (*ActivityLotteryResp, error)
 	//奖券信息
 	LotteryInfo(ctx context.Context, in *Request, opts ...grpc.CallOption) (*LotteryResp, error)
+	//广告联盟-点击
+	AdvertisingClick(ctx context.Context, in *AdvertisingReq, opts ...grpc.CallOption) (*Response, error)
+	//广告联盟-曝光
+	AdvertisingExposure(ctx context.Context, in *AdvertisingReq, opts ...grpc.CallOption) (*Response, error)
 }
 
 type activityClient struct {
@@ -1302,6 +1412,24 @@ func (c *activityClient) LotteryInfo(ctx context.Context, in *Request, opts ...g
 	return out, nil
 }
 
+func (c *activityClient) AdvertisingClick(ctx context.Context, in *AdvertisingReq, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/activity.Activity/advertisingClick", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *activityClient) AdvertisingExposure(ctx context.Context, in *AdvertisingReq, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/activity.Activity/advertisingExposure", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ActivityServer is the server API for Activity service.
 type ActivityServer interface {
 	//查询活动下的奖券
@@ -1316,6 +1444,10 @@ type ActivityServer interface {
 	UserLottery(context.Context, *Request) (*ActivityLotteryResp, error)
 	//奖券信息
 	LotteryInfo(context.Context, *Request) (*LotteryResp, error)
+	//广告联盟-点击
+	AdvertisingClick(context.Context, *AdvertisingReq) (*Response, error)
+	//广告联盟-曝光
+	AdvertisingExposure(context.Context, *AdvertisingReq) (*Response, error)
 }
 
 // UnimplementedActivityServer can be embedded to have forward compatible implementations.
@@ -1340,6 +1472,12 @@ func (*UnimplementedActivityServer) UserLottery(context.Context, *Request) (*Act
 func (*UnimplementedActivityServer) LotteryInfo(context.Context, *Request) (*LotteryResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method LotteryInfo not implemented")
 }
+func (*UnimplementedActivityServer) AdvertisingClick(context.Context, *AdvertisingReq) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method AdvertisingClick not implemented")
+}
+func (*UnimplementedActivityServer) AdvertisingExposure(context.Context, *AdvertisingReq) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method AdvertisingExposure not implemented")
+}
 
 func RegisterActivityServer(s *grpc.Server, srv ActivityServer) {
 	s.RegisterService(&_Activity_serviceDesc, srv)
@@ -1453,6 +1591,42 @@ func _Activity_LotteryInfo_Handler(srv interface{}, ctx context.Context, dec fun
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Activity_AdvertisingClick_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(AdvertisingReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ActivityServer).AdvertisingClick(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/activity.Activity/AdvertisingClick",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ActivityServer).AdvertisingClick(ctx, req.(*AdvertisingReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Activity_AdvertisingExposure_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(AdvertisingReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ActivityServer).AdvertisingExposure(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/activity.Activity/AdvertisingExposure",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ActivityServer).AdvertisingExposure(ctx, req.(*AdvertisingReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _Activity_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "activity.Activity",
 	HandlerType: (*ActivityServer)(nil),
@@ -1481,6 +1655,14 @@ var _Activity_serviceDesc = grpc.ServiceDesc{
 			MethodName: "lotteryInfo",
 			Handler:    _Activity_LotteryInfo_Handler,
 		},
+		{
+			MethodName: "advertisingClick",
+			Handler:    _Activity_AdvertisingClick_Handler,
+		},
+		{
+			MethodName: "advertisingExposure",
+			Handler:    _Activity_AdvertisingExposure_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "activity.proto",

+ 18 - 1
rpc/activityclient/activity.go

@@ -15,14 +15,15 @@ import (
 
 type (
 	Request             = activity.Request
+	LotteryOperation    = activity.LotteryOperation
 	UpdateStateReq      = activity.UpdateStateReq
 	LotteryJson         = activity.LotteryJson
 	LotteryResp         = activity.LotteryResp
-	LotteryOperation    = activity.LotteryOperation
 	Response            = activity.Response
 	ActivityLotteryResp = activity.ActivityLotteryResp
 	ActivityJson        = activity.ActivityJson
 	ProductJson         = activity.ProductJson
+	AdvertisingReq      = activity.AdvertisingReq
 
 	Activity interface {
 		// 查询活动下的奖券
@@ -37,6 +38,10 @@ type (
 		UserLottery(ctx context.Context, in *Request) (*ActivityLotteryResp, error)
 		// 奖券信息
 		LotteryInfo(ctx context.Context, in *Request) (*LotteryResp, error)
+		// 广告联盟-点击
+		AdvertisingClick(ctx context.Context, in *AdvertisingReq) (*Response, error)
+		// 广告联盟-曝光
+		AdvertisingExposure(ctx context.Context, in *AdvertisingReq) (*Response, error)
 	}
 
 	defaultActivity struct {
@@ -85,3 +90,15 @@ func (m *defaultActivity) LotteryInfo(ctx context.Context, in *Request) (*Lotter
 	client := activity.NewActivityClient(m.cli.Conn())
 	return client.LotteryInfo(ctx, in)
 }
+
+// 广告联盟-点击
+func (m *defaultActivity) AdvertisingClick(ctx context.Context, in *AdvertisingReq) (*Response, error) {
+	client := activity.NewActivityClient(m.cli.Conn())
+	return client.AdvertisingClick(ctx, in)
+}
+
+// 广告联盟-曝光
+func (m *defaultActivity) AdvertisingExposure(ctx context.Context, in *AdvertisingReq) (*Response, error) {
+	client := activity.NewActivityClient(m.cli.Conn())
+	return client.AdvertisingExposure(ctx, in)
+}

+ 38 - 0
rpc/internal/logic/advertisingclicklogic.go

@@ -0,0 +1,38 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/service"
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type AdvertisingClickLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewAdvertisingClickLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdvertisingClickLogic {
+	return &AdvertisingClickLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+var (
+	advertisingService = &service.AdvertisingService{}
+)
+
+// 广告联盟-点击
+func (l *AdvertisingClickLogic) AdvertisingClick(in *activity.AdvertisingReq) (*activity.Response, error) {
+	// todo: add your logic here and delete this line
+	result := &activity.Response{}
+	code,msg := advertisingService.AdvertisingClick(in)
+	result.Code = code
+	result.Message = msg
+	return result, nil
+}

+ 39 - 0
rpc/internal/logic/advertisingexposurelogic.go

@@ -0,0 +1,39 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/service"
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+var (
+	adService = &service.AdvertisingService{}
+)
+
+type AdvertisingExposureLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewAdvertisingExposureLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdvertisingExposureLogic {
+	return &AdvertisingExposureLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 广告联盟-曝光
+func (l *AdvertisingExposureLogic) AdvertisingExposure(in *activity.AdvertisingReq) (*activity.Response, error) {
+	// todo: add your logic here and delete this line
+	result := &activity.Response{}
+	code, msg := adService.InsertAdExposure(in)
+	result.Code =code
+	result.Message = msg
+	return result, nil
+}

+ 12 - 0
rpc/internal/server/activityserver.go

@@ -56,3 +56,15 @@ func (s *ActivityServer) LotteryInfo(ctx context.Context, in *activity.Request)
 	l := logic.NewLotteryInfoLogic(ctx, s.svcCtx)
 	return l.LotteryInfo(in)
 }
+
+// 广告联盟-点击
+func (s *ActivityServer) AdvertisingClick(ctx context.Context, in *activity.AdvertisingReq) (*activity.Response, error) {
+	l := logic.NewAdvertisingClickLogic(ctx, s.svcCtx)
+	return l.AdvertisingClick(in)
+}
+
+// 广告联盟-曝光
+func (s *ActivityServer) AdvertisingExposure(ctx context.Context, in *activity.AdvertisingReq) (*activity.Response, error) {
+	l := logic.NewAdvertisingExposureLogic(ctx, s.svcCtx)
+	return l.AdvertisingExposure(in)
+}

+ 23 - 0
rpc/test/test1_test.go

@@ -80,3 +80,26 @@ func Test_timme(t *testing.T)  {
 	tn:= time.Now().Format("2006-01-02 15:04:05")
 	fmt.Println(tn)
 }
+func Test_advertising_click(t *testing.T) {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem := activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	for i := 0; i < 10; i++ {
+		req := &activity.AdvertisingReq{
+			UserID:         fmt.Sprint(i),
+			Client:         "123",
+			AdvertisingID:  "123",
+			AdvertisingUrl: "123",
+		}
+		res, err := FileSystem.AdvertisingClick(ctx, req)
+		log.Println("err ", err)
+		log.Println("req ", res)
+	}
+}
+func  Test_InsertAdExposure(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 50*time.Second)
+	FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	req := &activity.AdvertisingReq{UserID: "34333", AdvertisingID: "10000",AdvertisingUrl:"222",Client:"wx"}
+	res, err := FileSystem.AdvertisingExposure(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}

+ 60 - 0
service/advertisingService.go

@@ -0,0 +1,60 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/entity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	_ "github.com/garyburd/redigo/redis"
+	"log"
+	"sync"
+	"time"
+
+)
+type AdvertisingService struct{}
+func (s AdvertisingService) AdvertisingClick(in *activity.AdvertisingReq) (int64, string) {
+	orm := entity.Engine
+	var wg = new(sync.WaitGroup)
+	wg.Add(1)
+	go func() {
+		defer wg.Done()
+		data := &entity.Exposure{}
+		data.UserID = in.UserID
+		data.Client = in.Client
+		data.AdvertisingID = in.AdvertisingID
+		data.AdvertisingUrl = in.AdvertisingUrl
+		data.CreateTime = time.Now()
+		af,err := orm.Table("advertising_click").Insert(data)
+		if af > 0 && err == nil {
+			log.Println("点击广告记录成功...")
+		}
+	}()
+	wg.Wait()
+	return entity.SuccessCode,"Success"
+}
+
+// 插入广告曝光记录
+func (service *AdvertisingService) InsertAdExposure(data *activity.AdvertisingReq) (int64, string) {
+	orm := entity.Engine.NewSession()
+	adExpose := &entity.Exposure{
+		UserID:         data.UserID,
+		Client:         data.Client,
+		AdvertisingID:  data.AdvertisingID,
+		AdvertisingUrl: data.AdvertisingUrl,
+		CreateTime:     time.Now(),
+	}
+	defer orm.Close()
+	err := orm.Begin()
+	if err != nil {
+		return entity.ErrorCode,"数据库连接失败"
+	}
+	numb, err := orm.Table("advertising_exposure").Insert(adExpose)
+	if err != nil || numb == int64(0) {
+		log.Println("广告曝光记录插入失败:", err)
+		orm.Rollback()
+		return entity.ErrorCode, "广告曝光记录插入失败"
+	}
+	orm.Commit()
+	log.Println("广告曝光记录插入成功...")
+
+	return entity.SuccessCode, ""
+}
+