Пример #1
0
        /// <summary>
        /// 编辑报名数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string EditActivityData(HttpContext context)
        {
            string activityId = context.Request["ActivityID"];
            int    uId        = Convert.ToInt32(context.Request["UID"]);

            BLLJIMP.Model.ActivityDataInfo model    = bllActivity.Get <BLLJIMP.Model.ActivityDataInfo>(string.Format(" ActivityID = '{0}' AND UID = {1} ", activityId, uId));
            BLLJIMP.Model.ActivityDataInfo reqModel = bllActivity.ConvertRequestToModel <BLLJIMP.Model.ActivityDataInfo>(new BLLJIMP.Model.ActivityDataInfo());
            WebsiteInfo websiteModel = bllWebsite.GetWebsiteInfo(bllWebsite.WebsiteOwner);

            reqModel.InsertDate    = model.InsertDate;
            reqModel.IsDelete      = model.IsDelete;
            reqModel.WeixinOpenID  = model.WeixinOpenID;
            reqModel.SpreadUserID  = model.SpreadUserID;
            reqModel.WebsiteOwner  = model.WebsiteOwner;
            reqModel.MonitorPlanID = model.MonitorPlanID;

            reqModel.PaymentStatus = model.PaymentStatus;
            reqModel.OrderId       = model.OrderId;
            reqModel.IsSignIn      = model.IsSignIn;
            reqModel.UserId        = model.UserId;
            reqModel.ActivityID    = model.ActivityID;
            reqModel.Amount        = model.Amount;
            reqModel.ArticleType   = model.ArticleType;
            reqModel.CategoryId    = model.CategoryId;
            reqModel.CouponName    = model.CouponName;
            reqModel.Distance      = model.Distance;
            reqModel.DistributionOffLineRecommendCode = model.DistributionOffLineRecommendCode;
            reqModel.DistributionOffLineRecommendName = model.DistributionOffLineRecommendName;
            reqModel.FromUserId            = model.FromUserId;
            reqModel.GuaranteeCreditAcount = model.GuaranteeCreditAcount;
            reqModel.InsertDateStr         = model.InsertDateStr;
            reqModel.IsFee         = model.IsFee;
            reqModel.ItemAmount    = model.ItemAmount;
            reqModel.ItemName      = model.ItemName;
            reqModel.SpreadUserID  = model.SpreadUserID;
            reqModel.Status        = model.Status;
            reqModel.ToUserId      = model.ToUserId;
            reqModel.UID           = model.UID;
            reqModel.UseAmount     = model.UseAmount;
            reqModel.UserLatitude  = model.UserLatitude;
            reqModel.UserLongitude = model.UserLongitude;
            reqModel.UseScore      = model.UseScore;

            if (
                websiteModel.IsSynchronizationData == 1
                &&
                websiteModel.IsSynchronizationData != null
                &&
                !string.IsNullOrWhiteSpace(model.UserId)
                )
            {
                UserInfo userModel = bllUser.GetUserInfo(model.UserId);
                if (userModel != null)
                {
                    userModel.Phone    = model.Phone;
                    userModel.TrueName = model.Name;
                    bllWebsite.Update(userModel);
                }
            }

            if (bllActivity.Update(reqModel))
            {
                resp.Status = 1;
            }
            else
            {
                resp.Msg = "编辑失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
Пример #2
0
        /// <summary>
        /// 接收活动转赠
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string ReceiveActivity(HttpContext context)
        {
            if (currentUserInfo==null)
            {
                resp.Msg = "请在微信中打开";
                return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }
            string activityId = context.Request["ActivityId"];//活动ID
            string fromUserAutoId = context.Request["FromUserAutoId"];//赠送用户ID
            JuActivityInfo juActivityInfo = bllJuactivity.GetJuActivityByActivityID(activityId);

            //检查
            if (juActivityInfo == null)
            {
                resp.Msg = "转赠活动不存在";
                return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }

            UserInfo fromUserInfo = bllUser.GetUserInfoByAutoID(int.Parse(fromUserAutoId));
            if (fromUserInfo == null)
            {
                resp.Msg = "转赠用户不存在";
                return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }
            WXSignInInfo signInfo = bllActivity.Get<WXSignInInfo>(string.Format(" JuActivityID='{0}' And SignInUserID='{1}'", juActivityInfo.JuActivityID, fromUserInfo.UserID));
            if (signInfo!=null)
            {
                resp.Msg = "不能接受此转赠";
                return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }
            ActivityDataInfo dataInfo = bllActivity.Get<ActivityDataInfo>(string.Format(" ActivityID='{0}' And UserId='{1}' And IsDelete=0 And OrderId!=''  And PaymentStatus=1", activityId, fromUserInfo.UserID));

            if (dataInfo == null)
            {
                resp.Msg = " 不能接受此转赠";
                return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }
            if (fromUserInfo.UserID==currentUserInfo.UserID)
            {
                resp.Msg = "不能接收自己的转赠";
                return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }
            if (!string.IsNullOrEmpty(dataInfo.ToUserId))
            {
                if (dataInfo.ToUserId == currentUserInfo.UserID)
                {
                    resp.Msg = " 您已经接收过转赠";
                    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
                }
                else
                {
                    resp.Msg = " 此活动已经转赠过了";
                    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
                }
            }
            ActivityDataInfo dataCurrentInfo = bllActivity.Get<ActivityDataInfo>(string.Format(" ActivityID='{0}' And UserId='{1}' And IsDelete=0", activityId,currentUserInfo.UserID));
            if (dataCurrentInfo!=null)
            {
                    resp.Msg = " 您已经报名过此活动,不能再接受转赠";
                    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            }

            WXMallOrderInfo fromUserOrderInfo = bllMall.GetOrderInfo(dataInfo.OrderId);
            ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
            try
            {
                //订单
                WXMallOrderInfo orderInfo = new WXMallOrderInfo();//订单表
                orderInfo.Consignee = bllUser.GetUserDispalyName(currentUserInfo);
                orderInfo.InsertDate = DateTime.Now;
                orderInfo.OrderUserID = currentUserInfo.UserID;
                orderInfo.Phone = currentUserInfo.Phone;
                orderInfo.WebsiteOwner = bllMall.WebsiteOwner;
                orderInfo.OrderID = bllMall.GetGUID(BLLJIMP.TransacType.AddMallOrder);
                orderInfo.MyCouponCardId = fromUserOrderInfo.MyCouponCardId;
                orderInfo.UseScore = fromUserOrderInfo.UseScore;
                orderInfo.Status = "待发货";
                orderInfo.ArticleCategoryType = "Mall";
                orderInfo.OrderType = 4;
                orderInfo.Ex1 = juActivityInfo.ActivityName;
                orderInfo.Ex2 = orderInfo.Ex2;
                orderInfo.Ex3 = orderInfo.Ex3;
                orderInfo.OrderMemo = orderInfo.OrderMemo;
                orderInfo.TotalAmount = fromUserOrderInfo.TotalAmount;
                orderInfo.PaymentStatus = 1;
                orderInfo.PayTime = DateTime.Now;

                //订单
                if (!bllMall.Add(orderInfo,tran))
                {
                    tran.Rollback();
                    resp.Msg = " 插入订单表失败";
                    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
                }
                ActivityDataInfo newData = new ActivityDataInfo();
                newData.ActivityID = dataInfo.ActivityID;
                newData.UserId = currentUserInfo.UserID;
                newData.WebsiteOwner = bllUser.WebsiteOwner;
                newData.OrderId =orderInfo.OrderID;
                newData.PaymentStatus = 1;
                newData.Name = bllUser.GetUserDispalyName(currentUserInfo);
                newData.Phone = currentUserInfo.Phone;
                newData.FromUserId = fromUserInfo.UserID;
                newData.InsertDate = DateTime.Now;
                newData.UID = bllJuactivity.Get<ActivityDataInfo>(string.Format(" ActivityID='{0}'  Order By UID DESC",activityId)).UID + 1;
                if (!bllJuactivity.Add(newData, tran))
                {
                    tran.Rollback();
                    resp.Msg = " 插入报名表失败";
                    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
                }
                dataInfo.ToUserId = currentUserInfo.UserID;
                if (!bllJuactivity.Update(dataInfo,tran))
                {
                    tran.Rollback();
                    resp.Msg = " 转赠失败";
                    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
                }


                string showName = "活动";
                var config = bllActivity.Get<BLLJIMP.Model.ActivityConfig>(string.Format(" WebsiteOwner='{0}'", bllActivity.WebsiteOwner));
                if (config!=null)
                {
                    if (!string.IsNullOrEmpty(config.ShowName))
                    {
                        showName = config.ShowName;
                    }
                }

                bllWeixin.SendTemplateMessageNotifyComm(fromUserInfo, string.Format("{0}转赠通知",showName), string.Format(" {0}已接收你转赠的{1}{2}", bllUser.GetUserDispalyName(currentUserInfo),showName,juActivityInfo.ActivityName));

                bllWeixin.SendTemplateMessageNotifyComm(currentUserInfo, string.Format("{0}接收通知",showName), string.Format(" 您已接收了{0}转赠的{1}{2}", bllUser.GetUserDispalyName(fromUserInfo), showName,juActivityInfo.ActivityName));
               

                tran.Commit();
                resp.Status = 1;
                resp.Msg = "ok";
            }
            catch (Exception ex)
            {
                resp.Msg = ex.Message;
                tran.Rollback();

            }
            return ZentCloud.Common.JSONHelper.ObjectToJson(resp);

        }