Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string orderid = null;

            orderid = Request["oid"];
            if (string.IsNullOrEmpty(orderid))
            {
                Response.End();
            }

            if (bll.IsLogin)
            {
                userInfo  = bll.GetCurrentUserInfo();
                OrderInfo = bll.GetOrderInfo(orderid);
                if (OrderInfo == null)
                {
                    Response.End();
                }

                bool CanAccess = false;
                if (!OrderInfo.OrderUserID.Equals(userInfo.UserID))
                {
                    try
                    {
                        if (bll.GetWebsiteInfoModel().IsDistributionMall.Equals(1))
                        {
                            //检查是否是上下级关系
                            BLLJIMP.BLLDistribution bllDis  = new BLLJIMP.BLLDistribution();
                            BLLJIMP.BLLUser         bllUser = new BLLJIMP.BLLUser("");
                            if (bllDis.GetUserBetweenLevel(userInfo, bllUser.GetUserInfo(OrderInfo.OrderUserID)) > 0)
                            {
                                CanAccess = true;
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    CanAccess = true;
                }
                if (!CanAccess)
                {
                    Response.End();
                }
            }
            else
            {
                Response.Redirect("/App/Cation/Wap/Login.aspx?redirecturl=/App/Cation/Wap/Mall/Index.aspx");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取主卡券
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetMainCardCoupon(HttpContext context)
        {
            string cardCouponId   = context.Request["cardcoupon_id"];    //主卡券ID
            string myCardCouponId = context.Request["my_cardcoupon_id"]; //我的卡券ID

            if (string.IsNullOrEmpty(cardCouponId))
            {
                resp.errcode = 1;
                resp.errmsg  = "cardcoupon_id 参数必传";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(int.Parse(cardCouponId));

            if (cardCoupon == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "cardcoupon_id 不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon);
            if (!string.IsNullOrEmpty(cardCoupon.BindChannelUserId))
            {
                if (string.IsNullOrEmpty(currentUserInfo.DistributionOwner))
                {
                    resp.errcode = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyChannel;
                    resp.errmsg  = "只有指定渠道才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
                BLLJIMP.BLLDistribution bllDis = new BLLJIMP.BLLDistribution();
                string channelUserId           = bllDis.GetUserChannel(currentUserInfo);
                if (cardCoupon.BindChannelUserId != channelUserId)
                {
                    resp.errcode = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyChannel;
                    resp.errmsg  = "只有指定渠道才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
            }

            MainCardModel model = new MainCardModel();

            model.cardcoupon_id       = cardCoupon.CardId;
            model.cardcoupon_name     = cardCoupon.Name;
            model.cardcoupon_type     = ConvertCardCouponType(cardCoupon.CardCouponType);
            model.valid_from          = cardCoupon.ValidFrom.ToString();
            model.valid_to            = cardCoupon.ValidTo.ToString();
            model.img_url             = bllMall.GetImgUrl(cardCoupon.Logo);
            model.discount            = string.IsNullOrEmpty(cardCoupon.Ex1) ? 0 : double.Parse(cardCoupon.Ex1);
            model.product_id          = string.IsNullOrEmpty(cardCoupon.Ex2) ? 0 : double.Parse(cardCoupon.Ex2);
            model.deductible_amount   = string.IsNullOrEmpty(cardCoupon.Ex3) ? 0 : double.Parse(cardCoupon.Ex3);
            model.freefreight_amount  = string.IsNullOrEmpty(cardCoupon.Ex4) ? 0 : double.Parse(cardCoupon.Ex4);
            model.buckle_amount       = string.IsNullOrEmpty(cardCoupon.Ex5) ? 0 : double.Parse(cardCoupon.Ex5);
            model.buckle_sub_amount   = string.IsNullOrEmpty(cardCoupon.Ex6) ? 0 : double.Parse(cardCoupon.Ex6);
            model.max_count           = cardCoupon.MaxCount;
            model.send_count          = cardCoupon.SendCount;
            model.un_send_count       = cardCoupon.UnSendCount;
            model.is_recivece         = bllCardCoupon.IsReciveCoupon(cardCoupon.CardId, currentUserInfo.UserID);
            model.valid_to_timestamp  = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
            model.limit_type          = cardCoupon.Ex7;
            model.product_tags        = cardCoupon.Ex8;
            model.user_get_limit_type = cardCoupon.GetLimitType;
            model.is_can_use_shop     = cardCoupon.IsCanUseShop;
            model.is_can_use_groupbuy = cardCoupon.IsCanUseGroupbuy;
            model.expire_time_type    = cardCoupon.ExpireTimeType;
            model.expire_day          = cardCoupon.ExpireDay;
            model.weixin_card_id      = cardCoupon.WeixinCardId == null?"":cardCoupon.WeixinCardId;
            if (!string.IsNullOrEmpty(myCardCouponId))
            {
                MyCardCoupons myCardCoupon = bllCardCoupon.GetMyCardCoupon(int.Parse(myCardCouponId));
                if (myCardCoupon != null)
                {
                    UserInfo fromUserInfo = bllUser.GetUserInfo(myCardCoupon.UserId);
                    if (fromUserInfo != null)
                    {
                        model.from_user_info = new UserInfoModel();
                        model.from_user_info.head_img_url = bllUser.GetUserDispalyAvatar(fromUserInfo);
                        model.from_user_info.nick_name    = bllUser.GetUserDispalyName(fromUserInfo);
                    }
                    if (!string.IsNullOrEmpty(myCardCoupon.ToUserId))
                    {
                        model.is_donation = true;
                    }
                    model.cardcoupon_number = myCardCoupon.CardCouponNumber;
                }
            }

            return(ZentCloud.Common.JSONHelper.ObjectToJson(model));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 卡券转赠
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Give(HttpContext context)
        {
            string cardcouponId = context.Request["cardcoupon_id"];//我的卡券ID

            if (string.IsNullOrEmpty(cardcouponId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "cardcoupon_id 参数必传";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }
            MyCardCoupons fromMyCardCoupon = bllCardCoupon.GetMyCardCoupon(int.Parse(cardcouponId));//要赠送的卡券信息
            CardCoupons   cardCoupon       = bllCardCoupon.GetCardCoupon(fromMyCardCoupon.CardId);

            if (fromMyCardCoupon == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "卡券不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }
            if (fromMyCardCoupon.UserId == currentUserInfo.UserID)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.NoFollow;
                apiResp.msg  = "不能接收自己的卡券";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }
            if (!string.IsNullOrEmpty(fromMyCardCoupon.FromUserId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.NoFollow;
                apiResp.msg  = "优惠券不能多次转赠";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }
            if (cardCoupon.GetLimitType != null)
            {
                if (cardCoupon.GetLimitType == "1" && !bllUser.IsDistributionMember(currentUserInfo, true))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyDistMember;
                    apiResp.msg  = "只有分销员才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                if (cardCoupon.GetLimitType == "2" && bllUser.IsDistributionMember(currentUserInfo))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyNotDistMember;
                    apiResp.msg  = "该券仅新用户(无购买历史)可以领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
            }
            if (!string.IsNullOrEmpty(cardCoupon.BindChannelUserId))
            {
                if (string.IsNullOrEmpty(currentUserInfo.DistributionOwner))
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyChannel;
                    apiResp.msg  = "只有指定渠道才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                BLLJIMP.BLLDistribution bllDis = new BLLJIMP.BLLDistribution();
                string channelUserId           = bllDis.GetUserChannel(currentUserInfo);
                if (cardCoupon.BindChannelUserId != channelUserId)
                {
                    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyChannel;
                    apiResp.msg  = "只有指定渠道才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
            }
            string msg = "";

            if (!bllCardCoupon.IsCanGiveCoupon(fromMyCardCoupon, out msg))//无法转赠给他人
            {
                apiResp.msg = msg;
                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }

            ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
            try
            {
                MyCardCoupons model = new MyCardCoupons();
                model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), bllMall.GetGUID(BLLJIMP.TransacType.CommAdd));
                model.CardCouponType   = fromMyCardCoupon.CardCouponType;
                model.CardId           = fromMyCardCoupon.CardId;
                model.InsertDate       = DateTime.Now;
                model.UserId           = currentUserInfo.UserID;
                model.WebSiteOwner     = currentUserInfo.WebsiteOwner;
                model.FromUserId       = fromMyCardCoupon.UserId;
                if (!bllCardCoupon.Add(model))
                {
                    tran.Rollback();
                    apiResp.msg = "接收失败";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }

                fromMyCardCoupon.Status   = 2;
                fromMyCardCoupon.ToUserId = currentUserInfo.UserID;
                if (!bllCardCoupon.Update(fromMyCardCoupon))
                {
                    tran.Rollback();
                    apiResp.msg = "接收失败";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }

                // CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(fromMyCardCoupon.CardId);
                //if (cardCoupon == null)
                //{
                //    tran.Rollback();
                //    apiResp.msg = "卡券不存在";
                //    return ZentCloud.Common.JSONHelper.ObjectToJson(apiResp);
                //}
                UserInfo fromUserInfo = bllUser.GetUserInfo(fromMyCardCoupon.UserId);
                if (fromUserInfo == null)
                {
                    tran.Rollback();
                    apiResp.msg = "赠送用户不存在";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                }
                bllWeixin.SendTemplateMessageNotifyComm(fromUserInfo, "优惠券转赠通知", string.Format(" {0}已领取你转赠的优惠券{1}", bllUser.GetUserDispalyName(currentUserInfo), cardCoupon.Name));
                bllWeixin.SendTemplateMessageNotifyComm(currentUserInfo, "优惠券领取通知", string.Format(" 您已经领取来自{0}转赠的优惠券{1}", bllUser.GetUserDispalyName(fromUserInfo), cardCoupon.Name));
                tran.Commit();

                #region 分销关系建立
                BLLPermission.BLLMenuPermission bllMenuPermission = new BLLPermission.BLLMenuPermission("");
                if (bllMenuPermission.CheckUserAndPmsKey(currentUserInfo.WebsiteOwner, BLLPermission.Enums.PermissionSysKey.OnlineDistribution))
                {
                    if (string.IsNullOrWhiteSpace(currentUserInfo.DistributionOwner))
                    {
                        WebsiteInfo websiteInfo = bllMall.GetWebsiteInfoModelFromDataBase();
                        if (websiteInfo.DistributionRelationBuildMallOrder == 1)
                        {
                            if (bllUser.IsDistributionMember(fromUserInfo) || (fromUserInfo.UserID == websiteInfo.WebsiteOwner))//上级符合分销员标准
                            {
                                BLLJIMP.BLLDistribution bllDis = new BLLJIMP.BLLDistribution();

                                var setUserDistributionOwnerResult = bllDis.SetUserDistributionOwner(currentUserInfo.UserID, fromUserInfo.UserID, currentUserInfo.WebsiteOwner);
                            }
                        }
                    }
                }
                #endregion


                apiResp.status = true;
                apiResp.msg    = "ok";
            }
            catch (Exception ex)
            {
                apiResp.msg = ex.Message;
                return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 领取卡券
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string ReciveCardCoupon(HttpContext context)
        {
            string      cardCouponId = context.Request["cardcoupon_id"];
            CardCoupons cardCoupon   = bllCardCoupon.GetCardCoupon(int.Parse(cardCouponId));

            if (cardCoupon == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "cardcoupon_id 不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon);
            var myCardCoupon = bllCardCoupon.GetMyCardCouponMainId(int.Parse(cardCouponId), currentUserInfo.UserID);

            if (myCardCoupon != null)
            {
                resp.errcode = 1;
                resp.errmsg  = "已经领取过了";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (DateTime.Now > (DateTime)(cardCoupon.ValidTo))
            {
                resp.errcode = 2;
                resp.errmsg  = "卡券已过期";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (cardCoupon.MaxCount > 0)
            {
                if (bllCardCoupon.GetCardCouponSendCount(cardCoupon.CardId) >= cardCoupon.MaxCount)
                {
                    resp.errcode = 2;
                    resp.errmsg  = "卡券已经领完";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
            }

            if (cardCoupon.GetLimitType != null)
            {
                if (cardCoupon.GetLimitType == "1" && !bllUser.IsDistributionMember(currentUserInfo, true))
                {
                    resp.errcode = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyDistMember;
                    resp.errmsg  = "只有分销员才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
                if (cardCoupon.GetLimitType == "2" && bllUser.IsDistributionMember(currentUserInfo))
                {
                    resp.errcode = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyNotDistMember;
                    resp.errmsg  = "该券仅新用户(无购买历史)可以领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
            }
            if (!string.IsNullOrEmpty(cardCoupon.BindChannelUserId))
            {
                if (string.IsNullOrEmpty(currentUserInfo.DistributionOwner))
                {
                    resp.errcode = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyChannel;
                    resp.errmsg  = "只有指定渠道才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
                BLLJIMP.BLLDistribution bllDis = new BLLJIMP.BLLDistribution();
                string channelUserId           = bllDis.GetUserChannel(currentUserInfo);

                if (cardCoupon.BindChannelUserId != channelUserId)
                {
                    resp.errcode = (int)BLLJIMP.Enums.APIErrCode.MallGetCardOnlyChannel;
                    resp.errmsg  = "只有指定渠道才能领取";
                    return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                }
            }



            MyCardCoupons model = new MyCardCoupons();

            model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), bllMall.GetGUID(BLLJIMP.TransacType.CommAdd));
            model.CardCouponType   = cardCoupon.CardCouponType;
            model.CardId           = cardCoupon.CardId;
            model.InsertDate       = DateTime.Now;
            model.UserId           = currentUserInfo.UserID;
            model.WebSiteOwner     = bllCardCoupon.WebsiteOwner;
            if (bllCardCoupon.Add(model))
            {
                resp.errmsg = "ok";
                string title   = "您收到了一张优惠券";
                string content = string.Format("{0}", cardCoupon.Name);

                if (cardCoupon.ValidTo.HasValue)
                {
                    content += string.Format("\\n{0}", ((DateTime)cardCoupon.ValidTo).ToString("yyyy-MM-dd"));
                }

                string url = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", context.Request.Url.Host);

                if (bllUser.WebsiteOwner == "jikuwifi")
                {
                    url = string.Format("http://{0}/customize/jikuwifi/?v=1.0&ngroute=/mycoupons#/mycoupons", context.Request.Url.Host);
                }

                bllWeixin.SendTemplateMessageNotifyComm(currentUserInfo, title, content, url);

                //#region 同时发放到微信卡包
                //if (!string.IsNullOrEmpty(cardCoupon.WeixinCardId) && (!string.IsNullOrEmpty(CurrentUserInfo.WXOpenId)))
                //{
                //    bllWeixinCard.SendByMass(cardCoupon.WeixinCardId, CurrentUserInfo.WXOpenId);

                //}
                //#endregion
            }
            else
            {
                resp.errcode = 1;
                resp.errmsg  = "领取优惠券失败";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }