예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int AddModel(MemberCardBuyRecord model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into MemberCardBuyRecord(");
            strSql.Append("OrderNo,HotelId,WeixinId,userWeixinId,CardId,BuyMoney,CardName,CardLevel,OrderStatus,AddTime,Name,Mobile");
            strSql.Append(") values (");
            strSql.Append("@OrderNo,@HotelId,@WeixinId,@userWeixinId,@CardId,@BuyMoney,@CardName,@CardLevel,@OrderStatus,@AddTime,@Name,@Mobile");
            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> {
                { "OrderNo", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.OrderNo.ToString()
                  } },
                { "HotelId", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.HotelId.ToString()
                  } },
                { "WeixinId", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.WeixinId.ToString()
                  } },
                { "userWeixinId", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.userWeixinId.ToString()
                  } },
                { "CardId", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.CardId.ToString()
                  } },
                { "BuyMoney", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.BuyMoney.ToString()
                  } },
                { "CardName", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.CardName.ToString()
                  } },
                { "CardLevel", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.CardLevel.ToString()
                  } },
                { "OrderStatus", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.OrderStatus.ToString()
                  } },
                { "AddTime", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.AddTime.ToString()
                  } },
                { "Name", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.Name.ToString()
                  } },
                { "Mobile", new HotelCloud.SqlServer.DBParam {
                      ParamValue = model.Mobile.ToString()
                  } },
            });


            if (!string.IsNullOrEmpty(obj))
            {
                return(Convert.ToInt32(obj));
            }

            return(0);
        }
예제 #2
0
        public ContentResult saveorderinfo()
        {
            try
            {
                Dictionary <string, object> result = new Dictionary <string, object>();

                string    source        = "weixinweb";
                string    saveinfo      = HCRequest.GetString("saveinfo");
                Hashtable saveinfotable = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(saveinfo);
                DateTime  now           = DateTime.Now;
                string    orderno       = string.Format("w{0}", now.ToString("yyMMddHHmmssfff"));
                string    weixinid      = saveinfotable["weixinid"].ToString();
                string    userWeixinid  = saveinfotable["userWeixinid"].ToString();

                int couponid = Convert.ToInt32(saveinfotable["couponid"]);
                if (couponid > 0)
                {
                    bool couPonEnable = WeiXin.Models.Home.CouPonContent.IsCouPonContentEnable(weixinid, userWeixinid, couponid);
                    if (!couPonEnable)
                    {
                        result.Add("success", false);
                        result.Add("message", "红包已被使用,不能再次使用");
                        string _json = Newtonsoft.Json.JsonConvert.SerializeObject(result);
                        return(Content(_json));
                    }
                }

                string token         = saveinfotable["token"].ToString();
                string sourceorderid = null;
                try
                {
                    sourceorderid = hotel3g.Models.DES.DESDecrypt(token, "wkn128uu");
                }
                catch (Exception)
                {
                    sourceorderid = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                }



                var tgyModel = hotel3g.Models.MemberFxLogic.GetTuiGuangProfit(ProfitType.kefang, weixinid, userWeixinid, Convert.ToInt32(saveinfotable["ssumprice"]));

                SQLMerge.MergeScript script = new SQLMerge.MergeScript("hotelorder");
                script.AddInsertField("OrderNO").AddInsertField("LinkTel").AddInsertField("UserName").AddInsertField("UserWeiXinID").AddInsertField("HotelID").AddInsertField("HotelName").AddInsertField("WeiXinID").AddInsertField("RoomID").AddInsertField("RoomName").AddInsertField("demo").AddInsertField("RatePlanID").AddInsertField("RatePlanName").AddInsertField("yRoomNum").AddInsertField("yinDate").AddInsertField("youtDate").AddInsertField("Ordertime").AddInsertField("PayType").AddInsertField("lastTime").AddInsertField("state").AddInsertField("yPriceStr").AddInsertField("ySumPrice").AddInsertField("sSumPrice").AddInsertField("fpSubmitPrice").AddInsertField("Source").AddInsertField("jifen").AddInsertField("ishourroom").AddInsertField("hourstarttime").AddInsertField("hourendtime").AddInsertField("foregift").AddInsertField("foregiftstate")
                .AddInsertField("needinvoice").AddInsertField("invoicestate").AddInsertField("invoicetitle").AddInsertField("CouponInfo").AddInsertField("sourceorderid").AddInsertField("UserID").AddInsertField("isMeeting").AddInsertField("promoterid").AddInsertField("fxCommission").AddInsertField("fxmoneyprofit").AddInsertField("invoicenum");
                script.AddCriteria("Source").AddCriteria("sourceorderid");

                string        yPriceStr = string.Empty;
                List <string> priceAry  = saveinfotable["priceAry"].ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries).ToList();
                foreach (string item in priceAry)
                {
                    DateTime time  = WeiXinPublic.ConvertHelper.ToDateTime(item.Remove(item.IndexOf(":")));
                    int      price = WeiXinPublic.ConvertHelper.ToInt(item.Substring(item.IndexOf(":") + 1));
                    yPriceStr += string.Format("price{0}|{1}|money{0}|0|", time.ToString("yyyy-MM-dd"), price);
                }
                int fpSubmitPrice = 0;
                int sSumPrice     = 0;
                int paytype       = Convert.ToInt32(saveinfotable["paytype"]);
                if (paytype == 1)
                {
                    fpSubmitPrice = Convert.ToInt32(saveinfotable["ssumprice"]);
                }
                else
                {
                    sSumPrice = Convert.ToInt32(saveinfotable["ssumprice"]);
                }
                int    ishourroom    = Convert.ToInt32(saveinfotable["ishourroom"]);
                string hourstarttime = null;
                string hourendtime   = null;
                string lasttime      = null;
                if (ishourroom == 1)
                {
                    hourstarttime = saveinfotable["hourstarttime"].ToString();
                    hourendtime   = saveinfotable["hourendtime"].ToString();
                }
                else
                {
                    lasttime = saveinfotable["lasttime"].ToString();
                }
                int    needinvoice  = Convert.ToInt32(saveinfotable["needinvoice"]);
                string invoicetitle = null;
                string invoicenum   = null;
                if (needinvoice == 1)
                {
                    invoicetitle = saveinfotable["invoicetitle"].ToString();
                    invoicenum   = saveinfotable["invoicenum"].ToString();
                }
                string demo = null;
                if (!saveinfotable["demo"].ToString().Equals("无"))
                {
                    demo = saveinfotable["demo"].ToString();
                }

                Dictionary <string, object> CouponInfoDic = new Dictionary <string, object>();
                if (couponid > 0)
                {
                    CouponInfoDic.Add("CouponId", couponid);
                    CouponInfoDic.Add("CouPon", Convert.ToInt32(saveinfotable["couponprice"]));
                }

                object gradename = saveinfotable["gradename"];
                int    isvip     = WeiXinPublic.ConvertHelper.ToInt(saveinfotable["isvip"]);
                //会员专享不能享受打折优惠,只有为非会员专享时才添加折扣信息
                if (isvip != 1)
                {
                    double graderate = WeiXinPublic.ConvertHelper.ToDouble(saveinfotable["graderate"]);
                    CouponInfoDic.Add("GradeRate", graderate);
                    CouponInfoDic.Add("Reduce", WeiXinPublic.ConvertHelper.ToDouble(saveinfotable["reduce"]));
                }
                CouponInfoDic.Add("GradeName", gradename == null ? string.Empty : gradename.ToString());
                CouponInfoDic.Add("IsVip", isvip);

                CouponInfoDic.Add("CouponType", WeiXinPublic.ConvertHelper.ToInt(saveinfotable["coupontype"]));

                string   couponinfo = Newtonsoft.Json.JsonConvert.SerializeObject(CouponInfoDic);
                int      jifen      = WeiXinPublic.ConvertHelper.ToInt(saveinfotable["jifen"]);
                DateTime indate     = WeiXinPublic.ConvertHelper.ToDateTime(saveinfotable["yindate"]);
                DateTime outdate    = WeiXinPublic.ConvertHelper.ToDateTime(saveinfotable["youtdate"]);

                int ismeeting = 0;
                if (saveinfotable["ismeeting"] != null)
                {
                    ismeeting = Convert.ToInt32(saveinfotable["ismeeting"]);
                }


                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("OrderNO", orderno);
                dic.Add("LinkTel", saveinfotable["linktel"].ToString());
                dic.Add("UserName", saveinfotable["username"].ToString());
                dic.Add("UserWeiXinID", userWeixinid);
                dic.Add("HotelID", saveinfotable["hotelid"].ToString());
                dic.Add("HotelName", saveinfotable["hotelname"].ToString());
                dic.Add("WeiXinID", weixinid);
                dic.Add("UserID", 0);
                dic.Add("RoomID", saveinfotable["roomid"].ToString());
                dic.Add("RoomName", saveinfotable["roomname"].ToString());
                dic.Add("demo", demo);
                dic.Add("RatePlanID", saveinfotable["rateplanid"].ToString());
                dic.Add("RatePlanName", saveinfotable["rateplanname"].ToString());
                dic.Add("yRoomNum", saveinfotable["yroomnum"].ToString());
                dic.Add("yinDate", indate.ToString());
                dic.Add("youtDate", outdate.ToString());
                dic.Add("Ordertime", now);
                dic.Add("PayType", paytype);
                dic.Add("lastTime", lasttime);
                dic.Add("state", 1);    //待处理
                dic.Add("yPriceStr", yPriceStr);
                dic.Add("ySumPrice", Convert.ToInt32(saveinfotable["originalsaleprice"]));
                dic.Add("sSumPrice", sSumPrice);
                dic.Add("fpSubmitPrice", fpSubmitPrice);
                dic.Add("Source", source);
                dic.Add("jifen", jifen);
                dic.Add("ishourroom", saveinfotable["ishourroom"].ToString());
                dic.Add("hourstarttime", hourstarttime);
                dic.Add("hourendtime", hourendtime);
                dic.Add("foregift", saveinfotable["foregift"]);
                dic.Add("foregiftstate", 1);
                dic.Add("needinvoice", needinvoice);
                dic.Add("invoicetitle", invoicetitle);
                dic.Add("invoicestate", 1);
                dic.Add("CouponInfo", couponinfo);
                dic.Add("sourceorderid", sourceorderid);
                dic.Add("ismeeting", ismeeting);
                dic.Add("promoterid", tgyModel.promoterid);
                dic.Add("fxCommission", tgyModel.hotelCommission);
                dic.Add("fxmoneyprofit", tgyModel.userCommission);
                dic.Add("invoicenum", invoicenum);
                script.ListValues.Add(dic);
                string sql = script.SQL();

                int rows = SQLHelper.Run_SQL(sql, SQLHelper.GetCon(), null);
                result.Add("success", rows > 0);
                if (rows > 0)
                {
                    sql = "select id from hotelorder with (nolock) where source=@source and sourceorderid=@sourceorderid";
                    int orderid = WeiXinPublic.ConvertHelper.ToInt(SQLHelper.Get_Value(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
                    {
                        { "source", new DBParam()
                          {
                              ParamValue = source
                          } },
                        { "sourceorderid", new DBParam()
                          {
                              ParamValue = sourceorderid
                          } }
                    }));
                    if (couponid > 0)
                    {
                        if (orderid > 0)
                        {
                            sql = "update couponcontent set isemploy=1,employtime=@time,orderid=@orderid where id=@couponid and weixinid=@weixinid and userweixinno=@userweixinid";
                            SQLHelper.Run_SQL(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
                            {
                                { "time", new DBParam()
                                  {
                                      ParamValue = now.ToString()
                                  } },
                                { "orderid", new DBParam()
                                  {
                                      ParamValue = orderid.ToString()
                                  } },
                                { "couponid", new DBParam()
                                  {
                                      ParamValue = couponid.ToString()
                                  } },
                                { "weixinid", new DBParam()
                                  {
                                      ParamValue = weixinid
                                  } },
                                { "userweixinid", new DBParam()
                                  {
                                      ParamValue = userWeixinid
                                  } }
                            });
                        }
                    }
                    if (jifen > 0)
                    {
                        //sql = "update Member set Emoney+=@Emoney where weixinID=@weixinID and userWeiXinNO=@userWeiXinNO";
                        //int rs = SQLHelper.Run_SQL(sql, SQLHelper.GetCon(), new Dictionary<string, DBParam>()
                        //{
                        //    {"Emoney",new DBParam(){ParamValue=jifen.ToString()}},
                        //    {"weixinID",new DBParam(){ParamValue=weixinid}},
                        //    {"userWeiXinNO",new DBParam(){ParamValue=userWeixinid}},
                        //});

                        string cardno   = saveinfotable["cardno"] == null ? string.Empty : saveinfotable["cardno"].ToString();
                        string memberid = saveinfotable["memberid"] == null ? string.Empty : saveinfotable["memberid"].ToString();
                        sql = "insert into jifendetail (weixinid,userweixinid,jifen,addtime,orderid,night,cardno,userid) values (@weixinid,@userweixinid,@jifen,@addtime,@orderid,@night,@cardno,@userid)";
                        int rs = SQLHelper.Run_SQL(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
                        {
                            { "weixinid", new DBParam()
                              {
                                  ParamValue = weixinid
                              } },
                            { "userweixinid", new DBParam()
                              {
                                  ParamValue = userWeixinid
                              } },
                            { "jifen", new DBParam()
                              {
                                  ParamValue = jifen.ToString()
                              } },
                            { "addtime", new DBParam()
                              {
                                  ParamValue = DateTime.Now.ToString()
                              } },
                            { "orderid", new DBParam()
                              {
                                  ParamValue = orderid.ToString()
                              } },
                            { "night", new DBParam()
                              {
                                  ParamValue = (outdate - indate).Days.ToString()
                              } },
                            { "cardno", new DBParam()
                              {
                                  ParamValue = cardno
                              } },
                            { "userid", new DBParam()
                              {
                                  ParamValue = memberid
                              } },
                        });
                    }

                    //新旧版会议都是调用此方法下单
                    if (ismeeting == 0)
                    {
                        int roomstock = MemberCardBuyRecord.ReduceRoomStock(Convert.ToInt32(saveinfotable["hotelid"].ToString()), Convert.ToInt32(saveinfotable["roomid"].ToString()), indate, outdate, Convert.ToInt32(saveinfotable["yroomnum"].ToString()));
                    }

                    result.Add("message", "提交成功!");
                    result.Add("orderno", orderno);
                    result.Add("orderid", orderid);
                }
                else
                {
                    sql = "select count(1) from hotelorder with (nolock) where source=@source and sourceorderid=@sourceorderid";
                    int c = WeiXinPublic.ConvertHelper.ToInt(SQLHelper.Get_Value(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
                    {
                        { "source", new DBParam()
                          {
                              ParamValue = source
                          } },
                        { "sourceorderid", new DBParam()
                          {
                              ParamValue = sourceorderid
                          } }
                    }));
                    result.Add("message", c > 0 ? "已存在订单不要重复提交!" : "提交失败!");
                }

                string json = Newtonsoft.Json.JsonConvert.SerializeObject(result);
                return(Content(json));
            }
            catch (Exception ex)
            {
                Dictionary <string, object> result = new Dictionary <string, object>();
                result.Add("message", ex.Message + ex.StackTrace);
                result.Add("success", false);
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(result);
                return(Content(json));
            }
        }
예제 #3
0
        /// <summary>
        /// 获取酒店设置的佣金及推广员可实际获得的佣金
        /// </summary>
        /// <param name="TypeValue"></param>
        /// <param name="weixinid"></param>
        /// <param name="Money"></param>
        /// <returns></returns>
        public static TuiGuangMoney GetTuiGuangProfit(this ProfitType TypeValue, string weixinid, string userweixinid, double Money)
        {
            TuiGuangMoney Result = new TuiGuangMoney()
            {
                promoterid = 0, hotelCommission = 0, userCommission = 0
            };

            int promoterid = 0;

            if (!userweixinid.Contains(DAL.PromoterDAL.WX_ShareLinkUserWeiXinId))
            {
                promoterid = MemberCardBuyRecord.GetPromoterid(weixinid, userweixinid);
                if (promoterid <= 0)
                {
                    //不存在推广员id
                    return(Result);
                }
            }

            Result.promoterid = promoterid;
            string sql = "select kefang,canyin,tuangou,chaoshi from S_HuoDongTianBao_fenxiao with(nolock) where  weixinId=@weixinId";
            Dictionary <string, DBParam> Dic = new Dictionary <string, DBParam>();

            Dic.Add("weixinId", new DBParam {
                ParamValue = weixinid
            });
            DataTable dt = SQLHelper.Get_DataTable(sql, SQLHelper.GetCon(), Dic);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(Result);
            }

            string kefangStr  = dt.Rows[0]["kefang"].ToString();
            string canyinStr  = dt.Rows[0]["canyin"].ToString();
            string tuangouStr = dt.Rows[0]["tuangou"].ToString();
            string chaoshiStr = dt.Rows[0]["chaoshi"].ToString();

            int    Error = 0;
            double TuiGuangProfitValue = TuiGuangProfit();


            int ProfitValue = 0;

            switch (TypeValue)
            {
            case ProfitType.kefang:
                int kefang = int.TryParse(kefangStr, out Error) ? int.Parse(kefangStr) : 0;
                ProfitValue = kefang;
                break;

            case ProfitType.canyin:
                int canyin = int.TryParse(canyinStr, out Error) ? int.Parse(canyinStr) : 0;
                ProfitValue = canyin;
                break;

            case ProfitType.tuangou:
                int tuangou = int.TryParse(tuangouStr, out Error) ? int.Parse(tuangouStr) : 0;
                ProfitValue = tuangou;
                break;

            case ProfitType.chaoshi:
                int chaoshi = int.TryParse(chaoshiStr, out Error) ? int.Parse(chaoshiStr) : 0;
                ProfitValue = chaoshi;
                break;
            }
            Result.hotelCommission = Money * ProfitValue / 100;
            Result.userCommission  = Result.hotelCommission * TuiGuangProfitValue;
            return(Result);
        }