Exemple #1
0
 public ActionResult CreateProduct(Off_Product model)
 {
     if (ModelState.IsValid)
     {
         var         user = UserManager.FindById(User.Identity.GetUserId());
         Off_Product item = new Off_Product();
         if (TryUpdateModel(item))
         {
             item.Off_System_Id = user.DefaultSystemId;
             _offlineDB.Off_Product.Add(item);
             _offlineDB.SaveChanges();
             return(Content("SUCCESS"));
         }
         return(PartialView("Error"));
     }
     else
     {
         ModelState.AddModelError("", "发生错误");
         return(PartialView(model));
     }
 }
Exemple #2
0
        public JsonResult UpdateManagerToSeniorAjax(int id)
        {
            var manager = _offlineDB.Off_StoreManager.SingleOrDefault(m => m.Id == id);

            if (manager != null)
            {
                var currentuser = UserManager.FindById(User.Identity.GetUserId());
                if (manager.Off_System_Id == currentuser.DefaultSystemId)
                {
                    var user = UserManager.FindByName(manager.UserName);
                    UserManager.AddToRole(user.Id, "Senior");
                    manager.Status = 2;
                    _offlineDB.Entry(manager).State = System.Data.Entity.EntityState.Modified;
                    _offlineDB.SaveChanges();
                    return(Json(new { result = "SUCCESS" }));
                }
                else
                {
                    return(Json(new { result = "UNZUTHORIZED" }));
                }
            }
            else
            {
                return(Json(new { result = "FAIL" }));
            }
        }
Exemple #3
0
        public ActionResult wx_pay_nofity()
        {
            StreamReader reader = new StreamReader(Request.InputStream, Encoding.UTF8);
            XmlDocument  doc    = new XmlDocument();

            doc.Load(reader);
            //CommonUtilities.writeLog(doc.OuterXml);
            string return_code = doc.GetElementsByTagName("return_code")[0].InnerText;

            try
            {
                if (return_code == "SUCCESS")
                {
                    string appid          = doc.GetElementsByTagName("appid")[0] == null ? "" : doc.GetElementsByTagName("appid")[0].InnerText;
                    string mch_id         = doc.GetElementsByTagName("mch_id")[0] == null ? "" : doc.GetElementsByTagName("mch_id")[0].InnerText;
                    string is_subscribe   = doc.GetElementsByTagName("is_subscribe")[0] == null ? "" : doc.GetElementsByTagName("is_subscribe")[0].InnerText;
                    string nonce_str      = doc.GetElementsByTagName("nonce_str")[0] == null ? "" : doc.GetElementsByTagName("nonce_str")[0].InnerText;
                    string request_sign   = doc.GetElementsByTagName("sign")[0] == null ? "" : doc.GetElementsByTagName("sign")[0].InnerText;
                    string result_code    = doc.GetElementsByTagName("result_code")[0] == null ? "" : doc.GetElementsByTagName("result_code")[0].InnerText;
                    string openid         = doc.GetElementsByTagName("openid")[0] == null ? "" : doc.GetElementsByTagName("openid")[0].InnerText;
                    string trade_type     = doc.GetElementsByTagName("trade_type")[0] == null ? "" : doc.GetElementsByTagName("trade_type")[0].InnerText;
                    string bank_type      = doc.GetElementsByTagName("bank_type")[0] == null ? "" : doc.GetElementsByTagName("bank_type")[0].InnerText;
                    string total_fee      = doc.GetElementsByTagName("total_fee")[0] == null ? "" : doc.GetElementsByTagName("total_fee")[0].InnerText;
                    string fee_type       = doc.GetElementsByTagName("fee_type")[0] == null ? "" : doc.GetElementsByTagName("fee_type")[0].InnerText;
                    string transaction_id = doc.GetElementsByTagName("transaction_id")[0] == null ? "" : doc.GetElementsByTagName("transaction_id")[0].InnerText;
                    string out_trade_no   = doc.GetElementsByTagName("out_trade_no")[0] == null ? "" : doc.GetElementsByTagName("out_trade_no")[0].InnerText;
                    string attach         = doc.GetElementsByTagName("attach")[0] == null ? "" : doc.GetElementsByTagName("attach")[0].InnerText;
                    string time_end       = doc.GetElementsByTagName("time_end")[0] == null ? "" : doc.GetElementsByTagName("time_end")[0].InnerText;
                    string device_info    = doc.GetElementsByTagName("device_info")[0] == null ? "" : doc.GetElementsByTagName("device_info")[0].InnerText;
                    var    order          = offlineDB.WxPayOrder.SingleOrDefault(m => m.Trade_No == out_trade_no);
                    if (order != null)
                    {
                        // 已成功订单
                        CommonUtilities.writeLog("有订单");
                        if (order.Trade_Status == WeChatUtilities.TRADE_STATUS_SUCCESS)
                        {
                            CommonUtilities.writeLog("已成功");
                            string xmldoc = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
                            return(Content(xmldoc, "text/plain"));
                        }
                        // 通知成功
                        if (result_code == "SUCCESS")
                        {
                            //order.Attach = attach;
                            order.Bank_Type    = bank_type;
                            order.Fee_Type     = fee_type;
                            order.Trade_Status = WeChatUtilities.TRADE_STATUS_SUCCESS;
                            order.Trade_Type   = trade_type;
                            //CommonUtilities.writeLog("修改订单");

                            order.Time_Expire = DateTime.ParseExact(time_end, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
                            offlineDB.SaveChanges();
                            //判断是否需要打印小票
                            if (device_info != "")
                            {
                                string printContent = "上海寿全斋电子商务有限公司\r\n" +
                                                      "订单编号:" + transaction_id + "\r\n" +
                                                      "订单金额:" + (double)Convert.ToInt32(total_fee) / 100 + "元\r\n" +
                                                      "付款时间:" + time_end + "\r\n" + "<q>http://www.shouquanzhai.cn/</q>";
                                GPRSPrint.SendGprsPrintContent(printContent);
                            }
                            string xmldoc = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
                            return(Content(xmldoc, "text/plain"));
                        }
                        else
                        {
                            string xmldoc = "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[未知错误]]></return_msg></xml>";
                            return(Content(xmldoc, "text/plain"));
                        }
                    }
                    CommonUtilities.writeLog("无订单");
                }
                else
                {
                    string err_code     = doc.GetElementsByTagName("err_code")[0].InnerText;
                    string err_code_des = doc.GetElementsByTagName("err_code_des")[0].InnerText;
                    string out_trade_no = doc.GetElementsByTagName("out_trade_no")[0].InnerText;
                    var    order        = offlineDB.WxPayOrder.SingleOrDefault(m => m.Trade_No == out_trade_no);
                    if (order != null)
                    {
                        // 已成功订单
                        if (order.Trade_Status == WeChatUtilities.TRADE_STATUS_SUCCESS)
                        {
                            string xmldoc = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
                            return(Content(xmldoc, "text/plain"));
                        }
                        // 不成功订单
                        else
                        {
                            order.Error_Msg     = err_code;
                            order.Error_Msg_Des = err_code_des;
                            order.Trade_Status  = WeChatUtilities.TRADE_STATUS_CLOSE;
                            offlineDB.SaveChanges();

                            string xmldoc = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
                            return(Content(xmldoc, "text/plain"));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CommonUtilities.writeLog(e.Message + "," + e.StackTrace + "," + e.Source + "," + e.InnerException);
            }
            string xml = "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[未知错误]]></return_msg></xml>";

            return(Content(xml, "text/plain"));
        }