Ejemplo n.º 1
0
        public Result <TCom.EF.MyOrder> DetailFoyPay(string iduser, string orderno)
        {
            Result <TCom.EF.MyOrder> result = new Result <TCom.EF.MyOrder>();

            try
            {
                if (!string.IsNullOrWhiteSpace(iduser) && !string.IsNullOrWhiteSpace(orderno))
                {
                    long _iduser  = long.Parse(iduser);
                    long _orderno = long.Parse(orderno);
                    using (TN db = new TN())
                    {
                        TCom.EF.MyOrder o = db.MyOrders.Where(m => m.inuse == true && m.iduser == _iduser && m.orderno == _orderno).FirstOrDefault();
                        result.Data = o;
                        result.Code = R.Ok;
                    }
                }
            }
            catch (Exception)
            {
                result.Code = R.Error;
                result.Msg  = "出现异常";
            }
            return(result);
        }
Ejemplo n.º 2
0
        //派生类需要重写这个方法,进行不同的回调处理
        public static int Press()
        {
            WxPayData data = OrdeQquery();

            if (data != null)
            {
                string return_code = data.GetValue("return_code") + "";
                if (return_code == "SUCCESS")
                {
                    string orderno = data.GetValue("out_trade_no") + "";
                    string openid  = data.GetValue("openid") + "";

                    if (!string.IsNullOrWhiteSpace(orderno) && !string.IsNullOrWhiteSpace(openid))
                    {
                        string   trade_state = data.GetValue("trade_state") + "";
                        long     _orderno    = long.Parse(orderno);
                        DateTime paytime     = DateTime.Now;
                        try
                        {
                            string time_end = data.GetValue("time_end") + "";
                            if (string.IsNullOrWhiteSpace(time_end))
                            {
                                paytime = DateTime.ParseExact(time_end, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
                            }
                        }
                        catch (Exception)
                        {
                        }
                        using (TN db = new TN())
                        {
                            TCom.EF.User u = db.Users.Where(m => m.idweixin == openid && m.inuse == true).FirstOrDefault();
                            if (u != null)
                            {
                                TCom.EF.MyOrder o = db.MyOrders.Where(m => m.orderno == _orderno && m.inuse == true).FirstOrDefault();
                                if (o != null)
                                {
                                    // bool ok = false;
                                    if (o.status == OrderStatus.WaitPay &&
                                        o.paystatus != PayStatus.WeiXin_SUCCESS &&
                                        o.paystatus != PayStatus.WeiXin_CLOSED)
                                    {
                                        if (trade_state == PayStatus.WeiXin_SUCCESS)
                                        {
                                            o.status = OrderStatus.PayFinish;
                                            MyOrderPress s = new MyOrderPress();
                                            s.idpress = Pub.ID().ToString();
                                            s.orderno = orderno;
                                            s.status  = OrderStatus.PayFinish;
                                            s.statust = OrderStatus.get(s.status).text;
                                            s.oper    = u.name;
                                            s.inuse   = true;
                                            s.cretime = paytime;
                                            db.MyOrderPresses.Add(s);
                                            MsgMgr.PostFinishPay(o.orderno + "", o.otype != null ? o.otype.Value : 0, db);
                                        }
                                        else
                                        {
                                            o.status = OrderStatus.WaitPay;
                                        }
                                        o.paystatus = trade_state;

                                        if (db.SaveChanges() > 0)
                                        {
                                            MsgMgr.Post();
                                            return(PayNotifyResult.Pay);
                                        }
                                    }
                                    else
                                    {
                                        return(PayNotifyResult.Payed);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(PayNotifyResult.Fail);
            //returnPayPressResult("FAIL");
        }