Пример #1
0
 public static int AddRechargeCard(RechargeCard model)
 {
     return(RechargeCardDAL.AddRechargeCard(model));
 }
Пример #2
0
 public static int UpdateRechargeCard(RechargeCard model)
 {
     return(RechargeCardDAL.UpdateRechargeCard(model));
 }
Пример #3
0
        /// <summary>
        /// 微信支付成功后处理
        /// </summary>
        /// <param name="ordeNO"></param>
        /// <returns></returns>
        public static bool DoUserRechargeSuccess(string ordeNO)
        {
            bool flag = false;

            try
            {
                string sql = "select cardId,hotelweixinId,userweixinId,Mprice  from RechargeUser  with(nolock)   where orderNO=@orderNo and orderStatus=0 ";

                DataTable db_RechargeOrder = HotelCloud.SqlServer.SQLHelper.Get_DataTable(sql, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam>            {
                    { "orderNo", new HotelCloud.SqlServer.DBParam {
                          ParamValue = ordeNO
                      } },
                });

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



                DataTable dbMember = RechargeCard.GetRechargeMemberInfo(db_RechargeOrder.Rows[0]["hotelweixinId"].ToString(), db_RechargeOrder.Rows[0]["userweixinId"].ToString());

                if (dbMember.Rows.Count != 1)
                {
                    return(false);
                }

                using (TransactionScope scop = new TransactionScope())
                {
                    //销售数量+1
                    sql = "update RechargeCard  set saleNum=saleNum+1  where  weixinId=@weixinId  and Id=@Id ";
                    int row = HotelCloud.SqlServer.SQLHelper.Run_SQL(sql, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam>
                    {
                        { "weixinId", new HotelCloud.SqlServer.DBParam {
                              ParamValue = db_RechargeOrder.Rows[0]["hotelweixinId"].ToString()
                          } },
                        { "Id", new HotelCloud.SqlServer.DBParam {
                              ParamValue = db_RechargeOrder.Rows[0]["cardId"].ToString()
                          } },
                    });

                    if (row > 0)
                    {
                        //更新订单状态及金额
                        sql = "update RechargeUser set  orderStatus=1,Beforebalance=@Beforebalance,Balance=Mprice + @Beforebalance,addTime=getdate()    where  orderNo=@orderNo ";
                        row = HotelCloud.SqlServer.SQLHelper.Run_SQL(sql, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam>
                        {
                            { "orderNo", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = ordeNO
                              } },
                            { "Beforebalance", new HotelCloud.SqlServer.DBParam {
                                  ParamValue = dbMember.Rows[0]["balance"].ToString()
                              } }
                        });


                        if (row > 0)
                        {
                            //充值账户

                            row = RechargeCard.UpdateRechargeMemberBalance(db_RechargeOrder.Rows[0]["hotelweixinId"].ToString(), db_RechargeOrder.Rows[0]["userweixinId"].ToString(), Convert.ToDecimal(db_RechargeOrder.Rows[0]["Mprice"].ToString()));

                            //三部曲完成提交
                            if (row > 0)
                            {
                                flag = true;
                                scop.Complete();
                            }
                        }
                    }
                }
            }

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