/// <summary> /// 所选日期判断是否能预约 /// </summary> /// <param name="ydjh"></param> /// <param name="date"></param> /// <returns></returns> public bool GetScheduleResult(string yybh, string qybh, string ydjh, string rq, string sj) { DateTime rq_date = Convert.ToDateTime(rq); var kssj = sj.Split('-')[0]; DateTime sj_date = Convert.ToDateTime(rq + " " + kssj); var ygxx = new QyygjbxxService().GetModel(yybh, ydjh); var jbsz = new PqJbszService().GetModel(yybh); var qypq = new PqQyszService().GetModelByDate(yybh, qybh, rq_date); var tjrq = new PqTjrqService().GetModel(yybh, qybh, rq_date); var tjsj = new PqTjsjService().GetListByRq(qybh, yybh, rq_date).FirstOrDefault(x => x.kssj <= sj_date && sj_date < x.jssj); var yyList = new DdJbxxService().GetQyYyListByDate(yybh, qybh, rq_date);//每天预约人数 if (jbsz == null || jbsz.tjyl <= yyList.Count) { return(false); } var weekDay = Convert.ToInt32(rq_date.DayOfWeek).ToString(); if ((jbsz.xxr.Contains(weekDay) || jbsz.ztyy.Contains(rq)) && !jbsz.tsky.Contains(rq)) { return(false); } if (tjrq == null || tjrq.flag > 0 || tjrq.tjrs <= yyList.Count) { return(false); } if (tjsj == null) { return(false); } var sj_yyList = yyList.Where(x => x.yykssj <= sj_date && sj_date < x.yyjssj); if (tjsj.tjrs <= sj_yyList.Count()) { return(false); } if (qypq != null) { var pjtcList = new PqQyszService().GetPjtc(qypq.pqbh);//瓶颈套餐 var pjtcModel = pjtcList.FirstOrDefault(x => x.tcbh == ygxx.tcbh); if (pjtcModel != null) { var pjtcs = pjtcList.Where(x => x.fzbh == pjtcModel.pqbh).Select(a => a.tcbh).ToArray();; var tcyyrs = yyList.Where(a => pjtcs.Contains(a.tcid)).Count();//套餐体检人数 if (tcyyrs >= pjtcModel.tjrs) { return(false); } } } return(true); }
public void CreateOrder(List <OrderModel> li) { using (IDbConnection conn = new DapperConnection().DbConnection) { IDbTransaction transaction = conn.BeginTransaction(); foreach (OrderModel model in li) { string ddbh = new DdJbxxService().GetDdbh(); int sfjx = 0; string sql = @"insert into dd_jbxx(ddbh,dsfdd,dsfbzid,ddzt,tcid,tcmc,dwbh,tcjg, jxbjg,ddze,intime,sfout,outtime,dh,xm,xb,hz, zjlx,zjhm,yykssj,yyjssj,sfdj,djtime,sfbg,bgtime, djlsh,sfjx,jxlist,sfjs,csrq,nl,remark,yybh,ddly,dwmc,jsbz,ygzh,trade_no,ysjsj) values(@ddbh,@dsfdd,@dsfbzid,2,@tcid,@tcmc,@dwbh,@tcjg, 0,@ddze,getdate(),0,'1970-01-01',@dh,@xm,@xb,@hz, @zjlx,@zjhm,@yysj,@yysj,0,'1970-01-01',0,'1970-01-01', '',@sfjx,@jxlist,0,@csrq,@nl,'',@yybh,0,@dwmc,0,'',@trade_no,@ysjsj) "; int id = conn.Execute(sql, new { ddbh = ddbh, dsfdd = model.outOrderCode, dsfbzid = model.dsfbzId, tcid = model.appointmentPackageCode, tcmc = model.appointmentPackageName, dwbh = model.deptID, tcjg = model.ddJe, ddze = model.ddJe, dh = model.customerMobilePhone, xm = model.customerName, xb = model.customerGender, hz = model.customerMedicalStatus, zjlx = model.customerIDType, zjhm = model.customerIDCard, yysj = model.appointmentDate, sfjx = sfjx, jxlist = "", csrq = model.customerBirthday, nl = model.customerAge, yybh = model.yybh, dwmc = model.deptNm, trade_no = "", ysjsj = model.ysjsj }, transaction); string sqlDetail = "insert into dd_zhxm(ddbh,zhxmbh,zhxmmc,jg,sfjx,sfdj) select '" + ddbh + "',b.zhxmbh,b.zhxmmc,b.zhxmjg,0,0 from xt_tc_zhxmb a join xt_zhxmb b on a.yybh=b.yybh and a.zhxmbh=b.zhxmbh where a.yybh='" + model.yybh + "' and a.tcbh='" + model.appointmentPackageCode + "' and a.dwbh='" + model.deptID + "'"; conn.Execute(sqlDetail, null, transaction); } transaction.Commit(); } }