| | |
| | | //return null == result || result.Count < 1 ? null : result[0]; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据订单编号获取订单 |
| | | /// </summary> |
| | | /// <param name="orderIds">订单编号</param> |
| | | /// <returns></returns> |
| | | public IEnumerable<EC_OrderBasic> GetOrderByIds(string orderIds) |
| | | { |
| | | //return _eC_OrderBasicDAL.SelectModelById(orderId); |
| | | IList<EC_OrderBasic> result = _dataBase.SelectModel<EC_OrderBasic>(" * ", "EC_OrderBasic ", string.Format(" Keyid in ({0})", orderIds)); |
| | | return null == result || result.Count < 1 ? null : result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取已支付订单的明细 |
| | | /// </summary> |
| | |
| | | new SqlParameter("@KaipiaoshenqingId",trueModel.KaipiaoshenqingId), |
| | | }; |
| | | string sql = " Update EC_OrderExtend Set KaipiaoshenqingTime=@KaipiaoshenqingTime ,Kaipiaoshenqing=@Kaipiaoshenqing ,KaipiaoshenqingCreater=@KaipiaoshenqingCreater ,KaipiaoshenqingId=@KaipiaoshenqingId Where Keyid =@keyid "; |
| | | try |
| | | { |
| | | _dataBase.ExecuteSql(sql, sqlParms.ToArray<SqlParameter>()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public bool OldUpdateKaipiaoshenqings(EC_OrderExtend model,string ids) |
| | | { |
| | | |
| | | Model.EC_OrderExtend trueModel = model; |
| | | if (trueModel == null) |
| | | { |
| | | return false; |
| | | } |
| | | SqlParameter KaipiaoshenqingTime = null; |
| | | if (trueModel.KaipiaoshenqingTime.HasValue) |
| | | { |
| | | KaipiaoshenqingTime = new SqlParameter("@KaipiaoshenqingTime", trueModel.KaipiaoshenqingTime); |
| | | } |
| | | else |
| | | { |
| | | KaipiaoshenqingTime = new SqlParameter("@KaipiaoshenqingTime", DBNull.Value); |
| | | } |
| | | IList<SqlParameter> sqlParms = new List<SqlParameter>() |
| | | { |
| | | //new SqlParameter("@Keyid",trueModel.Keyid), |
| | | KaipiaoshenqingTime, |
| | | new SqlParameter("@Kaipiaoshenqing",trueModel.Kaipiaoshenqing), |
| | | new SqlParameter("@KaipiaoshenqingCreater",trueModel.KaipiaoshenqingCreater), |
| | | new SqlParameter("@KaipiaoshenqingId",trueModel.KaipiaoshenqingId), |
| | | }; |
| | | string sql = " Update EC_OrderExtend Set KaipiaoshenqingTime=@KaipiaoshenqingTime ,Kaipiaoshenqing=@Kaipiaoshenqing ,KaipiaoshenqingCreater=@KaipiaoshenqingCreater ,KaipiaoshenqingId=@KaipiaoshenqingId Where Keyid in ("+ ids + ") ";//@keyid |
| | | try |
| | | { |
| | | _dataBase.ExecuteSql(sql, sqlParms.ToArray<SqlParameter>()); |
| | |
| | | |
| | | fromSouce += @" |
| | | |
| | | select occ.Province+occ.City+occ.County as quyu ,oc.CompanyName as BuyerName,os.Name as BusinessManager,oc.CreateTime,contracttype.Name as ContracttypeName,oc.Contractmoney |
| | | select occ.City+occ.County as quyu ,oc.CompanyName as BuyerName,os.Name as BusinessManager,oc.CreateTime,contracttype.Name as ContracttypeName,oc.Contractmoney |
| | | ,expiretype.Name as ExpiretypeName,oc.ExpireTime,ob.SumPrice, ob.PayedMoney,oc.CustomerId |
| | | |
| | | |
| | |
| | | fromSouce += " )as t "; |
| | | |
| | | var result = _dataBase.SelectModelPage<Model.OA_DeliverPlan>(pagination, selectTarget, fromSouce, " DepartmentId ASC");//执行查询 |
| | | |
| | | foreach(var oA_DeliverPlan in result) |
| | | { |
| | | StringBuilder from = new StringBuilder(); |
| | | var datetimenow = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | from.Append(" ( "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =1 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 and DATEDIFF(MONTH,ob.CreateTime,'"+ datetimenow + "') > 0 "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | from.Append(" UNION "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =2 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 and DATENAME(year, ob.CreateTime) +'第'+DATENAME(quarter, ob.CreateTime) <DATENAME(year, '"+ datetimenow + "') +'第'+DATENAME(quarter, '"+ datetimenow + "') "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | from.Append(" UNION "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =3 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 and DATENAME(year, ob.CreateTime) +'第'+CONVERT(varchar,(month(ob.CreateTime)+5)/6)+'半年'<DATENAME(year,'"+ datetimenow + "') +'第'+CONVERT(varchar,(month('"+ datetimenow + "')+5)/6)+'半年' "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | from.Append(" UNION "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =4 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 and DATENAME(year, ob.CreateTime)+'年' <DATENAME(year, '"+ datetimenow + "')+'年' "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | from.Append(" UNION "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =6 and oc.Shifouwanjie=1 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | from.Append(" UNION "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =7 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 and DATEDIFF(day,ob.CreateTime,GETDATE()) > oc.Paydays "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | from.Append(" UNION "); |
| | | from.Append(" select ob.* from OA_Staff os inner join [OA_CorporateClients] oc on oc.BusinessManagerId = os.Keyid and os.Keyid="+ oA_DeliverPlan.BusinessManagerId + " and oc.Paytime =5 "); |
| | | from.Append(" inner join EC_OrderBasic ob on ob.BuyerId =oc.Keyid and ob.OrderState !=0 and ob.OrderState !=-2 and DATEDIFF(MONTH,ob.CreateTime,'" + chaxuntime + "')=0 and "); |
| | | from.Append(" case when DATEDIFF(day,ob.CreateTime,DATENAME(year, ob.CreateTime)+'-03-01')>0 then CONVERT(varchar,YEAR(ob.CreateTime)-1)+'至'+CONVERT(varchar,YEAR(ob.CreateTime))+ '1学期' "); |
| | | from.Append(" when DATEDIFF(day,ob.CreateTime,DATENAME(year, ob.CreateTime)+'-09-01')<=0 then CONVERT(varchar,YEAR(ob.CreateTime))+'至'+CONVERT(varchar,YEAR(ob.CreateTime)+1)+ '1学期' "); |
| | | from.Append(" else CONVERT(varchar,YEAR(ob.CreateTime)-1)+'至'+CONVERT(varchar,YEAR(ob.CreateTime))+'2学期' end < "); |
| | | from.Append(" case when DATEDIFF(day,'"+ datetimenow + "',DATENAME(year, '"+ datetimenow + "')+'-03-01')>0 then CONVERT(varchar,YEAR('"+ datetimenow + "')-1)+'至'+CONVERT(varchar,YEAR('"+ datetimenow + "'))+ '1学期' "); |
| | | from.Append(" when DATEDIFF(day,'"+ datetimenow + "',DATENAME(year, '"+ datetimenow + "')+'-09-01')<=0 then CONVERT(varchar,YEAR('"+ datetimenow + "'))+'至'+CONVERT(varchar,YEAR('"+ datetimenow + "')+1)+ '1学期' "); |
| | | from.Append(" else CONVERT(varchar,YEAR('"+ datetimenow + "')-1)+'至'+CONVERT(varchar,YEAR('"+ datetimenow + "'))+'2学期' end "); |
| | | from.Append(" inner join EC_OrderExtend oe on ob.Keyid=oe.Keyid and oe.KaipiaoshenqingId is null "); |
| | | |
| | | |
| | | from.Append(" ) as t "); |
| | | |
| | | |
| | | var eC_OrderBasics = _dataBase.SelectModel<Model.EC_OrderBasic>(" t.* ", from.ToString()); |
| | | oA_DeliverPlan.fapiaoshuliang = eC_OrderBasics.Count; |
| | | } |
| | | |
| | | return null == result ? null : result;//返回结果 |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取业务经理业绩 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | |
| | | public IEnumerable<OA_DeliverPlan> GetyewurenportList(Infrastructure.Query.Pagination pagination, Guid FirmId, string BusinessManagerId, string chaxuntimestart, string chaxuntimeend) |
| | | { |
| | | string selectTarget = " t.* "; |
| | | string where = " and os.[FirmId] ='" + FirmId + "'"; |
| | | |
| | | if (!string.IsNullOrEmpty(BusinessManagerId)) |
| | | { |
| | | where += " and os.Keyid='" + BusinessManagerId + "'"; |
| | | } |
| | | |
| | | string fromSouce = "( "; |
| | | |
| | | fromSouce += " select os.DepartmentId,os.[Name] as BusinessManager ,os.[Keyid] as BusinessManagerId, os.FirmId,gendan.gendanshuliang,xinzeng.xinzengshuliang,wanjie.wanjieshuliang,xiadan.xiadanshuliang,ob.shuliang,ob.SumPrice,ob.PayedMoney,eob.kaipiaojine,huifang.huifangshuliang ,'" + chaxuntimestart + "' as chaxuntimestart ,'" + chaxuntimeend + "' as chaxuntimeend ,obhuikuan.huikuankehu,obweihuikuan.weihuikuankehu "; |
| | | fromSouce += " from [OA_Staff] os "; |
| | | fromSouce += " left join ( select COUNT(*) gendanshuliang ,oc.BusinessManagerId from OA_CorporateClients oc where ( oc.Shifouwanjie is null or oc.Shifouwanjie=2 ) and DATEDIFF(DAY,oc.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,oc.CreateTime,'" + chaxuntimeend + "') >=0 group by oc.BusinessManagerId ) gendan on gendan.BusinessManagerId = os.Keyid "; |
| | | fromSouce += " left join ( select COUNT(*) xinzengshuliang ,oc.BusinessManagerId from OA_CorporateClients oc where DATEDIFF(DAY,oc.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,oc.CreateTime,'" + chaxuntimeend + "') >=0 group by oc.BusinessManagerId ) xinzeng on xinzeng.BusinessManagerId = os.Keyid "; |
| | | fromSouce += " left join ( select COUNT(*) wanjieshuliang ,oc.BusinessManagerId from OA_CorporateClients oc where oc.Shifouwanjie=1 and DATEDIFF(DAY,oc.[LastUpdateTime],'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,oc.[LastUpdateTime],'" + chaxuntimeend + "') >=0 group by oc.BusinessManagerId ) wanjie on wanjie.BusinessManagerId = os.Keyid "; |
| | | fromSouce += " left join ( select COUNT( distinct oc.Keyid) xiadanshuliang ,oc.BusinessManagerId from OA_CorporateClients oc Inner Join EC_OrderBasic ob On oc.Keyid=ob.[BuyerId] where DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimeend + "') >=0 group by oc.BusinessManagerId ) xiadan on xiadan.BusinessManagerId = os.Keyid "; |
| | | fromSouce += " left join ( select COUNT(*) huifangshuliang,occ.Creater as BusinessManagerId from OA_CorporateClientsVisit occ where DATEDIFF(DAY,occ.[VisitTime],'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,occ.[VisitTime],'" + chaxuntimeend + "') >=0 group by occ.Creater ) huifang on huifang.BusinessManagerId = os.MemberId "; |
| | | fromSouce += " left join ( select oc.BusinessManagerId,sum(ob.SumPrice) SumPrice,sum(ts.PayedMoney) PayedMoney ,COUNT(*) as shuliang "; |
| | | fromSouce += " from EC_OrderBasic ob "; |
| | | fromSouce += " Inner Join EC_OrderExtend as oe On(ob.Keyid=oe.Keyid) "; |
| | | fromSouce += " Inner Join Pay_TradingSingle as ts On(ob.Keyid = ts.OrderId) "; |
| | | fromSouce += " Inner Join OA_CorporateClients as oc On(ob.BuyerId = oc.Keyid) "; |
| | | fromSouce += " left join EC_AwbInfo ea on ob.Keyid = ea.Keyid where DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimeend + "') >=0 "; |
| | | fromSouce += " group by oc.BusinessManagerId ) ob on os.Keyid = ob.BusinessManagerId "; |
| | | |
| | | fromSouce += " left join ( select oc.BusinessManagerId ,COUNT( distinct ob.BuyerId ) as huikuankehu "; |
| | | fromSouce += " from EC_OrderBasic ob "; |
| | | fromSouce += " Inner Join EC_OrderExtend as oe On(ob.Keyid=oe.Keyid) "; |
| | | fromSouce += " Inner Join Pay_TradingSingle as ts On(ob.Keyid = ts.OrderId) "; |
| | | fromSouce += " Inner Join OA_CorporateClients as oc On(ob.BuyerId = oc.Keyid) "; |
| | | fromSouce += " left join EC_AwbInfo ea on ob.Keyid = ea.Keyid where DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimeend + "') >=0 and ob.PayState = -1 "; |
| | | fromSouce += " group by oc.BusinessManagerId ) obhuikuan on os.Keyid = obhuikuan.BusinessManagerId "; |
| | | |
| | | |
| | | fromSouce += " left join ( select oc.BusinessManagerId ,COUNT( distinct ob.BuyerId ) as weihuikuankehu "; |
| | | fromSouce += " from EC_OrderBasic ob "; |
| | | fromSouce += " Inner Join EC_OrderExtend as oe On(ob.Keyid=oe.Keyid) "; |
| | | fromSouce += " Inner Join Pay_TradingSingle as ts On(ob.Keyid = ts.OrderId) "; |
| | | fromSouce += " Inner Join OA_CorporateClients as oc On(ob.BuyerId = oc.Keyid) "; |
| | | fromSouce += " left join EC_AwbInfo ea on ob.Keyid = ea.Keyid where DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimeend + "') >=0 and ob.PayState != -1 "; |
| | | fromSouce += " group by oc.BusinessManagerId ) obweihuikuan on os.Keyid = obweihuikuan.BusinessManagerId "; |
| | | |
| | | |
| | | fromSouce += " left join ( select oc.BusinessManagerId,sum(ob.SumPrice) kaipiaojine "; |
| | | fromSouce += " from EC_OrderBasic ob "; |
| | | fromSouce += " Inner Join EC_OrderExtend as oe On(ob.Keyid=oe.Keyid) "; |
| | | fromSouce += " Inner Join OA_CorporateClients as oc On(ob.BuyerId = oc.Keyid) "; |
| | | fromSouce += " left join EC_AwbInfo ea on ob.Keyid = ea.Keyid "; |
| | | fromSouce += " left join OA_Kaipiaoshenqing ks on ks.Keyid = oe.KaipiaoshenqingId "; |
| | | fromSouce += " where ks.Kaipiaoshenqing = 3 and DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimestart + "') <=0 and DATEDIFF(DAY,ob.CreateTime,'" + chaxuntimeend + "') >=0 "; |
| | | fromSouce += " group by oc.BusinessManagerId ) eob on os.Keyid = eob.BusinessManagerId "; |
| | | fromSouce += " where os.Status='在职' And IsBusinessManager='true' " + where; |
| | | |
| | | |
| | | fromSouce += " )as t "; |
| | | |
| | | var result = _dataBase.SelectModelPage<Model.OA_DeliverPlan>(pagination, selectTarget, fromSouce, " DepartmentId ASC");//执行查询 |
| | | return null == result ? null : result;//返回结果 |
| | | } |
| | | |
| | | |
| | | } |
| | | } |