コード例 #1
0
        public ActionResult AjaxUpdateOrder()
        {
            #region Form参数
            string ticketID      = System.Web.HttpContext.Current.Request.Form["TicketID"];
            string followID      = System.Web.HttpContext.Current.Request.Form["FollowID"];
            string BankName      = System.Web.HttpContext.Current.Request.Form["BankName"];
            string ProvinceID    = System.Web.HttpContext.Current.Request.Form["ProvinceID"];
            string CityID        = System.Web.HttpContext.Current.Request.Form["CityID"];
            string TicketType    = System.Web.HttpContext.Current.Request.Form["TicketType"];
            string BankTyp       = System.Web.HttpContext.Current.Request.Form["BankTyp"];
            string TicketEndTime = System.Web.HttpContext.Current.Request.Form["TicketEndTime"];
            string auditState    = System.Web.HttpContext.Current.Request.Form["AuditState"];
            string AuditNote     = System.Web.HttpContext.Current.Request.Form["AuditNote"];
            string UserNote      = System.Web.HttpContext.Current.Request.Form["UserNote"];
            #endregion

            try
            {
                TicketDiscount model = db.TicketDiscount.Where(t => t.TicketID == Convert.ToInt32(ticketID)).FirstOrDefault();
                UpdateModel(model);//修改模型必须在此之后
                #region 编辑信息
                model.TicketCategory = StaticDictiory.getCategory(Convert.ToInt32(TicketType), model.TicketPrice);
                model.TermType       = StaticDictiory.getTerm(Convert.ToInt32(TicketType), (int)model.TicketCategory, Convert.ToDateTime(Convert.ToDateTime(model.PublishTime).ToString("yyyy-MM-dd 23:59:59")));
                model.TicketEndTime  = Convert.ToDateTime(Convert.ToDateTime(TicketEndTime).ToString("yyyy-MM-dd 23:59:59"));
                model.AuditTime      = DateTime.Now;
                model.AuditorID      = 0;
                model.BankName       = BankName;
                model.ProvinceID     = ProvinceID;
                model.CityID         = CityID;
                model.TicketType     = Convert.ToInt32(TicketType);
                model.BankType       = Convert.ToInt32(BankTyp);
                model.AuditState     = Convert.ToInt32(auditState);
                model.AuditNote      = AuditNote;
                model.UserNote       = UserNote;
                #endregion

                if (auditState == AuditState.审核通过.ToString())
                {
                    #region 通过
                    #region MyRegion
                    model.AuditorName = "BBBBBBB";
                    model.TradeState  = (int)TradeState.交易完成;
                    Random ran = new Random();
                    model.YykbTime  = DateTime.Now;
                    model.JjzTime   = DateTime.Now;
                    model.QryyTime  = DateTime.Now.AddMinutes(ran.Next(5, 8)).AddSeconds(ran.Next(0, 59));
                    model.ZfdjTime  = DateTime.Now.AddMinutes(ran.Next(9, 11)).AddSeconds(ran.Next(0, 59));
                    model.CprbsTime = DateTime.Now.AddMinutes(ran.Next(12, 14)).AddSeconds(ran.Next(0, 59));
                    model.QsjdTime  = DateTime.Now.AddMinutes(ran.Next(15, 17)).AddSeconds(ran.Next(0, 59));
                    model.WcjyTime  = DateTime.Now.AddMinutes(ran.Next(18, 22)).AddSeconds(ran.Next(0, 59));
                    #endregion
                    #region MyRegion
                    var             bidmodel = db.DiscountBidding;
                    DiscountBidding biding   = new DiscountBidding();
                    biding.TicketID        = model.TicketID;
                    biding.BidUserID       = (Int32)model.BidId;
                    biding.BidTime         = DateTime.Now.AddMinutes(ran.Next(2, 8));
                    biding.BidResult       = 1;
                    biding.BidRelateResult = 1;
                    biding.LoginMode       = 1;
                    biding.TotalPrice      = model.BidPrice;
                    //(price - parseFloat(inputQuote.val().replace(/,/ig, ''))) * 100000 / price,
                    //biding.BidPrice = (decimal)((model.TicketPrice - model.BidPrice) * 100000 / model.TicketPrice);
                    biding.BidPrice = (decimal)((model.TicketPrice - model.BidPrice) / model.TicketPrice);
                    //(30 * per10 / days / 100) * 10 / 12;
                    Decimal mony    = (Decimal)(model.TicketPrice - model.BidPrice);                     //利息
                    int     sjdays  = RestDays(model.TicketEndTime);                                     //实际天数
                    Decimal bidrate = sjdays <= 0 ? 0 : mony * 360 * 100 / (model.TicketPrice * sjdays); //例如3.17%
                    biding.BidRate = bidrate;
                    bidmodel.Add(biding);
                    #endregion
                    #region MyRegion
                    //ClientUser client=db.ClientUser.Where(u=>u.ID== model.UserID)
                    var client = (from cu in db.ClientUser
                                  join uc in db.UserCenter on cu.ID equals uc.ID
                                  join pro in db.SysStatic on cu.ProvinceID equals pro.Value.ToString()
                                  join city in db.SysStatic on cu.CityID equals city.Value.ToString()
                                  where uc.ID.Equals(model.UserID)
                                  select new
                    {
                        #region MyRegion
                        CityName = pro.Text,
                        ProvinceName = city.Text,
                        uc.ID,
                        cu.Avatar,
                        cu.FullName,
                        cu.Name,
                        cu.NameOfPIC,
                        cu.Address,
                        uc.RegisterTime,
                        uc.LastLoginTime,
                        uc.Phone
                        #endregion
                    }).FirstOrDefault();
                    //创建交易请求
                    TradingRequest tr = new TradingRequest();
                    tr.BZ      = null;
                    tr.CPRBH   = client.ID;    //持票企业编号
                    tr.CPRDH   = client.Phone; //持票企业电话
                    tr.CPRMC   = null;
                    tr.EndTime = null;
                    tr.FQR     = client.ID;    //发起人默认为持票企业
                    tr.FQSJ    = DateTime.Now; //交易发起时间
                    tr.JYSHR   = null;
                    tr.JYSHSJ  = null;
                    tr.JYSHZT  = "1";
                    tr.JYZT    = ((int)TradeState.交易完成).ToString();
                    tr.SPRBH   = (int)model.BidId; //贴现机构编号
                    tr.SPRDH   = "";               //贴现机构电话
                    tr.SPRMC   = null;
                    tr.YWBH    = followID;

                    //创建票面信息
                    ParValueInfo pv = new ParValueInfo();
                    pv.CDHQC = model.BankName;
                    Double cjjg = (Convert.ToDouble((model.BidPrice.ToString().Substring(0, model.BidPrice.ToString().LastIndexOf(".") + 3))));
                    pv.CJJG    = (decimal)cjjg;
                    pv.CJMSWJG = biding.BidPrice;
                    pv.CJYLL   = biding.BidRate;
                    pv.DQR     = (DateTime)model.TicketEndTime;
                    //pv.JYQQBH = followID;
                    pv.PMJE = model.TicketPrice;

                    int imagesCount = 0;
                    List <TicketImage> imageOrigin = db.TicketImage.Where(p => p.TicketID == model.TicketID).ToList();
                    if (imagesCount > 0)
                    {
                        pv.PMJT = imageOrigin[0].OriginImg;
                    }
                    else
                    {
                        pv.PMJT = model.TicketFaceImg;
                    }

                    pv.Pvid = model.TicketID;


                    //交易记录
                    TCPJW_BATradingSystemCore.Trading.Trading.AddTradingDetail(tr, pv, client.ID, (int)model.BidId);
                    CapitalDealInfo.UpdateJYCGCS((int)model.BidId);
                    CapitalDealInfo.UpdatePJJYHS((int)model.BidId, (DateTime)model.ZfdjTime, (DateTime)model.WcjyTime);
                    #endregion


                    db.SaveChanges();
                    #endregion
                }
                else if (auditState == AuditState.审核不通过.ToString())
                {
                    #region  通过
                    model.TradeState = (int)TradeState.竞价中;

                    db.SaveChanges();
                    #endregion
                }
                else
                {
                }
                return(Json(new { Tips = "操作成功", Status = 1 }));
            }
            catch (Exception ex)
            {
                return(Json(new { Tips = "操作失败", Status = 0 }));
            }

            return(null);
        }
コード例 #2
0
        //[Bind(Include = "ProvinceID,CityID")]
        public ActionResult IndexPartialUpdate(tcpjw3.oa.Models.TicketDiscount item, FormCollection Form)
        {
            //string aa = Form["ProvinceID"].ToString();
            string cbPush = Form["dASPxCheckBoxPush"].ToString();//C-选中 I-未选中
            string cbData = Form["cbDate"].ToString();
            //string aa = Form["comboCs"].ToString();
            List <viewUserDetail> agentList = new List <viewUserDetail>();
            List <TicketPush>     pushList  = new List <TicketPush>();

            var model = db.TicketDiscount;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.TicketID == item.TicketID);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);//修改模型必须在此之后
                        modelItem.TicketCategory = StaticDictiory.getCategory((int)modelItem.TicketType, modelItem.TicketPrice);
                        modelItem.TermType       = StaticDictiory.getTerm((int)modelItem.TicketType, (int)modelItem.TicketCategory, Convert.ToDateTime(Convert.ToDateTime(modelItem.PublishTime).ToString("yyyy-MM-dd 23:59:59")));
                        modelItem.TicketEndTime  = Convert.ToDateTime(Convert.ToDateTime(modelItem.TicketEndTime).ToString("yyyy-MM-dd 23:59:59"));
                        modelItem.AuditTime      = DateTime.Now;
                        modelItem.AuditorID      = 0;
                        modelItem.AuditorName    = "管理员";
                        #region 审核通过
                        if (item.AuditState == 2)
                        {
                            #region
                            if (modelItem.TradeState == 128)
                            {
                                string yyTime = string.Format("{0} {1}:00", DateTime.Now.ToString("yyyy-MM-dd"), cbData);
                                modelItem.YykbTime = Convert.ToDateTime(yyTime);
                            }
                            else if (modelItem.TradeState == 1)
                            {
                                modelItem.JjzTime  = DateTime.Now;
                                modelItem.YykbTime = DateTime.Now;
                            }

                            switch (modelItem.TradeState)
                            {
                            case 128:
                                #region 推送实体
                                if (cbPush == "C")
                                {
                                    agentList = db.viewUserDetail.ToList();

                                    foreach (viewUserDetail agent in agentList)
                                    {
                                        TicketPush push = new TicketPush();
                                        push.BankName       = modelItem.BankName;
                                        push.BankType       = modelItem.BankType;
                                        push.CityID         = modelItem.CityID;
                                        push.ProvinceID     = modelItem.ProvinceID;
                                        push.PushTime       = DateTime.Now;
                                        push.State          = 1;//新推送
                                        push.TermType       = modelItem.TermType;
                                        push.TicketType     = (int)modelItem.TicketType;
                                        push.TicketCategory = modelItem.TicketCategory;
                                        push.TicketEndTime  = (DateTime)modelItem.TicketEndTime;
                                        push.TicketID       = modelItem.TicketID;
                                        push.TicketPrice    = modelItem.TicketPrice;
                                        push.ToUserID       = agent.ID;
                                        push.UserID         = modelItem.UserID;
                                        pushList.Add(push);
                                    }
                                }
                                #endregion

                                #region 推送 -- 票源推送, 电票, 预约开标

                                #endregion
                                break;

                            case 1:
                                #region 给上传汇票的用户发送审核通过提醒

                                #endregion
                                #region 推送实体
                                if (cbPush == "C")
                                {
                                    agentList = db.viewUserDetail.ToList();

                                    foreach (viewUserDetail agent in agentList)
                                    {
                                        TicketPush push = new TicketPush();
                                        push.BankName       = modelItem.BankName;
                                        push.BankType       = modelItem.BankType;
                                        push.CityID         = modelItem.CityID;
                                        push.ProvinceID     = modelItem.ProvinceID;
                                        push.PushTime       = DateTime.Now;
                                        push.State          = 1;//新推送
                                        push.TermType       = modelItem.TermType;
                                        push.TicketType     = (int)modelItem.TicketType;
                                        push.TicketCategory = modelItem.TicketCategory;
                                        push.TicketEndTime  = (DateTime)modelItem.TicketEndTime;
                                        push.TicketID       = modelItem.TicketID;
                                        push.TicketPrice    = modelItem.TicketPrice;
                                        push.ToUserID       = agent.ID;
                                        push.UserID         = modelItem.UserID;
                                        pushList.Add(push);
                                    }
                                }
                                #endregion

                                #region 推送 -- 票源审核通知, 电票, 竞价中

                                #endregion
                                break;
                            }
                            #endregion

                            #region 新增推送
                            var pushModel = db.TicketPush;
                            foreach (TicketPush push in pushList)
                            {
                                pushModel.Add(push);
                            }
                            #endregion
                        }
                        #endregion
                        else if (item.AuditState == 4)
                        #region 审核不通过
                        {
                            if (string.IsNullOrEmpty(modelItem.BankName))
                            {
                                modelItem.BankName = "未填写";
                            }

                            #region 给发票人发送消息推送

                            #endregion
                        }
                        #endregion

                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }

                var query = (from discount in db.TicketDiscount
                             join pro in db.SysStatic on discount.ProvinceID equals pro.Value.ToString()
                             join city in db.SysStatic on discount.CityID equals city.Value.ToString()
                             where discount.UploadChannel.Equals(2)
                             //orderby discount.PublishTime descending
                             select new
                {
                    #region MyRegion
                    CityName = city.Text,
                    ProvinceName = pro.Text,
                    discount.TicketID,
                    discount.TicketType,
                    discount.BankType,
                    discount.BankName,
                    discount.TicketCategory,
                    discount.TermType,
                    discount.TicketPrice,
                    discount.TicketStartTime,
                    discount.TicketEndTime,
                    discount.TicketFaceImg,
                    discount.TicketBackImg,
                    discount.ProvinceID,
                    discount.CityID,
                    discount.TradeState,
                    discount.PublishTime,
                    discount.LastEditTime,
                    discount.UserID,
                    discount.UserName,
                    discount.AuditorID,
                    discount.PublishTunes,
                    discount.AuditTime,
                    discount.AuditNote,
                    discount.AuditorName,
                    discount.AuditState,
                    discount.BidPrice,
                    discount.BidId,
                    discount.ToAccount,
                    discount.Hits,
                    discount.UserNote,
                    discount.UploadChannel,
                    discount.JjzTime,
                    #endregion
                }
                             ).Distinct().OrderByDescending(p => p.PublishTime);

                return(Content("<script>alert('编辑成功!');window.parent.location.href='/Discount/Index'</script>"));
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";

                var query = (from discount in db.TicketDiscount
                             join pro in db.SysStatic on discount.ProvinceID equals pro.Value.ToString()
                             join city in db.SysStatic on discount.CityID equals city.Value.ToString()
                             where discount.UploadChannel.Equals(2)
                             //orderby discount.PublishTime descending
                             select new
                {
                    #region MyRegion
                    CityName = city.Text,
                    ProvinceName = pro.Text,
                    discount.TicketID,
                    discount.TicketType,
                    discount.BankType,
                    discount.BankName,
                    discount.TicketCategory,
                    discount.TermType,
                    discount.TicketPrice,
                    discount.TicketStartTime,
                    discount.TicketEndTime,
                    discount.TicketFaceImg,
                    discount.TicketBackImg,
                    discount.ProvinceID,
                    discount.CityID,
                    discount.TradeState,
                    discount.PublishTime,
                    discount.LastEditTime,
                    discount.UserID,
                    discount.UserName,
                    discount.AuditorID,
                    discount.PublishTunes,
                    discount.AuditTime,
                    discount.AuditNote,
                    discount.AuditorName,
                    discount.AuditState,
                    discount.BidPrice,
                    discount.BidId,
                    discount.ToAccount,
                    discount.Hits,
                    discount.UserNote,
                    discount.UploadChannel,
                    discount.JjzTime,
                    #endregion
                }
                             ).Distinct().OrderByDescending(p => p.PublishTime);

                return(Content("<script>alert('编辑失败!');window.parent.location.href='/Discount/Index'</script>"));
            }

            //return RedirectToAction("Index");
            //return null;

            //return PartialView("DiscountTicketInformation", query.ToList());
        }