예제 #1
0
        /// <summary>
        /// 验证签名和订单有效性
        /// </summary>
        /// <param name="mod">查询到的订单实体</param>
        /// <param name="mode">接收到的参数实体</param>
        /// <returns></returns>
        private InnerResponse checkSign(PayBankModels mode, JMP.MDL.jmp_order mod)
        {
            InnerResponse Inn         = new InnerResponse();
            int           bizcodeTime = Int32.Parse(ConfigurationManager.AppSettings["bizcodeTime"]);

            //规则=JMP.TOOL.MD5.md5strGet((mod.o_code + mod.o_price), true).ToUpper();
            if (!VerificationCode(mode.code, bizcodeTime, mod.o_app_id))
            {
                return(Inn = Inn.ToResponse(ErrorCode.Code8988));
            }
            string sign = JMP.TOOL.MD5.md5strGet((mod.o_code + mode.price), true).ToUpper();

            if (mode.price == mod.o_price && sign == mode.sign)
            {
                int  szsj = int.Parse(ConfigurationManager.AppSettings["EffectiveTime"].ToString());
                bool pdsj = DateTime.ParseExact(mode.code.Substring(0, 14), "yyyyMMddHHmmss", CultureInfo.InvariantCulture) > DateTime.Parse(DateTime.Now.AddMinutes(-(szsj)).ToString("yyyy-MM-dd HH:mm:ss")) ? true : false;//判断是否在规定时间范围内
                if (pdsj == false)
                {
                    Inn = Inn.ToResponse(ErrorCode.Code8992);
                }
                else
                {
                    Inn = Inn.ToResponse(ErrorCode.Code100);
                }
            }
            else
            {
                Inn = Inn.ToResponse(ErrorCode.Code9989);
            }
            return(Inn);
        }
예제 #2
0
 /// <summary>
 /// 根据商户订单号和appid查询订单信息
 /// </summary>
 /// <param name="mod">参数实体</param>
 /// <param name="json">参数json字符串</param>
 /// <returns></returns>
 private jmp_order SelectOrder(QueryModels mod, string json)
 {
     JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order();
     JMP.BLL.jmp_order bll  = new JMP.BLL.jmp_order();
     try
     {
         mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, "jmp_order");
         if (mode == null)
         {
             string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.ToString("yyyy-MM-dd")); //获取订单表名
             mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, orderTableName);                      //查询本周归档表
             string weekstr = DateTime.Now.DayOfWeek.ToString();
             if (mode == null && weekstr == "Monday" && Int32.Parse(DateTime.Now.ToString("HH")) <= 2)
             {
                 string TableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")); //获取订单表名
                 mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, orderTableName);                             //查询上周归档表
             }
         }
     }
     catch (Exception e)
     {
         string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息
         PayApiGlobalErrorLogger.Log("报错信息:查询接口查询订单报错,获取到的参数:" + json + ",报错信息:" + bcxx, summary: "接口错误信息");
         return(null);
     }
     return(mode);
 }
예제 #3
0
        /// <summary>
        /// 查询相关订单信息
        /// </summary>
        /// <param name="mod">查询参数实体</param>
        /// <param name="json">json字符串</param>
        /// <returns></returns>
        private QueryRespon OrderSelect(QueryModels mod, string json)
        {
            //订单缓存时间
            int         infoTime = Int32.Parse(ConfigurationManager.AppSettings["infoTime"]);
            QueryRespon qu       = new QueryRespon();

            JMP.MDL.jmp_order mode   = new JMP.MDL.jmp_order();
            string            hcname = "Query" + mod.appid.ToString();
            int QueryNum             = 0;

            if (JMP.TOOL.CacheHelper.IsCache(hcname))                   //判读是否存在缓存
            {
                QueryNum = JMP.TOOL.CacheHelper.GetCaChe <int>(hcname); //获取缓存
            }
            mode = SelectOrder(mod, json);
            if (mode != null)
            {
                qu             = qu.QueryResp(QueryErrorCode.Code100);
                qu.trade_code  = mode.o_code;
                qu.trade_no    = mode.o_bizcode;
                qu.trade_price = mode.o_price.ToString("f2");
                qu.o_state     = mode.o_state == 1 ? mode.o_state : 0;
                qu.trade_time  = mode.o_state == 1 ? mode.o_ptime.ToString("yyyyMMddHHmmss") : "";
                qu.trade_type  = string.IsNullOrEmpty(mode.o_paymode_id) ? 0 : Int32.Parse(mode.o_paymode_id);
                QueryNum       = QueryNum + 1;
                JMP.TOOL.CacheHelper.UpdateCacheObjectLocak <int>(QueryNum, hcname, infoTime);//存入缓存
            }
            else
            {
                qu = qu.QueryResp(QueryErrorCode.Code101);
            }
            return(qu);
        }
예제 #4
0
파일: PreOrder.cs 프로젝트: dmhai/dxpay
        /// <summary>
        /// 验证商户订单号是否唯一
        /// </summary>
        /// <param name="bizcode">商户订单号</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private bool VerificationCode(string bizcode, int appid)
        {
            bool IsRepeat = false;

            JMP.MDL.jmp_order mode     = new JMP.MDL.jmp_order();
            JMP.BLL.jmp_order bll      = new JMP.BLL.jmp_order();
            string            Cachekey = "VerificationCode" + bizcode + appid;

            if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存
            {
                PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口验证参数错误,商户订单重复,缓存值:" + Cachekey + ",商户订单号:" + bizcode, summary: "接口错误信息", appId: appid, errorType: EnumForLogForApi.ErrorType.OrderNoRepeat);
                IsRepeat = true;
            }
            else
            {
                IsRepeat = false;
            }
            return(IsRepeat);
        }
예제 #5
0
파일: PreOrder.cs 프로젝트: dmhai/dxpay
        /// <summary>
        /// 添加订单入库
        /// </summary>
        /// <param name="mode">传入参数实体</param>
        /// <param name="json">传入参数json字符串</param>
        /// <returns></returns>
        private InnerResponse DownOrder(RequestParameter mode, string json)
        {
            InnerResponse Inn = new InnerResponse();

            JMP.MDL.jmp_order mod          = new JMP.MDL.jmp_order(); //订单表实体类
            JMP.BLL.jmp_order jmp_orderbll = new JMP.BLL.jmp_order(); //订单表业务逻辑层
            mod.o_address     = mode.address;
            mod.o_showaddress = mode.showaddress;
            mod.o_app_id      = mode.appid;
            mod.o_bizcode     = mode.bizcode;
            mod.o_term_key    = mode.termkey;
            mod.o_paymode_id  = mode.paytype.ToString();
            mod.o_goodsname   = mode.goodsname;
            mod.o_price       = mode.price;
            mod.o_privateinfo = mode.privateinfo;
            Random r = new Random(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0));

            mod.o_code        = DateTime.Now.ToString("yyyyMMddHHmmssfff") + r.Next(111111111, 999999999).ToString() + r.Next(1111, 9999).ToString();
            mod.o_state       = 0;
            mod.o_times       = 0;
            mod.o_noticestate = 0;
            mod.o_ctime       = DateTime.Now;
            mod.o_noticetimes = DateTime.Now;
            mod.o_ptime       = DateTime.Now;
            int cg = 0;

            cg = jmp_orderbll.AddOrder(mod);
            if (cg > 0)
            {
                pr.orderid   = cg;
                pr.code      = mod.o_code;
                pr.goodsname = mode.goodsname;
                pr.price     = mode.price;
                Inn          = Inn.ToResponse(ErrorCode.Code100);
            }
            else
            {
                PayApiGlobalErrorLogger.Log("报错信息:支付信息生成订单失败,获取到的参数:" + json, summary: "接口错误信息");
                Inn = Inn.ToResponse(ErrorCode.Code101);
            }
            return(Inn);
        }
예제 #6
0
        /// <summary>
        /// 根据订单编号查询订单信息并调取支付当时
        /// </summary>
        /// <param name="Code">订单编号</param>
        /// <param name="json">接受参数json字符串</param>
        /// <param name="ip">请求ip地址</param>
        /// <returns></returns>
        private JMP.MDL.jmp_order SelectCode(string Code, int CacheTime, string paytype)
        {
            JMP.MDL.jmp_order mode     = new JMP.MDL.jmp_order();
            JMP.BLL.jmp_order bll      = new JMP.BLL.jmp_order();
            string            Cachekey = "SelectCode" + Code + paytype;

            if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存
            {
                if (paytype == "4")
                {
                    mode = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存
                }
                else
                {
                    JMP.MDL.jmp_order moded = new JMP.MDL.jmp_order();
                    moded = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存
                    PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:商户发起重复下单请求,订单编号" + Code, summary: "接口错误信息,商户多次发起支付请求!", appId: moded.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat);
                    mode = null;
                }
                //mode = JMP.TOOL.CacheHelper.GetCaChe<JMP.MDL.jmp_order>(Cachekey);//获取缓存
                //if (mode == null)
                //{
                //    mode = bll.GetModelbycode(Code, "jmp_order");
                //    if (mode != null)
                //    {
                //        JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存
                //    }
                //}
            }
            else
            {
                mode = bll.SelectCode(Code, "jmp_order");
                if (mode != null)
                {
                    JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存
                }
            }
            return(mode);
        }
예제 #7
0
        /// <summary>
        /// H5和收银台模式下单主通道
        /// </summary>
        /// <param name="mode">接受参数modes实体</param>
        /// <param name="CacheTime"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        public InnerResponse H5OrBankEntrance(PayBankModels mode, int CacheTime, string ip)
        {
            InnerResponse Inn = new InnerResponse();

            if (mode != null)
            {
                Inn = InspectParameter(mode);
                if (Inn.Success == true)
                {
                    JMP.MDL.jmp_order mod = new JMP.MDL.jmp_order();
                    mod = SelectCode(mode.code, CacheTime, mode.paytype);
                    if (mod != null && mod.o_state == 0)
                    {
                        Inn = checkSign(mode, mod);
                        if (Inn.Success == true)
                        {
                            Apprate apprate = new Apprate();
                            if (Int32.Parse(mode.paytype) > 0 && !apprate.SelectApprate(mod.o_app_id, Int32.Parse(mode.paytype), CacheTime))
                            {
                                return(Inn = Inn.ToResponse(ErrorCode.Code8987));
                            }
                            if (UpdateCode(mod.o_id, int.Parse(mode.paytype)))
                            {
                                try
                                {
                                    JmPayParameter.PayTypeFactory.PayTypeFactory payTypeFactory = new PayTypeFactory.PayTypeFactory();
                                    var payType = payTypeFactory.Create(int.Parse(mode.paytype));
                                    if (mode.paytype == "4" && (mode.paymode == 2 || mode.paymode == 1))
                                    {
                                        mode.paymode = 3;
                                    }
                                    var channel = payType.LoadChannel(mode.paymode, mode.apptype, CacheTime, mod.o_app_id);
                                    JmPayParameter.PlaceOrder.PlaceOrderFactory placeOrderFactory = new PlaceOrder.PlaceOrderFactory();
                                    //返回支付信息
                                    Inn = placeOrderFactory.Create(channel.PassName, mode.paymode, mode.apptype, mode.code, mode.goodsname, mode.price, mod.o_id, ip, mod.o_app_id);
                                }
                                catch (Exc e)
                                {
                                    Inn = e.Response;
                                    return(Inn);
                                }
                            }
                            else
                            {
                                PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口收银台模式报错,修改订单失败:订单id:" + mod.o_id + ",支付方式:" + mode.paymode + ",订单编号:" + mode.code, summary: "接口错误信息", appId: mod.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat);
                                Inn = Inn.ToResponse(ErrorCode.Code8999);
                            }
                        }
                    }
                    else
                    {
                        Inn = Inn.ToResponse(ErrorCode.Code8991);
                    }
                }
            }
            else
            {
                PayApiGlobalErrorLogger.Log("报错信息103:支付接口收银台模式报错,未获取到下单参数,接收参数的实体为空", summary: "接口错误信息");
                Inn = Inn.ToResponse(ErrorCode.Code103);
            }
            return(Inn);
        }
예제 #8
0
        public JsonResult Orderrewire()
        {
            object retJson   = new { success = 0, msg = "操作失败" };
            string ordercode = string.IsNullOrEmpty(Request["code"]) ? "" : Request["code"];
            string ptime     = string.IsNullOrEmpty(Request["ptime"]) ? "" : Request["ptime"];
            bool   sess      = Convert.ToDateTime(Session["sendtime_" + ordercode]) > System.DateTime.Now.AddMinutes(-1) ? true : false;

            if (!string.IsNullOrEmpty(ordercode) && !string.IsNullOrEmpty(ptime))
            {
                if (DateTime.Parse(DateTime.Parse(ptime).ToString("yyyy-MM-dd")) > DateTime.Parse(DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd")))
                {
                    if (sess)
                    {
                        retJson = new { success = 0, msg = "请间隔一分钟,再次发送!" };
                        return(Json(retJson));
                    }
                    else
                    {
                        JMP.BLL.jmp_order bll        = new JMP.BLL.jmp_order();
                        JMP.MDL.jmp_order morder     = new JMP.MDL.jmp_order();
                        string            tabalename = "dbo.jmp_order_" + JMP.TOOL.WeekDateTime.GetWeekFirstDayMon(DateTime.Parse(ptime)).ToString("yyyyMMdd");
                        morder = bll.SelectOrder(ordercode, tabalename);
                        if (morder != null)
                        {
                            if (morder.o_times > 8 && morder.o_times < 12)
                            {
                                JMP.MDL.jmp_queuelist quli = new JMP.MDL.jmp_queuelist();
                                JMP.BLL.jmp_queuelist bllq = new JMP.BLL.jmp_queuelist();
                                quli.q_address     = morder.o_address;
                                quli.q_sign        = new JMP.BLL.jmp_app().GetModel(morder.o_app_id).a_secretkey;
                                quli.q_noticestate = 0;
                                quli.q_times       = morder.o_times;
                                quli.q_noticetimes = DateTime.Now;
                                quli.q_tablename   = tabalename;
                                quli.q_o_id        = morder.o_id;
                                quli.trade_type    = Int32.Parse(morder.o_paymode_id);
                                quli.trade_time    = morder.o_ptime;
                                quli.trade_price   = morder.o_price;
                                quli.trade_paycode = morder.o_tradeno;
                                quli.trade_code    = morder.o_code;
                                quli.trade_no      = morder.o_bizcode;
                                quli.q_privateinfo = morder.o_privateinfo;
                                quli.q_uersid      = UserInfo.UserId;
                                int cg = bllq.Add(quli);
                                if (cg > 0)
                                {
                                    Session["sendtime_" + morder.o_code] = System.DateTime.Now;
                                    retJson = new { success = 1, msg = "已重发通知!手动通知次数剩余:" + (11 - morder.o_times) + "次" };
                                }
                                else
                                {
                                    Logger.OperateLog("商务平台手动重发通知失败", "订单号:" + morder.o_code + ",表名:" + tabalename); //写入报错日
                                    retJson = new { success = 0, msg = "操作失败!" };
                                }
                            }
                            else
                            {
                                retJson = new { success = 0, msg = "手动通知无效!" };
                            }
                        }
                    }
                }
                else
                {
                    retJson = new { success = 0, msg = "只能重发三天以内的数据!" };
                }
            }
            else
            {
                retJson = new { success = 0, msg = "数据异常!" };
            }
            return(Json(retJson));
        }