Ejemplo n.º 1
0
 public ActionResult Add(Coupon model)
 {
     using (HouseMovingDBEntities db = new HouseMovingDBEntities())
     {
         ResponseMessage msg = new ResponseMessage();
         try
         {
             //先校验优惠码是否重复
             var isExist = db.Coupon.Any(p => p.Code == model.Code.Trim());
             if (isExist)
             {
                 msg.Status = false;
                 msg.Result = "900";
                 return(Json(msg, JsonRequestBehavior.AllowGet));
             }
             model.IsUsed = false;
             msg.Status   = true;
             var entity = db.Coupon.Add(model);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             msg.Status = false;
             msg.Result = "500";
         }
         return(Json(msg, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 2
0
        public ActionResult Add(Order model)
        {
            using (HouseMovingDBEntities db = new HouseMovingDBEntities())
            {
                ResponseMessage msg = new ResponseMessage();
                try
                {
                    //先校验优惠码
                    if (!string.IsNullOrWhiteSpace(model.CouponCode))
                    {
                        var couponModel = db.Coupon.FirstOrDefault(p => p.IsUsed == false && p.Code == model.CouponCode.Trim());
                        if (couponModel == null)
                        {
                            msg.Status = false;
                            msg.Result = "900";
                            return(Json(msg, JsonRequestBehavior.AllowGet));
                        }
                        model.CouponID = couponModel.ID;
                        //优惠金额
                        model.SalePrice = couponModel.Amount;
                        //支付金额
                        model.PayPrice = model.OrgPrice - couponModel.Amount;

                        //db.Children.Attach(model);
                        couponModel.IsUsed          = true;
                        db.Entry(couponModel).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    model.PayState   = "0";
                    model.OrderNo    = DateTime.Now.ToString(FormatDateTime.DateTimeFormatNoStr);
                    model.CreateTime = DateTime.Now.ToString(FormatDateTime.LongDateTimeStr);
                    var entity = db.Order.Add(model);
                    db.SaveChanges();
                    msg.Status = true;
                    msg.Data   = model;
                }
                catch (Exception e)
                {
                    msg.Status = false;
                    msg.Result = "500";
                }
                return(Json(msg, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 回调函数
        /// </summary>
        public void PayNotifyUrl()
        {
            PayLogHelper.Debug("进入微信支付回调HttpPost WeChatPay PayNotifyUrl");
            WxPayData notifyData     = GetNotifyData();
            string    out_trade_no   = notifyData.GetValue("out_trade_no").ToString();
            string    transaction_id = notifyData.GetValue("transaction_id").ToString();
            string    totalFee       = notifyData.GetValue("total_fee").ToString();

            if (notifyData.GetValue("return_code").ToString() == "SUCCESS" && notifyData.GetValue("result_code").ToString() == "SUCCESS")
            {
                PayLogHelper.Debug("WX:获取到notifyData值");
                PayLogHelper.Debug("WXout_trade_no:" + out_trade_no);
                Response.Write("成功");
                //支付成功,以下执行业务处理

                using (HouseMovingDBEntities db = new HouseMovingDBEntities())
                {
                    ResponseMessage msg = new ResponseMessage();
                    msg.Status = true;
                    var entity = db.Order.FirstOrDefault(p => p.OrderNo == out_trade_no && p.PayState != "2");
                    if (entity != null)
                    {
                        entity.PayTime         = DateTime.Now.ToString(FormatDateTime.LongDateTimeStr);
                        entity.PayState        = "1";
                        entity.PayType         = "WX";
                        db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    //注释下处代码,允许微信回调,重复通知申请支付的网站,让客户端做重复处理
                    WxPayData res = new WxPayData();
                    res.SetValue("return_code", "SUCCESS");
                    res.SetValue("return_msg", "OK");
                    PayLogHelper.Debug("WX:order query success : " + res.ToXml());
                    System.Web.HttpContext.Current.Response.Write(res.ToXml());
                    System.Web.HttpContext.Current.Response.End();
                }
            }
            else
            {
                PayLogHelper.Debug("WX支付失败");
                Response.Write("失败");
                //失败
                //msg.Result = AESEncryption.AESEncrypt("false");
            }
        }
 public ActionResult Update(CarPriceSetting model)
 {
     using (HouseMovingDBEntities db = new HouseMovingDBEntities())
     {
         ResponseMessage msg = new ResponseMessage();
         try
         {
             db.CarPriceSetting.Attach(model);
             db.Entry(model).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             msg.Status = true;
         }
         catch (Exception e)
         {
             msg.Status = false;
             msg.Result = "500";
         }
         return(Json(msg, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 5
0
 public ActionResult Add(Comment model)
 {
     using (HouseMovingDBEntities db = new HouseMovingDBEntities())
     {
         ResponseMessage msg = new ResponseMessage();
         try
         {
             model.CreateTime = DateTime.Now.ToString(FormatDateTime.LongDateTimeStr);
             var entity = db.Comment.Add(model);
             db.SaveChanges();
             msg.Status = true;
         }
         catch (Exception e)
         {
             msg.Status = false;
             msg.Result = "500";
         }
         return(Json(msg, JsonRequestBehavior.AllowGet));
     }
 }