/// <summary> /// 根据卡号取得卡信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public static CardInfo GetCardInfo(CardInfoParam param) { RechargeFactory factory = new RechargeFactory(); try { if (param == null) { throw new Exception("Param is null"); } CardInfo card = factory.GetCardInfo(param); if (card == null) { throw new Exception("DAL.WeChat.RechargeFactory.GetCardInfo()==null"); } return(card); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "GetCardInfo"); return(null); } }
/// <summary> /// 根据卡号取得卡信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public static UserBalance GetBalance(CardInfoParam param) { RechargeFactory factory = new RechargeFactory(); try { if (param == null) { throw new Exception("Param is null"); } UserBalance userBalance = factory.GetBalance(param); if (userBalance == null) { throw new Exception("DAL.WeChat.RechargeFactory.GetBalance()==null"); } return(userBalance); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "GetBalance"); throw ex; } }
/// <summary> /// 取得最后一笔充值成功记录 /// </summary> /// <param name="param"></param> /// <returns></returns> public static UserBalance GetLastRecharge(CardInfoParam param) { RechargeFactory factory = new RechargeFactory(); try { if (param == null) { throw new Exception("Param is null"); } UserBalance userBalance = new UserBalance(); WxOrder wxOrder = factory.GetLastRecharge(param); //if (wxOrder == null) throw new Exception("DAL.WeChat.RechargeFactory.GetLastRecharge()==null"); userBalance.lastOrder = wxOrder; return(userBalance); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "GetLastRecharge"); throw ex; } }
public Response GetCardInfo(string token, [FromBody] CardInfoParam param) { Response response = new Response(); if (string.IsNullOrEmpty(token) || !token.Equals(_token)) { response.code = "404"; response.message = "Invild token"; } else { var data = RechargeHelper.GetCardInfo(param); if (data == null) { response.code = "500"; response.message = "Get data failed"; } else { response.code = "200"; response.content = data; } } return(response); }
public Response GetBalance(string token, [FromBody] CardInfoParam param) { Response response = new Response(); if (string.IsNullOrEmpty(token) || !token.Equals(_token)) { response.code = "404"; response.message = "Invild token"; } else { try { var data = RechargeHelper.GetBalance(param); if (data == null) { response.code = "500"; response.message = "Get data failed"; } else { response.code = "200"; response.content = data; } } catch (Exception ex) { response.code = "404"; response.message = ex.Message; var data = RechargeHelper.GetLastRecharge(param); response.content = data; } } return(response); }
/// <summary> /// 根据卡号取得卡信息及余额 /// </summary> /// <param name="param"></param> /// <returns></returns> public UserBalance GetBalance(CardInfoParam param) { #region 当前余额信息 //CCMastFactory ccmf = new CCMastFactory(); //// Table CCMast //CCMast ccm = ccmf.GetCCMastInfo(param.costCenterCode); //// Table SqlMast //SingleField ccObj = new SingleField(); //ccObj.code = param.costCenterCode; //List<SingleField> lstCcObj = new List<SingleField>(); //lstCcObj.Add(ccObj); //SqlMast sm = ccmf.GetSqlMastInfo(lstCcObj, "GetPOSUserBal")[0]; //// Sql Connection //string strConn = string.Format(string.Format(SqlServerHelper.customerAllConn, ccm.posIp, ccm.posDBName, ccm.posDBUserName // , ccm.posDBPassword)); ////strConn = "Data Source=222.92.143.28,11233;Initial Catalog=YCCY;User ID=120dw201;Password=gladis0083;Persist Security Info=True;Connection Timeout=10"; //// Sql文 //string strSql = string.Format(sm.sqlCommand, param.cardkey); //// 取得余额信息 ////List<dynamic> lst = SqlServerHelper.GetDynamicList(strConn, strSql); ////return (lst[0] as IDictionary<string, object>).Values.FirstOrDefault().ToDecimal().ToString("0.##"); //UserBalance userBalance = SqlServerHelper.GetEntity<UserBalance>(strConn, strSql); #endregion return(GetData <UserBalance>(param.costCenterCode, param.cardkey, "GetPOSUserBal"));//userBalance; }
/// <summary> /// 根据CardId取得Card相关信息 /// </summary> /// <param name="CardInfoParam"></param> /// <param name="sqlType"></param> /// <returns></returns> public CardInfo GetCardInfo(CardInfoParam param) { //if (string.IsNullOrWhiteSpace(param.cardkey)) return null; //CCMastFactory ccmf = new CCMastFactory(); //// Table CCMast //CCMast ccm = ccmf.GetCCMastInfo(param.costCenterCode); //// Table SqlMast //SingleField ccObj = new SingleField(); //ccObj.code = param.costCenterCode; //List<SingleField> lstCcObj = new List<SingleField>(); //lstCcObj.Add(ccObj); //SqlMast sm = ccmf.GetSqlMastInfo(lstCcObj, "GetPOSUsers")[0]; //// Sql Connection //string strConn = string.Format(string.Format(SqlServerHelper.customerAllConn, ccm.posIp, ccm.posDBName, ccm.posDBUserName // , ccm.posDBPassword)); //// Sql文 //string strSql = string.Format(sm.sqlCommand, param.cardkey); ////strConn = "Data Source=192.168.0.97,1433;Initial Catalog=DWPOS;User ID=sa;Password=gladis0083;Persist Security Info=True;Connection Timeout=10"; //// 取得卡信息 //List<CardInfo> cardObjs = SqlServerHelper.GetEntityList<CardInfo>(strConn, strSql); List <CardInfo> cardObjs = GetList <CardInfo>(param.costCenterCode, param.cardkey, "GetPOSUsers"); if (!cardObjs.Any()) { return(null); } //检查用户卡是否已绑定 CardInfo cardObj = cardObjs.FirstOrDefault(); WxUserCard card = CheckBind(param.wechatId, string.Join("','", cardObjs.Select(q => q.oldCardId))); cardObj.userCode = string.IsNullOrWhiteSpace(cardObj.userCode)? cardObj.cardCode: cardObj.userCode; if (card == null) { return(cardObj); } //更改已绑定的cardId cardObj.cardId = card.cardId; cardObj.isBind = true; return(cardObj); }
/// <summary> /// 取得最后一笔充值成功记录 /// </summary> /// <param name="wechatId"></param> /// <returns></returns> public WxOrder GetLastRecharge(CardInfoParam param) { // 最后一笔成功充值信息 string strSql = " SELECT TOP 1 " + " CAST(TOTAL_FEE * 1.0 / 100 AS DEC(10, 2)) AS TOTAL_FEE " + " , TIME_END " + " FROM WXORDER " + " WHERE OPENID = '{0}' " + " AND TRANSFERTIME IS NOT NULL " + " ORDER BY ID DESC "; WxOrder lastOrder = SqlServerHelper.GetEntity <WxOrder>(SqlServerHelper.salesorderConn(), string.Format(strSql, param.wechatId)); if (lastOrder != null) { lastOrder.time_end = DateTimeHelper.convertDateTime(lastOrder.time_end, "yyyyMMddHHmmss", "yyyy-MM-dd HH:mm:ss"); } return(lastOrder); }