Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                ToLog("已经进入——ApplyActivity");

                var userInfo = bll.GetCurrentUserInfo();
                ToLog("userInfo:" + JsonConvert.SerializeObject(userInfo));

                string activityId = bll.GetDistributionOffLineApplyActivityID();
                ToLog("activityId:" + activityId);

                ActivityDataInfo model = bllActivity.GetActivityDataInfo(activityId, bll.GetCurrUserID());

                bool isEnroll = model != null;               //是否报过名

                int                       apply_status  = 0; //0未申请  1待审核 2已通过 4001已拒绝 4002 微转发通过
                string                    remarks       = string.Empty;
                List <SignField>          signfieldList = new List <SignField>();
                List <ActivityDataRecord> applyRecord   = new List <ActivityDataRecord>();
                var                       fieldList     = bllActivity.GetActivityFieldMappingList(activityId).Where(p => p.IsHideInSubmitPage != "1");
                //检查当前是否已经是分销员
                if (!string.IsNullOrWhiteSpace(userInfo.DistributionOffLinePreUserId))
                {
                    apply_status = 2;
                }
                else
                {
                    if (isEnroll)
                    {
                        //判断是待审核还是审核不通过
                        if (model.Status == 4001)
                        {
                            apply_status = 4001;
                            remarks      = model.Remarks;
                        }
                        //else if (model.Status==0&&(!string.IsNullOrEmpty(model.SpreadUserID)))//微转发待审核
                        //{
                        //    apply_status = 4002;
                        //    remarks = string.Format("您已报名过 {0}分享的活动 {1},系统正在审核中,审核通过可以直接成为平台会员",model.K59,model.K60);
                        //}
                        //else if (model.Status == 4003)//微转发审核通过
                        //{
                        //    apply_status = 4003;
                        //    remarks = string.Format("您已报名过 {0}分享的活动 {1},可以直接成为平台会员", model.K59, model.K60);
                        //}
                        else
                        {
                            apply_status = 1;
                        }

                        Type type = model.GetType();
                        //数据记录
                        foreach (var item in fieldList)
                        {
                            ActivityDataRecord record = new ActivityDataRecord();
                            record.field = item.FieldName;
                            record.value = type.GetProperty(item.FieldName).GetValue(model, null).ToString();
                            applyRecord.Add(record);
                        }

                        //分销推荐id加上
                        applyRecord.Add(new ActivityDataRecord()
                        {
                            field = "DistributionOffLineRecommendCode",
                            value = model.DistributionOffLineRecommendCode,
                        });
                    }
                    else
                    {
                        apply_status = 0;
                    }
                    //如果未报过名,把活动字段信息返回

                    foreach (var item in fieldList)
                    {
                        SignField signModel = new SignField();
                        signModel.key    = item.MappingName;
                        signModel.value  = item.FieldName;
                        signModel.isnull = item.FieldIsNull;
                        signfieldList.Add(signModel);
                    }


                    //分销推荐id加上
                    signfieldList.Add(new SignField()
                    {
                        key    = "推荐码",
                        value  = "DistributionOffLineRecommendCode",
                        isnull = 0
                    });
                }

                apiResp.result = new
                {
                    activity_id  = activityId,
                    is_enroll    = isEnroll,
                    signfield    = signfieldList,
                    apply_record = applyRecord,
                    apply_status = apply_status,
                    remarks      = remarks
                };
                apiResp.status = true;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }
            catch (Exception ex)
            {
                ToLog("活动状态异常:" + ex.Message);
                throw ex;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 手动添加报名数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Add(HttpContext context)
        {
            string autoIds      = context.Request["Ids"];
            string activityId   = context.Request["ActivityID"];
            int    successCount = 0;

            foreach (var autoId in autoIds.Split(','))
            {
                UserInfo userInfo = bllUser.GetUserInfoByAutoID(int.Parse(autoId));
                if (bllActivity.GetCount <ActivityDataInfo>(string.Format(" ActivityID={0} And IsDelete=0 And UserId='{1}'", activityId, userInfo.UserID)) > 0)
                {
                    resp.Msg = string.Format("{0}已经报过名了,不需要重复报名", userInfo.TrueName);
                    return(Common.JSONHelper.ObjectToJson(resp));
                }

                ActivityDataInfo model   = new ActivityDataInfo();
                var newActivityUId       = 1001;
                var lastActivityDataInfo = bllActivity.Get <ActivityDataInfo>(string.Format("ActivityID='{0}' order by UID DESC", activityId));
                if (lastActivityDataInfo != null)
                {
                    newActivityUId = lastActivityDataInfo.UID + 1;
                }
                model.ActivityID   = activityId;
                model.UID          = newActivityUId;
                model.InsertDate   = DateTime.Now;
                model.WebsiteOwner = bllActivity.WebsiteOwner;
                model.SpreadUserID = "system";
                #region 自动补充信息
                model.WeixinOpenID = userInfo.WXOpenId;
                model.UserId       = userInfo.UserID;
                if (!string.IsNullOrEmpty(userInfo.TrueName))
                {
                    model.Name = userInfo.TrueName;
                }
                else
                {
                    model.Name = "系统添加";
                }
                if (!string.IsNullOrEmpty(userInfo.Phone))
                {
                    model.Phone = userInfo.Phone;
                }
                if (string.IsNullOrEmpty(model.Phone))
                {
                    resp.Msg = string.Format("手机号不能为空");
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
                var  fieldMappingList = bllActivity.GetActivityFieldMappingList(activityId);
                Type type             = model.GetType();
                if (!string.IsNullOrEmpty(userInfo.Company))
                {
                    if (fieldMappingList.Where(p => p.MappingName.Contains("公司")).Count() > 0)
                    {
                        PropertyInfo propertyInfo = type.GetProperty("K" + fieldMappingList.Where(p => p.MappingName.Contains("公司")).First().ExFieldIndex.ToString());

                        propertyInfo.SetValue(model, userInfo.Company, null);
                    }
                }
                if (!string.IsNullOrEmpty(userInfo.Postion))
                {
                    if (fieldMappingList.Where(p => p.MappingName.Contains("职位")).Count() > 0)
                    {
                        PropertyInfo propertyInfo = type.GetProperty("K" + fieldMappingList.Where(p => p.MappingName.Contains("职位")).First().ExFieldIndex.ToString());

                        propertyInfo.SetValue(model, userInfo.Postion, null);
                    }
                }
                if (!string.IsNullOrEmpty(userInfo.Email))
                {
                    if (fieldMappingList.Where(p => p.MappingName.Contains("邮箱")).Count() > 0)
                    {
                        PropertyInfo propertyInfo = type.GetProperty("K" + fieldMappingList.Where(p => p.MappingName.Contains("邮箱")).First().ExFieldIndex.ToString());

                        propertyInfo.SetValue(model, userInfo.Email, null);
                    }
                }



                #endregion


                if (bllActivity.Add(model))
                {
                    successCount++;
                    resp.Status = 1;
                }
                else
                {
                    resp.Msg = "添加失败";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
            }
            resp.ExInt = successCount;
            return(Common.JSONHelper.ObjectToJson(resp));
        }