Ejemplo n.º 1
0
 public JsonResult OrderAuditing(string ordercode)
 {
     string msg = "";
     var result = false;
     var model = UserOrdersBusiness.GetUserOrderDetail(ordercode);
     if (model != null && model.Status ==0)
     {
         result = UserOrdersBusiness.OrderAuditting(ordercode, "", model.TotalFee);
     }
     else
     {
         msg = "订单状态不正确";
     }
     JsonDictionary.Add("errorMsg", msg);
     JsonDictionary.Add("result", result);
     return new JsonResult
     {
         Data = JsonDictionary,
         JsonRequestBehavior = JsonRequestBehavior.AllowGet
     };
 }
Ejemplo n.º 2
0
        public void ZHFNotify()
        {
            string merchant_code      = Request.Params.AllKeys.Contains("merchant_code") ? Request["merchant_code"].ToString().Trim() : ZHFPayTools.partner;
            string notify_type        = Request.Params.AllKeys.Contains("notify_type") ? Request["notify_type"].ToString().Trim() : "offline_notify";
            string notify_id          = Request.Params.AllKeys.Contains("notify_id") ? Request["notify_id"] ?? "".ToString().Trim() : "";
            string interface_version  = Request.Params.AllKeys.Contains("interface_version") ? Request["interface_version"].ToString().Trim() : "V3.0";
            string sign_type          = Request.Params.AllKeys.Contains("sign_type") ? Request["sign_type"].ToString().Trim() : "RSA-S";
            string zhfsign            = Request.Params.AllKeys.Contains("sign") ? Request["sign"].ToString().Trim() : "";
            string order_no           = Request.Params.AllKeys.Contains("order_no") ? Request["order_no"].ToString().Trim() : "";
            string order_time         = Request.Params.AllKeys.Contains("order_time") ? Request["order_time"].ToString().Trim() : "";
            string order_amount       = Request.Params.AllKeys.Contains("order_amount") ? Request["order_amount"].ToString().Trim() : "";
            string extra_return_param = Request.Params.AllKeys.Contains("extra_return_param") ? Request["extra_return_param"] : "";
            string trade_no           = Request.Params.AllKeys.Contains("trade_no") ? Request["trade_no"].ToString().Trim() : "";
            string orginal_money      = Request.Params.AllKeys.Contains("orginal_money") ? Request["orginal_money"] : "";
            string trade_time         = Request.Params.AllKeys.Contains("trade_time") ? Request["trade_time"].ToString().Trim() : "";
            string trade_status       = Request.Params.AllKeys.Contains("trade_status") ? Request["trade_status"].ToString().Trim() : "";
            string bank_seq_no        = Request.Params.AllKeys.Contains("bank_seq_no") ? Request["bank_seq_no"] : "";

            /**
             *签名顺序按照参数名a到z的顺序排序,若遇到相同首字母,则看第二个字母,以此类推,
             *参数名1=参数值1&参数名2=参数值2&……&参数名n=参数值n
             **/
            //组织订单信息
            string signStr = "";

            if (null != bank_seq_no && bank_seq_no != "")
            {
                signStr = signStr + "bank_seq_no=" + bank_seq_no.ToString().Trim() + "&";
            }

            if (null != extra_return_param && extra_return_param != "")
            {
                signStr = signStr + "extra_return_param=" + extra_return_param + "&";
            }
            signStr = signStr + "interface_version=" + interface_version + "&";
            signStr = signStr + "merchant_code=" + merchant_code + "&";


            if (null != notify_id && notify_id != "")
            {
                signStr = signStr + "notify_id=" + notify_id + "&notify_type=" + notify_type + "&";
            }

            signStr = signStr + "order_amount=" + order_amount + "&";
            signStr = signStr + "order_no=" + order_no + "&";
            signStr = signStr + "order_time=" + order_time + "&";
            if (null != orginal_money && orginal_money != "")
            {
                signStr = signStr + "orginal_money=" + orginal_money + "&";
            }
            signStr = signStr + "trade_no=" + trade_no + "&";
            signStr = signStr + "trade_status=" + trade_status;

            if (null != trade_time && trade_time != "")
            {
                signStr = signStr + "&trade_time=" + trade_time;
            }

            /**
             * 1)zhf_public_key,智汇付公钥,每个商家对应一个固定的智汇付公钥(不是使用工具生成的密钥merchant_public_key,不要混淆),
             * 即为智汇付商家后台"公钥管理"->"智汇付公钥"里的绿色字符串内容
             * 2)demo提供的zhf_public_key是测试商户号1111110166的智汇付公钥,请自行复制对应商户号的智汇付公钥进行调整和替换。
             */

            string zhf_public_key = ZHFPayTools.zhfpubkey;

            //将智汇付公钥转换成C#专用格式
            zhf_public_key = ZHFPayTools.RSAPublicKeyJava2DotNet(zhf_public_key);
            //验签
            bool result = ZHFPayTools.ValidateRsaSign(signStr, zhf_public_key, zhfsign);

            if (result == true)
            {
                //判断该笔订单是否在商户网站中已经做过处理
                //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
                //如果有做过处理,不执行商户的业务程序
                //获取订单详情
                UserOrders order = UserOrdersBusiness.GetUserOrderDetail(order_no);
                if (order != null && !string.IsNullOrEmpty(order.OrderCode))
                {
                    decimal total_fee = decimal.Parse(order_amount);
                    if (string.IsNullOrEmpty(orginal_money))
                    {
                        total_fee = decimal.Parse(orginal_money);
                    }
                    if (order.PayFee == total_fee)
                    {
                        //订单支付及后台客户授权
                        bool flag = UserOrdersBusiness.OrderAuditting(order.OrderCode, trade_no, total_fee);
                        if (flag)
                        {
                            //如果验签结果为true,则对订单进行更新
                            //订单更新完之后必须打印SUCCESS来响应智汇付服务器以示商户已经正常收到智汇付服务器发送的异步数据通知,否则智汇付服务器将会在之后的时间内若干次发送同一笔订单的异步数据!!
                            Response.Write("success"); //请不要修改或删除
                        }
                    }
                }
            }
            else
            {
                //验签失败
                Response.Write("验签失败");
            }
        }