Beispiel #1
0
        /// <summary>
        /// 修改推广活动
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        public bool UpdateActivity(AddSpreadActivity activity)
        {
            //var req = Mapper.Map<AddSpreadActivity, UpdateSpreadActivityRequest>(activity);
            var req = new UpdateSpreadActivityRequest();

            req.ActivityId        = activity.ActivityId;
            req.ActivityName      = activity.ActivityName;
            req.ActivityPic       = activity.ActivityPic;
            req.StartTime         = activity.StartTime ?? DateTime.Now;
            req.EndTime           = activity.EndTime ?? DateTime.Now;
            req.LimitNumber       = activity.LimitNumber;
            req.Status            = (short)activity.Status;
            req.NecessaryInfoJson = activity.NecessaryInfoJson;
            req.ShareInfoJson     = activity.ShareInfoJson;
            req.EnableOldUser     = activity.EnableOldUser;

            req.IsDelete           = activity.IsDelete;
            req.BackGroundPhotoUrl = activity.BackGroundPhotoUrl;
            req.Remark             = activity.Remark;
            req.RoleDetail         = activity.RoleDetail;

            var res = MKMSClient.Send <UpdateSpreadActivityResponse>(req);

            return(res.DoFlag);
        }
Beispiel #2
0
        /// <summary>
        /// 创建活动
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ActivityDetail(int?id)
        {
            var result = new AddSpreadActivity();

            //查询活动详情
            if (id > 0)
            {
                result = SpreadInfoClient.Instance.QuerySpreadActivityById(id.Value);

                ViewBag.SpreadActivity = result;
            }
            return(View(result));
        }
Beispiel #3
0
        /// <summary>
        /// 查询活动详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AddSpreadActivity QuerySpreadActivityById(int id)
        {
            var result = new AddSpreadActivity();
            var req    = new QuerySpreadActivityByIdRequest();

            req.ActivityId = id;

            var res = MKMSClient.Send <QuerySpreadActivityByIdResponse>(req);

            if (res.DoFlag)
            {
                result = Mapper.Map <Spread_ActivityExt, AddSpreadActivity>(res.ActivityDos);
                result.ActivityPrize = Mapper.MappGereric <Spread_Activity_PrizeExt, SpreadActivityPrize>(res.ActivityPrize);
            }
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 创建活动
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        public JsonResult SaveActivity(AddSpreadActivity activity)
        {
            var result = new BaseResponse();

            try
            {
                if (activity.ActivityId > 0)
                {
                    //修改
                    var res = SpreadInfoClient.Instance.UpdateActivity(activity);
                    if (res)
                    {
                        result.DoFlag   = true;
                        result.DoResult = "修改活动成功... ...";
                    }
                    else
                    {
                        result.DoResult = "修改活动失败... ...";
                    }
                }
                else
                {
                    activity.CreateByUserId = UserInfo.UserSysNo;
                    activity.CreatedTime    = DateTime.Now;
                    activity.IsDelete       = false;

                    var res = SpreadInfoClient.Instance.AddSpreadActivity(activity);
                    if (res)
                    {
                        result.DoFlag   = true;
                        result.DoResult = "创建活动成功... ...";
                    }
                    else
                    {
                        result.DoResult = "创建活动失败... ...";
                    }
                }
            }
            catch (Exception ex)
            {
                result.DoResult = "保存活动异常,请稍后重试... ...";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        /// <summary>
        /// 创建推广活动
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        public bool AddSpreadActivity(AddSpreadActivity activity)
        {
            var req = Mapper.Map <AddSpreadActivity, AddSpreadActivityRequest>(activity);

            req.PrizeList = new List <ActivityPrize>();

            int codeLeg   = 0;
            int couponleg = 0;

            if (!string.IsNullOrEmpty(activity.PrizeId))
            {
                codeLeg = activity.PrizeId.Length;
            }
            if (!string.IsNullOrEmpty(activity.CouponId))
            {
                couponleg = activity.CouponId.Length;
            }


            var pPrizIdList   = new string[codeLeg];
            var pcouponIdList = new string[couponleg];

            if (!string.IsNullOrEmpty(activity.PrizeId))
            {
                pPrizIdList = activity.PrizeId.Split(new string[] { " ", ",", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            }

            if (!string.IsNullOrEmpty(activity.CouponId))
            {
                pcouponIdList = activity.CouponId.Split(new string[] { " ", ",", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            }

            if (pPrizIdList != null && pPrizIdList.Length > 0)
            {
                foreach (var pid in pPrizIdList)
                {
                    req.PrizeList.Add(new ActivityPrize()
                    {
                        PrizeIdentity = pid,
                        PrizeType     = PrizeType.Code
                    });
                }
            }

            if (pcouponIdList != null && pcouponIdList.Length > 0)
            {
                foreach (var prize in pcouponIdList)
                {
                    string couponId = prize;
                    req.PrizeList.Add(new ActivityPrize()
                    {
                        PrizeIdentity = couponId,

                        PrizeType = PrizeType.Coupon
                    });
                }
            }

            var res = MKMSClient.Send <AddSpreadActivityResponse>(req);

            return(res.DoFlag);
        }