Esempio n. 1
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="operatorId">操作人id</param>
        /// <param name="cancelTime">取消时间</param>
        public static void CancelOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int operatorId, DateTime cancelTime)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Cancelled);//将订单状态设为取消状态

            if (orderInfo.CouponMoney > 0)//退回用户使用的优惠劵
                Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);

            if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, cancelTime);

            if (orderInfo.PaySN.Length > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                OrderRefunds.ApplyRefund(new OrderRefundInfo
                {
                    Oid = orderInfo.Oid,
                    OSN = orderInfo.OSN,
                    Uid = orderInfo.Uid,
                    State = 0,
                    ApplyTime = cancelTime,
                    PayMoney = orderInfo.SurplusMoney,
                    RefundMoney = orderInfo.SurplusMoney,
                    PaySN = orderInfo.PaySN,
                    PaySystemName = orderInfo.PaySystemName,
                    PayFriendName = orderInfo.PayFriendName
                });

            Products.IncreaseProductStockNumber(GetOrderProductList(orderInfo.Oid));//增加商品库存数量
        }
Esempio n. 2
0
 /// <summary>
 /// 获得配送费用
 /// </summary>
 /// <param name="totalWeight">商品总重量</param>
 /// <param name="productAmount">商品合计</param>
 /// <param name="orderProductList">订单商品列表</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="provinceId">省id</param>
 /// <param name="cityId">市id</param>
 /// <param name="countyId">县或区id</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public decimal GetShipFee(int totalWeight, decimal productAmount, List<OrderProductInfo> orderProductList, DateTime buyTime, int provinceId, int cityId, int countyId, PartUserInfo partUserInfo)
 {
     foreach (ShipRuleInfo shipRuleInfo in PluginUtils.GetShipRuleList())
     {
         if (shipRuleInfo.RegionId == 0 || shipRuleInfo.RegionId == provinceId || shipRuleInfo.RegionId == cityId || shipRuleInfo.RegionId == countyId)
         {
             if (productAmount >= shipRuleInfo.FreeMoney)
                 return 0M;
             if (shipRuleInfo.Type == 0)
             {
                 if (totalWeight <= 1000)
                 {
                     return shipRuleInfo.ExtCode1;
                 }
                 else
                 {
                     if (((totalWeight - shipRuleInfo.ExtCode1 * 1000) % (shipRuleInfo.ExtCode2 * 1000)) == 0)
                         return shipRuleInfo.ExtCode1 + shipRuleInfo.ExtCode2 * ((totalWeight - shipRuleInfo.ExtCode1 * 1000) / (shipRuleInfo.ExtCode2 * 1000));
                     else
                         return shipRuleInfo.ExtCode1 + shipRuleInfo.ExtCode2 * (((totalWeight - shipRuleInfo.ExtCode1 * 1000) / (shipRuleInfo.ExtCode2 * 1000)) + 1);
                 }
             }
             else if (shipRuleInfo.Type == 1)
             {
                 decimal shipFee = 0M;
                 foreach (OrderProductInfo orderProductInfo in orderProductList)
                     shipFee += shipRuleInfo.ExtCode1 * orderProductInfo.RealCount;
                 return shipFee;
             }
         }
     }
     return 0M;
 }
Esempio n. 3
0
 /// <summary>
 /// 获得支付手续费
 /// </summary>
 /// <param name="productAmount">商品合计</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 public decimal GetPayFee(decimal productAmount, DateTime buyTime, PartUserInfo partUserInfo)
 {
     PluginSetInfo pluginSetInfo = PluginUtils.GetPluginSet();
     if (productAmount >= pluginSetInfo.FreeMoney)
         return 0M;
     else
         return pluginSetInfo.PayFee;
 }
Esempio n. 4
0
 /// <summary>
 /// 获得货到付款支付手续费
 /// </summary>
 /// <param name="productAmount">商品合计</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="provinceId">省id</param>
 /// <param name="cityId">市id</param>
 /// <param name="countyId">县或区id</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 public decimal GetCODPayFee(decimal productAmount, DateTime buyTime, int provinceId, int cityId, int countyId, PartUserInfo partUserInfo)
 {
     foreach (ShipRuleInfo shipRuleInfo in PluginUtils.GetShipRuleList())
     {
         if (shipRuleInfo.RegionId == 0 || shipRuleInfo.RegionId == provinceId || shipRuleInfo.RegionId == cityId || shipRuleInfo.RegionId == countyId)
             return shipRuleInfo.CODPayFee;
     }
     return 0M;
 }
Esempio n. 5
0
        /// <summary>
        /// 管理员发放积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="payCredits">支付积分</param>
        /// <param name="rankCredits">等级积分</param>
        /// <param name="sendUid">发放用户id</param>
        /// <param name="sendTime">发放时间</param>
        public static void AdminSendCredits(PartUserInfo partUserInfo, int payCredits, int rankCredits, int sendUid, DateTime sendTime)
        {
            int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits + rankCredits).UserRid;
            if (userRid == partUserInfo.UserRid)
                userRid = 0;

            CreditLogInfo creditLogInfo = new CreditLogInfo();

            creditLogInfo.Uid = partUserInfo.Uid;
            creditLogInfo.PayCredits = payCredits;
            creditLogInfo.RankCredits = rankCredits;
            creditLogInfo.Action = (int)CreditAction.AdminSend;
            creditLogInfo.ActionTime = sendTime;
            creditLogInfo.ActionCode = 0;
            creditLogInfo.ActionDes = "管理员发放";
            creditLogInfo.Operator = sendUid;

            SendCredits(userRid, creditLogInfo);
        }
Esempio n. 6
0
        /// <summary>
        /// 从IDataReader创建PartUserInfo
        /// </summary>
        public static PartUserInfo BuildPartUserFromReader(IDataReader reader)
        {
            PartUserInfo partUserInfo = new PartUserInfo();

            partUserInfo.Uid = TypeHelper.ObjectToInt(reader["uid"]);
            partUserInfo.UserName = reader["username"].ToString();
            partUserInfo.Email = reader["email"].ToString();
            partUserInfo.Mobile = reader["mobile"].ToString();
            partUserInfo.Password = reader["password"].ToString();
            partUserInfo.UserRid = TypeHelper.ObjectToInt(reader["userrid"]);
            partUserInfo.AdminGid = TypeHelper.ObjectToInt(reader["admingid"]);
            partUserInfo.NickName = reader["nickname"].ToString();
            partUserInfo.Avatar = reader["avatar"].ToString();
            partUserInfo.PayCredits = TypeHelper.ObjectToInt(reader["paycredits"]);
            partUserInfo.RankCredits = TypeHelper.ObjectToInt(reader["rankcredits"]);
            partUserInfo.VerifyEmail = TypeHelper.ObjectToInt(reader["verifyemail"]);
            partUserInfo.VerifyMobile = TypeHelper.ObjectToInt(reader["verifymobile"]);
            partUserInfo.LiftBanTime = TypeHelper.ObjectToDateTime(reader["liftbantime"]);
            partUserInfo.Salt = reader["salt"].ToString();

            return partUserInfo;
        }
Esempio n. 7
0
        /// <summary>
        /// 支付订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="credits">积分数量</param>
        /// <param name="payTime">支付时间</param>
        public static void PayOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int credits, DateTime payTime)
        {
            if (credits > 0)
            {
                partUserInfo.PayCredits -= credits;

                CreditLogInfo creditLogInfo = new CreditLogInfo();
                creditLogInfo.Uid = partUserInfo.Uid;
                creditLogInfo.PayCredits = -1 * credits;
                creditLogInfo.RankCredits = 0;
                creditLogInfo.Action = (int)CreditAction.PayOrder;
                creditLogInfo.ActionCode = orderInfo.Oid;
                creditLogInfo.ActionTime = payTime;
                creditLogInfo.ActionDes = "支付订单:" + orderInfo.OSN;
                creditLogInfo.Operator = partUserInfo.Uid;

                SendCredits(0, creditLogInfo);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 退回用户订单发放的积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="payCredits">支付积分</param>
        /// <param name="rankCredits">等级积分</param>
        /// <param name="operatorId">操作人</param>
        /// <param name="returnTime">退回时间</param>
        public static void ReturnUserOrderSendCredits(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int payCredits, int rankCredits, int operatorId, DateTime returnTime)
        {
            partUserInfo.PayCredits -= payCredits;
            partUserInfo.RankCredits -= rankCredits;

            int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
            if (userRid != partUserInfo.UserRid)
                partUserInfo.UserRid = userRid;
            else
                userRid = 0;

            CreditLogInfo creditLogInfo = new CreditLogInfo();
            creditLogInfo.Uid = orderInfo.Uid;
            creditLogInfo.PayCredits = -1 * payCredits;
            creditLogInfo.RankCredits = -1 * rankCredits;
            creditLogInfo.Action = (int)CreditAction.ReturnOrderSend;
            creditLogInfo.ActionCode = orderInfo.Oid;
            creditLogInfo.ActionTime = returnTime;
            creditLogInfo.ActionDes = "收回订单发放的积分:" + orderInfo.OSN;
            creditLogInfo.Operator = operatorId;

            SendCredits(userRid, creditLogInfo);
        }
Esempio n. 9
0
        /// <summary>
        /// 完成订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="completeTime">完成时间</param>
        /// <param name="ip">ip</param>
        public static void CompleteOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, DateTime completeTime, string ip)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Completed);//将订单状态设为完成状态

            //订单商品列表
            List<OrderProductInfo> orderProductList = GetOrderProductList(orderInfo.Oid);

            //发放完成订单积分
            Credits.SendCompleteOrderCredits(ref partUserInfo, orderInfo, orderProductList, completeTime);

            //发放单品促销活动支付积分和优惠劵
            foreach (OrderProductInfo orderProductInfo in orderProductList)
            {
                if (orderProductInfo.Type == 0)
                {
                    if (orderProductInfo.PayCredits > 0)
                        Credits.SendSinglePromotionCredits(ref partUserInfo, orderInfo, orderProductInfo.PayCredits, completeTime);
                    if (orderProductInfo.CouponTypeId > 0)
                        Coupons.SendSinglePromotionCoupon(partUserInfo, orderProductInfo.CouponTypeId, orderInfo, ip);
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 退回用户订单使用的积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="operatorId">操作人</param>
        /// <param name="returnTime">退回时间</param>
        public static void ReturnUserOrderUseCredits(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int operatorId, DateTime returnTime)
        {
            partUserInfo.PayCredits += orderInfo.PayCreditCount;

            CreditLogInfo creditLogInfo = new CreditLogInfo();
            creditLogInfo.Uid = orderInfo.Uid;
            creditLogInfo.PayCredits = orderInfo.PayCreditCount;
            creditLogInfo.RankCredits = 0;
            creditLogInfo.Action = (int)CreditAction.ReturnOrderUse;
            creditLogInfo.ActionCode = orderInfo.Oid;
            creditLogInfo.ActionTime = returnTime;
            creditLogInfo.ActionDes = "退回用户订单使用的积分:" + orderInfo.OSN;
            creditLogInfo.Operator = operatorId;

            SendCredits(0, creditLogInfo);
        }
Esempio n. 11
0
        /// <summary>
        /// 退货
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="operatorId">操作人id</param>
        /// <param name="returnTime">退货时间</param>
        public static void ReturnOrder(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int operatorId, DateTime returnTime)
        {
            UpdateOrderState(orderInfo.Oid, OrderState.Returned);//将订单状态设为退货状态

            if (orderInfo.OrderState == (int)OrderState.Sended)//用户收货时退货
            {
                if (orderInfo.CouponMoney > 0)//退回用户使用的优惠劵
                    Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);

                if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                    Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, returnTime);

                if (orderInfo.PaySN.Length > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                    OrderRefunds.ApplyRefund(new OrderRefundInfo
                    {
                        Oid = orderInfo.Oid,
                        OSN = orderInfo.OSN,
                        Uid = orderInfo.Uid,
                        State = 0,
                        ApplyTime = returnTime,
                        PayMoney = orderInfo.SurplusMoney,
                        RefundMoney = orderInfo.SurplusMoney,
                        PaySN = orderInfo.PaySN,
                        PaySystemName = orderInfo.PaySystemName,
                        PayFriendName = orderInfo.PayFriendName
                    });

            }
            else if (orderInfo.OrderState == (int)OrderState.Completed)//订单完成后退货
            {
                if (orderInfo.CouponMoney > 0)//退回用户使用的优惠劵
                    Coupons.ReturnUserOrderUseCoupons(orderInfo.Oid);

                if (orderInfo.PayCreditCount > 0)//退回用户使用的积分
                    Credits.ReturnUserOrderUseCredits(ref partUserInfo, orderInfo, operatorId, returnTime);

                //应退金钱
                decimal returnMoney = orderInfo.SurplusMoney;

                //订单发放的积分
                DataTable sendCredits = Credits.GetUserOrderSendCredits(orderInfo.Oid);
                int payCreditAmount = TypeHelper.ObjectToInt(sendCredits.Rows[0]["paycreditamount"]);
                int rankCreditAmount = TypeHelper.ObjectToInt(sendCredits.Rows[0]["rankcreditamount"]);
                //判断用户当前积分是否足够退回,如果不足够就将差额核算成金钱并在应退金钱中减去
                if (partUserInfo.PayCredits < payCreditAmount)
                {
                    returnMoney = returnMoney - Credits.PayCreditsToMoney(payCreditAmount - partUserInfo.PayCredits);
                    payCreditAmount = partUserInfo.PayCredits;
                }
                //收回订单发放的积分
                Credits.ReturnUserOrderSendCredits(ref partUserInfo, orderInfo, payCreditAmount, rankCreditAmount, operatorId, returnTime);

                StringBuilder couponIdList = new StringBuilder();
                //订单发放的优惠劵列表
                List<CouponInfo> couponList = Coupons.GetUserOrderSendCouponList(orderInfo.Oid);
                //判断优惠劵是否已经被使用,如果已经使用就在应退金钱中减去优惠劵金额
                foreach (CouponInfo couponInfo in couponList)
                {
                    if (couponInfo.Oid > 0)
                        returnMoney = returnMoney - couponInfo.Money;
                    else
                        couponIdList.AppendFormat("{0},", couponInfo.CouponId);
                }
                //收回订单发放的优惠劵
                if (couponIdList.Length > 0)
                {
                    Coupons.DeleteCouponById(couponIdList.Remove(couponIdList.Length - 1, 1).ToString());
                }

                if (returnMoney > 0)//退回用户支付的金钱(此操作只是将退款记录保存到表'orderrefunds'中,实际退款还需要再次操作)
                    OrderRefunds.ApplyRefund(new OrderRefundInfo
                    {
                        Oid = orderInfo.Oid,
                        OSN = orderInfo.OSN,
                        Uid = orderInfo.Uid,
                        State = 0,
                        ApplyTime = returnTime,
                        PayMoney = orderInfo.SurplusMoney,
                        RefundMoney = returnMoney,
                        PaySN = orderInfo.PaySN,
                        PaySystemName = orderInfo.PaySystemName,
                        PayFriendName = orderInfo.PayFriendName
                    });
            }

            Products.IncreaseProductStockNumber(GetOrderProductList(orderInfo.Oid));//增加商品库存数量
        }
Esempio n. 12
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderProductList">订单商品列表</param>
        /// <param name="singlePromotionList">单品促销活动列表</param>
        /// <param name="fullShipAddressInfo">配送地址</param>
        /// <param name="payPluginInfo">支付方式</param>
        /// <param name="shipPluginInfo">配送方式</param>
        /// <param name="payCreditCount">支付积分数</param>
        /// <param name="couponList">优惠劵列表</param>
        /// <param name="fullCut">满减</param>
        /// <param name="buyerRemark">买家备注</param>
        /// <param name="bestTime">最佳配送时间</param>
        /// <param name="ip">ip地址</param>
        /// <returns>订单信息</returns>
        public static OrderInfo CreateOrder(PartUserInfo partUserInfo, List<OrderProductInfo> orderProductList, List<SinglePromotionInfo> singlePromotionList, FullShipAddressInfo fullShipAddressInfo, PluginInfo payPluginInfo, PluginInfo shipPluginInfo, int payCreditCount, List<CouponInfo> couponList, int fullCut, string buyerRemark, DateTime bestTime, string ip)
        {
            DateTime nowTime = DateTime.Now;
            IShipPlugin shipPlugin = (IShipPlugin)shipPluginInfo.Instance;
            IPayPlugin payPlugin = (IPayPlugin)payPluginInfo.Instance;

            OrderInfo orderInfo = new OrderInfo();

            orderInfo.OSN = GenerateOSN(partUserInfo.Uid, fullShipAddressInfo.RegionId, nowTime);
            orderInfo.Uid = partUserInfo.Uid;

            orderInfo.Weight = Carts.SumOrderProductWeight(orderProductList);
            orderInfo.ProductAmount = Carts.SumOrderProductAmount(orderProductList);
            orderInfo.FullCut = fullCut;

            decimal amount = orderInfo.ProductAmount - orderInfo.FullCut;
            orderInfo.ShipFee = shipPlugin.GetShipFee(orderInfo.Weight, amount, orderProductList, nowTime, fullShipAddressInfo.ProvinceId, fullShipAddressInfo.CityId, fullShipAddressInfo.RegionId, partUserInfo);
            if (payPlugin.PayMode == 0)
                orderInfo.PayFee = shipPlugin.GetCODPayFee(amount, nowTime, fullShipAddressInfo.ProvinceId, fullShipAddressInfo.CityId, fullShipAddressInfo.RegionId, partUserInfo);
            else
                orderInfo.PayFee = payPlugin.GetPayFee(amount, nowTime, partUserInfo);

            orderInfo.OrderAmount = orderInfo.ProductAmount - orderInfo.FullCut + orderInfo.ShipFee + orderInfo.PayFee;
            orderInfo.PayCreditCount = payCreditCount;
            orderInfo.PayCreditMoney = Credits.PayCreditsToMoney(payCreditCount);
            orderInfo.CouponMoney = Coupons.SumCouponMoney(couponList);
            orderInfo.SurplusMoney = orderInfo.OrderAmount - orderInfo.PayCreditMoney - orderInfo.CouponMoney;

            orderInfo.OrderState = (orderInfo.SurplusMoney <= 0 || payPlugin.PayMode == 0) ? (int)OrderState.Confirming : (int)OrderState.WaitPaying;

            orderInfo.ParentId = 0;
            orderInfo.IsReview = 0;
            orderInfo.AddTime = nowTime;
            orderInfo.ShipSystemName = shipPluginInfo.SystemName;
            orderInfo.ShipFriendName = shipPluginInfo.FriendlyName;
            orderInfo.ShipTime = new DateTime(1900, 1, 1);
            orderInfo.PaySystemName = payPluginInfo.SystemName;
            orderInfo.PayFriendName = payPluginInfo.FriendlyName;
            orderInfo.PayMode = payPlugin.PayMode;
            orderInfo.PayTime = new DateTime(1900, 1, 1);

            orderInfo.RegionId = fullShipAddressInfo.RegionId;
            orderInfo.Consignee = fullShipAddressInfo.Consignee;
            orderInfo.Mobile = fullShipAddressInfo.Mobile;
            orderInfo.Phone = fullShipAddressInfo.Phone;
            orderInfo.Email = fullShipAddressInfo.Email;
            orderInfo.ZipCode = fullShipAddressInfo.ZipCode;
            orderInfo.Address = fullShipAddressInfo.Address;
            orderInfo.BestTime = bestTime;

            orderInfo.BuyerRemark = buyerRemark;
            orderInfo.IP = ip;

            try
            {
                //添加订单
                int oid = _iorderstrategy.CreateOrder(orderInfo, Carts.IsPersistOrderProduct, orderProductList);
                if (oid > 0)
                {
                    orderInfo.Oid = oid;

                    //减少商品库存数量
                    Products.DecreaseProductStockNumber(orderProductList);
                    //更新限购库存
                    if (singlePromotionList.Count > 0)
                        Promotions.UpdateSinglePromotionStock(singlePromotionList);
                    //使用支付积分
                    Credits.PayOrder(ref partUserInfo, orderInfo, orderInfo.PayCreditCount, nowTime);
                    //使用优惠劵
                    foreach (CouponInfo couponInfo in couponList)
                    {
                        if (couponInfo.Uid > 0)
                            Coupons.UseCoupon(couponInfo.CouponId, oid, nowTime, ip);
                        else
                            Coupons.ActivateAndUseCoupon(couponInfo.CouponId, partUserInfo.Uid, oid, nowTime, ip);
                    }

                    return orderInfo;
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }

            return null;
        }
Esempio n. 13
0
        /// <summary>
        /// 发放完善用户信息积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="completeTime">完成时间</param>
        public static void SendCompleteUserInfoCredits(ref PartUserInfo partUserInfo, DateTime completeTime)
        {
            if ((_creditconfiginfo.CompleteUserInfoPayCredits > 0 || _creditconfiginfo.CompleteUserInfoRankCredits > 0) && !IsSendCompleteUserInfoCredit(partUserInfo.Uid))
            {
                int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, completeTime.Date);
                int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, completeTime.Date);
                if (surplusPayCredits == 0 && surplusRankCredits == 0)
                    return;

                int payCredits = 0;
                int rankCredits = 0;
                if (surplusPayCredits > 0)
                    payCredits = surplusPayCredits < _creditconfiginfo.CompleteUserInfoPayCredits ? surplusPayCredits : _creditconfiginfo.CompleteUserInfoPayCredits;
                else if (surplusPayCredits == -1)
                    payCredits = _creditconfiginfo.CompleteUserInfoPayCredits;
                if (surplusRankCredits > 0)
                    rankCredits = surplusRankCredits < _creditconfiginfo.CompleteUserInfoRankCredits ? surplusRankCredits : _creditconfiginfo.CompleteUserInfoRankCredits;
                else if (surplusRankCredits == -1)
                    rankCredits = _creditconfiginfo.CompleteUserInfoRankCredits;

                partUserInfo.PayCredits += payCredits;
                partUserInfo.RankCredits += rankCredits;

                int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                if (userRid != partUserInfo.UserRid)
                    partUserInfo.UserRid = userRid;
                else
                    userRid = 0;

                CreditLogInfo creditLogInfo = new CreditLogInfo();
                creditLogInfo.Uid = partUserInfo.Uid;
                creditLogInfo.PayCredits = payCredits;
                creditLogInfo.RankCredits = rankCredits;
                creditLogInfo.Action = (int)CreditAction.CompleteUserInfo;
                creditLogInfo.ActionCode = 0;
                creditLogInfo.ActionTime = completeTime;
                creditLogInfo.ActionDes = "完善用户信息";
                creditLogInfo.Operator = 0;

                SendCredits(userRid, creditLogInfo);
            }
        }
Esempio n. 14
0
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            ip = WebHelper.GetIP();
            //当用户ip不在允许的后台访问ip列表时
            if (!string.IsNullOrEmpty(shopConfigInfo.AdminAllowAccessIP) && !ValidateHelper.InIPList(ip, shopConfigInfo.AdminAllowAccessIP))
            {
                filterContext.Result = HttpNotFound();
                return;
            }
            //当用户IP被禁止时
            if (BannedIPs.CheckIP(ip))
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //获得用户id
            int uid = ShopUtils.GetUidCookie();
            if (uid < 1)
                uid = WebHelper.GetRequestInt("uid");
            if (uid < 1)//当用户为游客时
            {
                //创建游客
                partUserInfo = Users.CreatePartGuest();
            }
            else//当用户为会员时
            {
                //获得保存在cookie中的密码
                string encryptPwd = ShopUtils.GetCookiePassword();
                if (string.IsNullOrWhiteSpace(encryptPwd))
                    encryptPwd = WebHelper.GetRequestString("password");
                //防止用户密码被篡改为危险字符
                if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd))
                {
                    //创建游客
                    partUserInfo = Users.CreatePartGuest();
                    ShopUtils.SetUidCookie(-1);
                    ShopUtils.SetCookiePassword("");
                }
                else
                {
                    partUserInfo = Users.GetPartUserByUidAndPwd(uid, ShopUtils.DecryptCookiePassword(encryptPwd));
                    if (partUserInfo == null)
                    {
                        partUserInfo = Users.CreatePartGuest();
                        ShopUtils.SetUidCookie(-1);
                        ShopUtils.SetCookiePassword("");
                    }
                }
            }

            //当用户等级是禁止访问等级时
            if (partUserInfo.UserRid == 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //如果当前用户没有登录
            if (partUserInfo.Uid < 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }

            //如果当前用户不是管理员
            if (partUserInfo.AdminGid == 1)
            {
                filterContext.Result = HttpNotFound();
                return;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 发放验证手机积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="verifyTime">验证时间</param>
        public static void SendVerifyMobileCredits(ref PartUserInfo partUserInfo, DateTime verifyTime)
        {
            if (partUserInfo.VerifyMobile == 0 && (_creditconfiginfo.VerifyMobilePayCredits > 0 || _creditconfiginfo.VerifyMobileRankCredits > 0))
            {
                int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, verifyTime.Date);
                int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, verifyTime.Date);
                if (surplusPayCredits == 0 && surplusRankCredits == 0)
                    return;

                int payCredits = 0;
                int rankCredits = 0;
                if (surplusPayCredits > 0)
                    payCredits = surplusPayCredits < _creditconfiginfo.VerifyMobilePayCredits ? surplusPayCredits : _creditconfiginfo.VerifyMobilePayCredits;
                else if (surplusPayCredits == -1)
                    payCredits = _creditconfiginfo.VerifyMobilePayCredits;
                if (surplusRankCredits > 0)
                    rankCredits = surplusRankCredits < _creditconfiginfo.VerifyMobileRankCredits ? surplusRankCredits : _creditconfiginfo.VerifyMobileRankCredits;
                else if (surplusRankCredits == -1)
                    rankCredits = _creditconfiginfo.VerifyMobileRankCredits;

                partUserInfo.PayCredits += payCredits;
                partUserInfo.RankCredits += rankCredits;

                int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                if (userRid != partUserInfo.UserRid)
                    partUserInfo.UserRid = userRid;
                else
                    userRid = 0;

                CreditLogInfo creditLogInfo = new CreditLogInfo();
                creditLogInfo.Uid = partUserInfo.Uid;
                creditLogInfo.PayCredits = payCredits;
                creditLogInfo.RankCredits = rankCredits;
                creditLogInfo.Action = (int)CreditAction.VerifyMobile;
                creditLogInfo.ActionCode = 0;
                creditLogInfo.ActionTime = verifyTime;
                creditLogInfo.ActionDes = "验证用户手机";
                creditLogInfo.Operator = 0;

                SendCredits(userRid, creditLogInfo);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 发放单品促销活动积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="credits">积分</param>
        /// <param name="sendTime">发放时间</param>
        public static void SendSinglePromotionCredits(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int credits, DateTime sendTime)
        {
            int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, sendTime.Date);
            if (surplusPayCredits != 0)
            {
                int creditCount = credits;
                if (surplusPayCredits > 0 && surplusPayCredits < creditCount)
                    creditCount = surplusPayCredits;

                partUserInfo.PayCredits += creditCount;

                CreditLogInfo creditLogInfo = new CreditLogInfo();
                creditLogInfo.Uid = partUserInfo.Uid;
                creditLogInfo.PayCredits = creditCount;
                creditLogInfo.RankCredits = 0;
                creditLogInfo.Action = (int)CreditAction.SinglePromotion;
                creditLogInfo.ActionCode = orderInfo.Oid;
                creditLogInfo.ActionTime = sendTime;
                creditLogInfo.ActionDes = "单品促销活动";
                creditLogInfo.Operator = 0;

                SendCredits(0, creditLogInfo);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 发放评价商品积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderProductInfo">订单商品</param>
        /// <param name="reviewTime">评价时间</param>
        public static int SendReviewProductCredits(ref PartUserInfo partUserInfo, OrderProductInfo orderProductInfo, DateTime reviewTime)
        {
            if (_creditconfiginfo.ReviewProductPayCredits > 0 || _creditconfiginfo.ReviewProductRankCredits > 0)
            {
                int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, reviewTime.Date);
                int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, reviewTime.Date);
                if (surplusPayCredits == 0 && surplusRankCredits == 0)
                    return 0;

                int payCredits = 0;
                int rankCredits = 0;
                if (surplusPayCredits > 0)
                    payCredits = surplusPayCredits < _creditconfiginfo.ReviewProductPayCredits ? surplusPayCredits : _creditconfiginfo.ReviewProductPayCredits;
                else if (surplusPayCredits == -1)
                    payCredits = _creditconfiginfo.ReviewProductPayCredits;
                if (surplusRankCredits > 0)
                    rankCredits = surplusRankCredits < _creditconfiginfo.ReviewProductRankCredits ? surplusRankCredits : _creditconfiginfo.ReviewProductRankCredits;
                else if (surplusRankCredits == -1)
                    rankCredits = _creditconfiginfo.ReviewProductRankCredits;

                partUserInfo.PayCredits += payCredits;
                partUserInfo.RankCredits += rankCredits;

                int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                if (userRid != partUserInfo.UserRid)
                    partUserInfo.UserRid = userRid;
                else
                    userRid = 0;

                CreditLogInfo creditLogInfo = new CreditLogInfo();
                creditLogInfo.Uid = partUserInfo.Uid;
                creditLogInfo.PayCredits = payCredits;
                creditLogInfo.RankCredits = rankCredits;
                creditLogInfo.Action = (int)CreditAction.ReviewProduct;
                creditLogInfo.ActionCode = orderProductInfo.Oid;
                creditLogInfo.ActionTime = reviewTime;
                creditLogInfo.ActionDes = "评价商品:" + orderProductInfo.Name;
                creditLogInfo.Operator = 0;

                SendCredits(userRid, creditLogInfo);

                return payCredits;
            }
            return 0;
        }
Esempio n. 18
0
        /// <summary>
        /// 发放登陆积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="loginTime">登陆时间</param>
        public static void SendLoginCredits(ref PartUserInfo partUserInfo, DateTime loginTime)
        {
            if (_creditconfiginfo.LoginPayCredits > 0 || _creditconfiginfo.LoginRankCredits > 0)
            {
                DateTime slcTime = TypeHelper.StringToDateTime(WebHelper.UrlDecode(ShopUtils.GetBSPCookie("slctime")), loginTime.Date.AddDays(-2));
                if (loginTime.Date <= slcTime.Date)
                    return;

                if (!IsSendTodayLoginCredit(partUserInfo.Uid, DateTime.Now))
                {
                    ShopUtils.SetBSPCookie("slctime", WebHelper.UrlEncode(loginTime.ToString()));

                    int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, loginTime.Date);
                    int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, loginTime.Date);
                    if (surplusPayCredits == 0 && surplusRankCredits == 0)
                        return;

                    int payCredits = 0;
                    int rankCredits = 0;
                    if (surplusPayCredits > 0)
                        payCredits = surplusPayCredits < _creditconfiginfo.LoginPayCredits ? surplusPayCredits : _creditconfiginfo.LoginPayCredits;
                    else if (surplusPayCredits == -1)
                        payCredits = _creditconfiginfo.LoginPayCredits;
                    if (surplusRankCredits > 0)
                        rankCredits = surplusRankCredits < _creditconfiginfo.LoginRankCredits ? surplusRankCredits : _creditconfiginfo.LoginRankCredits;
                    else if (surplusRankCredits == -1)
                        rankCredits = _creditconfiginfo.LoginRankCredits;

                    partUserInfo.PayCredits += payCredits;
                    partUserInfo.RankCredits += rankCredits;

                    int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                    if (userRid != partUserInfo.UserRid)
                        partUserInfo.UserRid = userRid;
                    else
                        userRid = 0;

                    CreditLogInfo creditLogInfo = new CreditLogInfo();
                    creditLogInfo.Uid = partUserInfo.Uid;
                    creditLogInfo.PayCredits = payCredits;
                    creditLogInfo.RankCredits = rankCredits;
                    creditLogInfo.Action = (int)CreditAction.Login;
                    creditLogInfo.ActionCode = 0;
                    creditLogInfo.ActionTime = loginTime;
                    creditLogInfo.ActionDes = "登陆赠送积分";
                    creditLogInfo.Operator = 0;

                    SendCredits(userRid, creditLogInfo);
                }
            }
        }
Esempio n. 19
0
 /// <summary>
 /// 更新部分用户
 /// </summary>
 /// <returns></returns>
 public static void UpdatePartUser(PartUserInfo partUserInfo)
 {
     BrnShop.Data.Users.UpdatePartUser(partUserInfo);
 }
Esempio n. 20
0
        /// <summary>
        /// 更新部分用户
        /// </summary>
        /// <returns></returns>
        public void UpdatePartUser(PartUserInfo partUserInfo)
        {
            DbParameter[] parms = {
                                       GenerateInParam("@username",SqlDbType.NChar,20,partUserInfo.UserName),
                                       GenerateInParam("@email",SqlDbType.Char,50,partUserInfo.Email),
                                       GenerateInParam("@mobile",SqlDbType.Char,15,partUserInfo.Mobile),
                                       GenerateInParam("@password",SqlDbType.Char,32,partUserInfo.Password),
                                       GenerateInParam("@userrid",SqlDbType.SmallInt,2,partUserInfo.UserRid),
                                       GenerateInParam("@admingid",SqlDbType.SmallInt,2,partUserInfo.AdminGid),
                                       GenerateInParam("@nickname",SqlDbType.NChar,20,partUserInfo.NickName),
                                       GenerateInParam("@avatar",SqlDbType.Char,40,partUserInfo.Avatar),
                                       GenerateInParam("@paycredits",SqlDbType.Int,4,partUserInfo.PayCredits),
                                       GenerateInParam("@rankcredits",SqlDbType.Int,4,partUserInfo.RankCredits),
                                       GenerateInParam("@verifyemail",SqlDbType.TinyInt,1,partUserInfo.VerifyEmail),
                                       GenerateInParam("@verifymobile",SqlDbType.TinyInt,1,partUserInfo.VerifyMobile),
                                       GenerateInParam("@liftbantime",SqlDbType.DateTime,8,partUserInfo.LiftBanTime),
                                       GenerateInParam("@salt",SqlDbType.NChar,6,partUserInfo.Salt),
                                       GenerateInParam("@uid",SqlDbType.Int,4,partUserInfo.Uid)
                                   };

            RdbsHelper.ExecuteScalar(CommandType.StoredProcedure,
                                     string.Format("{0}updatepartuser", RdbsHelper.RdbsTablePre),
                                     parms);
        }
Esempio n. 21
0
 /// <summary>
 /// 更新部分用户
 /// </summary>
 /// <returns></returns>
 public static void UpdatePartUser(PartUserInfo partUserInfo)
 {
     BrnShop.Core.BSPData.RDBS.UpdatePartUser(partUserInfo);
     if (_usernosql != null)
         _usernosql.UpdatePartUser(partUserInfo);
 }
Esempio n. 22
0
        /// <summary>
        /// 发放完成订单积分
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="orderProductList">订单商品列表</param>
        /// <param name="completeTime">完成时间</param>
        public static void SendCompleteOrderCredits(ref PartUserInfo partUserInfo, OrderInfo orderInfo, List<OrderProductInfo> orderProductList, DateTime completeTime)
        {
            if (_creditconfiginfo.CompleteOrderPayCredits > 0 || _creditconfiginfo.CompleteOrderRankCredits > 0)
            {
                int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, completeTime.Date);
                int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, completeTime.Date);
                if (surplusPayCredits == 0 && surplusRankCredits == 0)
                    return;

                int payCredits = 0;
                int rankCredits = 0;
                int tempPayCredits = (int)Math.Floor(orderInfo.OrderAmount * _creditconfiginfo.CompleteOrderPayCredits / 100);
                int tempRankCredits = (int)Math.Floor(orderInfo.OrderAmount * _creditconfiginfo.CompleteOrderRankCredits / 100);
                if (surplusPayCredits > 0)
                    payCredits = surplusPayCredits < tempPayCredits ? surplusPayCredits : tempPayCredits;
                else if (surplusPayCredits == -1)
                    payCredits = tempPayCredits;
                if (surplusRankCredits > 0)
                    rankCredits = surplusRankCredits < tempRankCredits ? surplusRankCredits : tempRankCredits;
                else if (surplusRankCredits == -1)
                    rankCredits = tempRankCredits;

                partUserInfo.PayCredits += payCredits;
                partUserInfo.RankCredits += rankCredits;

                int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid;
                if (userRid != partUserInfo.UserRid)
                    partUserInfo.UserRid = userRid;
                else
                    userRid = 0;

                CreditLogInfo creditLogInfo = new CreditLogInfo();
                creditLogInfo.Uid = partUserInfo.Uid;
                creditLogInfo.PayCredits = payCredits;
                creditLogInfo.RankCredits = rankCredits;
                creditLogInfo.Action = (int)CreditAction.CompleteOrder;
                creditLogInfo.ActionCode = orderInfo.Oid;
                creditLogInfo.ActionTime = completeTime;
                creditLogInfo.ActionDes = "完成订单:" + orderInfo.OSN;
                creditLogInfo.Operator = 0;

                SendCredits(userRid, creditLogInfo);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 设置用户
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="password">密码</param>
        /// <param name="sid">sid</param>
        /// <param name="expires">过期时间</param>
        public static void SetUserCookie(PartUserInfo partUserInfo, int expires)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies["bsp"];
            if (cookie == null)
                cookie = new HttpCookie("bsp");

            cookie.Values["uid"] = partUserInfo.Uid.ToString();
            cookie.Values["password"] = WebHelper.UrlEncode(AESEncrypt(partUserInfo.Password));
            if (expires > 0)
            {
                cookie.Values["expires"] = expires.ToString();
                cookie.Expires = DateTime.Now.AddDays(expires);
            }
            string cookieDomain = BSPConfig.ShopConfig.CookieDomain;
            if (cookieDomain.Length != 0)
                cookie.Domain = cookieDomain;

            HttpContext.Current.Response.AppendCookie(cookie);
        }
Esempio n. 24
0
 /// <summary>
 /// 获得支付手续费
 /// </summary>
 /// <param name="productAmount">商品合计</param>
 /// <param name="buyTime">购买时间</param>
 /// <param name="partUserInfo">购买用户</param>
 /// <returns></returns>
 public decimal GetPayFee(decimal productAmount, DateTime buyTime, PartUserInfo partUserInfo)
 {
     return 0M;
 }