Exemple #1
0
 private void CloseReturnBalance(int userId, string orderId, decimal balanceAmount)
 {
     if (balanceAmount > decimal.Zero)
     {
         Users.ClearUserCache(userId, "");
         Hidistro.Entities.Members.MemberInfo user = Users.GetUser(userId);
         BalanceDetailInfo balanceDetailInfo       = new BalanceDetailInfo();
         balanceDetailInfo.TradeDate       = DateTime.Now;
         balanceDetailInfo.TradeType       = TradeTypes.RefundOrder;
         balanceDetailInfo.UserId          = userId;
         balanceDetailInfo.UserName        = user.UserName;
         balanceDetailInfo.Balance         = user.Balance + balanceAmount;
         balanceDetailInfo.Expenses        = null;
         balanceDetailInfo.Income          = balanceAmount;
         balanceDetailInfo.InpourId        = "";
         balanceDetailInfo.ManagerUserName = "";
         balanceDetailInfo.Remark          = "订单" + orderId + "自动关闭,还原抵扣的余额";
         if (new BaseDao().Add(balanceDetailInfo, null) > 0)
         {
             user.Balance += balanceAmount;
             MemberProcessor.UpdateMember(user);
             Users.ClearUserCache(user.UserId, user.SessionId);
         }
     }
 }
Exemple #2
0
        private void AddPointDetail(Hidistro.Entities.Members.MemberInfo member, string orderId, int points, int?deductionPoints, PointTradeType pType, DbTransaction dbTran)
        {
            PointDetailInfo pointDetailInfo = new PointDetailInfo();

            pointDetailInfo.OrderId   = orderId;
            pointDetailInfo.UserId    = member.UserId;
            pointDetailInfo.TradeDate = DateTime.Now;
            pointDetailInfo.TradeType = pType;
            switch (pType)
            {
            case PointTradeType.Bounty:
                pointDetailInfo.Increased = points;
                pointDetailInfo.Points    = points + member.Points;
                break;

            case PointTradeType.ShoppingDeduction:
                pointDetailInfo.Reduced = (deductionPoints.HasValue ? deductionPoints.Value : 0);
                pointDetailInfo.Points  = member.Points - (deductionPoints.HasValue ? deductionPoints.Value : 0);
                break;
            }
            if (pointDetailInfo.Points > 2147483647)
            {
                pointDetailInfo.Points = 2147483647;
            }
            if (pointDetailInfo.Points < 0)
            {
                pointDetailInfo.Points = 0;
            }
            if (pointDetailInfo.Increased > 0 || pointDetailInfo.Reduced > 0)
            {
                BaseDao baseDao = new BaseDao();
                baseDao.Add(pointDetailInfo, dbTran);
                member.Points = pointDetailInfo.Points;
            }
        }
Exemple #3
0
 public static bool CutNeedPoint(int needPoint, string orderId, PointTradeType pType, int userId)
 {
     Hidistro.Entities.Members.MemberInfo user = Users.GetUser(userId);
     if (user != null)
     {
         PointDetailInfo pointDetailInfo = new PointDetailInfo();
         pointDetailInfo.OrderId   = orderId;
         pointDetailInfo.UserId    = user.UserId;
         pointDetailInfo.TradeDate = DateTime.Now;
         pointDetailInfo.TradeType = pType;
         pointDetailInfo.Reduced   = needPoint;
         pointDetailInfo.Points    = user.Points - needPoint;
         pointDetailInfo.Remark    = "订单 " + orderId;
         if (pointDetailInfo.Points > 2147483647 || pointDetailInfo.Points < 0)
         {
             pointDetailInfo.Points = 0;
         }
         if (new PointDetailDao().Add(pointDetailInfo, null) > 0)
         {
             user.Points = pointDetailInfo.Points;
             return(true);
         }
     }
     return(false);
 }
 public ProductInfo GetProduct(MemberInfo member, int productId)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice");
     }
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Products WHERE ProductId =@ProductId;SELECT SkuId, ProductId, SKU,Weight, Stock, CostPrice, " + builder.ToString() + " FROM Hishop_SKUs s WHERE ProductId = @ProductId");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     ProductInfo info = null;
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateProduct(reader);
         }
         if (!reader.NextResult())
         {
             return info;
         }
         while (reader.Read())
         {
             info.Skus.Add((string) reader["SkuId"], DataMapper.PopulateSKU(reader));
         }
     }
     return info;
 }
 public DataTable GetBrandProducts(MemberInfo member, int? brandId, int pageNumber, int maxNum, out int total)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     builder.Append("ProductId,ProductName,ProductCode,ShowSaleCounts AS SaleCounts,ShortDescription,ShowSaleCounts,");
     builder.Append(" ThumbnailUrl60,ThumbnailUrl100,ThumbnailUrl160,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310,MarketPrice,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice");
     }
     StringBuilder builder2 = new StringBuilder();
     builder2.Append(" SaleStatus=1");
     if (brandId.HasValue)
     {
         builder2.AppendFormat(" AND BrandId = {0}", brandId);
     }
     DbQueryResult result = DataHelper.PagingByRownumber(pageNumber, maxNum, "DisplaySequence", SortAction.Desc, true, "vw_Hishop_BrowseProductList s", "ProductId", builder2.ToString(), builder.ToString());
     DataTable data = (DataTable) result.Data;
     total = result.TotalRecords;
     return data;
 }
 public void AddLineItem(MemberInfo member, string skuId, int quantity)
 {
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("ss_ShoppingCart_AddLineItem");
     this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, member.UserId);
     this.database.AddInParameter(storedProcCommand, "SkuId", DbType.String, skuId);
     this.database.AddInParameter(storedProcCommand, "Quantity", DbType.Int32, quantity);
     this.database.ExecuteNonQuery(storedProcCommand);
 }
 protected VActivityidTemplatedWebControl()
 {
     if (MemberProcessor.GetCurrentMember() == null)
     {
         SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
         if (masterSettings.IsValidationService)
         {
             string str = this.Page.Request.QueryString["code"];
             if (!string.IsNullOrEmpty(str))
             {
                 string responseResult = this.GetResponseResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + masterSettings.WeixinAppId + "&secret=" + masterSettings.WeixinAppSecret + "&code=" + str + "&grant_type=authorization_code");
                 if (responseResult.Contains("access_token"))
                 {
                     JObject obj2 = JsonConvert.DeserializeObject(responseResult) as JObject;
                     string str3 = this.GetResponseResult("https://api.weixin.qq.com/sns/userinfo?access_token=" + obj2["access_token"].ToString() + "&openid=" + obj2["openid"].ToString() + "&lang=zh_CN");
                     if (str3.Contains("nickname"))
                     {
                         JObject obj3 = JsonConvert.DeserializeObject(str3) as JObject;
                         string generateId = Globals.GetGenerateId();
                         MemberInfo member = new MemberInfo {
                             GradeId = MemberProcessor.GetDefaultMemberGrade(),
                             UserName = Globals.UrlDecode(obj3["nickname"].ToString()),
                             OpenId = obj3["openid"].ToString(),
                             CreateDate = DateTime.Now,
                             SessionId = generateId,
                             SessionEndTime = DateTime.Now.AddYears(10)
                         };
                         MemberProcessor.CreateMember(member);
                         MemberInfo info2 = MemberProcessor.GetMember(generateId);
                         HttpCookie cookie = new HttpCookie("Vshop-Member") {
                             Value = info2.UserId.ToString(),
                             Expires = DateTime.Now.AddYears(10)
                         };
                         HttpContext.Current.Response.Cookies.Add(cookie);
                         this.Page.Response.Redirect(HttpContext.Current.Request.Url.ToString());
                     }
                     else
                     {
                         this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/Default.aspx");
                     }
                 }
                 else
                 {
                     this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/Default.aspx");
                 }
             }
             else if (!string.IsNullOrEmpty(this.Page.Request.QueryString["state"]))
             {
                 this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/Default.aspx");
             }
             else
             {
                 string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + masterSettings.WeixinAppId + "&redirect_uri=" + Globals.UrlEncode(HttpContext.Current.Request.Url.ToString()) + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
                 this.Page.Response.Redirect(url);
             }
         }
     }
 }
 public static bool CreateMember(MemberInfo member)
 {
     MemberDao dao = new MemberDao();
     if (dao.IsExitOpenId(member.OpenId))
     {
         return dao.SetMemberSessionId(member.SessionId, member.SessionEndTime, member.OpenId);
     }
     return dao.CreateMember(member);
 }
 public static DbQueryResult GetHomeProduct(MemberInfo member, ProductQuery query)
 {
     DistributorsInfo currentDistributors = DistributorsBrower.GetCurrentDistributors();
     if ((currentDistributors != null) && (currentDistributors.UserId != 0))
     {
         return new HomeProductDao().GetHomeProducts(member, query, true);
     }
     return new HomeProductDao().GetHomeProducts(member, query, false);
 }
Exemple #10
0
 public static IList<string> BatchCreateMembers(IList<string> distributornames, int referruserId, string createtype = "1")
 {
     string str = string.Empty;
     string referralPath = string.Empty;
     IList<string> list = new List<string>();
     if (referruserId > 0)
     {
         referralPath = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
         if (string.IsNullOrEmpty(referralPath))
         {
             referralPath = referruserId.ToString();
         }
         else if (referralPath.Contains("|"))
         {
             referralPath = referralPath.Split(new char[] { '|' })[1];
         }
         else
         {
             referralPath = referralPath + "|" + referruserId.ToString();
         }
     }
     foreach (string str3 in distributornames)
     {
         MemberInfo member = new MemberInfo();
         string generateId = Globals.GetGenerateId();
         member.GradeId = new MemberGradeDao().GetDefaultMemberGrade();
         member.UserName = str3;
         member.CreateDate = DateTime.Now;
         member.SessionId = generateId;
         member.SessionEndTime = DateTime.Now.AddYears(10);
         member.Password = HiCryptographer.Md5Encrypt("888888");
         if ((new MemberDao().GetusernameMember(str3) == null) && new MemberDao().CreateMember(member))
         {
             DistributorsInfo distributor = new DistributorsInfo {
                 UserId = new MemberDao().GetusernameMember(str3).UserId,
                 RequestAccount = str3,
                 StoreName = str3,
                 StoreDescription = str3,
                 BackImage = "/Storage/data/DistributorBackgroundPic/default.jpg",
                 Logo = "/Utility/pics/headLogo.jpg"
             };
             str = distributor.UserId.ToString();
             distributor.ReferralPath = referralPath;
             distributor.DistributorGradeId = (referralPath.Split(new char[] { '|' }).Length == 1) ? DistributorGrade.TowDistributor : DistributorGrade.ThreeDistributor;
             distributor.ParentUserId = new int?(Convert.ToInt32((referralPath.Split(new char[] { '|' }).Length == 1) ? referralPath : referralPath.Split(new char[] { '|' })[1].ToString()));
             if (new DistributorsDao().CreateDistributor(distributor) && (createtype == "1"))
             {
                 list.Add(str3);
             }
         }
         else if (createtype == "2")
         {
             list.Add(str3);
         }
     }
     return list;
 }
Exemple #11
0
 private void UpdateUserPoint(string orderId, int points, int?deductionPoints, int userId, DbTransaction dbTran = null)
 {
     Hidistro.Entities.Members.MemberInfo user = Users.GetUser(userId);
     if (user != null)
     {
         this.AddPointDetail(user, orderId, points, deductionPoints, PointTradeType.Bounty, dbTran);
         int historyPoint = this.GetHistoryPoint(user.UserId, dbTran);
         this.ChangeMemberGrade(user.UserId, user.GradeId, historyPoint, dbTran);
     }
 }
Exemple #12
0
 protected override void AttachChildControls()
 {
     if (!int.TryParse(this.Page.Request.QueryString["activityid"], out this.activityid))
     {
         base.GotoResourceNotFound("");
     }
     this.bgimg = (HtmlImage) this.FindControl("bgimg");
     this.litActivityDesc = (Literal) this.FindControl("litActivityDesc");
     this.litPrizeNames = (Common_PrizeNames) this.FindControl("litPrizeNames");
     this.litPrizeUsers = (Common_PrizeUsers) this.FindControl("litPrizeUsers");
     this.litStartDate = (Literal) this.FindControl("litStartDate");
     this.litEndDate = (Literal) this.FindControl("litEndDate");
     PageTitle.AddSiteNameTitle("砸金蛋");
     LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(this.activityid);
     if (lotteryActivity == null)
     {
         base.GotoResourceNotFound("");
     }
     if (MemberProcessor.GetCurrentMember() == null)
     {
         MemberInfo member = new MemberInfo();
         string generateId = Globals.GetGenerateId();
         member.GradeId = MemberProcessor.GetDefaultMemberGrade();
         member.UserName = "";
         member.OpenId = "";
         member.CreateDate = DateTime.Now;
         member.SessionId = generateId;
         member.SessionEndTime = DateTime.Now;
         MemberProcessor.CreateMember(member);
         member = MemberProcessor.GetMember(generateId);
         HttpCookie cookie = new HttpCookie("Vshop-Member") {
             Value = member.UserId.ToString(),
             Expires = DateTime.Now.AddYears(10)
         };
         HttpContext.Current.Response.Cookies.Add(cookie);
     }
     this.litStartDate.Text = lotteryActivity.StartTime.ToString("yyyy年MM月dd日 HH:mm:ss");
     this.litEndDate.Text = lotteryActivity.EndTime.ToString("yyyy年MM月dd日 HH:mm:ss");
     if (VshopBrowser.GetUserPrizeCount(this.activityid) >= lotteryActivity.MaxNum)
     {
         this.Page.ClientScript.RegisterStartupScript(base.GetType(), "myscript", "<script>alert_h(\"亲,不好意思您的抽奖机会已经用完了哦,敬请期待下次活动吧!\",function(){window.location.href=\"/vshop/default.aspx\";});</script>");
     }
     if ((lotteryActivity.StartTime < DateTime.Now) && (DateTime.Now < lotteryActivity.EndTime))
     {
         this.litActivityDesc.Text = lotteryActivity.ActivityDesc;
         this.litPrizeNames.Activity = lotteryActivity;
         this.litPrizeUsers.Activity = lotteryActivity;
         int userPrizeCount = VshopBrowser.GetUserPrizeCount(this.activityid);
         this.litActivityDesc.Text = this.litActivityDesc.Text + string.Format("您一共有{0}次参与机会,目前还剩{1}次。", lotteryActivity.MaxNum, lotteryActivity.MaxNum - userPrizeCount);
     }
     else
     {
         this.Page.ClientScript.RegisterStartupScript(base.GetType(), "myscript", "<script>alert_h(\"活动还未开始或者已经结束!\",function(){window.location.href=\"/vshop/default.aspx\";})</script>");
     }
 }
Exemple #13
0
        public static SKUItem GetProductAndSku(int productId, string options)
        {
            int gradeId = 0;

            Hidistro.Entities.Members.MemberInfo user = HiContext.Current.User;
            if (user.UserId != 0)
            {
                gradeId = user.GradeId;
            }
            return(new SkuDao().GetProductAndSku(gradeId, productId, options));
        }
Exemple #14
0
 public bool CreateMember(MemberInfo member)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO aspnet_Members(GradeId,ReferralUserId,UserName,CreateDate,OrderNumber,Expenditure,Points,TopRegionId, RegionId,OpenId, SessionId, SessionEndTime,Password) VALUES(@GradeId,@ReferralUserId,@UserName,@CreateDate,0,0,0,0,0,@OpenId, @SessionId, @SessionEndTime,@Password)");
     this.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, member.GradeId);
     this.database.AddInParameter(sqlStringCommand, "ReferralUserId", DbType.Int32, member.ReferralUserId);
     this.database.AddInParameter(sqlStringCommand, "UserName", DbType.String, member.UserName);
     this.database.AddInParameter(sqlStringCommand, "CreateDate", DbType.DateTime, member.CreateDate);
     this.database.AddInParameter(sqlStringCommand, "OpenId", DbType.String, member.OpenId);
     this.database.AddInParameter(sqlStringCommand, "SessionId", DbType.String, member.SessionId);
     this.database.AddInParameter(sqlStringCommand, "SessionEndTime", DbType.DateTime, member.SessionEndTime);
     this.database.AddInParameter(sqlStringCommand, "Password", DbType.String, member.Password);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemple #15
0
        public static bool Update(Hidistro.Entities.Members.MemberInfo member)
        {
            bool flag = new MemberDao().Update(member);

            if (flag)
            {
                HiCache.Remove(string.Format("DataCache-Member-{0}", member.UserId));
                EventLogs.WriteOperationLog(Privilege.EditMember, string.Format(CultureInfo.InvariantCulture, "修改了编号为 “{0}” 的会员", new object[]
                {
                    member.UserId
                }));
            }
            return(flag);
        }
Exemple #16
0
 public static void OrderRefund(MemberInfo user, string orderId, decimal amount)
 {
     if (user != null)
     {
         MessageTemplate template = MessageTemplateHelper.GetTemplate("OrderRefund");
         if (template != null)
         {
             MailMessage email = null;
             string innerSubject = null;
             string innerMessage = null;
             string smsMessage = null;
             SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
             GenericOrderMessages(masterSettings, user.UserName, user.Email, orderId, 0M, null, null, null, null, null, null, null, null, null, amount, null, template, out email, out smsMessage, out innerSubject, out innerMessage);
             TemplateMessage templateMessage = GenerateWeixinMessageWhenOrderRefund(template.WeixinTemplateId, masterSettings, user, orderId, amount);
             Send(template, masterSettings, user, false, email, innerSubject, innerMessage, smsMessage, templateMessage);
         }
     }
 }
Exemple #17
0
 public static void OrderCreated(OrderInfo order, MemberInfo user)
 {
     if ((order != null) && (user != null))
     {
         MessageTemplate template = MessageTemplateHelper.GetTemplate("OrderCreated");
         if (template != null)
         {
             MailMessage email = null;
             string innerSubject = null;
             string innerMessage = null;
             string smsMessage = null;
             SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
             GenericOrderMessages(masterSettings, user.UserName, user.Email, order.OrderId, order.GetTotal(), order.Remark, order.ModeName, order.ShipTo, order.Address, order.ZipCode, order.TelPhone, order.CellPhone, order.EmailAddress, order.ShipOrderNumber, order.RefundAmount, order.CloseReason, template, out email, out smsMessage, out innerSubject, out innerMessage);
             TemplateMessage templateMessage = GenerateWeixinMessageWhenOrderCreate(template.WeixinTemplateId, masterSettings, order, user);
             Send(template, masterSettings, user, false, email, innerSubject, innerMessage, smsMessage, templateMessage);
         }
     }
 }
Exemple #18
0
 public SKUItem GetProductAndSku(MemberInfo currentMember, int productId, string options)
 {
     if (string.IsNullOrEmpty(options))
     {
         return null;
     }
     string[] strArray = options.Split(new char[] { ',' });
     if ((strArray == null) || (strArray.Length <= 0))
     {
         return null;
     }
     StringBuilder builder = new StringBuilder();
     if (currentMember != null)
     {
         int discount = new MemberGradeDao().GetMemberGrade(currentMember.GradeId).Discount;
         builder.Append("SELECT SkuId, ProductId, SKU,Weight, Stock, CostPrice,");
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) = 1", currentMember.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", currentMember.GradeId, discount);
         builder.Append(" FROM Hishop_SKUs s WHERE ProductId = @ProductId");
     }
     else
     {
         builder.Append("SELECT SkuId, ProductId, SKU,Weight, Stock, CostPrice, SalePrice FROM Hishop_SKUs WHERE ProductId = @ProductId");
     }
     foreach (string str in strArray)
     {
         string[] strArray2 = str.Split(new char[] { ':' });
         builder.AppendFormat(" AND SkuId IN (SELECT SkuId FROM Hishop_SKUItems WHERE AttributeId = {0} AND ValueId = {1}) ", strArray2[0], strArray2[1]);
     }
     SKUItem item = null;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             item = DataMapper.PopulateSKU(reader);
         }
     }
     return item;
 }
Exemple #19
0
 public DbQueryResult GetHomeProducts(MemberInfo member, ProductQuery query, bool isdistributor)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     int currentDistributorId = Globals.GetCurrentDistributorId();
     builder.Append("ProductId, ProductCode,ShortDescription,ProductName,ShowSaleCounts, ThumbnailUrl60,ThumbnailUrl40,ThumbnailUrl100,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310, MarketPrice,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice, ", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice,");
     }
     builder.Append("SaleCounts, Stock");
     StringBuilder builder2 = new StringBuilder(" SaleStatus =" + 1);
     if (isdistributor && (currentDistributorId > 0))
     {
         builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId);
     }
     return DataHelper.PagingByRownumber(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "vw_Hishop_BrowseProductList p", "ProductId", builder2.ToString(), builder.ToString());
 }
 public ShoppingCartItemInfo GetCartItemInfo(MemberInfo member, string skuId, int quantity)
 {
     ShoppingCartItemInfo info = null;
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("ss_ShoppingCart_GetItemInfo");
     this.database.AddInParameter(storedProcCommand, "Quantity", DbType.Int32, quantity);
     this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, (member != null) ? member.UserId : 0);
     this.database.AddInParameter(storedProcCommand, "SkuId", DbType.String, skuId);
     this.database.AddInParameter(storedProcCommand, "GradeId", DbType.Int32, (member != null) ? member.GradeId : 0);
     using (IDataReader reader = this.database.ExecuteReader(storedProcCommand))
     {
         if (!reader.Read())
         {
             return info;
         }
         info = new ShoppingCartItemInfo {
             SkuId = skuId,
             Quantity = info.ShippQuantity = quantity,
             ProductId = (int) reader["ProductId"]
         };
         if (reader["SKU"] != DBNull.Value)
         {
             info.SKU = (string) reader["SKU"];
         }
         info.Name = (string) reader["ProductName"];
         if (DBNull.Value != reader["Weight"])
         {
             info.Weight = (int) reader["Weight"];
         }
         info.MemberPrice = info.AdjustedPrice = (decimal) reader["SalePrice"];
         if (DBNull.Value != reader["ThumbnailUrl40"])
         {
             info.ThumbnailUrl40 = reader["ThumbnailUrl40"].ToString();
         }
         if (DBNull.Value != reader["ThumbnailUrl60"])
         {
             info.ThumbnailUrl60 = reader["ThumbnailUrl60"].ToString();
         }
         if (DBNull.Value != reader["ThumbnailUrl100"])
         {
             info.ThumbnailUrl100 = reader["ThumbnailUrl100"].ToString();
         }
         if (DBNull.Value != reader["IsfreeShipping"])
         {
             info.IsfreeShipping = Convert.ToBoolean(reader["IsfreeShipping"]);
         }
         string str = string.Empty;
         if (reader.NextResult())
         {
             while (reader.Read())
             {
                 if (!((((reader["AttributeName"] == DBNull.Value) || string.IsNullOrEmpty((string) reader["AttributeName"])) || (reader["ValueStr"] == DBNull.Value)) || string.IsNullOrEmpty((string) reader["ValueStr"])))
                 {
                     object obj2 = str;
                     str = string.Concat(new object[] { obj2, reader["AttributeName"], ":", reader["ValueStr"], "; " });
                 }
             }
         }
         info.SkuContent = str;
     }
     return info;
 }
Exemple #21
0
 private static void Send(MessageTemplate template, SiteSettings settings, MemberInfo user, bool sendFirst, MailMessage email, string innerSubject, string innerMessage, string smsMessage, TemplateMessage templateMessage)
 {
     if (template.SendEmail && (email != null))
     {
         if (sendFirst)
         {
             EmailSender sender = CreateEmailSender(settings);
             if (!((sender != null) && SendMail(email, sender)))
             {
                 Emails.EnqueuEmail(email, settings);
             }
         }
         else
         {
             Emails.EnqueuEmail(email, settings);
         }
     }
     if (template.SendSMS)
     {
     }
     if (template.SendInnerMessage)
     {
     }
     if ((template.SendWeixin && !string.IsNullOrWhiteSpace(template.WeixinTemplateId)) && (templateMessage != null))
     {
         TemplateApi.SendMessage(TokenApi.GetToken_Message(settings.WeixinAppId, settings.WeixinAppSecret), templateMessage);
     }
 }
Exemple #22
0
 private static string GetUserCellPhone(MemberInfo user)
 {
     if (user == null)
     {
         return null;
     }
     return user.CellPhone;
 }
Exemple #23
0
 private static TemplateMessage GenerateWeixinMessageWhenPasswordChange(string templateId, SiteSettings settings, MemberInfo user, string passowordType)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "productName",
         Value = passowordType + "密码"
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "time",
         Value = DateTime.Now.ToString("M月d日 HH:mm")
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Exemple #24
0
        public static IList <string> BatchCreateMembers(IList <string> distributornames, int referruserId, string createtype = "1")
        {
            string           text  = string.Empty;
            string           text2 = string.Empty;
            IList <string>   list  = new List <string>();
            DistributorGrade distributorGradeId = DistributorGrade.ThreeDistributor;

            if (referruserId > 0)
            {
                text2 = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
                if (string.IsNullOrEmpty(text2))
                {
                    text2 = referruserId.ToString();
                    distributorGradeId = DistributorGrade.TowDistributor;
                }
                else if (text2.Contains("|"))
                {
                    text2 = text2.Split(new char[]
                    {
                        '|'
                    })[1] + "|" + referruserId.ToString();
                }
                else
                {
                    text2 = text2 + "|" + referruserId.ToString();
                }
            }
            foreach (string current in distributornames)
            {
                Hidistro.Entities.Members.MemberInfo memberInfo = new Hidistro.Entities.Members.MemberInfo();
                string generateId = Globals.GetGenerateId();
                memberInfo.GradeId        = new MemberGradeDao().GetDefaultMemberGrade();
                memberInfo.UserName       = current;
                memberInfo.CreateDate     = DateTime.Now;
                memberInfo.UserBindName   = current;
                memberInfo.SessionId      = generateId;
                memberInfo.ReferralUserId = Convert.ToInt32(referruserId);
                memberInfo.SessionEndTime = DateTime.Now.AddYears(10);
                memberInfo.Password       = HiCryptographer.Md5Encrypt("888888");
                memberInfo.UserHead       = "/templates/common/images/user.png";
                if (new MemberDao().GetusernameMember(current) == null && new MemberDao().CreateMember(memberInfo))
                {
                    DistributorsInfo distributorsInfo = new DistributorsInfo();
                    distributorsInfo.UserId             = new MemberDao().GetusernameMember(current).UserId;
                    distributorsInfo.RequestAccount     = "";
                    distributorsInfo.StoreName          = current;
                    distributorsInfo.StoreDescription   = "";
                    distributorsInfo.BackImage          = "";
                    distributorsInfo.Logo               = "";
                    distributorsInfo.DistributorGradeId = distributorGradeId;
                    text = distributorsInfo.UserId.ToString();
                    distributorsInfo.ReferralPath = text2;
                    distributorsInfo.ParentUserId = new int?(Convert.ToInt32(referruserId));
                    DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorsDao().GetIsDefaultDistributorGradeInfo();
                    distributorsInfo.DistriGradeId = isDefaultDistributorGradeInfo.GradeId;
                    if (new DistributorsDao().CreateDistributor(distributorsInfo) && createtype == "1")
                    {
                        list.Add(current);
                    }
                }
                else if (createtype == "2")
                {
                    list.Add(current);
                }
            }
            return(list);
        }
 public DataTable GetTopicProducts(MemberInfo member, int topicid, int maxNum)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     builder.Append("select top " + maxNum);
     builder.Append(" p.ProductId, ProductCode, ProductName,ShortDescription,ShowSaleCounts,ThumbnailUrl40,ThumbnailUrl100,ThumbnailUrl160,MarketPrice,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice, ", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice,");
     }
     builder.Append("SaleCounts, Stock,t.DisplaySequence from vw_Hishop_BrowseProductList p inner join  Vshop_RelatedTopicProducts t on p.productid=t.RelatedProductId where t.topicid=" + topicid);
     builder.AppendFormat(" and SaleStatus = {0}", 1);
     builder.Append(" order by t.DisplaySequence asc");
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     return this.database.ExecuteDataSet(sqlStringCommand).Tables[0];
 }
Exemple #26
0
 public void UserLogin(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     MemberInfo usernameMember = new MemberInfo();
     string username = context.Request["userName"];
     string sourceData = context.Request["password"];
     usernameMember = MemberProcessor.GetusernameMember(username);
     StringBuilder builder = new StringBuilder();
     builder.Append("{");
     if (usernameMember == null)
     {
         builder.Append("\"Status\":\"-1\"");
         builder.Append("}");
         context.Response.Write(builder.ToString());
     }
     else
     {
         if (usernameMember.Password == HiCryptographer.Md5Encrypt(sourceData))
         {
             DistributorsInfo userIdDistributors = new DistributorsInfo();
             userIdDistributors = DistributorsBrower.GetUserIdDistributors(usernameMember.UserId);
             if ((userIdDistributors != null) && (userIdDistributors.UserId > 0))
             {
                 HttpContext.Current.Response.Cookies["Vshop-ReferralId"].Expires = DateTime.Now.AddDays(-1.0);
                 HttpCookie cookie = new HttpCookie("Vshop-ReferralId") {
                     Value = Globals.UrlEncode(userIdDistributors.UserId.ToString()),
                     Expires = DateTime.Now.AddYears(1)
                 };
                 HttpContext.Current.Response.Cookies.Add(cookie);
             }
             if (HttpContext.Current.Request.Cookies["Vshop-Member"] != null)
             {
                 HttpContext.Current.Response.Cookies["Vshop-Member"].Expires = DateTime.Now.AddDays(-1.0);
                 HttpCookie cookie3 = new HttpCookie("Vshop-Member") {
                     Value = usernameMember.UserId.ToString(),
                     Expires = DateTime.Now.AddYears(10)
                 };
                 HttpContext.Current.Response.Cookies.Add(cookie3);
             }
             else
             {
                 HttpCookie cookie4 = new HttpCookie("Vshop-Member") {
                     Value = Globals.UrlEncode(usernameMember.UserId.ToString()),
                     Expires = DateTime.Now.AddYears(1)
                 };
                 HttpContext.Current.Response.Cookies.Add(cookie4);
             }
             context.Session["userid"] = usernameMember.UserId.ToString();
             builder.Append("\"Status\":\"OK\"");
         }
         else
         {
             builder.Append("\"Status\":\"-2\"");
         }
         builder.Append("}");
         context.Response.Write(builder.ToString());
     }
 }
 public void UpdateLineItemQuantity(MemberInfo member, string skuId, int quantity)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_ShoppingCarts SET Quantity = @Quantity WHERE UserId = @UserId AND SkuId = @SkuId");
     this.database.AddInParameter(sqlStringCommand, "Quantity", DbType.Int32, quantity);
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, member.UserId);
     this.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
     this.database.ExecuteNonQuery(sqlStringCommand);
 }
 private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
     }
     else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
     }
     else
     {
         int maxCount        = 0;
         int yetOrderNum     = 0;
         int currentOrderNum = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,团购活动已结束,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
             yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             currentOrderNum = this.Order.GetGroupBuyOerderNumber();
             maxCount        = groupBuy.MaxCount;
             if (maxCount < yetOrderNum + currentOrderNum)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,订购数量超过订购总数,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
         {
             Task.Factory.StartNew(delegate
             {
                 TradeHelper.UserPayOrder(this.Order, false, true);
                 try
                 {
                     if (this.offlineOrder != null)
                     {
                         OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
                         OrderHelper.ConfirmTakeGoods(this.Order, true);
                     }
                     if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                     {
                         TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                     }
                     if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                     {
                         Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
                         string verificationPasswords = "";
                         if (this.Order.OrderType == OrderType.ServiceOrder)
                         {
                             verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
                         }
                         if (user != null)
                         {
                             Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(false), verificationPasswords);
                         }
                     }
                     StoresInfo storesInfo = null;
                     if (this.Order.StoreId > 0)
                     {
                         storesInfo = DepotHelper.GetStoreById(this.Order.StoreId);
                     }
                     if (storesInfo != null)
                     {
                         VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                         if (this.offlineOrder == null)
                         {
                             if (this.Order.ShippingModeId == -2)
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                             }
                             else
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                             }
                         }
                     }
                     if (this.offlineOrder == null)
                     {
                         ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                         Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo, null, this.Order, this.Order.GetTotal(false));
                     }
                     this.Order.OnPayment();
                 }
                 catch (Exception ex)
                 {
                     IDictionary <string, string> dictionary = new Dictionary <string, string>();
                     dictionary.Add("ErrorMessage", ex.Message);
                     dictionary.Add("StackTrace", ex.StackTrace);
                     if (ex.InnerException != null)
                     {
                         dictionary.Add("InnerException", ex.InnerException.ToString());
                     }
                     if (ex.GetBaseException() != null)
                     {
                         dictionary.Add("BaseException", ex.GetBaseException().Message);
                     }
                     if (ex.TargetSite != (MethodBase)null)
                     {
                         dictionary.Add("TargetSite", ex.TargetSite.ToString());
                     }
                     dictionary.Add("ExSource", ex.Source);
                     Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
                 }
                 this.Order.OnPayment();
             });
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
         else
         {
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
     }
 }
		private void UserPayOrder()
		{
			if (this.Order != null && this.Order.OrderStatus == OrderStatus.Closed)
			{
				OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
				Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
				base.Response.Write("success");
			}
			else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
			{
				Globals.WriteLog(new NameValueCollection
				{
					this.Page.Request.Form,
					this.Page.Request.QueryString
				}, "订单状态为已支付", "", "", "alipay");
				base.Response.Write("success");
			}
			else
			{
				int maxCount = 0;
				int yetOrderNum = 0;
				int currentOrderNum = 0;
				if (this.Order.GroupBuyId > 0)
				{
					GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
					if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
					{
						Globals.WriteLog(new NameValueCollection
						{
							this.Page.Request.Form,
							this.Page.Request.QueryString
						}, "错误的团购信息或者状态", "", "", "alipay");
						base.Response.Write("success");
						return;
					}
					yetOrderNum = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
					currentOrderNum = this.Order.GetGroupBuyOerderNumber();
					maxCount = groupBuy.MaxCount;
					if (maxCount < yetOrderNum + currentOrderNum)
					{
						Globals.WriteLog(new NameValueCollection
						{
							this.Page.Request.Form,
							this.Page.Request.QueryString
						}, "团购数量已超过指定数量错", "", "", "alipay");
						base.Response.Write("success");
						return;
					}
				}
				if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
				{
					Task.Factory.StartNew(delegate
					{
						TradeHelper.UserPayOrder(this.Order, false, true);
						try
						{
							if (this.offlineOrder != null)
							{
								OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
								OrderHelper.ConfirmTakeGoods(this.Order, true);
							}
							if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
							{
								TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
							}
							if (this.Order.UserId != 0 && this.Order.UserId != 1100)
							{
								Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
								string verificationPasswords = "";
								if (this.Order.OrderType == OrderType.ServiceOrder)
								{
									verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
								}
								if (user != null)
								{
									Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(false), verificationPasswords);
								}
							}
							StoresInfo storesInfo = null;
							if (this.Order.StoreId > 0)
							{
								storesInfo = DepotHelper.GetStoreById(this.Order.StoreId);
							}
							if (storesInfo != null)
							{
								VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
								if (this.offlineOrder == null)
								{
									if (this.Order.ShippingModeId == -2)
									{
										VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
									}
									else
									{
										VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
									}
								}
							}
							if (this.offlineOrder == null)
							{
								ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
								Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo, null, this.Order, this.Order.GetTotal(false));
							}
							this.Order.OnPayment();
						}
						catch (Exception ex)
						{
							IDictionary<string, string> dictionary = new Dictionary<string, string>();
							dictionary.Add("ErrorMessage", ex.Message);
							dictionary.Add("StackTrace", ex.StackTrace);
							if (ex.InnerException != null)
							{
								dictionary.Add("InnerException", ex.InnerException.ToString());
							}
							if (ex.GetBaseException() != null)
							{
								dictionary.Add("BaseException", ex.GetBaseException().Message);
							}
							if (ex.TargetSite != (MethodBase)null)
							{
								dictionary.Add("TargetSite", ex.TargetSite.ToString());
							}
							dictionary.Add("ExSource", ex.Source);
							Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
						}
					});
					base.Response.Write("success");
				}
				else
				{
					Globals.WriteLog(new NameValueCollection
					{
						this.Page.Request.Form,
						this.Page.Request.QueryString
					}, "订单不是待支付状态,或者更新订单状态失败", "", "", "alipay");
					base.Response.Write("success");
				}
			}
		}
Exemple #30
0
        //二维码

        public AbstractResponse GetQRCodeResponse(string openId)
        {
            //判断是否注册
            if (!MemberProcessor.IsExitOpenId(openId))
            {
                TextResponse response = new TextResponse
                {
                    CreateTime = DateTime.Now,
                    Content    = "您购买后系统会自动生成您的推广二维码海报."
                };
                return(response);
            }

            Hidistro.Entities.Members.MemberInfo member = MemberProcessor.GetMembers(openId);
            DistributorsInfo info = DistributorsBrower.GetUserIdDistributors(member.UserId);

            if (info == null)
            {
                TextResponse response = new TextResponse
                {
                    CreateTime = DateTime.Now,
                    Content    = "您购买后系统会自动生成您的推广二维码海报."
                };
                return(response);
            }

            ImageResponse imgResponse = new ImageResponse()
            {
                CreateTime = DateTime.Now,
                Image      = new Hishop.Weixin.MP.Domain.Image()
            };

            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

            //生成二维码图片
            string sApplicationPath = System.Web.HttpContext.Current.Request.MapPath("/Templates/vshop/default/images/qrcode/");

            string qr_code = sApplicationPath + @"/QRCodeBg.jpg";

            string qr_code_name = sApplicationPath + @"/tmp/QRCode_" + info.UserId + ".jpg";                                                     //二维码图片
            string qr_code_bg   = sApplicationPath + @"/tmp/QRCode_bg_" + info.UserId + ".jpg";                                                  //拼接后的图片
            string link         = "http://" + System.Web.HttpContext.Current.Request.Url.Host + "/vshop/Default.aspx?ReferralId=" + info.UserId; //二维码链接

            if (!File.Exists(qr_code_name))
            {
                //生成二维码名片
                string code_url = TokenApi.CreateQRCode(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, info.UserId);

                //下载二维码
                Utils.HttpHelper helper = new Utils.HttpHelper();
                helper.DownloadFiles(code_url, qr_code_name);

                //头像图片
                string img_logo_src = System.Web.HttpContext.Current.Request.MapPath("/") + info.Logo;   //拼接后的图片
                Bitmap img_logo     = new Bitmap(img_logo_src);

                //拼接
                File.Copy(qr_code, qr_code_bg, false);

                Bitmap newImg = new Bitmap(qr_code);

                Graphics g = Graphics.FromImage(newImg);

                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                //下面这个也设成高质量
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                //下面这个设成High
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

                System.Drawing.Image erweima = new Bitmap(qr_code_name);
                g.DrawImage(erweima, 158, 430, 204, 204);   //画二维码

                g.DrawImage(img_logo, 35, 26, 77, 77);      //画头像

                //我是...
                SolidBrush drawBrush  = new SolidBrush(Color.Red);
                SolidBrush drawBrush2 = new SolidBrush(Color.Black);

                Font drawFont = new Font("Arial", 16, FontStyle.Regular, GraphicsUnit.Pixel);

                MemberGradeInfo memberGrade = MemberProcessor.GetMemberGrade(member.GradeId);
                string          str         = member.UserName + " (" + memberGrade.Name + ")";
                string          str2        = info.StoreName + " 代言";

                g.DrawString("我是 ", drawFont, drawBrush2, 140, 50);
                g.DrawString(str, drawFont, drawBrush, 180, 50);

                g.DrawString("我为 ", drawFont, drawBrush2, 140, 75);
                g.DrawString(str2, drawFont, drawBrush, 180, 75);

                g.Dispose();
                newImg.Save(qr_code_bg);
            }

            //Utils.LogWriter.SaveLog("素材图片:" + qr_code_bg);

            //上传素材
            imgResponse.Image.MediaId = TokenApi.AddNews(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, qr_code_bg);
            //Utils.LogWriter.SaveLog("上传素材ID:" + imgResponse.Image.MediaId);

            return(imgResponse);
        }
Exemple #31
0
        //扫描二维码事件
        public override AbstractResponse OnEvent_ScanRequest(ScanEventRequest scanEventRequest)
        {
            Utils.LogWriter.SaveLog("产生扫码事件:" + scanEventRequest.EventKey);
            if (!string.IsNullOrEmpty(scanEventRequest.EventKey))
            {
                /*
                 * 打开分享图片
                 * 获取用户信息
                 *
                 * */

                string open_id        = scanEventRequest.FromUserName;
                int    ReferralUserId = int.Parse(scanEventRequest.EventKey);

                //判断是否会员
                if (MemberProcessor.IsExitOpenId(open_id))
                {
                    //Utils.LogWriter.SaveLog("已存在会员:" + open_id);
                    Hidistro.Entities.Members.MemberInfo m = MemberProcessor.GetMembers(open_id);
                    if (m.ReferralUserId == 0 && m.OpenId != open_id)
                    {
                        m.ReferralUserId = ReferralUserId;
                        MemberProcessor.UpdateMember(m);
                        Utils.LogWriter.SaveLog("扫码填补上级ID:" + ReferralUserId);
                        return(null);
                    }

                    //Utils.LogWriter.SaveLog("返回提示:" + open_id);
                    TextResponse response = new TextResponse
                    {
                        CreateTime   = DateTime.Now,
                        Content      = "您已经有上级了哦",
                        ToUserName   = scanEventRequest.FromUserName,
                        FromUserName = scanEventRequest.ToUserName
                    };
                    return(response);
                }

                SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

                JObject wx_user_info = TokenApi.GetUserInfo(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, open_id);
                Utils.LogWriter.SaveLog("wx_user_info:" + wx_user_info["nickname"].ToString());

                string generateId = Globals.GetGenerateId();
                Hidistro.Entities.Members.MemberInfo member = new Hidistro.Entities.Members.MemberInfo
                {
                    GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                    UserName       = Globals.UrlDecode(wx_user_info["nickname"].ToString()),
                    OpenId         = open_id,
                    CreateDate     = DateTime.Now,
                    SessionId      = generateId,
                    SessionEndTime = DateTime.Now.AddYears(10),
                    ReferralUserId = ReferralUserId
                };

                //Utils.LogWriter.SaveLog("创建客户资料");
                MemberProcessor.CreateMember(member);
            }

            return(null);
        }
Exemple #32
0
        //关注事件
        public override AbstractResponse OnEvent_SubscribeRequest(SubscribeEventRequest subscribeEventRequest)
        {
            Utils.LogWriter.SaveLog("产生关注事件:" + subscribeEventRequest.EventKey);
            string event_key = subscribeEventRequest.EventKey;

            if (!string.IsNullOrEmpty(event_key) && event_key.IndexOf("qrscene_") != -1)
            {
                //关联上级

                /*
                 * 打开分享图片
                 * 获取用户信息
                 *
                 * */

                string open_id = subscribeEventRequest.FromUserName;
                Utils.LogWriter.SaveLog("产生关注事件step1:" + open_id);
                int ReferralUserId = int.Parse(subscribeEventRequest.EventKey.Replace("qrscene_", ""));
                Utils.LogWriter.SaveLog("产生关注事件step2:" + ReferralUserId);

                //判断是否会员
                if (MemberProcessor.IsExitOpenId(open_id))
                {
                    Utils.LogWriter.SaveLog("产生关注事件step3:已存在会员信息");
                    Hidistro.Entities.Members.MemberInfo m = MemberProcessor.GetMembers(open_id);
                    if (m.ReferralUserId == 0 && m.OpenId != open_id)
                    {
                        m.ReferralUserId = ReferralUserId;
                        MemberProcessor.UpdateMember(m);
                        //Utils.LogWriter.SaveLog("扫码填补上级ID:" + ReferralUserId);
                        return(null);
                    }
                }
                else
                {
                    Utils.LogWriter.SaveLog("产生关注事件step3:不存在会员信息");
                    //关联上级并增加客户资料
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

                    JObject wx_user_info = TokenApi.GetUserInfo(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, open_id);
                    Utils.LogWriter.SaveLog("产生关注事件step4:" + wx_user_info["nickname"].ToString());

                    string generateId = Globals.GetGenerateId();
                    Hidistro.Entities.Members.MemberInfo member = new Hidistro.Entities.Members.MemberInfo
                    {
                        GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                        UserName       = Globals.UrlDecode(wx_user_info["nickname"].ToString()),
                        OpenId         = open_id,
                        CreateDate     = DateTime.Now,
                        SessionId      = generateId,
                        SessionEndTime = DateTime.Now.AddYears(10),
                        ReferralUserId = ReferralUserId
                    };

                    Utils.LogWriter.SaveLog("创建客户资料");
                    MemberProcessor.CreateMember(member);

                    //获取上级
                    Hidistro.Entities.Members.MemberInfo parentInfo = MemberProcessor.GetMember(ReferralUserId);

                    //获取第多少个会员
                    int count = MemberProcessor.GetMemberCount();

                    TextResponse r = new TextResponse
                    {
                        CreateTime = DateTime.Now,
                        Content    = "恭喜您!您已通过【" + parentInfo.UserName + "】的推荐成为本站会员,您是本站第" + (10000 + count)
                                     + "个会员,点击右下方【创业良机】~【组建团队】进入财富倍增快通道。",
                        ToUserName   = subscribeEventRequest.FromUserName,
                        FromUserName = subscribeEventRequest.ToUserName
                    };
                    return(r);
                }
            }

            ReplyInfo subscribeReply = ReplyHelper.GetSubscribeReply();

            if (subscribeReply == null)
            {
                return(null);
            }
            subscribeReply.Keys = "登录";
            AbstractResponse response = this.GetResponse(subscribeReply, subscribeEventRequest.FromUserName);

            if (response == null)
            {
                this.GotoManyCustomerService(subscribeEventRequest);
            }
            response.ToUserName   = subscribeEventRequest.FromUserName;
            response.FromUserName = subscribeEventRequest.ToUserName;
            return(response);
        }
Exemple #33
0
 private void Vote(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     int result = 1;
     int.TryParse(context.Request["voteId"], out result);
     string itemIds = context.Request["itemIds"];
     itemIds = itemIds.Remove(itemIds.Length - 1);
     if (MemberProcessor.GetCurrentMember() == null)
     {
         MemberInfo member = new MemberInfo();
         string generateId = Globals.GetGenerateId();
         member.GradeId = MemberProcessor.GetDefaultMemberGrade();
         member.UserName = "";
         member.OpenId = "";
         member.CreateDate = DateTime.Now;
         member.SessionId = generateId;
         member.SessionEndTime = DateTime.Now;
         MemberProcessor.CreateMember(member);
         member = MemberProcessor.GetMember(generateId);
         HttpCookie cookie = new HttpCookie("Vshop-Member") {
             Value = member.UserId.ToString(),
             Expires = DateTime.Now.AddYears(10)
         };
         HttpContext.Current.Response.Cookies.Add(cookie);
     }
     StringBuilder builder = new StringBuilder();
     builder.Append("{");
     if (VshopBrowser.Vote(result, itemIds))
     {
         builder.Append("\"Status\":\"OK\"");
     }
     else
     {
         builder.Append("\"Status\":\"Error\"");
     }
     builder.Append("}");
     context.Response.Write(builder.ToString());
 }
Exemple #34
0
 private void UserPayOrder()
 {
     if (this.Order != null && this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
         this.ResponseReturn(true, "");
     }
     else if ((this.Order != null && this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid) || (this.offlineOrder != null && this.offlineOrder.Status == 1))
     {
         this.ResponseReturn(true, "");
     }
     else
     {
         try
         {
             int maxCount        = 0;
             int yetOrderNum     = 0;
             int currentOrderNum = 0;
             if (this.Order != null)
             {
                 if (this.Order.GroupBuyId > 0)
                 {
                     GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                     if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                     {
                         return;
                     }
                     yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                     currentOrderNum = this.Order.GetGroupBuyOerderNumber();
                     maxCount        = groupBuy.MaxCount;
                     if (maxCount < yetOrderNum + currentOrderNum)
                     {
                         return;
                     }
                 }
                 if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
                 {
                     Task.Factory.StartNew(delegate
                     {
                         TradeHelper.UserPayOrder(this.Order, false, true);
                         try
                         {
                             if (this.offlineOrder != null)
                             {
                                 OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
                                 OrderHelper.ConfirmTakeGoods(this.Order, true);
                             }
                             if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                             {
                                 TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                             }
                             if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                             {
                                 string verificationPasswords = "";
                                 if (this.Order.OrderType == OrderType.ServiceOrder)
                                 {
                                     verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
                                 }
                                 Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
                                 if (user != null)
                                 {
                                     Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(true), verificationPasswords);
                                 }
                             }
                             StoresInfo storesInfo2 = null;
                             if (this.Order.StoreId > 0)
                             {
                                 storesInfo2 = DepotHelper.GetStoreById(this.Order.StoreId);
                             }
                             if (storesInfo2 != null)
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                                 if (this.offlineOrder == null)
                                 {
                                     if (this.Order.ShippingModeId == -2)
                                     {
                                         VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                                     }
                                     else
                                     {
                                         VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                                     }
                                 }
                             }
                             if (this.offlineOrder == null)
                             {
                                 ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                                 Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo2, null, this.Order, this.Order.GetTotal(true));
                             }
                             this.Order.OnPayment();
                         }
                         catch (Exception ex2)
                         {
                             IDictionary <string, string> dictionary2 = new Dictionary <string, string>();
                             dictionary2.Add("ErrorMessage", ex2.Message);
                             dictionary2.Add("StackTrace", ex2.StackTrace);
                             if (ex2.InnerException != null)
                             {
                                 dictionary2.Add("InnerException", ex2.InnerException.ToString());
                             }
                             if (ex2.GetBaseException() != null)
                             {
                                 dictionary2.Add("BaseException", ex2.GetBaseException().Message);
                             }
                             if (ex2.TargetSite != (MethodBase)null)
                             {
                                 dictionary2.Add("TargetSite", ex2.TargetSite.ToString());
                             }
                             dictionary2.Add("ExSource", ex2.Source);
                             Globals.AppendLog(dictionary2, "支付更新订单收款记录或者消息通知时出错:" + ex2.Message, "", "", "UserPay");
                         }
                         this.Order.OnPayment();
                         this.ResponseReturn(true, "");
                     });
                 }
                 if (this.Order.FightGroupId > 0)
                 {
                     VShopHelper.SetFightGroupSuccess(this.Order.FightGroupId);
                 }
             }
             if (this.offlineOrder != null && this.offlineOrder.Status == 0)
             {
                 this.offlineOrder.Status  = 1;
                 this.offlineOrder.PayTime = DateTime.Now;
                 if (StoresHelper.UpdateStoreCollectionInfo(this.offlineOrder) && this.isOfflineOrder)
                 {
                     string     text      = "";
                     StoresInfo storeById = DepotHelper.GetStoreById(this.offlineOrder.StoreId);
                     if (storeById != null)
                     {
                         text = storeById.StoreName;
                         StoreBalanceDetailInfo storeBalanceDetailInfo = new StoreBalanceDetailInfo();
                         storeBalanceDetailInfo.StoreId         = this.offlineOrder.StoreId;
                         storeBalanceDetailInfo.TradeDate       = DateTime.Now;
                         storeBalanceDetailInfo.TradeType       = StoreTradeTypes.OfflineCashier;
                         storeBalanceDetailInfo.Expenses        = default(decimal);
                         storeBalanceDetailInfo.Income          = this.offlineOrder.PayAmount;
                         storeBalanceDetailInfo.Balance         = storeById.Balance + this.offlineOrder.PayAmount;
                         storeBalanceDetailInfo.Remark          = "线下收银(" + this.offlineOrder.OrderId + ")";
                         storeBalanceDetailInfo.ManagerUserName = "";
                         storeBalanceDetailInfo.TradeNo         = this.offlineOrder.OrderId;
                         storeBalanceDetailInfo.CreateTime      = DateTime.Now;
                         storeBalanceDetailInfo.PlatCommission  = decimal.Zero;
                         if (StoreBalanceHelper.AddBalanceDetailInfo(storeBalanceDetailInfo))
                         {
                             StoresInfo storesInfo = storeById;
                             storesInfo.Balance += this.offlineOrder.PayAmount;
                             StoresHelper.UpdateStore(storeById);
                         }
                     }
                     if (storeById != null)
                     {
                         VShopHelper.AppPsuhRecordForStore(storeById.StoreId, this.offlineOrder.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             IDictionary <string, string> dictionary = new Dictionary <string, string>();
             dictionary.Add("ErrorMessage", ex.Message);
             dictionary.Add("StackTrace", ex.StackTrace);
             if (ex.InnerException != null)
             {
                 dictionary.Add("InnerException", ex.InnerException.ToString());
             }
             if (ex.GetBaseException() != null)
             {
                 dictionary.Add("BaseException", ex.GetBaseException().Message);
             }
             if (ex.TargetSite != (MethodBase)null)
             {
                 dictionary.Add("TargetSite", ex.TargetSite.ToString());
             }
             dictionary.Add("ExSource", ex.Source);
             Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay1");
         }
         this.ResponseReturn(true, "");
     }
 }
 public ShoppingCartInfo GetShoppingCart(MemberInfo member)
 {
     ShoppingCartInfo info = new ShoppingCartInfo();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ShoppingCarts WHERE UserId = @UserId");
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, member.UserId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         while (reader.Read())
         {
             ShoppingCartItemInfo item = this.GetCartItemInfo(member, (string) reader["SkuId"], (int) reader["Quantity"]);
             if (item != null)
             {
                 info.LineItems.Add(item);
             }
         }
     }
     return info;
 }
Exemple #36
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderCreate(string templateId, SiteSettings settings, OrderInfo order, MemberInfo user)
 {
     TemplateMessage message = null;
     if (!string.IsNullOrWhiteSpace(user.OpenId))
     {
         string weixinToken = settings.WeixinToken;
         TemplateMessage message2 = new TemplateMessage {
             Url = "",
             TemplateId = templateId,
             Touser = user.OpenId
         };
         TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[3];
         TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
             Name = "first",
             Value = "您的订单已提交成功!"
         };
         partArray[0] = part;
         TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
             Name = "orderID",
             Value = order.OrderId
         };
         partArray[1] = part2;
         TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
             Name = "orderMoneySum",
             Color = "#ff3300",
             Value = "¥" + order.GetTotal().ToString("F2")
         };
         partArray[2] = part3;
         message2.Data = partArray;
         message = message2;
     }
     return message;
 }
Exemple #37
0
 public void RegisterUser(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     string username = context.Request["userName"];
     string sourceData = context.Request["password"];
     string str3 = context.Request["passagain"];
     StringBuilder builder = new StringBuilder();
     builder.Append("{");
     if (sourceData == str3)
     {
         MemberInfo info = new MemberInfo();
         if (MemberProcessor.GetusernameMember(username) == null)
         {
             MemberInfo member = new MemberInfo();
             string generateId = Globals.GetGenerateId();
             member.GradeId = MemberProcessor.GetDefaultMemberGrade();
             member.UserName = username;
             member.CreateDate = DateTime.Now;
             member.SessionId = generateId;
             member.SessionEndTime = DateTime.Now.AddYears(10);
             member.Password = HiCryptographer.Md5Encrypt(sourceData);
             MemberProcessor.CreateMember(member);
             MemberInfo info3 = MemberProcessor.GetMember(generateId);
             if (HttpContext.Current.Request.Cookies["Vshop-Member"] != null)
             {
                 HttpContext.Current.Response.Cookies["Vshop-Member"].Expires = DateTime.Now.AddDays(-1.0);
                 HttpCookie cookie = new HttpCookie("Vshop-Member") {
                     Value = info3.UserId.ToString(),
                     Expires = DateTime.Now.AddYears(10)
                 };
                 HttpContext.Current.Response.Cookies.Add(cookie);
             }
             else
             {
                 HttpCookie cookie3 = new HttpCookie("Vshop-Member") {
                     Value = info3.UserId.ToString(),
                     Expires = DateTime.Now.AddYears(10)
                 };
                 HttpContext.Current.Response.Cookies.Add(cookie3);
             }
             context.Session["userid"] = info3.UserId.ToString();
             builder.Append("\"Status\":\"OK\"");
         }
         else
         {
             builder.Append("\"Status\":\"-1\"");
         }
     }
     else
     {
         builder.Append("\"Status\":\"-2\"");
     }
     builder.Append("}");
     context.Response.Write(builder.ToString());
 }
Exemple #38
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderPay(string templateId, SiteSettings settings, MemberInfo user, string orderId, decimal fee)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单" + orderId + "支付成功"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "orderMoneySum",
         Color = "#ff3300",
         Value = "¥" + fee.ToString("F2")
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "orderProductName",
         Value = ""
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Exemple #39
0
 private void GetPrize(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     int result = 1;
     int.TryParse(context.Request["activityid"], out result);
     LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(result);
     int userPrizeCount = VshopBrowser.GetUserPrizeCount(result);
     if (MemberProcessor.GetCurrentMember() == null)
     {
         MemberInfo member = new MemberInfo();
         string generateId = Globals.GetGenerateId();
         member.GradeId = MemberProcessor.GetDefaultMemberGrade();
         member.UserName = "";
         member.OpenId = "";
         member.CreateDate = DateTime.Now;
         member.SessionId = generateId;
         member.SessionEndTime = DateTime.Now;
         MemberProcessor.CreateMember(member);
         member = MemberProcessor.GetMember(generateId);
         HttpCookie cookie = new HttpCookie("Vshop-Member") {
             Value = member.UserId.ToString(),
             Expires = DateTime.Now.AddYears(10)
         };
         HttpContext.Current.Response.Cookies.Add(cookie);
     }
     StringBuilder builder = new StringBuilder();
     builder.Append("{");
     if (userPrizeCount >= lotteryActivity.MaxNum)
     {
         builder.Append("\"No\":\"-1\"");
         builder.Append("}");
         context.Response.Write(builder.ToString());
     }
     else if ((DateTime.Now < lotteryActivity.StartTime) || (DateTime.Now > lotteryActivity.EndTime))
     {
         builder.Append("\"No\":\"-3\"");
         builder.Append("}");
         context.Response.Write(builder.ToString());
     }
     else
     {
         PrizeQuery page = new PrizeQuery {
             ActivityId = result
         };
         List<PrizeRecordInfo> prizeList = VshopBrowser.GetPrizeList(page);
         int num3 = 0;
         int num4 = 0;
         int num5 = 0;
         int num6 = 0;
         int num7 = 0;
         int num8 = 0;
         if ((prizeList != null) && (prizeList.Count > 0))
         {
             num3 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "一等奖");
             num4 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "二等奖");
             num5 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "三等奖");
         }
         PrizeRecordInfo model = new PrizeRecordInfo {
             PrizeTime = new DateTime?(DateTime.Now),
             UserID = Globals.GetCurrentMemberUserId(),
             ActivityName = lotteryActivity.ActivityName,
             ActivityID = result,
             IsPrize = true
         };
         List<PrizeSetting> prizeSettingList = lotteryActivity.PrizeSettingList;
         decimal num9 = prizeSettingList[0].Probability * 100M;
         decimal num10 = prizeSettingList[1].Probability * 100M;
         decimal num11 = prizeSettingList[2].Probability * 100M;
         int num15 = new Random(Guid.NewGuid().GetHashCode()).Next(1, 0x2711);
         if (prizeSettingList.Count > 3)
         {
             decimal num12 = prizeSettingList[3].Probability * 100M;
             decimal num13 = prizeSettingList[4].Probability * 100M;
             decimal num14 = prizeSettingList[5].Probability * 100M;
             num6 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "四等奖");
             num7 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "五等奖");
             num8 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "六等奖");
             if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3))
             {
                 builder.Append("\"No\":\"9\"");
                 model.Prizelevel = "一等奖";
                 model.PrizeName = prizeSettingList[0].PrizeName;
             }
             else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4))
             {
                 builder.Append("\"No\":\"11\"");
                 model.Prizelevel = "二等奖";
                 model.PrizeName = prizeSettingList[1].PrizeName;
             }
             else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5))
             {
                 builder.Append("\"No\":\"1\"");
                 model.Prizelevel = "三等奖";
                 model.PrizeName = prizeSettingList[2].PrizeName;
             }
             else if ((num15 < num12) && (prizeSettingList[3].PrizeNum > num6))
             {
                 builder.Append("\"No\":\"3\"");
                 model.Prizelevel = "四等奖";
                 model.PrizeName = prizeSettingList[3].PrizeName;
             }
             else if ((num15 < num13) && (prizeSettingList[4].PrizeNum > num7))
             {
                 builder.Append("\"No\":\"5\"");
                 model.Prizelevel = "五等奖";
                 model.PrizeName = prizeSettingList[4].PrizeName;
             }
             else if ((num15 < num14) && (prizeSettingList[5].PrizeNum > num8))
             {
                 builder.Append("\"No\":\"7\"");
                 model.Prizelevel = "六等奖";
                 model.PrizeName = prizeSettingList[5].PrizeName;
             }
             else
             {
                 model.IsPrize = false;
                 builder.Append("\"No\":\"0\"");
             }
         }
         else if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3))
         {
             builder.Append("\"No\":\"9\"");
             model.Prizelevel = "一等奖";
             model.PrizeName = prizeSettingList[0].PrizeName;
         }
         else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4))
         {
             builder.Append("\"No\":\"11\"");
             model.Prizelevel = "二等奖";
             model.PrizeName = prizeSettingList[1].PrizeName;
         }
         else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5))
         {
             builder.Append("\"No\":\"1\"");
             model.Prizelevel = "三等奖";
             model.PrizeName = prizeSettingList[2].PrizeName;
         }
         else
         {
             model.IsPrize = false;
             builder.Append("\"No\":\"0\"");
         }
         builder.Append("}");
         if (context.Request["activitytype"] != "scratch")
         {
             VshopBrowser.AddPrizeRecord(model);
         }
         context.Response.Write(builder.ToString());
     }
 }
Exemple #40
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderSend(string templateId, SiteSettings settings, MemberInfo user, OrderInfo order)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[5];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单号已经发货"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "keyword1",
         Value = order.OrderId
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "keyword2",
         Value = order.ExpressCompanyName
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "keyword3",
         Value = order.ShipOrderNumber
     };
     partArray[3] = part4;
     TemplateMessage.MessagePart part5 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[4] = part5;
     message2.Data = partArray;
     return message2;
 }
Exemple #41
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderRefund(string templateId, SiteSettings settings, MemberInfo user, string orderId, decimal amount)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[4];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单号为" + orderId + "的订单已经退款"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "reason",
         Value = "-"
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "refund",
         Color = "#ff3300",
         Value = "¥" + amount.ToString("F2")
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "remark",
         Value = ""
     };
     partArray[3] = part4;
     message2.Data = partArray;
     return message2;
 }
Exemple #42
0
        public static bool CreateDistributorByUserIds(string userids, ref string msg)
        {
            bool flag = false;

            userids = userids.Trim(new char[]
            {
                ','
            });
            string[] array = userids.Split(new char[]
            {
                ','
            });
            bool result;

            if (array.Length == 0)
            {
                msg    = "没有会员被选择!";
                result = flag;
            }
            else
            {
                DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorGradeDao().GetIsDefaultDistributorGradeInfo();
                if (isDefaultDistributorGradeInfo == null)
                {
                    msg    = "默认分销商等级未设置,无法生成分销商!";
                    result = flag;
                }
                else
                {
                    Dictionary <int, bool> existDistributorList = new DistributorsDao().GetExistDistributorList(userids);
                    List <int>             list = new List <int>();
                    string[] array2             = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string s   = array2[i];
                        int    num = 0;
                        if (int.TryParse(s, out num) && !existDistributorList.ContainsKey(num))
                        {
                            list.Add(num);
                        }
                    }
                    if (list.Count == 0)
                    {
                        msg    = "选择的会员已经是分销商,操作终止!";
                        result = flag;
                    }
                    else
                    {
                        int          num2           = 0;
                        SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
                        foreach (int current in list)
                        {
                            int userId = current;
                            Hidistro.Entities.Members.MemberInfo member = MemberHelper.GetMember(userId);
                            int              referralUserId             = member.ReferralUserId;
                            string           referralPath     = string.Empty;
                            DistributorsInfo distributorsInfo = new DistributorsInfo();
                            distributorsInfo.DistributorGradeId = DistributorGrade.OneDistributor;
                            if (referralUserId > 0)
                            {
                                DistributorsInfo distributorInfo = new DistributorsDao().GetDistributorInfo(referralUserId);
                                if (distributorInfo != null)
                                {
                                    if (!string.IsNullOrEmpty(distributorInfo.ReferralPath) && !distributorInfo.ReferralPath.Contains("|"))
                                    {
                                        referralPath = distributorInfo.ReferralPath + "|" + distributorInfo.UserId.ToString();
                                    }
                                    else if (!string.IsNullOrEmpty(distributorInfo.ReferralPath) && distributorInfo.ReferralPath.Contains("|"))
                                    {
                                        referralPath = distributorInfo.ReferralPath.Split(new char[]
                                        {
                                            '|'
                                        })[1] + "|" + distributorInfo.UserId.ToString();
                                    }
                                    else
                                    {
                                        referralPath = distributorInfo.UserId.ToString();
                                    }
                                    if (!string.IsNullOrEmpty(distributorInfo.Logo))
                                    {
                                        distributorsInfo.Logo = distributorInfo.Logo;
                                    }
                                    if (distributorInfo.DistributorGradeId == DistributorGrade.OneDistributor)
                                    {
                                        distributorsInfo.DistributorGradeId = DistributorGrade.TowDistributor;
                                    }
                                    else if (distributorInfo.DistributorGradeId == DistributorGrade.TowDistributor)
                                    {
                                        distributorsInfo.DistributorGradeId = DistributorGrade.ThreeDistributor;
                                    }
                                    else
                                    {
                                        distributorsInfo.DistributorGradeId = DistributorGrade.ThreeDistributor;
                                    }
                                }
                            }
                            if (string.IsNullOrEmpty(distributorsInfo.Logo))
                            {
                                distributorsInfo.Logo = masterSettings.DistributorLogoPic;
                            }
                            distributorsInfo.UserId           = member.UserId;
                            distributorsInfo.RequestAccount   = "";
                            distributorsInfo.StoreName        = Globals.GetStoreNameByUserIDAndName(member.UserId, member.UserName, member.OpenId, masterSettings.SiteName);
                            distributorsInfo.StoreDescription = "";
                            distributorsInfo.BackImage        = "";
                            distributorsInfo.DistriGradeId    = isDefaultDistributorGradeInfo.GradeId;
                            distributorsInfo.ReferralPath     = referralPath;
                            distributorsInfo.ParentUserId     = new int?(Convert.ToInt32(referralUserId));
                            if (new DistributorsDao().CreateDistributor(distributorsInfo))
                            {
                                num2++;
                            }
                        }
                        if (num2 > 0)
                        {
                            msg  = "成功生成" + num2.ToString() + "位分销商,请检查!";
                            flag = true;
                        }
                        else
                        {
                            msg  = "生成分销商失败!";
                            flag = false;
                        }
                        result = flag;
                    }
                }
            }
            return(result);
        }
 public DataTable GetProducts(MemberInfo member, int? topicId, int? categoryId, int distributorId, string keyWord, int pageNumber, int maxNum, out int toal, string sort, bool isAsc = false)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     builder.AppendFormat("ProductId,ProductName,ProductCode,ShowSaleCounts AS SaleCounts,ShortDescription,", maxNum);
     builder.Append(" ThumbnailUrl60,ThumbnailUrl100,ThumbnailUrl160,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310,MarketPrice,VistiCounts,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = vw_Hishop_BrowseProductList.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = vw_Hishop_BrowseProductList.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice");
     }
     StringBuilder builder2 = new StringBuilder();
     builder2.Append(" SaleStatus=1");
     if (topicId.HasValue)
     {
         builder2.AppendFormat(" AND ProductId IN (SELECT RelatedProductId FROM Vshop_RelatedTopicProducts WHERE TopicId = {0})", topicId.Value);
     }
     if (categoryId.HasValue)
     {
         CategoryInfo category = new CategoryDao().GetCategory(categoryId.Value);
         if (category != null)
         {
             builder2.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path);
         }
     }
     if (!string.IsNullOrEmpty(keyWord))
     {
         builder2.AppendFormat(" AND (ProductName LIKE '%{0}%' OR ProductCode LIKE '%{0}%')", keyWord);
     }
     if (distributorId > 0)
     {
         builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", distributorId);
     }
     if (string.IsNullOrWhiteSpace(sort))
     {
         sort = "ProductId";
     }
     DbQueryResult result = DataHelper.PagingByRownumber(pageNumber, maxNum, sort, isAsc ? SortAction.Asc : SortAction.Desc, true, "vw_Hishop_BrowseProductList", "ProductId", builder2.ToString(), builder.ToString());
     DataTable data = (DataTable) result.Data;
     toal = result.TotalRecords;
     return data;
 }
Exemple #44
0
 private static TemplateMessage GenerateWeixinMessageWhenOrderClose(string templateId, SiteSettings settings, MemberInfo user, OrderInfo order, string reason)
 {
     if (string.IsNullOrWhiteSpace(user.OpenId))
     {
         return null;
     }
     string weixinToken = settings.WeixinToken;
     TemplateMessage message2 = new TemplateMessage {
         Url = "",
         TemplateId = templateId,
         Touser = user.OpenId
     };
     TemplateMessage.MessagePart[] partArray = new TemplateMessage.MessagePart[5];
     TemplateMessage.MessagePart part = new TemplateMessage.MessagePart {
         Name = "first",
         Value = "您好,您的订单已关闭,请核对"
     };
     partArray[0] = part;
     TemplateMessage.MessagePart part2 = new TemplateMessage.MessagePart {
         Name = "transid",
         Value = order.OrderId
     };
     partArray[1] = part2;
     TemplateMessage.MessagePart part3 = new TemplateMessage.MessagePart {
         Name = "fee",
         Color = "#ff3300",
         Value = "¥" + order.GetTotal().ToString("F2")
     };
     partArray[2] = part3;
     TemplateMessage.MessagePart part4 = new TemplateMessage.MessagePart {
         Name = "pay_time",
         Value = (order.PayDate.ToString() != "") ? DateTime.Parse(order.PayDate.ToString()).ToString("M月d日 HH:mm:ss") : DateTime.Parse(order.OrderDate.ToString()).ToString("M月d日 HH:mm:ss")
     };
     partArray[3] = part4;
     TemplateMessage.MessagePart part5 = new TemplateMessage.MessagePart {
         Name = "remark",
         Color = "#000000",
         Value = "关闭原因:" + reason
     };
     partArray[4] = part5;
     message2.Data = partArray;
     return message2;
 }