Ejemplo n.º 1
0
        /// <summary>
        /// 新注册用户赠送优惠券
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public bool NewUserGiveCoupons(string uid)
        {
            try
            {
                SysSettingManager settingManager = new SysSettingManager();

                List <StringBuilder> sqls = new List <StringBuilder>();
                List <object>        objs = new List <object>();

                int couponNum = 0;
                int.TryParse(settingManager.GetValueByKey("RegCouponNum"), out couponNum);
                decimal couponMoney = 0.00m;
                decimal.TryParse(settingManager.GetValueByKey("RegCouponMoney"), out couponMoney);
                double CouponPeriod = 0;
                double.TryParse(settingManager.GetValueByKey("CouponPeriod"), out CouponPeriod);
                if (couponNum > 0 && couponMoney > 0)
                {
                    for (int i = 1; i <= couponNum; i++)
                    {
                        StringBuilder sbInsertCoupon = new StringBuilder();
                        sbInsertCoupon.Append("insert into YR_UserCoupon(ID,Money,MinMoney,BeginTime,EndTime,UserID,CreateTime)values(@ID,@Money,@MinMoney,@BeginTime,@EndTime,@UserID,@CreateTime)");
                        SqlParam[] parmInsertCoupon = new SqlParam[] {
                            new SqlParam("@ID", Guid.NewGuid().ToString()),
                            new SqlParam("@Money", couponMoney),
                            new SqlParam("@MinMoney", "2.00"),
                            new SqlParam("@BeginTime", DateTime.Now),
                            new SqlParam("@EndTime", DateTime.Now.AddDays(CouponPeriod)),
                            new SqlParam("@UserID", uid),
                            new SqlParam("@CreateTime", DateTime.Now)
                        };
                        sqls.Add(sbInsertCoupon);
                        objs.Add(parmInsertCoupon);
                    }

                    StringBuilder sbInsertMessage = new StringBuilder();
                    sbInsertMessage.Append("Insert into YR_Messages(");
                    sbInsertMessage.Append("ID,OperatorID,UserID,MessageTitle,MessageContent,MessageType,ReleaseTime,state) ");
                    sbInsertMessage.Append(" values(@ID,@OperatorID,@UserID,@MessageTitle,@MessageContent,@MessageType,@ReleaseTime,@State)");
                    string     msg = string.Format("您于{0}获取{1}张{2}元骑行券,祝您用车愉快!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), couponNum, couponMoney);
                    SqlParam[] parmInsertMessage = new SqlParam[] {
                        new SqlParam("@ID", CommonHelper.GetGuid),
                        new SqlParam("@OperatorID", ""),
                        new SqlParam("@UserID", uid),
                        new SqlParam("@MessageTitle", "骑行券提醒"),
                        new SqlParam("@MessageContent", msg),
                        new SqlParam("@MessageType", MessageType.System.GetHashCode()),
                        new SqlParam("@ReleaseTime", SiteHelper.GetWebServerCurrentTime()),
                        new SqlParam("@State", MessageState.Enable.GetHashCode())
                    };
                    sqls.Add(sbInsertMessage);
                    objs.Add(parmInsertMessage);
                }

                return(DataFactory.SqlDataBase().BatchExecuteBySqlWithTrans(sqls.ToArray(), objs.ToArray()));
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据用户和车辆id获取车辆计费规则
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="vehicleid"></param>
        /// <returns></returns>
        public Hashtable GetVehiclePrice(string vehicleid)
        {
            Hashtable result = new Hashtable();

            UserInfoManager   userManager    = new UserInfoManager();
            VehicleManager    vehicleManager = new VehicleManager();
            SysSettingManager settingManager = new SysSettingManager();
            Hashtable         vehicle_ht     = vehicleManager.GetVehicleInfoByID(vehicleid);

            if (vehicle_ht != null)
            {
                decimal minutePrice = 0.00m;
                decimal kmPrice     = 0.00m;
                decimal minPrice    = 0.00m;
                decimal maxPrice    = 0.00m;

                DataTable price_dt = GetPriceInfo(SiteHelper.GetHashTableValueByKey(vehicle_ht, "CityID"), SiteHelper.GetHashTableValueByKey(vehicle_ht, "Model"));
                if (price_dt != null && price_dt.Rows.Count > 0)
                {
                    decimal.TryParse(price_dt.Rows[0]["MinutePrice"].ToString(), out minutePrice);
                    decimal.TryParse(price_dt.Rows[0]["KmPrice"].ToString(), out kmPrice);
                    decimal.TryParse(price_dt.Rows[0]["MinPrice"].ToString(), out minPrice);
                    decimal.TryParse(price_dt.Rows[0]["MaxPrice"].ToString(), out maxPrice);
                }
                result["MinutePrice"] = minutePrice;
                result["KmPrice"]     = kmPrice;
                result["MinPrice"]    = minPrice;
                result["MaxPrice"]    = maxPrice;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public bool OrderPayCallback(Hashtable ht)
        {
            try
            {
                OrdersManager     om             = new OrdersManager();
                VehicleManager    vm             = new VehicleManager();
                SysSettingManager settingManager = new SysSettingManager();

                string  ordernum = ht["OrderNum"].ToString();
                decimal paymoney = 0.00m;
                decimal.TryParse(ht["TotalFee"].ToString(), out paymoney);
                Hashtable orderinfo = GetOrderInfo(ordernum);

                List <StringBuilder> sqls = new List <StringBuilder>();
                List <object>        objs = new List <object>();

                //更改订单状态
                StringBuilder sbUpdateOrder = new StringBuilder();
                sbUpdateOrder.Append(@"UPDATE yr_orders SET PayMoney=@PayMoney,PayTime=@PayTime,FinishedTime=@FinishedTime,PayState=@PayState,OrderState=@OrderState where OrderNum=@OrderNum");
                SqlParam[] updateOrderParam = new SqlParam[] {
                    new SqlParam("@PayMoney", paymoney),
                    new SqlParam("@PayState", OrderPayState.AlreadyPay.GetHashCode()),
                    new SqlParam("@OrderState", OrderState.Finished.GetHashCode()),
                    new SqlParam("@PayTime", SiteHelper.GetWebServerCurrentTime()),
                    new SqlParam("@FinishedTime", SiteHelper.GetWebServerCurrentTime()),
                    new SqlParam("@OrderNum", ordernum)
                };
                sqls.Add(sbUpdateOrder);
                objs.Add(updateOrderParam);

                return(DataFactory.SqlDataBase().BatchExecuteBySqlWithTrans(sqls.ToArray(), objs.ToArray()));
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 订单计费时长,单位:分钟
        /// </summary>
        /// <param name="ordernum"></param>
        /// <returns></returns>
        public int GetOrderBillingTime(string ordernum)
        {
            int minutes = 0;

            Hashtable order      = GetOrderInfoByNum(ordernum);
            string    orderState = SiteHelper.GetHashTableValueByKey(order, "OrderState");

            if (orderState == "1")
            {
                SysSettingManager settingManager = new SysSettingManager();
                int OrderDelayMinutes            = 15;
                int.TryParse(settingManager.GetValueByKey("OrderDelayMinutes"), out OrderDelayMinutes);

                DateTime createtime   = DateTime.Now;
                DateTime startTime    = DateTime.Now;
                string   strStartTime = SiteHelper.GetHashTableValueByKey(order, "StartTime");
                DateTime.TryParse(SiteHelper.GetHashTableValueByKey(order, "CreateTime"), out createtime);
                DateTime.TryParse(SiteHelper.GetHashTableValueByKey(order, "StartTime"), out startTime);
                DateTime billingTime = createtime.AddMinutes(OrderDelayMinutes);
                if (!string.IsNullOrEmpty(strStartTime))
                {
                    if (SiteHelper.ExecDateDiff(createtime, startTime) < OrderDelayMinutes)
                    {
                        billingTime = startTime;
                    }
                }
                if (billingTime <= DateTime.Now)
                {
                    minutes = SiteHelper.ExecDateDiff(billingTime, DateTime.Now);
                }
            }
            else
            {
                int.TryParse(SiteHelper.GetHashTableValueByKey(order, "Minutes"), out minutes);
            }
            return(minutes);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 邀请好友注册赠送优惠券,在用户首次缴纳押金成功后进行赠券操作
        /// </summary>
        /// <param name="reg_uid"></param>
        /// <returns></returns>
        public bool InviteUserGiveCoupons(string uid)
        {
            try
            {
                UserInfoManager      userManager    = new UserInfoManager();
                DepositReturnManager depositManager = new DepositReturnManager();
                SysSettingManager    settingManager = new SysSettingManager();

                List <StringBuilder> sqls = new List <StringBuilder>();
                List <object>        objs = new List <object>();

                bool      isFirstDeposit = depositManager.IsFirstDeposit(uid);
                Hashtable user_ht        = userManager.GetUserInfoByUserID(uid);
                if (user_ht != null && user_ht.Keys.Count > 0 && isFirstDeposit)
                {
                    string invite_uid = SiteHelper.GetHashTableValueByKey(user_ht, "InviteUserID");

                    if (!string.IsNullOrEmpty(invite_uid))
                    {
                        int     couponNum    = 0;
                        decimal couponMoney  = 0.00m;
                        double  CouponPeriod = 0;
                        //邀请注册双方同时赠送优惠券
                        couponNum = 0;
                        int.TryParse(settingManager.GetValueByKey("InviteCouponNum"), out couponNum);
                        couponMoney = 0.00m;
                        decimal.TryParse(settingManager.GetValueByKey("InviteCouponMoney"), out couponMoney);
                        CouponPeriod = 0;
                        double.TryParse(settingManager.GetValueByKey("CouponPeriod"), out CouponPeriod);
                        if (couponNum > 0 && couponMoney > 0)
                        {
                            for (int i = 1; i <= couponNum; i++)
                            {
                                StringBuilder sbInsertCoupon = new StringBuilder();
                                sbInsertCoupon.Append("insert into YR_UserCoupon(ID,Money,MinMoney,BeginTime,EndTime,UserID,CreateTime)values(@ID,@Money,@MinMoney,@BeginTime,@EndTime,@UserID,@CreateTime)");
                                SqlParam[] parmInsertCoupon = new SqlParam[] {
                                    new SqlParam("@ID", Guid.NewGuid().ToString()),
                                    new SqlParam("@Money", couponMoney),
                                    new SqlParam("@MinMoney", "2.00"),
                                    new SqlParam("@BeginTime", DateTime.Now),
                                    new SqlParam("@EndTime", DateTime.Now.AddDays(CouponPeriod)),
                                    new SqlParam("@UserID", uid),
                                    new SqlParam("@CreateTime", DateTime.Now)
                                };
                                sqls.Add(sbInsertCoupon);
                                objs.Add(parmInsertCoupon);
                            }

                            StringBuilder sbInsertMessage = new StringBuilder();
                            sbInsertMessage.Append("Insert into YR_Messages(");
                            sbInsertMessage.Append("ID,OperatorID,UserID,MessageTitle,MessageContent,MessageType,ReleaseTime,state) ");
                            sbInsertMessage.Append(" values(@ID,@OperatorID,@UserID,@MessageTitle,@MessageContent,@MessageType,@ReleaseTime,@State)");
                            string     msg = string.Format("您于{0}获取{1}张{2}元骑行券,祝您用车愉快!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), couponNum, couponMoney);
                            SqlParam[] parmInsertMessage = new SqlParam[] {
                                new SqlParam("@ID", CommonHelper.GetGuid),
                                new SqlParam("@OperatorID", ""),
                                new SqlParam("@UserID", uid),
                                new SqlParam("@MessageTitle", "骑行券提醒"),
                                new SqlParam("@MessageContent", msg),
                                new SqlParam("@MessageType", MessageType.System.GetHashCode()),
                                new SqlParam("@ReleaseTime", SiteHelper.GetWebServerCurrentTime()),
                                new SqlParam("@State", MessageState.Enable.GetHashCode())
                            };
                            sqls.Add(sbInsertMessage);
                            objs.Add(parmInsertMessage);

                            for (int i = 1; i <= couponNum; i++)
                            {
                                StringBuilder sbInsertCoupon = new StringBuilder();
                                sbInsertCoupon.Append("insert into YR_UserCoupon(ID,Money,MinMoney,BeginTime,EndTime,UserID,CreateTime)values(@ID,@Money,@MinMoney,@BeginTime,@EndTime,@UserID,@CreateTime)");
                                SqlParam[] parmInsertCoupon = new SqlParam[] {
                                    new SqlParam("@ID", Guid.NewGuid().ToString()),
                                    new SqlParam("@Money", couponMoney),
                                    new SqlParam("@MinMoney", "2.00"),
                                    new SqlParam("@BeginTime", DateTime.Now),
                                    new SqlParam("@EndTime", DateTime.Now.AddDays(CouponPeriod)),
                                    new SqlParam("@UserID", invite_uid),
                                    new SqlParam("@CreateTime", DateTime.Now)
                                };
                                sqls.Add(sbInsertCoupon);
                                objs.Add(parmInsertCoupon);
                            }

                            StringBuilder sbInsertMessage2 = new StringBuilder();
                            sbInsertMessage2.Append("Insert into YR_Messages(");
                            sbInsertMessage2.Append("ID,OperatorID,UserID,MessageTitle,MessageContent,MessageType,ReleaseTime,state) ");
                            sbInsertMessage2.Append(" values(@ID,@OperatorID,@UserID,@MessageTitle,@MessageContent,@MessageType,@ReleaseTime,@State)");
                            string     msg2 = string.Format("邀请好友注册成功,您于{0}获取{1}张{2}元骑行券,祝您用车愉快!", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), couponNum, couponMoney);
                            SqlParam[] parmInsertMessage2 = new SqlParam[] {
                                new SqlParam("@ID", CommonHelper.GetGuid),
                                new SqlParam("@OperatorID", ""),
                                new SqlParam("@UserID", invite_uid),
                                new SqlParam("@MessageTitle", "骑行券提醒"),
                                new SqlParam("@MessageContent", msg2),
                                new SqlParam("@MessageType", MessageType.System.GetHashCode()),
                                new SqlParam("@ReleaseTime", SiteHelper.GetWebServerCurrentTime()),
                                new SqlParam("@State", MessageState.Enable.GetHashCode())
                            };
                            sqls.Add(sbInsertMessage2);
                            objs.Add(parmInsertMessage2);
                        }
                    }
                }

                return(DataFactory.SqlDataBase().BatchExecuteBySqlWithTrans(sqls.ToArray(), objs.ToArray()));
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取订单结算信息
        /// </summary>
        /// <param name="orderid"></param>
        /// <returns></returns>
        public Hashtable GetOrderSettlement(string orderid)
        {
            Hashtable result = new Hashtable();

            UserInfoManager   userManager    = new UserInfoManager();
            OrdersManager     ordersManager  = new OrdersManager();
            VehicleManager    vehicleManager = new VehicleManager();
            SysSettingManager settingManager = new SysSettingManager();
            Hashtable         order_ht       = ordersManager.GetOrderInfoByID(orderid);

            string orderState = SiteHelper.GetHashTableValueByKey(order_ht, "OrderState");
            string userID     = SiteHelper.GetHashTableValueByKey(order_ht, "UserID");

            if (OrderState.Valid.GetHashCode().ToString() == orderState)
            {
                #region 未结算订单

                int     minutes     = 0;
                float   mileage     = 0.00f;
                decimal minutePrice = 0.00m;
                decimal kmPrice     = 0.00m;
                decimal minPrice    = 0.00m;
                decimal maxPrice    = 0.00m;
                decimal totalMoney  = 0.00m;

                int orderFreeMinutes = 0;
                int.TryParse(settingManager.GetValueByKey("OrderFreeMinutes"), out orderFreeMinutes);
                double orderFreeKm = 0;
                double.TryParse(settingManager.GetValueByKey("OrderFreeKm"), out orderFreeKm);

                float.TryParse(SiteHelper.GetHashTableValueByKey(order_ht, "Mileage"), out mileage);

                Hashtable vehicle_ht = vehicleManager.GetVehicleInfoByID(SiteHelper.GetHashTableValueByKey(order_ht, "VehicleID"));
                Hashtable user_ht    = userManager.GetUserInfoByUserID(userID);
                DataTable price_dt   = GetPriceInfo(SiteHelper.GetHashTableValueByKey(order_ht, "CityID"), SiteHelper.GetHashTableValueByKey(vehicle_ht, "Model"));
                if (price_dt != null && price_dt.Rows.Count > 0)
                {
                    decimal.TryParse(price_dt.Rows[0]["MinutePrice"].ToString(), out minutePrice);
                    decimal.TryParse(price_dt.Rows[0]["KmPrice"].ToString(), out kmPrice);
                    decimal.TryParse(price_dt.Rows[0]["MinPrice"].ToString(), out minPrice);
                    decimal.TryParse(price_dt.Rows[0]["MaxPrice"].ToString(), out maxPrice);
                }
                minutes = ordersManager.GetOrderBillingTime(SiteHelper.GetHashTableValueByKey(order_ht, "OrderNum"));
                if (minutes > 0)
                {
                    //totalMoney = minutePrice * minutes + kmPrice * (decimal)mileage;
                    totalMoney = minutePrice * (minutes - (minutes > orderFreeMinutes ? orderFreeMinutes : 0)) + kmPrice * (decimal)(mileage - (mileage > orderFreeKm ? orderFreeKm : 0));
                    if (totalMoney < minPrice)
                    {
                        totalMoney = minPrice;
                    }
                    if (totalMoney > maxPrice)
                    {
                        totalMoney = maxPrice;
                    }
                }

                //用车5分钟以内或骑行100米以内还车都不收费
                if (minutes < orderFreeMinutes || mileage < orderFreeKm)
                {
                    totalMoney = 0.00m;
                }

                result["MinutePrice"] = minutePrice;
                result["KmPrice"]     = kmPrice;
                result["Minutes"]     = minutes;
                result["TotalMoney"]  = totalMoney;

                #endregion
            }
            else
            {
                #region 已结算订单

                result["MinutePrice"] = SiteHelper.GetHashTableValueByKey(order_ht, "MinutePrice");
                result["KmPrice"]     = SiteHelper.GetHashTableValueByKey(order_ht, "KMPrice");
                result["Minutes"]     = SiteHelper.GetHashTableValueByKey(order_ht, "Minutes");
                result["TotalMoney"]  = SiteHelper.GetHashTableValueByKey(order_ht, "TotalMoney");

                #endregion
            }

            return(result);
        }