예제 #1
0
        public static int AddModel(RechargeRange model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RechargeRange(");
            strSql.Append("weixinId,UseRange,Remark");
            strSql.Append(") values (");
            strSql.Append("@weixinId,@UseRange,@Remark ");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");

            string obj = HotelCloud.SqlServer.SQLHelper.Get_Value(strSql.ToString(), HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                { "UseRange", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.UseRange
                  } },
                { "Remark", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.Remark
                  } },
                { "WeixinId", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.WeixinId.ToString()
                  } }
            });

            if (!string.IsNullOrEmpty(obj))
            {
                return(Convert.ToInt32(obj));
            }
            return(0);
        }
예제 #2
0
        public ActionResult RechargeUser()
        {

            string key = HotelCloud.Common.HCRequest.GetString("key");
            string hotelweixinId = key.Split('@')[0];
            string userweixinId = key.Split('@')[1];

            int page = 1;
            int pagesize = 30;
            int count = 0;

            DataTable dblist = RechargeCard.GeteRechargeCardList(hotelweixinId, out count, page, pagesize, "", "");
            var list = DataTableToEntity.GetEntities<RechargeCard>(dblist);
            ViewData["list"] = list;

            DataTable db_range = RechargeRange.GetRechargeRange(hotelweixinId);
            var range = DataTableToEntity.GetEntity<RechargeRange>(db_range);
            ViewData["range"] = range;


            DataTable db_member = RechargeCard.GetRechargeMemberInfo(hotelweixinId, userweixinId);

            if (db_member.Rows.Count == 0)
            {
                return RedirectToAction("MemberRegister", "MemberCardA", new { id = RouteData.Values["id"], key = HotelCloud.Common.HCRequest.GetString("key") });
            }


            ViewData["balance"] = Convert.ToDouble(db_member.Rows[0]["balance"].ToString());

            ViewData["count"] = count;
            ViewData["page"] = page;
            ViewData["pagesize"] = pagesize;

            return View();


        }
예제 #3
0
        public static int UpdateModel(RechargeRange model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RechargeRange set ");
            strSql.Append(" UseRange = @UseRange , ");
            strSql.Append(" Remark = @Remark  ");
            strSql.Append(" where weixinId=@weixinId  ");

            int row = HotelCloud.SqlServer.SQLHelper.Run_SQL(strSql.ToString(), HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                { "UseRange", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.UseRange
                  } },
                { "Remark", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.Remark
                  } },
                { "WeixinId", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.WeixinId.ToString()
                  } }
            });

            return(row);
        }
예제 #4
0
        public ActionResult CardPay(string orderNo)
        {
            try
            {
                orderNo = orderNo.ToLower();
                string key           = HotelCloud.Common.HCRequest.GetString("key");
                string hotelweixinId = key.Split('@')[0];
                string userweixinId  = key.Split('@')[1];

                #region 获取appid Ashbur20170427
                string appid = "wx9f84537c7ce94a29";
                var    dt    = HotelCloud.SqlServer.SQLHelper.Get_DataTable(@"select top 1 appid from WeiXin..WeiXinNO with(nolock)  where WeiXinID=@WeiXinID and iszhifu=1", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                    { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                          ParamValue = hotelweixinId.Trim()
                      } }
                });
                if (dt.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dt.Rows)
                    {
                        appid = dr["appid"].ToString().Trim();
                    }
                }
                ViewData["appid"] = appid;
                #endregion

                ViewData["edition"] = HotelCloud.SqlServer.SQLHelper.Get_Value("select  edition from WeiXin..WeiXinNO with(nolock)  where WeiXinID=@WeiXinID",
                                                                               HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam>
                {
                    { "WeiXinID", new HotelCloud.SqlServer.DBParam {
                          ParamValue = hotelweixinId.Trim()
                      } }
                });


                DataTable db_TradeOrder = WeiXin.Models.Home.RechargeUser.GeteRechargUserByTradeOrderNo(orderNo);
                if (db_TradeOrder.Rows.Count > 0)
                {
                    //return RedirectToAction("ProductErrMsg", "Product", new { id = RouteData.Values["id"], errmsg = "订单已支付!", key = HotelCloud.Common.HCRequest.GetString("key") });
                }



                if (orderNo.Contains("k"))
                {
                    return(View());
                }


                string wkn_shareopenid = hotel3g.Models.DAL.PromoterDAL.WX_ShareLinkUserWeiXinId;


                DataTable db_member = RechargeCard.GetRechargeMemberInfo(hotelweixinId, userweixinId);

                //if (db_member.Rows.Count == 0)
                //{
                //    return RedirectToAction("ProductErrMsg", "Product", new { id = RouteData.Values["id"], errmsg = "抱歉,支付失败!", key = HotelCloud.Common.HCRequest.GetString("key") });
                //}



                ViewData["balance"] = 0;
                if (db_member.Rows.Count > 0)
                {
                    ViewData["balance"] = Convert.ToDouble(db_member.Rows[0]["balance"].ToString());
                }
                else
                {
                    if (!userweixinId.Contains(wkn_shareopenid))
                    {
                        MemberHelper.InsertUserAccount(hotelweixinId, userweixinId, "付款生成账号");
                    }
                }


                decimal payMoney = GetPayOrderMoney(orderNo);

                if (payMoney <= 0)
                {
                    return(RedirectToAction("ProductErrMsg", "Product", new { id = RouteData.Values["id"], errmsg = "找不到该产品!", key = HotelCloud.Common.HCRequest.GetString("key") }));
                }

                ViewData["payMoney"] = payMoney;


                int isMustWeixin = 0;

                DataTable     db_range  = RechargeRange.GetRechargeRange(hotelweixinId);
                var           range     = DataTableToEntity.GetEntity <RechargeRange>(db_range);
                List <string> list_rang = new List <string>();


                if (!string.IsNullOrEmpty(range.UseRange))
                {
                    list_rang.AddRange(range.UseRange.Split(','));
                }


                //团购预售
                if (orderNo.Contains("p"))
                {
                    if (list_rang.Contains("2") == false)
                    {
                        isMustWeixin = 1;
                    }
                }

                //餐饮
                else if (orderNo.Contains("l"))
                {
                    string canType = HotelCloud.SqlServer.SQLHelper.Get_Value("select Isaround   from T_Stores  with(nolock)   where  StoreId =(select top 1  StoreId  from T_OrderInfo  with(nolock) where  orderCode=@orderCode)",
                                                                              HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "orderCode", new HotelCloud.SqlServer.DBParam {
                              ParamValue = orderNo
                          } }
                    });


                    // 2 3 自营
                    if (canType == "2" || canType == "3")
                    {
                        if (list_rang.Contains("1") == false)
                        {
                            isMustWeixin = 1;
                        }
                    }

                    else
                    {
                        if (list_rang.Contains("4") == false)
                        {
                            isMustWeixin = 1;
                        }
                    }
                }

                //超市
                else if (orderNo.Contains("d"))
                {
                    if (list_rang.Contains("3") == false)
                    {
                        isMustWeixin = 1;
                    }
                }


                if (payMoney > Convert.ToDecimal(ViewData["balance"]))
                {
                    isMustWeixin = 1;
                }

                ViewData["isMustWeixin"] = isMustWeixin;

                return(View());
            }

            catch (Exception ex)
            {
                Logger.Instance.Error(ex.ToString());


                return(RedirectToAction("ProductErrMsg", ViewData["edition"].ToString() == "1" ? "ProductA" : "Product", new { id = RouteData.Values["id"], errmsg = "抱歉,支付失败!", key = HotelCloud.Common.HCRequest.GetString("key") }));
            }
        }