Exemplo n.º 1
0
        /// <summary>
        /// 购买会员卡成功后处理订单
        /// </summary>
        /// <param name="orderNo"></param>
        public static void DoneOrderSuccess(string orderNo)
        {
            try
            {
                System.Data.DataTable dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable("select * from  MemberCardBuyRecord  wiht(nolock)  where orderno=@orderno and  orderstatus=0 ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                    { "orderNo", new HotelCloud.SqlServer.DBParam {
                          ParamValue = orderNo
                      } }
                });


                if (dt.Rows.Count == 0)
                {
                    return;
                }

                int row = HotelCloud.SqlServer.SQLHelper.Run_SQL("update  MemberCardBuyRecord  set orderStatus=1,payTime=getdate() where orderno=@orderno", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                    { "orderNo", new HotelCloud.SqlServer.DBParam {
                          ParamValue = orderNo
                      } }
                });

                if (row > 0)
                {
                    int levelRows = HotelCloud.SqlServer.SQLHelper.Run_SQL("update  Member  set viptype=@viptype   where weixinId=@weixinId  and userweixinno=@userweixinno ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "viptype", new HotelCloud.SqlServer.DBParam {
                              ParamValue = dt.Rows[0]["CardLevel"].ToString()
                          } },
                        { "weixinId", new HotelCloud.SqlServer.DBParam {
                              ParamValue = dt.Rows[0]["weixinId"].ToString()
                          } },
                        { "userweixinno", new HotelCloud.SqlServer.DBParam {
                              ParamValue = dt.Rows[0]["userweixinId"].ToString()
                          } }
                    });


                    DataTable db_member = WeiXin.Models.Home.RechargeCard.GetRechargeMemberInfo(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString());


                    if (db_member.Rows[0]["cardNO"].ToString() == string.Empty)
                    {
                        //没有会员卡生成会员卡号

                        string cardNo = hotel3g.Repository.MemberHelper.GetNotUsedCard(dt.Rows[0]["hotelId"].ToString(), dt.Rows[0]["weixinId"].ToString());

                        if (!string.IsNullOrEmpty(cardNo))
                        {
                            int updateRows = HotelCloud.SqlServer.SQLHelper.Run_SQL("update  MemberCard  set isuse=1 , binddate=getdate()    where weixinId=@weixinId  and cardno=@cardno ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                { "cardno", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = cardNo
                                  } },
                                { "weixinId", new HotelCloud.SqlServer.DBParam {
                                      ParamValue = dt.Rows[0]["weixinId"].ToString()
                                  } }
                            });

                            if (updateRows > 0)
                            {
                                updateRows = HotelCloud.SqlServer.SQLHelper.Run_SQL("update  Member  set cardno=@cardno, name=@name,mobile=@mobile   where weixinId=@weixinId  and userweixinno=@userweixinno ", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                                    { "cardno", new HotelCloud.SqlServer.DBParam {
                                          ParamValue = cardNo
                                      } },
                                    { "weixinId", new HotelCloud.SqlServer.DBParam {
                                          ParamValue = dt.Rows[0]["weixinId"].ToString()
                                      } },
                                    { "userweixinno", new HotelCloud.SqlServer.DBParam {
                                          ParamValue = dt.Rows[0]["userweixinId"].ToString()
                                      } },
                                    { "name", new HotelCloud.SqlServer.DBParam {
                                          ParamValue = dt.Rows[0]["name"].ToString()
                                      } },
                                    { "mobile", new HotelCloud.SqlServer.DBParam {
                                          ParamValue = dt.Rows[0]["mobile"].ToString()
                                      } }
                                });

                                if (updateRows > 0)
                                {
                                    //会员注册赠送订房红包
                                    MemberHelper.RegisterCouponGift(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString());

                                    //绑定推广员赠送订房红包
                                    MemberHelper.UpdateCommission(dt.Rows[0]["hotelid"].ToString(), dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString());

                                    //推广员送红包

                                    int PromoterID = MemberHelper.GetPromoterID(dt.Rows[0]["userweixinId"].ToString(), dt.Rows[0]["weixinId"].ToString());

                                    if (PromoterID > 0)
                                    {
                                        bool   pstatus = false;
                                        string pstr    = PromoterDAL.SendCustomCoupon(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["mobile"].ToString(), Convert.ToInt32(db_member.Rows[0]["Id"].ToString()), Convert.ToInt32(dt.Rows[0]["hotelid"].ToString()), out pstatus);
                                    }
                                }
                            }
                        }
                    }

                    //送红包   积分
                    DataTable dt_hb = HotelCloud.SqlServer.SQLHelper.Get_DataTable("select  hongbaomoney,givejifen from   MemberCardCustom  with(nolock) where Id=@Id", HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> {
                        { "Id", new HotelCloud.SqlServer.DBParam {
                              ParamValue = dt.Rows[0]["CardId"].ToString()
                          } }
                    });

                    if (dt_hb.Rows.Count > 0)
                    {
                        string hongbaomoney = dt_hb.Rows[0]["hongbaomoney"].ToString();
                        if (!string.IsNullOrEmpty(hongbaomoney) && Convert.ToInt32(Convert.ToDecimal(hongbaomoney)) > 0)
                        {
                            int hbmoney = Convert.ToInt32(Convert.ToDecimal(hongbaomoney));
                            int rows    = AddCardCoupon(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString(), hbmoney, Convert.ToInt32(dt.Rows[0]["cardId"].ToString()));
                        }

                        int givejifen = Convert.ToInt32(dt_hb.Rows[0]["givejifen"].ToString());

                        if (givejifen > 0)
                        {
                            //重新获取会员最新信息
                            DataTable dbmember_new = WeiXin.Models.Home.RechargeCard.GetRechargeMemberInfo(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString());

                            int    userId = 0;
                            string cardno = string.Empty;
                            if (dbmember_new.Rows.Count > 0)
                            {
                                int.TryParse(dbmember_new.Rows[0]["Id"].ToString(), out userId);
                                cardno = dbmember_new.Rows[0]["cardno"].ToString();
                            }


                            int row_jifen = AddCardJifen(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString(), userId, cardno, givejifen, Convert.ToInt32(dt.Rows[0]["cardId"].ToString()));
                            if (row_jifen > 0)
                            {
                                row_jifen = MemberCardBuyRecord.UpdateUserJifen(dt.Rows[0]["weixinId"].ToString(), dt.Rows[0]["userweixinId"].ToString(), givejifen);
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                WeiXin.Common.Logger.Instance.Error(ex.ToString());
            }
        }
Exemplo n.º 2
0
 public static int AddModel(MemberCardBuyRecord model)
 {
     return(MemberCardBuyRecordDAL.AddModel(model));
 }