username@email.com
2024-09-24 e52888ec01a11ad8423e30b9505fee9624e88422
CY_ECommercePlatform/CY.SQLDAL/EC/EC_OrderDAL.cs
@@ -608,6 +608,19 @@
            //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>
@@ -812,6 +825,50 @@
                                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>());
@@ -1369,5 +1426,75 @@
            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;//返回结果
        }
    }
}