Ejemplo n.º 1
0
        /// <summary>
        /// 获取用户的积分返利比例
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="websiteOwner"></param>
        /// <returns></returns>
        public decimal GetUserRebateScoreRate(string userId, string websiteOwner)
        {
            BLLDistribution bllDist    = new BLLDistribution();
            decimal         rebateRate = 0;


            if (userId == null)
            {
                var defLevel = Get <UserLevelConfig>(string.Format(" [LevelType] = 'DistributionOnLine' AND [WebSiteOwner] = '{0}' AND [LevelNumber] = 0 ",
                                                                   websiteOwner
                                                                   ));

                if (defLevel != null)
                {
                    if (decimal.TryParse(defLevel.RebateScoreRate, out rebateRate))
                    {
                        rebateRate *= 0.01M;
                    }
                }

                return(rebateRate);
            }


            var userInfo  = bllUser.GetUserInfo(userId, websiteOwner);
            var userLevel = bllDist.GetUserLevel(userInfo);

            //获取积分返利比例
            //先取会员级别、没有会员级别则取全局配置的规则
            if (userLevel != null && userLevel.AutoId != null)
            {
                if (decimal.TryParse(userLevel.RebateScoreRate, out rebateRate))
                {
                    rebateRate *= 0.01M;
                }
            }
            else
            {
                ScoreConfig scoreConfig = GetScoreConfig();
                if (scoreConfig != null)
                {
                    if (scoreConfig.OrderScore == null)
                    {
                        rebateRate = 0;
                    }
                    else if (scoreConfig.OrderAmount > 0)
                    {
                        rebateRate = (decimal)scoreConfig.OrderScore / scoreConfig.OrderAmount;
                    }
                }
            }

            return(rebateRate);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 关注自动送券
        /// </summary>
        public void SubscribeGive(UserInfo userInfo)
        {
            try
            {
                BLLDistribution      bllDis         = new BLLDistribution();
                BLLWeixin            bllWeixin      = new BLLWeixin();
                BLLWebsiteDomainInfo bllDomain      = new BLLWebsiteDomainInfo();
                List <CardCoupons>   cardCouponList = GetList <CardCoupons>(string.Format("WebsiteOwner='{0}' And IsSubscribeGive='1'", userInfo.WebsiteOwner));
                foreach (var cardCoupon in cardCouponList)
                {
                    if (GetCount <MyCardCoupons>(string.Format("CardId='{0}' And UserId='{1}'", cardCoupon.CardId, userInfo.UserID)) > 0)
                    {
                        continue;//已经发过了
                    }
                    if (!string.IsNullOrEmpty(cardCoupon.BindChannelUserId))
                    {
                        if (bllDis.GetUserChannel(userInfo) != cardCoupon.BindChannelUserId)
                        {
                            continue;
                        }
                    }
                    if (cardCoupon.MaxCount > 0)
                    {
                        int sendCount = GetCount <MyCardCoupons>(string.Format(" CardID={0}", cardCoupon.CardId));
                        if (sendCount >= cardCoupon.MaxCount)
                        {
                            continue;
                        }
                    }


                    //给用户发满送券
                    MyCardCoupons model = new MyCardCoupons();
                    model.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), GetGUID(BLLJIMP.TransacType.CommAdd));
                    model.CardCouponType   = cardCoupon.CardCouponType;
                    model.CardId           = cardCoupon.CardId;
                    model.InsertDate       = DateTime.Now;
                    model.UserId           = userInfo.UserID;
                    model.WebSiteOwner     = userInfo.WebsiteOwner;
                    if (Add(model))
                    {
                        string title     = "您收到一张优惠券";
                        string content   = string.Format("{0}", cardCoupon.Name);
                        string redicturl = string.Format("http://{0}/customize/shop/?v=1.0&ngroute=/mycoupons#/mycoupons", bllDomain.GetWebsiteDoMain(userInfo.WebsiteOwner));
                        bllWeixin.SendTemplateMessageNotifyComm(userInfo, title, content, redicturl);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 计算每一个sku获得的积分
        /// </summary>
        /// <param name="skuId"></param>
        /// <param name="rebateRate"></param>
        /// <param name="payRate">
        /// 实付比例,
        /// 在需要均摊计算的时候用到
        /// </param>
        /// <param name="count">数量</param>
        /// <param name="isGetInt">
        /// 是否取整
        /// 如果多件商品计算获得积分,在最终总分里面做取整处理
        /// </param>
        /// <returns></returns>
        public decimal CalcProductSkuRebateScore(int skuId, decimal rebateRate, decimal?payRate = null, int count = 1, bool isGetInt = false)
        {
            BLLMall         bllMall  = new BLLMall();
            BLLDistribution bllDist  = new BLLDistribution();
            decimal         addScore = 0;

            var skuInfo = bllMall.GetProductSku(skuId);

            //判断如果是特卖中的商品则不给返积分
            if (bllMall.IsPromotionTime(skuInfo))
            {
                return(0);
            }

            var price = bllMall.GetSkuPrice(skuInfo);

            if (skuInfo.BasePrice <= 0)
            {
                var productInfo = bllMall.GetProduct(skuInfo.ProductId);
                skuInfo.BasePrice = productInfo.BasePrice;
            }

            price = price - skuInfo.BasePrice;

            if (payRate != null)
            {
                price = price * payRate.Value;
            }

            if (price < 0)
            {
                price = 0;
            }

            //全额获得的积分=售价*参与返积分的比例*积分返利比例  -- 已废除
            //按价格比例获得的积分=均摊价*参与返积分的比例*积分返利比例 -- 已废除
            //addScore = (int)(rebateRate * (productInfo.RebateScoreRate * 0.01M) * skuPrice * count);

            //获得的积分=实际售价(如果非全额则需要计算均摊差价:售价-基础价)* 返积分比例 * 数量
            addScore = rebateRate * price * count;

            if (isGetInt)
            {
                addScore = RebateScoreGetInt(addScore);
            }

            return(addScore);
        }
Ejemplo n.º 4
0
 public ActionResult DistributionData(int page, int rows)
 {
     if (Request.IsAjaxRequest())
     {
         int total = 0;
         var list  = BLLDistribution.GetMyDistributionList(page, rows, BLLUser.GetUserId(), out total);
         apiResp.status = true;
         apiResp.result = new {
             list  = list,
             total = total
         };
         apiResp.msg = "查询完成";
         return(Json(apiResp));
     }
     return(View());
 }
Ejemplo n.º 5
0
 public ActionResult TeamChildList(int page, int rows, int parentid)
 {
     if (Request.IsAjaxRequest())
     {
         int total = 0;
         var list  = BLLDistribution.GetCommussionByChild(page, rows, parentid, out total);
         apiResp.result = new
         {
             list  = list,
             total = total
         };
         apiResp.msg    = "查询完成";
         apiResp.status = true;
         return(Json(apiResp));
     }
     return(View());
 }
Ejemplo n.º 6
0
 public ActionResult TeamList(int page, int rows)
 {
     if (Request.IsAjaxRequest())
     {
         int     total                 = 0;
         decimal totalMoney            = 0;
         int     totalPeopleNum        = 0;
         List <ht_commission> teamlist = BLLDistribution.GetCommussionList(page, rows, BLLUser.GetUserId(), out total, out totalMoney, out totalPeopleNum);
         apiResp.result = new
         {
             list             = teamlist,
             total            = total,
             total_money      = totalMoney,
             total_people_num = totalPeopleNum
         };
         apiResp.msg    = "查询完成";
         apiResp.status = true;
         return(Json(apiResp));
     }
     return(View());
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 审核通过打款
        /// </summary>
        /// <param name="autoId">记录Id</param>
        /// <param name="userId">操作人账号</param>
        /// <param name="msg">提示信息</param>
        /// <returns></returns>
        public bool Pass(int autoId, string userId, out string msg)
        {
            msg = "";
            var record = Get(autoId);

            if (record.Status == 1)
            {
                msg = "该记录已打款";
                return(false);
            }

            switch (record.Type)
            {
                #region 分销提现
            case "DistributionWithdraw":    //分销提现
                BLLDistribution     bllDis = new BLLDistribution();
                List <WithdrawCash> list   = new List <WithdrawCash>();
                WithdrawCash        model  = Get <WithdrawCash>(string.Format("TranId='{0}'", record.TranId));
                if (model == null)
                {
                    msg = "该记录已标记为失败";
                    return(false);
                }
                list.Add(model);
                if (!bllDis.UpdateWithrawCashStatus(list, 2, out msg))
                {
                    return(false);
                }
                break;
                #endregion

                #region 商城退款
            case "MallRefund":    //退款
                BLLMall      bllMall = new BLLMall();
                WXMallRefund refund  = bllMall.Get <WXMallRefund>(string.Format("RefundId='{0}'", record.TranId));
                switch (refund.Status)
                {
                case 2:
                    msg = "未同意退款";
                    return(false);

                case 5:
                    msg = "未收到货拒绝退款";
                    return(false);

                case 7:
                    msg = "退款申请关闭";
                    return(false);

                default:
                    break;
                }
                if (!bllMall.Refund(refund.OrderDetailId, out msg))
                {
                    return(false);
                }

                break;

                #endregion
            default:
                msg = "未定义的类型";
                return(false);
            }
            record.UpdateTime  = DateTime.Now;
            record.Status      = 1;
            record.OperaUserId = userId;
            if (Update(record))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        public void ProcessRequest(HttpContext context)
        {
            BLLUser         userBll = new BLLUser();
            BLLSMS          smsBll  = new BLLSMS("");
            BLLDistribution bllDist = new BLLDistribution();

            try
            {
                var phone    = context.Request["phone"];
                var code     = context.Request["code"];
                var password = context.Request["password"];

                string openId = "";
                if (context.Session["currWXOpenId"] != null)
                {
                    openId = context.Session["currWXOpenId"].ToString();
                }

                //if (string.IsNullOrWhiteSpace(openId))
                //{
                //    apiResp.status = false;
                //    apiResp.code = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                //    apiResp.msg = "找不到微信OpenId";
                //    userBll.ContextResponse(context, apiResp);
                //    return;
                //}

                phone    = phone.Trim();
                code     = code.Trim();
                password = password.Trim();

                if (string.IsNullOrWhiteSpace(phone) || string.IsNullOrWhiteSpace(code))
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "手机以及验证码必传";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }


                if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(phone))
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "手机号码格式不正确";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }

                var vCode = smsBll.GetLastSmsVerificationCode(phone);

                if (vCode == null)
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "无效验证码";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }

                if (vCode.VerificationCode != code)
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.PrimaryKeyIncomplete;
                    apiResp.msg    = "无效验证码";
                    userBll.ContextResponse(context, apiResp);
                    return;
                }

                UserInfo phoneUser  = userBll.GetUserInfoByPhone(phone);
                UserInfo openIdUser = null;
                if (!string.IsNullOrWhiteSpace(openId))
                {
                    openIdUser = userBll.GetUserInfoByOpenId(openId);
                }

                #region phoneUser != null
                if (phoneUser != null)
                {
                    if (openIdUser == null && string.IsNullOrWhiteSpace(phoneUser.WXOpenId) && !string.IsNullOrWhiteSpace(openId))
                    {
                        StringBuilder sbSQL = new StringBuilder();
                        sbSQL.AppendFormat(" WXOpenId = '{0}' ", openId);
                        if (!string.IsNullOrWhiteSpace(password))
                        {
                            sbSQL.AppendFormat(",Password = '******' ", password);
                        }
                        //绑定openid到手机号账户上
                        if (userBll.Update(phoneUser, sbSQL.ToString(), string.Format(" AutoID = {0} ", phoneUser.AutoID)) > 0)
                        {
                            //设置登陆状态成功
                            //设置用户会话ID
                            context.Session[ZentCloud.Common.SessionKey.UserID]     = phoneUser.UserID;
                            context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                            apiResp.status = true;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                            apiResp.msg    = "绑定成功";
                            userBll.ContextResponse(context, apiResp);

                            bllDist.SetUserDistributionOwnerByTemp(phoneUser.UserID, phoneUser.WebsiteOwner);

                            return;
                        }
                        else
                        {
                            apiResp.status = false;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                            apiResp.msg    = "绑定失败";
                            userBll.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(password))
                    {
                        if (userBll.Update(phoneUser, string.Format(" Password = {0} ", password), string.Format(" AutoID = {0} ", phoneUser.AutoID)) > 0)
                        {
                            //设置登陆状态成功
                            //设置用户会话ID
                            context.Session[ZentCloud.Common.SessionKey.UserID]     = phoneUser.UserID;
                            context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                            apiResp.status = true;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                            apiResp.msg    = "登录成功";
                            userBll.ContextResponse(context, apiResp);
                            return;
                        }
                        else
                        {
                            apiResp.status = false;
                            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                            apiResp.msg    = "注册失败";
                            userBll.ContextResponse(context, apiResp);
                            return;
                        }
                    }
                    else
                    {
                        //设置登陆状态成功
                        //设置用户会话ID
                        context.Session[ZentCloud.Common.SessionKey.UserID]     = phoneUser.UserID;
                        context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                        apiResp.status = true;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                        apiResp.msg    = "登录成功";
                        userBll.ContextResponse(context, apiResp);
                        return;
                    }
                }
                #endregion

                if (openIdUser == null)
                {
                    //构造新用户
                    var currentUserInfo = new ZentCloud.BLLJIMP.Model.UserInfo();
                    currentUserInfo.UserID = string.Format("WXUser{0}", Guid.NewGuid().ToString());//Guid
                    if (!string.IsNullOrWhiteSpace(password))
                    {
                        currentUserInfo.Password = password;
                    }
                    else
                    {
                        currentUserInfo.Password = ZentCloud.Common.Rand.Str_char(6);
                    }
                    currentUserInfo.UserType     = 2;
                    currentUserInfo.WebsiteOwner = userBll.WebsiteOwner;
                    currentUserInfo.Regtime      = DateTime.Now;
                    if (!string.IsNullOrWhiteSpace(openId))
                    {
                        currentUserInfo.WXOpenId = openId;
                    }
                    currentUserInfo.RegIP           = ZentCloud.Common.MySpider.GetClientIP();
                    currentUserInfo.LastLoginIP     = ZentCloud.Common.MySpider.GetClientIP();
                    currentUserInfo.LastLoginDate   = DateTime.Now;
                    currentUserInfo.LoginTotalCount = 1;
                    currentUserInfo.Phone           = phone;

                    if (userBll.Add(currentUserInfo))
                    {
                        //设置登陆状态成功
                        //设置用户会话ID
                        context.Session[ZentCloud.Common.SessionKey.UserID]     = currentUserInfo.UserID;
                        context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                        apiResp.status = true;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                        apiResp.msg    = "注册成功";
                        userBll.ContextResponse(context, apiResp);

                        bllDist.SetUserDistributionOwnerByTemp(currentUserInfo.UserID, currentUserInfo.WebsiteOwner);

                        return;
                    }
                    else
                    {
                        apiResp.status = false;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                        apiResp.msg    = "注册失败";
                        userBll.ContextResponse(context, apiResp);
                        return;
                    }
                }
                else
                {
                    apiResp.status = false;
                    apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                    apiResp.msg    = "该微信已绑定其他账号";
                    userBll.ContextResponse(context, apiResp);
                    return;

                    StringBuilder sbSQL1 = new StringBuilder();
                    sbSQL1.AppendFormat(" Phone = '{0}' ", phone);
                    if (!string.IsNullOrWhiteSpace(password))
                    {
                        sbSQL1.AppendFormat(",Password = '******' ", password);
                    }
                    openIdUser.Phone = phone;
                    if (userBll.Update(openIdUser, sbSQL1.ToString(), string.Format(" AutoID = {0} ", openIdUser.AutoID)) > 0)
                    {
                        //设置登陆状态成功
                        //设置用户会话ID
                        context.Session[ZentCloud.Common.SessionKey.UserID]     = openIdUser.UserID;
                        context.Session[ZentCloud.Common.SessionKey.LoginStatu] = 1; //设置登录状态

                        apiResp.status = true;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
                        apiResp.msg    = "绑定成功";
                        userBll.ContextResponse(context, apiResp);

                        bllDist.SetUserDistributionOwnerByTemp(openIdUser.UserID, openIdUser.WebsiteOwner);
                        return;
                    }
                    else
                    {
                        apiResp.status = false;
                        apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                        apiResp.msg    = "绑定失败";
                        userBll.ContextResponse(context, apiResp);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                apiResp.status = false;
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg    = "绑定失败:" + ex.Message;
                userBll.ContextResponse(context, apiResp);
                return;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 支付注册
        /// </summary>
        /// <param name="orderPay"></param>
        /// <returns></returns>
        public bool PayRegister(OrderPay orderPay, string tradeNo)
        {
            BLLDistribution bllDist = new BLLDistribution();
            string          msg     = "";

            BLLJIMP.Model.API.User.PayRegisterUser requestUser = JsonConvert.DeserializeObject <BLLJIMP.Model.API.User.PayRegisterUser>(orderPay.Ex1);
            UserLevelConfig levelConfig = bll.QueryUserLevel(orderPay.WebsiteOwner, "DistributionOnLine", requestUser.level.ToString());

            if (levelConfig == null)
            {
                return(false);
            }
            UserInfo regUser = bllUser.GetUserInfoByPhone(requestUser.phone, orderPay.WebsiteOwner);

            if (regUser != null && regUser.MemberLevel >= 10)
            {
                return(false);
            }
            if (regUser != null && regUser.MemberLevel >= requestUser.level)
            {
                return(false);
            }
            if (regUser != null)
            {
                regUser.UserType          = 2;
                regUser.TrueName          = requestUser.truename;
                regUser.DistributionOwner = requestUser.spreadid;
                regUser.MemberLevel       = requestUser.level;
                regUser.MemberStartTime   = DateTime.Now;
                regUser.MemberApplyTime   = orderPay.InsertDate;
                regUser.RegIP             = requestUser.regIP;
                regUser.Password          = requestUser.password;
                regUser.MemberApplyStatus = 9;
                regUser.IdentityCard      = requestUser.idcard;
                regUser.Province          = requestUser.province;
                regUser.City         = requestUser.city;
                regUser.District     = requestUser.district;
                regUser.Town         = requestUser.town;
                regUser.ProvinceCode = requestUser.provinceCode;
                regUser.CityCode     = requestUser.cityCode;
                regUser.DistrictCode = requestUser.districtCode;
                regUser.TownCode     = requestUser.townCode;
                regUser.RegUserID    = null;
                regUser.RegisterWay  = "线上";
            }
            else
            {
                regUser                   = new UserInfo();
                regUser.UserID            = requestUser.userid;
                regUser.UserType          = 2;
                regUser.TrueName          = requestUser.truename;
                regUser.WebsiteOwner      = orderPay.WebsiteOwner;
                regUser.DistributionOwner = requestUser.spreadid;
                regUser.Phone             = requestUser.phone;
                regUser.MemberLevel       = requestUser.level;
                regUser.MemberStartTime   = DateTime.Now;
                regUser.MemberApplyTime   = orderPay.InsertDate;
                regUser.Regtime           = DateTime.Now;
                regUser.LastLoginDate     = DateTime.Parse("1970-01-01");
                regUser.RegIP             = requestUser.regIP;
                regUser.Password          = requestUser.password;
                regUser.MemberApplyStatus = 9;
                regUser.IdentityCard      = requestUser.idcard;
                regUser.Province          = requestUser.province;
                regUser.City              = requestUser.city;
                regUser.District          = requestUser.district;
                regUser.Town              = requestUser.town;
                regUser.ProvinceCode      = requestUser.provinceCode;
                regUser.CityCode          = requestUser.cityCode;
                regUser.DistrictCode      = requestUser.districtCode;
                regUser.TownCode          = requestUser.townCode;
                regUser.RegisterWay       = "线上";
            }
            orderPay.Trade_No = tradeNo;
            if (!string.IsNullOrEmpty(levelConfig.CouponId))
            {
                BLLCardCoupon bllCardCoupon = new BLLCardCoupon();
                bllCardCoupon.SendCardCouponsByCurrUserInfo(regUser, levelConfig.CouponId);
            }
            return(bll.PayRegisterTransfers(regUser, orderPay, "", tradeNo, levelConfig, out msg));
        }