Example #1
0
        /// <summary>
        /// 生成银行及物业订单
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>
        public string GenerateOrder(DataRow Row)
        {
            bool   IsBankOk        = false;
            bool   IsPropertyOk    = false;
            string PropertyOrderId = "";
            string BankOrderId     = "";

            string CommunityId = Row["CommunityId"].ToString();
            string CostID      = Row["CostID"].ToString();
            string StanID      = Row["StanID"].ToString();
            string HandID      = Row["HandID"].ToString();
            string RoomID      = Row["RoomID"].ToString();
            string txnTime     = DateTime.Now.ToString("yyyyMMddHHmmss");
            string CustID      = Row["CustID"].ToString();
            string UserID      = Row["UserID"].ToString();
            int    Months      = AppGlobal.StrToInt(Row["Months"].ToString());

            if (Months == 0)
            {
                return(JSONHelper.FromString(false, "请选择预存月数"));
            }

            //2017-06-05添加可选参数openId
            //用于区分是否来自于微信H5支付
            //默认为空
            string      openId      = Row.Table.Columns.Contains("openId") ? Row["openId"].ToString() : "";
            WxPayConfig wxPayConfig = GenerateConfig(CommunityId);

            if (null == wxPayConfig)
            {
                return(JSONHelper.FromString(false, "未配置证书文件"));
            }

            PubConstant.hmWyglConnectionString = GetConnection(CommunityId);
            Global_Var.CorpSQLConnstr          = PubConstant.hmWyglConnectionString;

            string Amount = "0";

            //生成物业账单
            string PropertyResult = GeneratePropertyOrder(CommunityId, CostID, StanID, HandID, RoomID, txnTime, CustID, Months, ref IsPropertyOk, ref Amount, ref PropertyOrderId, wxPayConfig);

            if (IsPropertyOk == true)
            {
                //生成银行订单,返回银行流水号
                WxPayData Data       = new WxPayData();
                string    BankResult = GenerateBankOrder(CommunityId, CustID, RoomID, UserID, Months, PropertyOrderId, txnTime, Amount, ref IsBankOk, ref BankOrderId, ref Data, wxPayConfig, openId);
                if (IsBankOk == false)
                {
                    return(JSONHelper.FromString(false, BankResult));
                }
                else
                {
                    //更新订单银行流水号
                    IDbConnection Conn  = new SqlConnection(PubConstant.hmWyglConnectionString);
                    string        Query = "UPDATE Tb_OL_WeiXinPayOrder SET prepay_id=@prepay_id WHERE out_trade_no = @out_trade_no ";
                    Conn.Execute(Query, new { prepay_id = Data.GetValue("prepay_id").ToString(), out_trade_no = PropertyOrderId });
                    //向手机端返回银行记录
                    WxPayData result = new WxPayData();
                    result.SetValue("appid", Data.GetValue("appid"));
                    result.SetValue("partnerid", Data.GetValue("mch_id"));
                    result.SetValue("prepayid", Data.GetValue("prepay_id"));
                    result.SetValue("noncestr", Data.GetValue("nonce_str"));
                    result.SetValue("package", "Sign=WXPay");
                    result.SetValue("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
                    result.SetValue("sign", result.MakeSign());

                    int presentedPoint = new AppPoint().CalcPresentedPointForPrec_lf(Months);
                    result.SetValue("presented_points", presentedPoint);
                    result.SetValue("out_trade_no", PropertyOrderId);

                    return(JSONHelper.FromJsonString(true, result.ToJson()));
                }
            }
            else
            {
                return(JSONHelper.FromString(false, PropertyResult));
            }
        }
Example #2
0
        /// <summary>
        /// 生成银行及物业订单
        /// </summary>
        /// <param name="Row"></param>
        /// <returns></returns>
        public string GenerateOrder(DataRow Row)
        {
            bool   IsBankOk        = false;
            bool   IsPropertyOk    = false;
            string PropertyOrderId = "";
            string prepay_str      = "";

            string CommunityId = Row["CommunityId"].ToString();
            string CostID      = Row["CostID"].ToString();
            string StanID      = Row["StanID"].ToString();
            string HandID      = Row["HandID"].ToString();
            string RoomID      = Row["RoomID"].ToString();
            string txnTime     = DateTime.Now.ToString("yyyyMMddHHmmss");
            string CustID      = Row["CustID"].ToString();
            string UserID      = Row["UserID"].ToString();
            int    Months      = AppGlobal.StrToInt(Row["Months"].ToString());

            if (Months == 0)
            {
                return(JSONHelper.FromString(false, "请选择预存月数"));
            }

            bool IsConfig = GenerateConfig(CommunityId);

            if (IsConfig == false)
            {
                return(JSONHelper.FromString(false, "未配置证书文件"));
            }

            PubConstant.hmWyglConnectionString = GetConnection(CommunityId);
            Global_Var.CorpSQLConnstr          = PubConstant.hmWyglConnectionString;

            string Amount = "0";

            //生成物业账单
            string PropertyResult = GeneratePropertyOrder(CommunityId, CostID, StanID, HandID, RoomID, txnTime, CustID, Months, ref IsPropertyOk, ref Amount, ref PropertyOrderId);

            if (IsPropertyOk == true)
            {
                //返回签名的订单信息
                string BankResult = GenerateBankOrder(CommunityId, CustID, RoomID, UserID, Months, PropertyOrderId, txnTime, Amount, ref IsBankOk, ref prepay_str);
                if (IsBankOk == false)
                {
                    return(JSONHelper.FromString(false, BankResult));
                }
                else
                {
                    int presentedPoint = new AppPoint().CalcPresentedPointForPrec_lf(Months);
                    prepay_str = prepay_str.Insert(prepay_str.Length - 1, ",\"presented_points\":" + presentedPoint + "");

                    //更新订单银行流水号
                    IDbConnection Conn  = new SqlConnection(PubConstant.hmWyglConnectionString);
                    string        Query = "UPDATE Tb_OL_AlipayOrder SET prepay_str=@prepay_str WHERE out_trade_no = @out_trade_no ";
                    Conn.Execute(Query, new { prepay_str = prepay_str.ToString(), out_trade_no = PropertyOrderId });
                    //返回请求字符串
                    return(JSONHelper.FromJsonString(true, prepay_str));
                }
            }
            else
            {
                return(JSONHelper.FromString(false, PropertyResult));
            }
        }