Beispiel #1
0
        /// <summary>
        /// 新增临时停车信息
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        private string TempPayFees(string requestParam)
        {
            try
            {
                if (string.IsNullOrEmpty(requestParam))
                {
                    new Logger().WriteLog("鸿坤道闸临停信息请求参数", DateTime.Now.ToString() + "--" + requestParam);
                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, "请求参数不能为空");
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }

                string        ContionString = PubConstant.GetConnectionString("HKSQLConnection").ToString();
                IDbConnection con           = new SqlConnection(ContionString);

                Tb_HSPR_HKCostInfo costInfo = JsonHelp.JsonDeserialize <Tb_HSPR_HKCostInfo>(requestParam);
                string             CommID   = null;//项目ID
                string             sKey     = "A2YGWFV7QP5KFOMLXIYRW";

                int    parkId       = costInfo.parkId;
                int    duration     = costInfo.duration;
                string dutyId       = costInfo.dutyId;
                string endTime      = costInfo.endTime;
                string feeAli       = costInfo.feeAli;
                string feeCash      = costInfo.feeCash;
                string feeCoupon    = costInfo.feeCoupon;
                string feeException = costInfo.feeException;
                string feeExpected  = costInfo.feeExpected;
                string feeFree      = costInfo.feeFree;
                string feeWechat    = costInfo.feeWechat;
                string roomNum      = costInfo.roomNum;
                string startTime    = costInfo.startTime;
                string tollManName  = costInfo.tollManName;
                string HtcSign      = costInfo.sign;

                //查询当前数据是否已经存在天问系统
                string    tmpStr         = "SELECT * FROM Tb_HSPR_TemporaryCarPrecostsDetail WHERE dutyId='" + dutyId + "'";
                DataTable dtTemporaryCar = new DbHelperSQLP(ContionString).Query(tmpStr).Tables[0];
                if (dtTemporaryCar.Rows.Count > 0)
                {
                    new Logger().WriteLog("鸿坤道闸临停信息同步异常", DateTime.Now.ToString() + "--" + "该条临停数据已经存在天问系统:" + tmpStr);

                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, "该条临停数据已经存在天问系统");
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }


                if (parkId <= 0)
                {
                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, "车场ID不能为空");
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }
                string signParm = "{\"duration\":" + duration + ",\"dutyId\":\"" + dutyId + "\",\"endTime\":\"" + endTime
                                  + "\",\"feeAli\":" + feeAli + ",\"feeCash\":" + feeCash + ",\"feeCoupon\":" + feeCoupon + ",\"feeException\":"
                                  + feeException + ",feeExpected:" + feeExpected + ",feeFree:" + feeFree + ",feeWechat:" + feeWechat
                                  + ",\"roomNum\":\"" + roomNum + "\",\"startTime\":\"" + startTime + "\",\"tollManName\":\"" + tollManName + "\"}";

                Dictionary <String, String> param = JSONHelper.StringToDictionary <string, string>(signParm);
                string signStr = BuildParamStr(param) + "&key=" + sKey + "";
                string sign    = MD5Encrypt(signStr);
                if (sign != HtcSign)
                {
                    new Logger().WriteLog("鸿坤道闸临停信息同步异常", DateTime.Now.ToString() + "--" + "签名错误:" + sign);

                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, "签名错误");
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }



                string    ctpStr       = "SELECT * FROM Tb_HTC_CommToPark WHERE ParkId='" + parkId + "'";
                DataTable dtCommToPark = new DbHelperSQLP(ContionString).Query(ctpStr).Tables[0];
                if (dtCommToPark.Rows.Count > 0)
                {
                    DataRow retRow = dtCommToPark.Rows[0];
                    CommID = retRow["CommID"].ToString();
                }
                else
                {
                    new Logger().WriteLog("鸿坤道闸临停信息同步异常", DateTime.Now.ToString() + "--" + "车场ID无法匹配天问CommID:" + ctpStr);

                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, "车场ID无法匹配天问CommID");
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }

                long      CustId         = 0;
                long      RoomId         = 0;
                long      CostId         = 0;
                long      CorpStanId     = 0;
                long      StanId         = 0;
                string    UserCode       = "";
                string    csStr          = "SELECT * FROM Tb_HTC_CostStandard WHERE ParkId='" + parkId + "'";
                DataTable dtCostStandard = new DbHelperSQLP(ContionString).Query(csStr).Tables[0];
                if (dtCostStandard.Rows.Count > 0)
                {
                    DataRow retRow = dtCostStandard.Rows[0];
                    CustId     = AppGlobal.StrToLong(retRow["CustId"].ToString());
                    RoomId     = AppGlobal.StrToLong(retRow["RoomId"].ToString());
                    CostId     = AppGlobal.StrToLong(retRow["CostId"].ToString());
                    CorpStanId = AppGlobal.StrToLong(retRow["CorpStanId"].ToString());
                    StanId     = AppGlobal.StrToLong(retRow["StanId"].ToString());
                    UserCode   = retRow["UserCode"].ToString();
                }
                else
                {
                    new Logger().WriteLog("鸿坤道闸临停信息同步异常", DateTime.Now.ToString() + "--" + "车场ID无法匹配天问收费标准:" + csStr);
                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, "车场ID无法匹配天问收费标准");
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }
                try
                {
                    DynamicParameters parameters = new DynamicParameters();
                    var InfoCode = Guid.NewGuid();
                    parameters.Add("@InfoCode", InfoCode);
                    parameters.Add("@CardID", null);
                    parameters.Add("@CardType", null);
                    parameters.Add("@GoName", null);
                    parameters.Add("@CommID", CommID);
                    parameters.Add("@OverTime", startTime);
                    parameters.Add("@OutTime", endTime);
                    parameters.Add("@CarNumber", null);
                    parameters.Add("@Money", feeExpected);
                    parameters.Add("@IssueDate", null);
                    parameters.Add("@dutyId", dutyId);
                    parameters.Add("@feeCash", feeCash);
                    parameters.Add("@feeWechat", feeWechat);
                    parameters.Add("@feeAli", feeAli);

                    int b = con.Execute("Proc_HSPR_TemporaryCarPrecostsDetail_Insert", parameters, null, null, CommandType.StoredProcedure);
                    con.Dispose();
                    if (b > 0)
                    {
                        string Memo = "";
                        if (AppGlobal.StrToDec(feeAli) > 0)
                        {
                            Memo = "支付宝收款";
                            CreateCarFees(AppGlobal.StrToInt(CommID), CustId, RoomId, AppGlobal.StrToDec(feeAli), CorpStanId,
                                          StanId, Memo, CostId, UserCode);
                        }
                        if (AppGlobal.StrToDec(feeWechat) > 0)
                        {
                            Memo = "微信收款";
                            CreateCarFees(AppGlobal.StrToInt(CommID), CustId, RoomId, AppGlobal.StrToDec(feeWechat), CorpStanId,
                                          StanId, Memo, CostId, UserCode);
                        }
                        if (AppGlobal.StrToDec(feeCash) > 0)
                        {
                            Memo = "现金收款";
                            CreateCarFees(AppGlobal.StrToInt(CommID), CustId, RoomId, AppGlobal.StrToDec(feeCash), CorpStanId,
                                          StanId, Memo, CostId, UserCode);
                        }
                        new Logger().WriteLog("鸿坤道闸临停信息请求参数", DateTime.Now.ToString() + "--同步成功 " + Memo);
                        string State        = "true";
                        string ErrorContent = JSONHelper.FromStringHK(false, "同步成功");
                        log.ErrorContent = ErrorContent;
                        log.State        = State;
                        LogAdd(log);
                        return(ErrorContent);
                    }
                    else
                    {
                        new Logger().WriteLog("鸿坤道闸临停信息请求参数", DateTime.Now.ToString() + "--同步失败!");
                        string State        = "false";
                        string ErrorContent = JSONHelper.FromStringHK(false, "同步失败");
                        log.ErrorContent = ErrorContent;
                        log.State        = State;
                        LogAdd(log);
                        return(ErrorContent);
                    }
                }
                catch (Exception ex)
                {
                    new Logger().WriteLog("鸿坤道闸临停信息同步异常", DateTime.Now.ToString() + "--" + ex.ToString());
                    string State        = "false";
                    string ErrorContent = JSONHelper.FromStringHK(false, ex.Message);
                    log.ErrorContent = ErrorContent;
                    log.State        = State;
                    LogAdd(log);
                    return(ErrorContent);
                }
            }
            catch (Exception ex)
            {
                new Logger().WriteLog("鸿坤道闸临停信息同步异常", DateTime.Now.ToString() + "--" + ex.ToString());
                string State        = "false";
                string ErrorContent = JSONHelper.FromStringHK(false, ex.Message);
                log.ErrorContent = ErrorContent;
                log.State        = State;
                LogAdd(log);
                return(ErrorContent);
            }
        }