username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
 
/**  
* OA_DeliverPlanBLL.cs
*
* 功 能: 合作客户业务逻辑类
* 类 名: OA_DeliverPlanBLL
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013-4-2 15:11       吴辉      初版
* V0.02  2013-5-29 17:43      吴崎均    增加转换在线会员为厂商客户方法 
*
*
*
*
*
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL;
using CY.Model;
using AbstractFactory;
using CY.IBaseDAL;
using CY.Infrastructure.DESEncrypt;
using CY.Infrastructure.Query;
 
namespace CY.BLL
{
    public class OA_DeliverPlanPaicheBLL
    {
        IOA_DeliverPlanPaicheDAL _IOA_DeliverPlanPaicheDAL = null;
 
        /// <summary>
        /// 初始化构造
        /// </summary>
        public OA_DeliverPlanPaicheBLL()
        {
            //获取OA_DeliverPlan DAL实现
            _IOA_DeliverPlanPaicheDAL = Factory.GetDALByInterfaceName(DALInterface.IOA_DeliverPlanPaicheDAL) as IOA_DeliverPlanPaicheDAL;
 
 
        }
 
        /// <summary>
        /// 新增送货安排
        /// </summary>
        /// <param name="rType"></param>
        /// <param name="m_OA_CustomerCommunications"></param>
        /// <param name="m_EC_AcceptWayByCustomers"></param>
        /// <returns></returns>
        public bool InsertModel(CY.Model.OA_DeliverPlan m_OA_DeliverPlan)
        {
            try
            {
                if (m_OA_DeliverPlan.Yichangchuli == null)
                {
                    m_OA_DeliverPlan.Yichangchuli = "";
                }
                if (m_OA_DeliverPlan.Xingzhengzhuize == null)
                {
                    m_OA_DeliverPlan.Xingzhengzhuize = "";
                }
                return _IOA_DeliverPlanPaicheDAL.InserModel(m_OA_DeliverPlan);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 
        /// <summary>
        /// 修改送货安排
        /// </summary>
        /// <param name="rType"></param>
        /// <returns></returns>
        public bool UpdateModel(CY.Model.OA_DeliverPlan m_OA_DeliverPlan)
        {
            try
            {
                if (m_OA_DeliverPlan.Yichangchuli == null)
                {
                    m_OA_DeliverPlan.Yichangchuli = "";
                }
                if (m_OA_DeliverPlan.Xingzhengzhuize == null)
                {
                    m_OA_DeliverPlan.Xingzhengzhuize = "";
                }
                return _IOA_DeliverPlanPaicheDAL.UpdateModel(m_OA_DeliverPlan);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 
        /// <summary>
        /// 获取全部合作客户
        /// </summary>
        /// <param name="Keyid">主键id</param>
        /// <returns></returns>
        public IEnumerable<OA_DeliverPlan> GetModelList()
        {
            Query query = new Query();
            return _IOA_DeliverPlanPaicheDAL.SelectAllModel(query);
        }
 
 
        /// <summary>
        /// 根据formid获得信息
        /// </summary>
        /// <param name="Keyid">编号</param>
        /// <returns></returns>
        public IEnumerable<Model.OA_DeliverPlan> GetModelByformid(Guid formid)
        {
 
            return _IOA_DeliverPlanPaicheDAL.GetModelByformid(formid);
        }
 
 
        /// <summary>
        /// 根据formid获得信息
        /// </summary>
        /// <param name="Keyid">编号</param>
        /// <returns></returns>
        public IEnumerable<Model.OA_DeliverPlan> GetModelByDeliveredTime(Guid FirmId, DateTime DeliverTime)
        {
 
            return _IOA_DeliverPlanPaicheDAL.GetModelByDeliveredTime(FirmId, DeliverTime);
        }
 
 
 
 
        /// <summary>
        /// 获取全部合作客户
        /// </summary>
        /// <param name="Keyid">主键id</param>
        /// <returns></returns>
        public OA_DeliverPlan GetModelByKeyid(Guid? keyid, Guid? BuyerId, DateTime? DeliveryTime)
        {
 
            return _IOA_DeliverPlanPaicheDAL.GetModelByKeyid(keyid, BuyerId, DeliveryTime);
        }
 
        /// <summary>
        /// 删除合作客户
        /// </summary>
        /// <param name="rType"></param>
        /// <returns></returns>
        public bool DeleteModel(CY.Model.OA_DeliverPlan rType)
        {
            try
            {
                _IOA_DeliverPlanPaicheDAL.DeleteModel(rType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return true;
        }
 
        /// <summary>
        /// 查询合作客户分页列表
        /// </summary>
        /// <param name="pa"></param>
        /// <returns></returns>
        public IEnumerable<OA_DeliverPlan> SelectModelPage(Pagination pa, Guid FirmId, string DeliveredTime,
  string CarId, string DriverId, string DeliveredTimeStart, string DeliveredTimeEnd, string trueMemberId = "", string CustormerName = "", string BusinessManager = "", string wancheng = "")
        {
            string Condition = " and od.FirmId ='" + FirmId + "' and od.shifouDelivery = 1 ";
            string sort = " [Sort] asc   ";
            if (string.IsNullOrEmpty(DeliveredTimeStart) && string.IsNullOrEmpty(DeliveredTimeEnd) && !string.IsNullOrEmpty(DeliveredTime))
            {
                if (DeliveredTime != "一周后")
                {
                    Condition += " and DATEDIFF(day,od.[DeliverTime],'" + DeliveredTime + "')=0 ";
 
                }
                else
                {
                    Condition += " and DATEDIFF(day,GETDATE(),od.[DeliverTime]) >= 6    ";
                    //sort = "  DeliverTime desc,[Sort] asc   ";
                   
                }
            }
 
            if (!string.IsNullOrEmpty(DeliveredTimeStart))
            {
                Condition += " and DATEDIFF(day,'"+ DeliveredTimeStart + "',od.[DeliverTime]) >= 0    ";
                sort = "  DeliverTime desc,[Sort] asc   ";
            }
 
            if (!string.IsNullOrEmpty(DeliveredTimeEnd))
            {
                Condition += " and DATEDIFF(day,'" + DeliveredTimeEnd + "',od.[DeliverTime]) <= 0    ";
                sort = "  DeliverTime desc,[Sort] asc   ";
            }
 
 
            if (!string.IsNullOrEmpty(CarId))
                Condition += " and  od.CarId = '" + CarId + "'";
            if (!string.IsNullOrEmpty(DriverId))
                Condition += " and  od.DriverId = '" + DriverId + "'";
            if (!string.IsNullOrEmpty(trueMemberId))
                Condition += " and  oss.MemberId = '" + trueMemberId + "'";
            if (!string.IsNullOrEmpty(BusinessManager))
                Condition += " and  od.BusinessManagerId = '" + BusinessManager + "'";
            if (!string.IsNullOrEmpty(CustormerName))
                Condition += " and  od.CompanyName like '%" + CustormerName + "%'";
            if (!string.IsNullOrEmpty(wancheng))
            {
                if (wancheng == "1")
                {
                    Condition += " and   od.DeliveredTime is not null ";
                }
                else
                {
                    Condition += " and   od.DeliveredTime is null";
                }
 
            }
 
 
            Query query = new Query();
            IList<Criterion> criterias = new List<Criterion>()
            {
                new Criterion("", Condition),
 
                new Criterion("orderBy",sort)
            };
            query.Criteria = criterias;
            return _IOA_DeliverPlanPaicheDAL.SelectModelPage(query, pa);
        }
 
 
 
 
 
 
 
        /// <summary>
        /// 查询合作客户分页列表
        /// </summary>
        /// <param name="pa"></param>
        /// <returns></returns>
        public IEnumerable<OA_DeliverPlan> SelectModelPageWenti(Pagination pa, Guid FirmId,
    string DeliveredTimeStart, string DeliveredTimeEnd, string DriverId, string Zerenren , string CustormerName , string Wanjiestatus )
        {
            string Condition = " and od.FirmId ='" + FirmId + "' and od.DeliveredTime is not null and od.wentifankui is not null and od.wentifankui!=''  "; // and od.shifouDelivery = 1
            string sort = "DeliveredTime desc   ";
             
 
            if (!string.IsNullOrEmpty(DeliveredTimeStart))
            {
                Condition += " and DATEDIFF(day,'" + DeliveredTimeStart + "',od.[DeliveredTime]) >= 0    ";
            }
 
            if (!string.IsNullOrEmpty(DeliveredTimeEnd))
            {
                Condition += " and DATEDIFF(day,'" + DeliveredTimeEnd + "',od.[DeliveredTime]) <= 0    ";
            }
 
            if (!string.IsNullOrEmpty(DriverId))
                Condition += " and  od.DriverId = '" + DriverId + "'";
 
            if (!string.IsNullOrEmpty(Zerenren))
                Condition += " and  od.Zerenren = '" + Zerenren + "'";
            if (!string.IsNullOrEmpty(CustormerName))
                Condition += " and  od.CompanyName like '%" + CustormerName + "%'";
 
 
            
           
            if (!string.IsNullOrEmpty(Wanjiestatus))
            {
                if (Wanjiestatus == "1")
                {
                    Condition += " and   od.Wanjiestatus = 1 ";
                }
                else
                {
                    Condition += " and ( od.Wanjiestatus is null   or   od.Wanjiestatus = 0 )";
                }
 
            }
 
 
            Query query = new Query();
            IList<Criterion> criterias = new List<Criterion>()
            {
                new Criterion("", Condition),
 
                new Criterion("orderBy",sort)
            };
            query.Criteria = criterias;
            return _IOA_DeliverPlanPaicheDAL.SelectModelPageWenti(query, pa);
        }
 
 
    }
}