Example #1
0
        public JsonResult DownloadQRCode(string gateId, int size)
        {
            try
            {
                List <int> dics = new List <int>();
                dics.Add(258);
                dics.Add(344);
                dics.Add(430);
                dics.Add(860);
                dics.Add(1280);

                List <string> imgs = new List <string>();
                ParkGate      gate = ParkGateServices.QueryByRecordId(gateId);
                if (gate == null)
                {
                    throw new MyException("获取通道信息失败");
                }
                BaseCompany company = CompanyServices.QueryByBoxID(gate.BoxID);
                if (company == null)
                {
                    throw new MyException("获取单位信息失败");
                }

                ParkBox box = ParkBoxServices.QueryByRecordId(gate.BoxID);
                if (box == null)
                {
                    throw new MyException("获取岗亭信息失败");
                }

                ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID);
                if (area == null)
                {
                    throw new MyException("获取区域信息失败");
                }

                BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(area.PKID);
                if (parking == null)
                {
                    throw new MyException("获取车场信息失败");
                }
                string content = string.Format("{0}/qrl/scio_ix_pid={1}^io={2}", SystemDefaultConfig.SystemDomain, parking.PKID, gate.GateID);
                foreach (var item in dics)
                {
                    string parkingName = string.Format("{0}_{1}_{2}_{3}_{4}", parking.PKName, area.AreaName, box.BoxName, gate.GateName, item);
                    string result      = QRCodeServices.GenerateQRCode(company.CPID, content, item, parkingName);
                    imgs.Add(item.ToString() + "|" + result);
                }

                return(Json(MyResult.Success("", imgs)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "下载二维码失败");
                return(Json(MyResult.Error("下载二维码失败")));
            }
        }
Example #2
0
        //根据人员和车场信息 下载二维码
        public JsonResult DownloadQRCode(string parkingId, string personId, int size)
        {
            try
            {
                List <int> dics = new List <int>();
                dics.Add(258);
                dics.Add(344);
                dics.Add(430);
                dics.Add(860);
                dics.Add(1280);

                List <string> imgs = new List <string>();
                //if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                //{
                //    throw new MyException("获取系统域名失败");
                //}
                BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(parkingId);
                if (parking == null)
                {
                    throw new MyException("获取车场信息失败");
                }

                BaseVillage village = VillageServices.QueryVillageByRecordId(parking.VID);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }
                //string url = SystemDefaultConfig.SystemDomain;
                string url     = "http://spscs.spsing.cn";
                string content = string.Format("{0}/qrl/qrp_ix_pid={1}^personId={2}", url, parkingId.Trim(), personId);
                foreach (var item in dics)
                {
                    try
                    {
                        string parkingName = string.Format("{0}_{1}", parking.PKName, item);
                        string result      = QRCodeServices.GenerateQRCode(village.CPID, content, item, parkingName);
                        imgs.Add(item.ToString() + "|" + result);
                        TxtLogServices.WriteTxtLogEx("DownloadQRCode", item.ToString() + "|" + result);
                    }
                    catch (Exception ex)
                    {
                        ExceptionsServices.AddExceptions(ex, "生存车场二维码失败");
                        imgs.Add(item.ToString() + "|");
                    }
                }

                return(Json(MyResult.Success("", imgs)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "下载二维码失败");
                return(Json(MyResult.Error("下载二维码失败")));
            }
        }
Example #3
0
        public JsonResult AddIdenticalQRCode(string recordId, string vid, bool isAdd)
        {
            try
            {
                ParkDerateQRcode derate = ParkDerateQRcodeServices.QueryByRecordId(recordId);
                if (derate == null)
                {
                    throw new MyException("获取优免二维码失败");
                }

                if (isAdd)
                {
                    derate.AlreadyUseTimes = 0;
                    derate.CreateTime      = DateTime.Now;
                    derate.OperatorId      = GetLoginUser.RecordID;
                    bool result = ParkDerateQRcodeServices.Add(derate);
                    if (!result)
                    {
                        throw new MyException("添加优免二维码失败");
                    }
                }
                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取系统域名失败");
                }
                BaseVillage village = VillageServices.QueryVillageByRecordId(vid);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }

                string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, vid, recordId, GetSignature(vid, recordId));
                using (System.Drawing.Image image = QRCodeServices.GenerateQRCode(content, 430))
                {
                    ImageFormat format = image.RawFormat;
                    byte[]      buffer;
                    using (MemoryStream ms = new MemoryStream())
                    {
                        image.Save(ms, ImageFormat.Jpeg);
                        buffer = new byte[ms.Length];
                        ms.Seek(0, SeekOrigin.Begin);
                        ms.Read(buffer, 0, buffer.Length);
                    }
                    return(Json(MyResult.Success("添加二维码成功", System.Convert.ToBase64String(buffer))));
                }
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "复制优免二维码失败");
                return(Json(MyResult.Error("复制优免二维码失败")));
            }
        }
        public ActionResult ViewOrderDetail(long OrderId = 0)
        {
            ViewOrderModel model       = new ViewOrderModel();
            CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel;

            if (currentUser == null || currentUser.IsAdmin == false)
            {
                return(RedirectToAction("Login", "Login"));
            }

            CommonService comService = new CommonService();
            CommonDa      da         = new CommonDa();
            AdminOrderDa  dataAccess = new AdminOrderDa();

            if (OrderId > 0)
            {
                ViewOrderModel infor = new ViewOrderModel();
                infor = dataAccess.getInforOrder(OrderId);
                model = infor != null ? infor : model;
                string CompanyCd    = "00000";
                var    inforCompany = da.getInfoCompany(CompanyCd);
                if (inforCompany != null)
                {
                    model.CompanyName    = inforCompany.COMPANY_NAME;
                    model.CompanyAddress = inforCompany.COMPANY_ADDRESS;
                    model.CompanyEmail   = inforCompany.COMPANY_EMAIL;
                    model.CompanyPhone   = inforCompany.COMPANY_PHONE;
                }

                model.AddressCustomer   = model.DistrictName + ", " + model.Receive_Address;
                model.ORDER_STATUS_TEXT = OrderStatus.Items[model.Status].ToString();

                var getOrderDetail = dataAccess.getOrderDetail(model.ID).Take(3);
                ViewBag.listOrderDetail = getOrderDetail.ToList();
                foreach (var data in getOrderDetail)
                {
                    model.ProductDetailTotal += data.ProductName + " (Số lượng: " + data.Quantity.ToString() + "), ";
                }

                if (String.IsNullOrEmpty(model.LINK_QRCODE))
                {
                    model.LINK_QRCODE = QRCodeServices.creatQR(model.Code);
                    dataAccess.UpdateQRLink(OrderId, model.LINK_QRCODE);
                }
                if (!String.IsNullOrEmpty(model.LINK_QRCODE))
                {
                    model.LINK_QRCODE = model.LINK_QRCODE.Replace("~", "");
                }
            }

            return(this.PartialView("ViewOrderDetail", model));
        }
Example #5
0
        public JsonResult DownloadQRCode(string vid, string qid, string sellerName, string derateName)
        {
            try
            {
                List <int> dics = new List <int>();
                dics.Add(258);
                dics.Add(344);
                dics.Add(430);
                dics.Add(860);
                dics.Add(1280);

                List <string> imgs = new List <string>();
                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取系统域名失败");
                }
                BaseVillage village = VillageServices.QueryVillageByRecordId(vid);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }

                string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, vid, qid, GetSignature(vid, qid));
                foreach (var item in dics)
                {
                    try
                    {
                        string fileName = string.Format("{0}_{1}_{2}_{3}", sellerName, derateName, item, qid);
                        string result   = QRCodeServices.GenerateQRCode(village.CPID, content, item, fileName);
                        imgs.Add(item.ToString() + "|" + result);
                        TxtLogServices.WriteTxtLogEx("DownloadQRCode", item.ToString() + "|" + result);
                    }
                    catch (Exception ex)
                    {
                        ExceptionsServices.AddExceptions(ex, "生存优免二维码失败");
                        imgs.Add(item.ToString() + "|");
                    }
                }

                return(Json(MyResult.Success("", imgs)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "下载优免二维码失败");
                return(Json(MyResult.Error("下载优免二维码失败")));
            }
        }
Example #6
0
        public long InsertOrder(OrderModel model, List <ItemGioHang> lstGioHang)
        {
            long res = 0;
            // Declare new DataAccess object
            OrderCartDa dataAccess = new OrderCartDa();

            using (var transaction = new TransactionScope())
            {
                try
                {
                    Order order = new Order();
                    order.UserID = model.UserID;
                    int maxOrder = dataAccess.getMaxOrder() + 1;

                    order.Code        = "VB" + DateTime.Now.ToString("ddMM") + maxOrder.ToString("D6");
                    order.LINK_QRCODE = QRCodeServices.creatQR(order.Code);

                    order.TongTienHang       = model.TongTienHang;
                    order.PriceTotal         = model.PriceTotal;
                    order.PriceShip          = model.PriceShip;
                    order.PriceDiscountTotal = model.PriceDiscountTotal;
                    order.PaymentMethod      = model.METHOD_TYPE;
                    order.Paid             = PayStatus.None;
                    order.Note             = model.Note;
                    order.Receive_District = model.Receive_District;
                    order.Receive_Address  = model.Receive_Address;
                    order.Receive_Phone    = model.Receive_Phone;
                    order.Receive_Address  = model.Receive_Address;
                    order.Status           = OrderStatus.Create;
                    order.del_flg          = Constant.DeleteFlag.NON_DELETE;

                    res = dataAccess.InsertOrder(order);

                    if (res <= 0)
                    {
                        transaction.Dispose();
                    }

                    if (res > 0)
                    {
                        long res1 = 0;
                        foreach (var data in lstGioHang)
                        {
                            OrderDetail detail = new OrderDetail();
                            detail.OrderID     = res;
                            detail.ProductID   = data.IdSanPham;
                            detail.ProductName = data.TenSanPham;
                            detail.Quantity    = data.SoLuong;
                            detail.Price       = data.TienHang;
                            detail.del_flg     = Constant.DeleteFlag.NON_DELETE;

                            res1 = dataAccess.InsertOrderDetail(detail);
                            if (res1 <= 0)
                            {
                                transaction.Dispose();
                            }

                            res1 = dataAccess.UpdateQuantityProduct(detail.ProductID, detail.Quantity.Value);
                            if (res1 <= 0)
                            {
                                transaction.Dispose();
                            }
                        }
                    }

                    transaction.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex);
                }
                finally
                {
                    transaction.Dispose();
                }
            }
            return(res);
        }
Example #7
0
        public JsonResult GrantCarDerate(string vid, string qid, string sellerName, string derateName, int number)
        {
            try
            {
                if (number <= 0)
                {
                    throw new MyException("发放优免券数量不正确");
                }

                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取系统域名失败");
                }
                ParkDerateQRcode qrCode = ParkDerateQRcodeServices.QueryByRecordId(qid);
                if (qrCode == null)
                {
                    throw new MyException("优免券规则不存在");
                }

                ParkDerate derate = ParkDerateServices.Query(qrCode.DerateID);
                if (derate == null)
                {
                    throw new MyException("获取优免规则失败");
                }

                if (derate.DerateType == DerateType.SpecialTimePeriodPayment)
                {
                    string     errorMsg = string.Empty;
                    ParkSeller seller   = ParkSellerServices.GetSeller(derate.SellerID, out errorMsg);
                    if (derate == null)
                    {
                        throw new MyException("获取优免规则失败");
                    }

                    decimal totalAmount = qrCode.DerateValue * number;
                    if ((seller.Creditline + seller.Balance) < totalAmount)
                    {
                        throw new MyException("商家余额不足");
                    }
                }

                BaseVillage village = VillageServices.QueryVillageByRecordId(vid);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }

                string        folderName   = string.Format("{0}_{1}_{2}", sellerName, derateName, IdGenerator.Instance.GetId().ToString());
                List <string> carDerateIds = new List <string>();
                for (int i = 0; i < number; i++)
                {
                    string carDerateId = GuidGenerator.GetGuidString();
                    string content     = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&did={3}&sign={4}", SystemDefaultConfig.SystemDomain, vid, qid, carDerateId, GetSignature(vid, qid, carDerateId));
                    string result      = QRCodeServices.GenerateQRCode(village.CPID, content, 430, carDerateId, folderName);
                    if (string.IsNullOrWhiteSpace(result))
                    {
                        throw new MyException("创建二维码失败");
                    }
                    carDerateIds.Add(carDerateId);
                }
                string filePath    = string.Format("/Uploads/{0}", folderName);
                string zipFilePath = string.Format("{0}/{1}_{2}.zip", filePath, sellerName, derateName);
                string mapPath     = Server.MapPath("~/");

                ZipHelper.ZipFiles(string.Format("{0}/{1}", mapPath, filePath), string.Format("{0}/{1}", mapPath, zipFilePath));
                if (carDerateIds.Count != number)
                {
                    throw new MyException("二维码数量与待创建的数量不匹配");
                }

                bool grantResult = ParkDerateQRcodeServices.GrantCarDerate(carDerateIds, zipFilePath, qid);
                if (!grantResult)
                {
                    throw new MyException("发放券失败");
                }

                return(Json(MyResult.Success("", zipFilePath)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "发放优免券失败");
                return(Json(MyResult.Error("发放优免券失败")));
            }
        }
Example #8
0
        public ActionResult DerateQRCode(string recordId)
        {
            try
            {
                ParkDerateQRcode derateQRcode = ParkDerateQRcodeServices.QueryByRecordId(recordId);
                if (derateQRcode == null)
                {
                    throw new MyException("该二维码不存在");
                }

                ParkDerate derate = ParkDerateServices.Query(derateQRcode.DerateID);
                if (derate == null)
                {
                    throw new MyException("优免规则不存在");
                }
                derateQRcode.DerateName = derate.Name;

                ParkSeller seller = ParkSellerServices.QueryBySellerId(derate.SellerID);
                if (seller == null)
                {
                    throw new MyException("商家不存在");
                }
                derateQRcode.SellerName = seller.SellerName;

                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取系统域名失败");
                }
                BaseVillage village = VillageServices.QueryVillageByRecordId(seller.VID);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }

                string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, seller.VID, recordId, GetSignature(seller.VID, recordId));
                using (System.Drawing.Image image = QRCodeServices.GenerateQRCode(content, 430))
                {
                    ImageFormat format = image.RawFormat;
                    byte[]      buffer;
                    using (MemoryStream ms = new MemoryStream())
                    {
                        image.Save(ms, ImageFormat.Jpeg);
                        buffer = new byte[ms.Length];
                        ms.Seek(0, SeekOrigin.Begin);
                        ms.Read(buffer, 0, buffer.Length);
                    }
                    derateQRcode.ImageData = System.Convert.ToBase64String(buffer);
                }
                ViewBag.CompanyID   = village.CPID;
                ViewBag.ShareAction = "XFJMDerateQRCode/DerateQRCode?recordId=" + recordId;
                return(View(derateQRcode));
            }
            catch (MyException ex)
            {
                return(RedirectToAction("Index", "XFJMDerateQRCode", new { RemindUserContent = ex.Message }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "微信获取二维码失败", LogFrom.WeiXin);
                return(RedirectToAction("Index", "XFJMDerateQRCode", new { RemindUserContent = "获取二维码失败" }));
            }
        }
        public ActionResult PrintOrderCustom(string ORDER_ID_STRING)
        {
            CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel;

            if (currentUser == null || currentUser.IsAdmin == false)
            {
                return(RedirectToAction("Login", "Login"));
            }

            CommonService         comService      = new CommonService();
            CommonDa              da              = new CommonDa();
            AdminOrderDa          dataAccess      = new AdminOrderDa();
            List <ViewOrderModel> listOrderDetail = new List <ViewOrderModel>();
            ViewOrderModel        model           = new ViewOrderModel();

            if (!string.IsNullOrEmpty(ORDER_ID_STRING))
            {
                List <long> ORDER_ID_LIST = ORDER_ID_STRING.Split(',').Select(long.Parse).ToList();
                if (ORDER_ID_LIST.Count > 0)
                {
                    for (int i = 0; i < ORDER_ID_LIST.Count(); i++)
                    {
                        if (ORDER_ID_LIST[i] > 0)
                        {
                            ViewOrderModel infor = new ViewOrderModel();
                            infor = dataAccess.getInforOrder(ORDER_ID_LIST[i]);
                            model = infor != null ? infor : model;
                            string CompanyCd    = "00000";
                            var    inforCompany = da.getInfoCompany(CompanyCd);
                            if (inforCompany != null)
                            {
                                model.CompanyName    = inforCompany.COMPANY_NAME;
                                model.CompanyAddress = inforCompany.COMPANY_ADDRESS;
                                model.CompanyEmail   = inforCompany.COMPANY_EMAIL;
                                model.CompanyPhone   = inforCompany.COMPANY_PHONE;
                            }

                            model.AddressCustomer   = model.DistrictName + ", " + model.Receive_Address;
                            model.ORDER_STATUS_TEXT = OrderStatus.Items[model.Status].ToString();

                            var getOrderDetail = dataAccess.getOrderDetail(model.ID).Take(3);
                            ViewBag.listOrderDetail = getOrderDetail.ToList();
                            foreach (var data in getOrderDetail)
                            {
                                model.ProductDetailTotal += data.ProductName + " (Số lượng: " + data.Quantity.ToString() + "), ";
                            }

                            if (String.IsNullOrEmpty(model.LINK_QRCODE))
                            {
                                model.LINK_QRCODE = QRCodeServices.creatQR(model.Code);
                                dataAccess.UpdateQRLink(ORDER_ID_LIST[i], model.LINK_QRCODE);
                            }
                            if (!String.IsNullOrEmpty(model.LINK_QRCODE))
                            {
                                model.LINK_QRCODE = model.LINK_QRCODE.Replace("~", "");
                            }
                            listOrderDetail.Add(model);
                        }
                    }
                }
                //return new ViewAsPdf("ViewOrderDetailPDF", listOrderDetail);
                return(PartialView("ViewOrderDetailPDF", listOrderDetail));
            }

            return(new EmptyResult());
        }
Example #10
0
        public JsonResult DownloadQRCode(string gateId, int size)
        {
            try
            {
                List <int> dics = new List <int>();
                dics.Add(258);
                dics.Add(344);
                dics.Add(430);
                dics.Add(860);
                dics.Add(1280);

                List <string> imgs = new List <string>();

                BWYGateMapping gate = BWYGateMappingServices.QueryByRecordId(gateId);
                if (gate == null)
                {
                    throw new MyException("获取车场信息失败");
                }


                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取域名失败");
                }
                BaseCompany company = null;
                if (gate.DataSource == 0)
                {
                    if (string.IsNullOrWhiteSpace(SystemDefaultConfig.BWPKID))
                    {
                        throw new MyException("获取车场编号失败");
                    }
                    company = CompanyServices.QueryByParkingId(SystemDefaultConfig.BWPKID);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SFMPKID))
                    {
                        throw new MyException("获取车场编号失败");
                    }
                    if (string.IsNullOrWhiteSpace(gate.ParkNo))
                    {
                        throw new MyException("二维码车场编号不能为空");
                    }
                    company = CompanyServices.QueryByParkingId(SystemDefaultConfig.SFMPKID);
                }
                if (company == null)
                {
                    throw new MyException("获取单位编号失败");
                }

                string content = string.Format("{0}/qrl/scio_ix_pid={1}^io={2}^source=0", SystemDefaultConfig.SystemDomain, SystemDefaultConfig.BWPKID, gate.GateID);
                if (gate.DataSource == 1)
                {
                    content = string.Format("{0}/qrl/scio_ix_pid={1}^io={2}^source=0", SystemDefaultConfig.SystemDomain, SystemDefaultConfig.SFMPKID, gate.ParkNo + "$" + gate.GateID);
                }
                foreach (var item in dics)
                {
                    string parkingName = string.Format("{0}_{1}_{2}", gate.ParkingName, gate.GateName, item);
                    string result      = QRCodeServices.GenerateQRCode(company.CPID, content, item, parkingName);
                    imgs.Add(item.ToString() + "|" + result);
                }

                return(Json(MyResult.Success("", imgs)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "下载外部车场二维码失败");
                return(Json(MyResult.Error("下载外部车场二维码失败")));
            }
        }