|
|
@@ -1,6 +1,8 @@
|
|
1
|
1
|
using CallCenter.Utility;
|
|
|
2
|
+using CallCenterApi.Common;
|
|
2
|
3
|
using CallCenterApi.Interface.Controllers.Base;
|
|
3
|
4
|
using CallCenterApi.Interface.Models.Input;
|
|
|
5
|
+using CallCenterApi.Model;
|
|
4
|
6
|
using Newtonsoft.Json;
|
|
5
|
7
|
using NPOI.HSSF.UserModel;
|
|
6
|
8
|
using NPOI.SS.UserModel;
|
|
|
@@ -10,6 +12,7 @@ using System.Collections.Generic;
|
|
10
|
12
|
using System.Data;
|
|
11
|
13
|
using System.IO;
|
|
12
|
14
|
using System.Linq;
|
|
|
15
|
+using System.Text.RegularExpressions;
|
|
13
|
16
|
using System.Web;
|
|
14
|
17
|
using System.Web.Mvc;
|
|
15
|
18
|
|
|
|
@@ -40,98 +43,50 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
40
|
43
|
/// <param name="conname">联系人姓名</param>
|
|
41
|
44
|
/// <param name="contel">联系人电话</param>
|
|
42
|
45
|
/// <returns></returns>
|
|
43
|
|
- public ActionResult GetList(string keywords, string code, string cmpname, string cmpaddress,
|
|
44
|
|
- string legname, string legtel, string subtrade, string layer, string bedept,
|
|
45
|
|
- string berelacc, string beaudacc, string bemakeacc, string conname, string contel,
|
|
46
|
|
- int pageindex = 1, int pagesize = 10)
|
|
|
46
|
+ public ActionResult GetList(string code, string cmpname, string legname, string legtel,string province, string city,
|
|
|
47
|
+ string country, string township, int areaid = 0, int branchid = 0,int pageindex = 1, int pagesize = 10)
|
|
47
|
48
|
{
|
|
48
|
|
- string sql = "";
|
|
|
49
|
+ string sql = $" and F_DeleteFlag=0";
|
|
49
|
50
|
DataTable dt = new DataTable();
|
|
50
|
51
|
#region 筛选条件
|
|
51
|
|
- if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
|
|
52
|
|
- sql += $" and F_KeyWords like '%" + keywords.Trim() + "%'";
|
|
|
52
|
+ if (areaid > 0)//大区
|
|
|
53
|
+ sql += $" and F_AreaID=" + areaid;
|
|
|
54
|
+ if (branchid > 0)//分公司
|
|
|
55
|
+ sql += $" and F_BranchID=" + branchid;
|
|
53
|
56
|
if (!string.IsNullOrWhiteSpace(code))//客户编号
|
|
54
|
|
- sql += $" and F_CustomerCode like '%" + code.Trim() + "%'";
|
|
|
57
|
+ {
|
|
|
58
|
+ if (valcode(code))
|
|
|
59
|
+ sql += $" and F_CustomerCode like '%" + code.Trim() + "%'";
|
|
|
60
|
+ }
|
|
55
|
61
|
if (!string.IsNullOrWhiteSpace(cmpname))//公司名称
|
|
56
|
62
|
sql += $" and F_CompanyName like '%" + cmpname.Trim() + "%'";
|
|
57
|
|
- if (!string.IsNullOrWhiteSpace(cmpaddress))//公司地址
|
|
58
|
|
- sql += $" and (F_CompanyAddress like '%" + cmpaddress.Trim()
|
|
59
|
|
- + "%' or F_RegisteredAddress like '%" + cmpaddress.Trim()
|
|
60
|
|
- + "%' or F_Address like '%" + cmpaddress.Trim()
|
|
61
|
|
- + "%' or F_Address1 like '%" + cmpaddress.Trim()
|
|
62
|
|
- + "%' or F_Address2 like '%" + cmpaddress.Trim()
|
|
63
|
|
- + "%' or F_Address3 like '%" + cmpaddress.Trim()
|
|
64
|
|
- + "%' or F_Address4 like '%" + cmpaddress.Trim()
|
|
65
|
|
- + "%')";
|
|
66
|
63
|
if (!string.IsNullOrWhiteSpace(legname))//法人姓名
|
|
67
|
|
- sql += $" and F_LegalName like '%" + legname.Trim() + "%'";
|
|
|
64
|
+ sql += $" and F_Legal like '%" + legname.Trim() + "%'";
|
|
68
|
65
|
if (!string.IsNullOrWhiteSpace(legtel))//法人电话
|
|
69
|
|
- sql += $" and F_LegalTel like '%" + legtel.Trim() + "%'";
|
|
70
|
|
- if (!string.IsNullOrWhiteSpace(subtrade))//所属行业
|
|
71
|
|
- sql += $" and isnull(F_SubTrade,'') = '" + subtrade.Trim() + "'";
|
|
72
|
|
- if (!string.IsNullOrWhiteSpace(layer))//客户信誉等级
|
|
73
|
|
- sql += $" and isnull(F_Layer,'') = '" + layer.Trim() + "'";
|
|
74
|
|
- if (!string.IsNullOrWhiteSpace(bedept))//客户所属部门
|
|
75
|
|
- sql += $" and isnull(F_BeDept,'') = '" + bedept.Trim() + "'";
|
|
76
|
|
- if (!string.IsNullOrWhiteSpace(berelacc))//涉税会计
|
|
77
|
|
- sql += $" and F_BeRelatedAcc like '%" + berelacc.Trim() + "%'";
|
|
78
|
|
- if (!string.IsNullOrWhiteSpace(beaudacc))//审核会计
|
|
79
|
|
- sql += $" and F_BeAuditAcc like '%" + beaudacc.Trim() + "%'";
|
|
80
|
|
- if (!string.IsNullOrWhiteSpace(bemakeacc))//做账会计
|
|
81
|
|
- sql += $" and F_BeMakeAcc like '%" + bemakeacc.Trim() + "%'";
|
|
82
|
|
- if (!string.IsNullOrWhiteSpace(conname) || !string.IsNullOrWhiteSpace(contel))
|
|
83
|
|
- {
|
|
84
|
|
- var sqlcon = " where F_DeleteFlag=0 ";
|
|
85
|
|
- if (!string.IsNullOrWhiteSpace(conname)) // 联系人
|
|
86
|
|
- sqlcon += " and F_Name like '%" + conname + "%'";
|
|
87
|
|
- if (!string.IsNullOrWhiteSpace(contel)) //联系人电话
|
|
88
|
|
- sqlcon += " and F_Telephone like '%" + contel + "%'";
|
|
89
|
|
- sql += $" and F_CustomerId in (select F_CustomerId from T_Cus_ContactPersonNew " + sqlcon + " )";
|
|
90
|
|
- }
|
|
|
66
|
+ sql += $" and F_LegalPhone like '%" + legtel.Trim() + "%'";
|
|
|
67
|
+ if (!string.IsNullOrWhiteSpace(province))//省
|
|
|
68
|
+ sql += $" and F_AddressProvince like '%" + province.Trim() + "%'";
|
|
|
69
|
+ if (!string.IsNullOrWhiteSpace(province))//市
|
|
|
70
|
+ sql += $" and F_AddressCity like '%" + city.Trim() + "%'";
|
|
|
71
|
+ if (!string.IsNullOrWhiteSpace(province))//县
|
|
|
72
|
+ sql += $" and F_AddressCountry like '%" + country.Trim() + "%'";
|
|
|
73
|
+ if (!string.IsNullOrWhiteSpace(province))//乡
|
|
|
74
|
+ sql += $" and F_AddressTownship like '%" + township.Trim() + "%'";
|
|
91
|
75
|
#endregion
|
|
92
|
76
|
|
|
93
|
77
|
int recordCount = 0;
|
|
94
|
|
- if(CurrentUser.UserData.F_RoleId==17)
|
|
95
|
|
- {
|
|
96
|
|
- sql += " and F_DeleteFlag=0";
|
|
97
|
|
- }
|
|
98
|
78
|
if (!string.IsNullOrWhiteSpace(sql))
|
|
99
|
79
|
{
|
|
100
|
|
- sql += " and F_DeleteFlag=0";
|
|
101
|
80
|
dt = BLL.PagerBLL.GetListPager(
|
|
102
|
81
|
"T_Cus_CustomerBaseNew",
|
|
103
|
82
|
"F_CustomerId",
|
|
104
|
|
- "*,dbo.GetDeptName(F_BeDept) as F_BeDeptName",
|
|
|
83
|
+ "*,dbo.GetUserName(F_CreateBy) as F_CreateByName",
|
|
105
|
84
|
sql,
|
|
106
|
85
|
"ORDER BY F_CustomerId desc",
|
|
107
|
86
|
pagesize,
|
|
108
|
87
|
pageindex,
|
|
109
|
88
|
true,
|
|
110
|
89
|
out recordCount);
|
|
111
|
|
- #region
|
|
112
|
|
- dt.Columns.Add("F_Contact");
|
|
113
|
|
- var dept = new BLL.T_Sys_Department().GetModelList("");
|
|
114
|
|
- foreach (DataRow dr in dt.Rows)
|
|
115
|
|
- {
|
|
116
|
|
- #region 绑定联系人信息
|
|
117
|
|
- var contact = "";
|
|
118
|
|
- string cusid = dr["F_CustomerId"] != null ? dr["F_CustomerId"].ToString() : "";
|
|
119
|
|
- if (cusid != "")
|
|
120
|
|
- {
|
|
121
|
|
- var conlist = conbll.GetModelList(" F_CustomerId=" + cusid);
|
|
122
|
|
- if (conlist.Count > 0)
|
|
123
|
|
- {
|
|
124
|
|
- foreach (var item in conlist)
|
|
125
|
|
- {
|
|
126
|
|
- contact += item.F_Name + "(" + item.F_Telephone + "),";
|
|
127
|
|
- }
|
|
128
|
|
- }
|
|
129
|
|
- dr["F_Contact"] = contact.TrimEnd(',');
|
|
130
|
|
- }
|
|
131
|
|
- #endregion
|
|
132
|
|
- }
|
|
133
|
|
-
|
|
134
|
|
- #endregion
|
|
135
|
90
|
}
|
|
136
|
91
|
var obj = new
|
|
137
|
92
|
{
|
|
|
@@ -151,7 +106,7 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
151
|
106
|
{
|
|
152
|
107
|
string sql = "";
|
|
153
|
108
|
if (!string.IsNullOrWhiteSpace(keywords))//关键字搜索
|
|
154
|
|
- sql += $" F_KeyWords like '%" + keywords.Trim() + "%'";
|
|
|
109
|
+ sql += $" ( F_CompanyName like '%" + keywords.Trim() + "%' or F_CustomerCode like '%" + keywords.Trim() + "%' ) ";
|
|
155
|
110
|
var list = new List<Model.T_Cus_CustomerBaseNew>();
|
|
156
|
111
|
if (!string.IsNullOrWhiteSpace(sql))
|
|
157
|
112
|
{
|
|
|
@@ -174,25 +129,7 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
174
|
129
|
Model.T_Cus_CustomerBaseNew userModel = cusbll.GetModel(cusid);
|
|
175
|
130
|
if (userModel != null)
|
|
176
|
131
|
{
|
|
177
|
|
- #region 绑定部门
|
|
178
|
|
- var deptname = "";
|
|
179
|
|
- if (userModel.F_BeDept != null)
|
|
180
|
|
- {
|
|
181
|
|
- var deptmodel = deptbll.GetModel(userModel.F_BeDept.Value);
|
|
182
|
|
- if (deptmodel != null)
|
|
183
|
|
- deptname = deptmodel.F_DeptName;
|
|
184
|
|
- }
|
|
185
|
|
- #endregion
|
|
186
|
|
- var conlist = conbll.GetModelList(" F_DeleteFlag=0 and F_CustomerId=" + cusid);
|
|
187
|
|
- var finlist = finbll.GetModelList(" F_DeleteFlag=0 and F_CustomerId=" + cusid);
|
|
188
|
|
- var obj = new
|
|
189
|
|
- {
|
|
190
|
|
- CustomerBase = userModel,
|
|
191
|
|
- BeDeptName = deptname,
|
|
192
|
|
- ContactList = conlist,
|
|
193
|
|
- FinaceList = finlist,
|
|
194
|
|
- };
|
|
195
|
|
- return Success("获取成功", obj);
|
|
|
132
|
+ return Success("获取成功", userModel);
|
|
196
|
133
|
}
|
|
197
|
134
|
else
|
|
198
|
135
|
{
|
|
|
@@ -213,31 +150,13 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
213
|
150
|
{
|
|
214
|
151
|
if (!string.IsNullOrWhiteSpace(tel))
|
|
215
|
152
|
{
|
|
216
|
|
- var sql = $" and (F_LegalTel like '%" + tel.Trim() + "%') or F_CustomerId in (select F_CustomerId from T_Cus_ContactPersonNew where F_Telephone like '%" + tel.Trim() + "%')";
|
|
|
153
|
+ var sql = $" and (F_SalesPhone like '%" + tel.Trim() + "%' or F_LegalPhone like '%" + tel.Trim() + "%')";
|
|
217
|
154
|
var userModel = new BLL.T_Cus_CustomerBaseNew().GetModelList(" F_DeleteFlag = 0 " + sql);
|
|
218
|
155
|
if (userModel.Count() > 0)
|
|
219
|
156
|
{
|
|
220
|
157
|
var model = userModel.Last();
|
|
221
|
|
- int cusid = model.F_CustomerId;
|
|
222
|
|
- var conlist = conbll.GetModelList(" F_DeleteFlag=0 and F_CustomerId=" + cusid);
|
|
223
|
|
- var finlist=finbll.GetModelList(" F_DeleteFlag=0 and F_CustomerId=" + cusid);
|
|
224
|
|
- #region 绑定部门
|
|
225
|
|
- var deptname = "";
|
|
226
|
|
- if (model.F_BeDept != null)
|
|
227
|
|
- {
|
|
228
|
|
- var deptmodel = deptbll.GetModel(model.F_BeDept.Value);
|
|
229
|
|
- if (deptmodel != null)
|
|
230
|
|
- deptname = deptmodel.F_DeptName;
|
|
231
|
|
- }
|
|
232
|
|
- #endregion
|
|
233
|
|
- var obj = new
|
|
234
|
|
- {
|
|
235
|
|
- CustomerBase = model,
|
|
236
|
|
- BeDeptName = deptname,
|
|
237
|
|
- ContactList = conlist,
|
|
238
|
|
- FinaceList = finlist,
|
|
239
|
|
- };
|
|
240
|
|
- return Success("获取成功", obj);
|
|
|
158
|
+
|
|
|
159
|
+ return Success("获取成功", model);
|
|
241
|
160
|
}
|
|
242
|
161
|
else
|
|
243
|
162
|
{
|
|
|
@@ -260,49 +179,21 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
260
|
179
|
#region 添加验证判断
|
|
261
|
180
|
if (string.IsNullOrEmpty(input.F_CustomerCode))
|
|
262
|
181
|
return Error("编号不能为空!");
|
|
263
|
|
- if (getunique(0, input.F_CustomerCode, input.F_CompanyName))
|
|
|
182
|
+ if (!valcode(input.F_CustomerCode))
|
|
|
183
|
+ return Error("编号必须是10位数字");
|
|
|
184
|
+ if (getunique(0, input.F_CustomerCode))
|
|
264
|
185
|
return Error("编号已被占用,请重新输入!");
|
|
265
|
186
|
#endregion
|
|
266
|
187
|
var model = new Model.T_Cus_CustomerBaseNew();
|
|
267
|
188
|
#region 保存客户基本信息
|
|
268
|
189
|
model = inputtoobj(model, input);
|
|
269
|
190
|
model.F_CreateBy = usercode;
|
|
270
|
|
- model.F_CreatedOn = DateTime.Now;
|
|
271
|
|
- model.F_DeleteFlag = 0;
|
|
|
191
|
+ model.F_CreateOn = DateTime.Now;
|
|
|
192
|
+ model.F_IsDelete = 0;
|
|
272
|
193
|
#endregion
|
|
273
|
194
|
int n = cusbll.Add(model);
|
|
274
|
195
|
if (n > 0)
|
|
275
|
196
|
{
|
|
276
|
|
- #region 添加联系人
|
|
277
|
|
- if (input.ContactList != null && input.ContactList.Count > 0)
|
|
278
|
|
- {
|
|
279
|
|
- var conmodel = new Model.T_Cus_ContactPersonNew();
|
|
280
|
|
- conmodel.F_CustomerId = n;
|
|
281
|
|
- conmodel.F_CreateBy = usercode;
|
|
282
|
|
- conmodel.F_CreateOn = DateTime.Now;
|
|
283
|
|
- conmodel.F_DeleteFlag = 0;
|
|
284
|
|
- foreach (var item in input.ContactList)
|
|
285
|
|
- {
|
|
286
|
|
- conmodel.F_IsMain = item.F_IsMain;
|
|
287
|
|
- conmodel.F_Name = item.F_Name;
|
|
288
|
|
- conmodel.F_Telephone = item.F_Telephone;
|
|
289
|
|
- conmodel.F_Duties = item.F_Duties;
|
|
290
|
|
- conmodel.F_Email = item.F_Email;
|
|
291
|
|
- conmodel.F_MSN = item.F_MSN;
|
|
292
|
|
- conmodel.F_QQ = item.F_QQ;
|
|
293
|
|
- conmodel.F_Remark = item.F_Remark;
|
|
294
|
|
-
|
|
295
|
|
- conbll.Add(conmodel);
|
|
296
|
|
- }
|
|
297
|
|
- }
|
|
298
|
|
- #endregion
|
|
299
|
|
- #region 添加财税情况
|
|
300
|
|
- var fincmodel = new CustomerFinanceInput();
|
|
301
|
|
- fincmodel.F_CustomerId = n;
|
|
302
|
|
- fincmodel.F_CustomerCode = model.F_CustomerCode;
|
|
303
|
|
- fincmodel.F_CreateBy = usercode;
|
|
304
|
|
- savefin(input.FinanceInfos);
|
|
305
|
|
- #endregion
|
|
306
|
197
|
return Success("新增成功!");
|
|
307
|
198
|
}
|
|
308
|
199
|
else
|
|
|
@@ -319,7 +210,7 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
319
|
210
|
#region 添加验证判断
|
|
320
|
211
|
if (input.F_CustomerId <= 0)
|
|
321
|
212
|
return Error("参数错误!");
|
|
322
|
|
- if (getunique(input.F_CustomerId, input.F_CustomerCode, input.F_CompanyName))
|
|
|
213
|
+ if (getunique(input.F_CustomerId, input.F_CustomerCode))
|
|
323
|
214
|
return Error("编号已被占用,请重新输入!");
|
|
324
|
215
|
#endregion
|
|
325
|
216
|
var model = cusbll.GetModel(input.F_CustomerId);
|
|
|
@@ -342,110 +233,23 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
342
|
233
|
{
|
|
343
|
234
|
var newmodel = model;
|
|
344
|
235
|
if (!string.IsNullOrWhiteSpace(input.F_CustomerCode))
|
|
345
|
|
- {
|
|
346
|
236
|
model.F_CustomerCode = input.F_CustomerCode;
|
|
347
|
|
- }
|
|
348
|
237
|
else
|
|
349
|
238
|
model.F_CustomerCode = model.F_CustomerCode;
|
|
350
|
239
|
if (!string.IsNullOrWhiteSpace(input.F_CompanyName))
|
|
351
|
|
- {
|
|
352
|
240
|
model.F_CompanyName = input.F_CompanyName;
|
|
353
|
|
- #region 处理关键字
|
|
354
|
|
- var keyword = model.F_CompanyName;
|
|
355
|
|
- var keyconfig = Configs.GetValue("keystring");
|
|
356
|
|
- var keystring = keyconfig.Split(',');
|
|
357
|
|
- foreach (var item in keystring)
|
|
358
|
|
- {
|
|
359
|
|
- if (model.F_CompanyName.Contains(item))
|
|
360
|
|
- keyword = keyword.Replace(item, "");
|
|
361
|
|
- }
|
|
362
|
|
- model.F_KeyWords = keyword;
|
|
363
|
|
- #endregion
|
|
364
|
|
- }
|
|
365
|
|
- if (!string.IsNullOrWhiteSpace(input.F_RegisteredAddress))
|
|
366
|
|
- model.F_RegisteredAddress = input.F_RegisteredAddress;
|
|
367
|
|
- if (!string.IsNullOrWhiteSpace(input.F_CompanyAddress))
|
|
368
|
|
- model.F_CompanyAddress = input.F_CompanyAddress;
|
|
369
|
|
- if (!string.IsNullOrWhiteSpace(input.F_LegalName))
|
|
370
|
|
- model.F_LegalName = input.F_LegalName;
|
|
371
|
|
- if (!string.IsNullOrWhiteSpace(input.F_LegalIDCards))
|
|
372
|
|
- model.F_LegalIDCards = input.F_LegalIDCards;
|
|
373
|
|
- if (!string.IsNullOrWhiteSpace(input.F_LegalTel))
|
|
374
|
|
- model.F_LegalTel = input.F_LegalTel;
|
|
375
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Qualification))
|
|
376
|
|
- model.F_Qualification = input.F_Qualification;
|
|
377
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Layer))
|
|
378
|
|
- model.F_Layer = input.F_Layer;
|
|
379
|
|
- if (!string.IsNullOrWhiteSpace(input.F_InvoiceRange))
|
|
380
|
|
- model.F_InvoiceRange = input.F_InvoiceRange;
|
|
381
|
|
- if (!string.IsNullOrWhiteSpace(input.F_SubTrade))
|
|
382
|
|
- model.F_SubTrade = input.F_SubTrade;
|
|
383
|
|
- if (!string.IsNullOrWhiteSpace(input.F_TaxCategory))
|
|
384
|
|
- model.F_TaxCategory = input.F_TaxCategory;
|
|
385
|
|
- if (!string.IsNullOrWhiteSpace(input.F_TaxPointDes))
|
|
386
|
|
- model.F_TaxPointDes = input.F_TaxPointDes;
|
|
387
|
|
- if (!string.IsNullOrWhiteSpace(input.F_WxPassword))
|
|
388
|
|
- model.F_WxPassword = input.F_WxPassword;
|
|
389
|
|
- if (input.F_BeDept > 0)
|
|
390
|
|
- model.F_BeDept = input.F_BeDept;
|
|
391
|
|
- if (!string.IsNullOrWhiteSpace(input.F_FinancialManager))
|
|
392
|
|
- model.F_FinancialManager = input.F_FinancialManager;
|
|
393
|
|
- if (!string.IsNullOrWhiteSpace(input.F_BusinessOwner))
|
|
394
|
|
- model.F_BusinessOwner = input.F_BusinessOwner;
|
|
395
|
|
- if (!string.IsNullOrWhiteSpace(input.F_BeRelatedAcc))
|
|
396
|
|
- model.F_BeRelatedAcc = input.F_BeRelatedAcc;
|
|
397
|
|
- if (!string.IsNullOrWhiteSpace(input.F_BeAuditAcc))
|
|
398
|
|
- model.F_BeAuditAcc = input.F_BeAuditAcc;
|
|
399
|
|
- if (!string.IsNullOrWhiteSpace(input.F_BeMakeAcc))
|
|
400
|
|
- model.F_BeMakeAcc = input.F_BeMakeAcc;
|
|
401
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Remark1))
|
|
402
|
|
- model.F_Remark1 = input.F_Remark1;
|
|
403
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Remark2))
|
|
404
|
|
- model.F_Remark2 = input.F_Remark2;
|
|
405
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Remark3))
|
|
406
|
|
- model.F_Remark3 = input.F_Remark3;
|
|
407
|
|
- if (!string.IsNullOrWhiteSpace(input.F_CusService))
|
|
408
|
|
- model.F_CusService = input.F_CusService;
|
|
409
|
|
- if (!string.IsNullOrWhiteSpace(input.F_HandoverDate))
|
|
410
|
|
- model.F_HandoverDate = input.F_HandoverDate;
|
|
411
|
|
- if (input.F_ISBankSlips > 0)
|
|
412
|
|
- model.F_ISBankSlips = input.F_ISBankSlips;
|
|
413
|
|
- else
|
|
414
|
|
- model.F_ISBankSlips = 0;
|
|
415
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Address))
|
|
416
|
|
- model.F_Address = input.F_Address;
|
|
417
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Address1))
|
|
418
|
|
- model.F_Address1 = input.F_Address1;
|
|
419
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Address2))
|
|
420
|
|
- model.F_Address2 = input.F_Address2;
|
|
421
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Address3))
|
|
422
|
|
- model.F_Address3 = input.F_Address3;
|
|
423
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Address4))
|
|
424
|
|
- model.F_Address4 = input.F_Address4;
|
|
425
|
|
- if (!string.IsNullOrWhiteSpace(input.F_Charges))
|
|
426
|
|
- model.F_Charges = input.F_Charges;
|
|
427
|
|
- if (input.F_ChargeType > 0)
|
|
428
|
|
- model.F_ChargeType = input.F_ChargeType;
|
|
429
|
|
- if (!string.IsNullOrWhiteSpace(input.F_CompanyLogo))
|
|
430
|
|
- model.F_CompanyLogo = input.F_CompanyLogo;
|
|
431
|
|
- if (input.F_CycleStart != null)
|
|
432
|
|
- model.F_CycleStart = input.F_CycleStart;
|
|
433
|
|
- if (input.F_CycleEnd != null)
|
|
434
|
|
- model.F_CycleEnd = input.F_CycleEnd;
|
|
435
|
|
- if (!string.IsNullOrWhiteSpace(input.F_TaxNumber))
|
|
436
|
|
- model.F_TaxNumber = input.F_TaxNumber;
|
|
437
|
|
- if (input.F_FeeExpires != null)
|
|
438
|
|
- model.F_FeeExpires = input.F_FeeExpires;
|
|
|
241
|
+ #region 基本字段
|
|
|
242
|
+ #endregion
|
|
439
|
243
|
return model;
|
|
440
|
244
|
}
|
|
441
|
245
|
|
|
442
|
246
|
/// <summary>
|
|
443
|
247
|
/// 验证客户编号是否唯一
|
|
444
|
248
|
/// </summary>
|
|
445
|
|
- private bool getunique(int id, string code,string name)
|
|
|
249
|
+ private bool getunique(int id, string code)
|
|
446
|
250
|
{
|
|
447
|
251
|
var sql = " F_DeleteFlag=0 ";
|
|
448
|
|
- sql += "and (F_CustomerCode='" + code + "' or F_CompanyName='"+ name + "')";
|
|
|
252
|
+ sql += "and (F_CustomerCode='" + code + "')";
|
|
449
|
253
|
if (id > 0)
|
|
450
|
254
|
sql += " and F_CustomerId<>"+id;
|
|
451
|
255
|
var count=cusbll.GetModelList(sql).Count();
|
|
|
@@ -488,288 +292,42 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
488
|
292
|
return Error("获取参数失败");
|
|
489
|
293
|
}
|
|
490
|
294
|
}
|
|
491
|
|
-
|
|
492
|
|
- /// <summary>
|
|
493
|
|
- /// 重置密码
|
|
494
|
|
- /// </summary>
|
|
495
|
|
- /// <param name="ids"></param>
|
|
496
|
|
- /// <returns></returns>
|
|
497
|
|
- public ActionResult UpdatePWD(string[] ids)
|
|
498
|
|
- {
|
|
499
|
|
- if (ids != null && ids.Length > 0)
|
|
500
|
|
- {
|
|
501
|
|
- string idd = " ";
|
|
502
|
|
- foreach (string str in ids)
|
|
503
|
|
- {
|
|
504
|
|
- idd += str + ",";
|
|
505
|
|
- }
|
|
506
|
|
- if (!string.IsNullOrEmpty(idd.Trim()))
|
|
507
|
|
- {
|
|
508
|
|
- if (cusbll.UpdatePWD(idd.TrimEnd(','),"123456"))
|
|
509
|
|
- {
|
|
510
|
|
- return Success("设置成功");
|
|
511
|
|
- }
|
|
512
|
|
- else
|
|
513
|
|
- {
|
|
514
|
|
- return Error("设置失败");
|
|
515
|
|
- }
|
|
516
|
|
- }
|
|
517
|
|
- else
|
|
518
|
|
- {
|
|
519
|
|
- return Error("请选择用户");
|
|
520
|
|
- }
|
|
521
|
|
- }
|
|
522
|
|
- else
|
|
523
|
|
- {
|
|
524
|
|
- return Error("获取参数失败");
|
|
525
|
|
- }
|
|
526
|
|
- }
|
|
527
|
|
- #endregion
|
|
528
|
|
- #region 联系人
|
|
529
|
|
- /// <summary>
|
|
530
|
|
- /// 获取客户联系人列表
|
|
531
|
|
- /// </summary>
|
|
532
|
|
- public ActionResult GetConList(string tel, string cusid, int pageindex = 1, int pagesize = 10)
|
|
533
|
|
- {
|
|
534
|
|
- string sql = "";
|
|
535
|
|
- DataTable dt = new DataTable();
|
|
536
|
|
- #region 筛选条件
|
|
537
|
|
- if (!string.IsNullOrWhiteSpace(cusid))
|
|
538
|
|
- sql += " and F_CustomerId=" + cusid + "";
|
|
539
|
|
- if (!string.IsNullOrWhiteSpace(tel)) //联系人电话
|
|
540
|
|
- sql += " and F_Telephone like '%" + tel + "%'";
|
|
541
|
|
- #endregion
|
|
542
|
|
- int recordCount = 0;
|
|
543
|
|
- if (!string.IsNullOrWhiteSpace(sql))
|
|
544
|
|
- {
|
|
545
|
|
- sql += " and F_DeleteFlag=0";
|
|
546
|
|
- dt = BLL.PagerBLL.GetListPager(
|
|
547
|
|
- "T_Cus_ContactPersonNew",
|
|
548
|
|
- "F_ManId",
|
|
549
|
|
- "*",
|
|
550
|
|
- sql,
|
|
551
|
|
- "ORDER BY F_ManId desc",
|
|
552
|
|
- pagesize,
|
|
553
|
|
- pageindex,
|
|
554
|
|
- true,
|
|
555
|
|
- out recordCount);
|
|
556
|
|
- }
|
|
557
|
|
- var obj = new
|
|
558
|
|
- {
|
|
559
|
|
- state = "success",
|
|
560
|
|
- message = "成功",
|
|
561
|
|
- rows = dt,
|
|
562
|
|
- total = recordCount
|
|
563
|
|
- };
|
|
564
|
|
-
|
|
565
|
|
- return Content(obj.ToJson());
|
|
566
|
|
-
|
|
567
|
|
- }
|
|
568
|
|
- /// <summary>
|
|
569
|
|
- /// 添加联系人
|
|
570
|
|
- /// </summary>
|
|
571
|
|
- /// <param name="coninput"></param>
|
|
572
|
|
- /// <returns></returns>
|
|
573
|
|
- public ActionResult AddContact(ContactPersonNewInput coninput)
|
|
574
|
|
- {
|
|
575
|
|
- string usercode = CurrentUser.UserData.F_UserCode;
|
|
576
|
|
- #region 添加验证判断
|
|
577
|
|
- if (coninput.F_CustomerId <= 0)
|
|
578
|
|
- return Error("客户ID获取失败!");
|
|
579
|
|
- #endregion
|
|
580
|
|
- var conmodel = new Model.T_Cus_ContactPersonNew();
|
|
581
|
|
- conmodel.F_CustomerId = coninput.F_CustomerId;
|
|
582
|
|
- conmodel.F_IsMain = coninput.F_IsMain;
|
|
583
|
|
- conmodel.F_Name = coninput.F_Name;
|
|
584
|
|
- conmodel.F_Telephone = coninput.F_Telephone;
|
|
585
|
|
- conmodel.F_Duties = coninput.F_Duties;
|
|
586
|
|
- conmodel.F_Email = coninput.F_Email;
|
|
587
|
|
- conmodel.F_MSN = coninput.F_MSN;
|
|
588
|
|
- conmodel.F_QQ = coninput.F_QQ;
|
|
589
|
|
- conmodel.F_Remark = coninput.F_Remark;
|
|
590
|
|
- conmodel.F_CreateBy = usercode;
|
|
591
|
|
- conmodel.F_CreateOn = DateTime.Now;
|
|
592
|
|
- conmodel.F_DeleteFlag = 0;
|
|
593
|
|
- int n = conbll.Add(conmodel);
|
|
594
|
|
- if (n > 0)
|
|
595
|
|
- return Success("联系人保存成功!");
|
|
596
|
|
- else
|
|
597
|
|
- return Error("联系人保存失败!");
|
|
598
|
|
- }
|
|
599
|
|
-
|
|
600
|
|
- /// <summary>
|
|
601
|
|
- /// 修改联系人
|
|
602
|
|
- /// </summary>
|
|
603
|
|
- /// <param name="coninput"></param>
|
|
604
|
|
- /// <returns></returns>
|
|
605
|
|
- public ActionResult UpdateContact(ContactPersonNewInput coninput)
|
|
606
|
|
- {
|
|
607
|
|
- string usercode = CurrentUser.UserData.F_UserCode;
|
|
608
|
|
- #region 添加验证判断
|
|
609
|
|
- if (coninput.F_ManId <= 0)
|
|
610
|
|
- return Error("参数错误!");
|
|
611
|
|
- if (coninput.F_CustomerId <= 0)
|
|
612
|
|
- return Error("客户ID获取失败!");
|
|
613
|
|
- #endregion
|
|
614
|
|
- var conmodel = conbll.GetModel(coninput.F_ManId);
|
|
615
|
|
- conmodel.F_CustomerId = coninput.F_CustomerId;
|
|
616
|
|
- conmodel.F_IsMain = coninput.F_IsMain;
|
|
617
|
|
- conmodel.F_Name = coninput.F_Name;
|
|
618
|
|
- conmodel.F_Telephone = coninput.F_Telephone;
|
|
619
|
|
- conmodel.F_Duties = coninput.F_Duties;
|
|
620
|
|
- conmodel.F_Email = coninput.F_Email;
|
|
621
|
|
- conmodel.F_MSN = coninput.F_MSN;
|
|
622
|
|
- conmodel.F_QQ = coninput.F_QQ;
|
|
623
|
|
- conmodel.F_Remark = coninput.F_Remark;
|
|
624
|
|
- var n = conbll.Update(conmodel);
|
|
625
|
|
- if (n)
|
|
626
|
|
- return Success("联系人保存成功!");
|
|
627
|
|
- else
|
|
628
|
|
- return Error("联系人保存失败!");
|
|
629
|
|
- }
|
|
630
|
|
-
|
|
631
|
|
- /// <summary>
|
|
632
|
|
- /// 删除联系人
|
|
633
|
|
- /// </summary>
|
|
634
|
|
- /// <param name="ids"></param>
|
|
635
|
|
- /// <returns></returns>
|
|
636
|
|
- public ActionResult DelContact(string[] ids)
|
|
637
|
|
- {
|
|
638
|
|
- if (ids != null && ids.Length > 0)
|
|
639
|
|
- {
|
|
640
|
|
- string idd = " ";
|
|
641
|
|
- foreach (string str in ids)
|
|
642
|
|
- {
|
|
643
|
|
- idd += str + ",";
|
|
644
|
|
- }
|
|
645
|
|
- if (!string.IsNullOrEmpty(idd.Trim()))
|
|
646
|
|
- {
|
|
647
|
|
- if (conbll.DeleteList(idd.TrimEnd(',')))
|
|
648
|
|
- {
|
|
649
|
|
- return Success("设置成功");
|
|
650
|
|
- }
|
|
651
|
|
- else
|
|
652
|
|
- {
|
|
653
|
|
- return Error("设置失败");
|
|
654
|
|
- }
|
|
655
|
|
- }
|
|
656
|
|
- else
|
|
657
|
|
- {
|
|
658
|
|
- return Error("请选择联系人");
|
|
659
|
|
- }
|
|
660
|
|
- }
|
|
661
|
|
- else
|
|
662
|
|
- {
|
|
663
|
|
- return Error("获取参数失败");
|
|
664
|
|
- }
|
|
665
|
|
- }
|
|
666
|
|
- #endregion
|
|
667
|
|
- #region 财税情况
|
|
668
|
|
- /// <summary>
|
|
669
|
|
- /// 根据客户id获取财税情况
|
|
670
|
|
- /// </summary>
|
|
671
|
|
- public ActionResult GetFinc(int cusid)
|
|
672
|
|
- {
|
|
673
|
|
- if (cusid != 0)
|
|
674
|
|
- {
|
|
675
|
|
- var model = finbll.GetModelList(" F_CustomerId=" + cusid).FirstOrDefault();
|
|
676
|
|
- if (model != null)
|
|
677
|
|
- return Success("获取财税情况成功", model);
|
|
678
|
|
- }
|
|
679
|
|
- return Error("获取财税情况失败");
|
|
680
|
|
- }
|
|
681
|
|
- /// <summary>
|
|
682
|
|
- /// 保存财税情况
|
|
683
|
|
- /// </summary>
|
|
684
|
|
- public ActionResult SaveFinance(CustomerFinanceInput input)
|
|
685
|
|
- {
|
|
686
|
|
- string usercode = CurrentUser.UserData.F_UserCode;
|
|
687
|
|
- input.F_CreateBy = usercode;
|
|
688
|
|
- var res = savefin(input);
|
|
689
|
|
- if (res)
|
|
690
|
|
- return Success("保存成功");
|
|
691
|
|
- else
|
|
692
|
|
- return Error("保存失败");
|
|
693
|
|
- }
|
|
694
|
|
- /// <summary>
|
|
695
|
|
- /// 公用方法保存财税情况
|
|
696
|
|
- /// </summary>
|
|
697
|
|
- public bool savefin(CustomerFinanceInput input)
|
|
698
|
|
- {
|
|
699
|
|
- Model.T_Cus_CustomerFinance model = new Model.T_Cus_CustomerFinance();
|
|
700
|
|
- if (input.F_CusFinId > 0)
|
|
701
|
|
- {
|
|
702
|
|
- model = finbll.GetModel(input.F_CusFinId);
|
|
703
|
|
- if (model == null)
|
|
704
|
|
- model = new Model.T_Cus_CustomerFinance();
|
|
705
|
|
- }
|
|
706
|
|
- #region 设置信息
|
|
707
|
|
- model.F_MonthState = input.F_MonthState;
|
|
708
|
|
- model.F_AnnualIncome = input.F_AnnualIncome;
|
|
709
|
|
- model.F_AnnualProfit = input.F_AnnualProfit;
|
|
710
|
|
- model.F_AnnualPersonCount = input.F_AnnualPersonCount;
|
|
711
|
|
- model.F_AnnualWages = input.F_AnnualWages;
|
|
712
|
|
- model.F_AnnualCost = input.F_AnnualCost;
|
|
713
|
|
- model.F_QuarterlyCost = input.F_QuarterlyCost;
|
|
714
|
|
- model.F_QuarterlyPersonCount = input.F_QuarterlyPersonCount;
|
|
715
|
|
- model.F_QuarterlyWages = input.F_QuarterlyWages;
|
|
716
|
|
- model.F_QuarterlyIncome = input.F_QuarterlyIncome;
|
|
717
|
|
- model.F_QPVAT = input.F_QPVAT;
|
|
718
|
|
- model.F_QPSurtax = input.F_QPSurtax;
|
|
719
|
|
- model.F_QPTaxes = input.F_QPTaxes;
|
|
720
|
|
- model.F_QPConTax = input.F_QPConTax;
|
|
721
|
|
- model.F_QPPerinTax = input.F_QPPerinTax;
|
|
722
|
|
- model.F_QPStampTax = input.F_QPStampTax;
|
|
723
|
|
- model.F_QPOtherTax = input.F_QPOtherTax;
|
|
724
|
|
- #endregion
|
|
725
|
|
- var res = false;
|
|
726
|
|
- if (input.F_CusFinId > 0)
|
|
727
|
|
- {
|
|
728
|
|
- res = finbll.Update(model);
|
|
729
|
|
- }
|
|
730
|
|
- else
|
|
731
|
|
- {
|
|
732
|
|
- model.F_CustomerId = input.F_CustomerId;
|
|
733
|
|
- model.F_CustomerCode = input.F_CustomerCode;
|
|
734
|
|
- model.F_CreateBy = input.F_CreateBy;
|
|
735
|
|
- model.F_CreatedOn = DateTime.Now;
|
|
736
|
|
- model.F_DeleteFlag = 0;
|
|
737
|
|
- res = finbll.Add(model)>0;
|
|
738
|
|
- }
|
|
739
|
|
- if (res)
|
|
740
|
|
- savefinlog(input);
|
|
741
|
|
- return res;
|
|
742
|
|
- }
|
|
743
|
|
- #region 财税情况日志
|
|
744
|
|
- private void savefinlog(CustomerFinanceInput input)
|
|
745
|
|
- {
|
|
746
|
|
- var model = new Model.T_Cus_CustomerFinanceLog();
|
|
747
|
|
- #region 设置信息
|
|
748
|
|
- model.F_CustomerId = input.F_CustomerId;
|
|
749
|
|
- model.F_CustomerCode = input.F_CustomerCode;
|
|
750
|
|
- model.F_CreateBy = input.F_CreateBy;
|
|
751
|
|
- model.F_CreatedOn = DateTime.Now;
|
|
752
|
|
- model.F_DeleteFlag = 0;
|
|
753
|
|
- model.F_MonthState = input.F_MonthState;
|
|
754
|
|
- model.F_AnnualIncome = input.F_AnnualIncome;
|
|
755
|
|
- model.F_AnnualProfit = input.F_AnnualProfit;
|
|
756
|
|
- model.F_AnnualPersonCount = input.F_AnnualPersonCount;
|
|
757
|
|
- model.F_AnnualWages = input.F_AnnualWages;
|
|
758
|
|
- model.F_AnnualCost = input.F_AnnualCost;
|
|
759
|
|
- model.F_QuarterlyCost = input.F_QuarterlyCost;
|
|
760
|
|
- model.F_QuarterlyPersonCount = input.F_QuarterlyPersonCount;
|
|
761
|
|
- model.F_QuarterlyWages = input.F_QuarterlyWages;
|
|
762
|
|
- model.F_QuarterlyIncome = input.F_QuarterlyIncome;
|
|
763
|
|
- model.F_QPVAT = input.F_QPVAT;
|
|
764
|
|
- model.F_QPSurtax = input.F_QPSurtax;
|
|
765
|
|
- model.F_QPTaxes = input.F_QPTaxes;
|
|
766
|
|
- model.F_QPConTax = input.F_QPConTax;
|
|
767
|
|
- model.F_QPPerinTax = input.F_QPPerinTax;
|
|
768
|
|
- model.F_QPStampTax = input.F_QPStampTax;
|
|
769
|
|
- model.F_QPOtherTax = input.F_QPOtherTax;
|
|
770
|
|
- #endregion
|
|
771
|
|
- new BLL.T_Cus_CustomerFinanceLog().Add(model);
|
|
772
|
|
- }
|
|
|
295
|
+ #region 客户使用微信端才会使用
|
|
|
296
|
+ ///// <summary>
|
|
|
297
|
+ ///// 重置密码
|
|
|
298
|
+ ///// </summary>
|
|
|
299
|
+ ///// <param name="ids"></param>
|
|
|
300
|
+ ///// <returns></returns>
|
|
|
301
|
+ //public ActionResult UpdatePWD(string[] ids)
|
|
|
302
|
+ //{
|
|
|
303
|
+ // if (ids != null && ids.Length > 0)
|
|
|
304
|
+ // {
|
|
|
305
|
+ // string idd = " ";
|
|
|
306
|
+ // foreach (string str in ids)
|
|
|
307
|
+ // {
|
|
|
308
|
+ // idd += str + ",";
|
|
|
309
|
+ // }
|
|
|
310
|
+ // if (!string.IsNullOrEmpty(idd.Trim()))
|
|
|
311
|
+ // {
|
|
|
312
|
+ // if (cusbll.UpdatePWD(idd.TrimEnd(','),"123456"))
|
|
|
313
|
+ // {
|
|
|
314
|
+ // return Success("设置成功");
|
|
|
315
|
+ // }
|
|
|
316
|
+ // else
|
|
|
317
|
+ // {
|
|
|
318
|
+ // return Error("设置失败");
|
|
|
319
|
+ // }
|
|
|
320
|
+ // }
|
|
|
321
|
+ // else
|
|
|
322
|
+ // {
|
|
|
323
|
+ // return Error("请选择用户");
|
|
|
324
|
+ // }
|
|
|
325
|
+ // }
|
|
|
326
|
+ // else
|
|
|
327
|
+ // {
|
|
|
328
|
+ // return Error("获取参数失败");
|
|
|
329
|
+ // }
|
|
|
330
|
+ //}
|
|
773
|
331
|
#endregion
|
|
774
|
332
|
#endregion
|
|
775
|
333
|
#region 导入客户资料
|
|
|
@@ -779,6 +337,7 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
779
|
337
|
public ActionResult ImportExcel()
|
|
780
|
338
|
{
|
|
781
|
339
|
string usercode = CurrentUser.UserData.F_UserCode;
|
|
|
340
|
+ string ip = DTRequest.GetIP();
|
|
782
|
341
|
if (!string.IsNullOrWhiteSpace(usercode))
|
|
783
|
342
|
{
|
|
784
|
343
|
HttpPostedFile _upFile = RequestString.GetFile("upFile");
|
|
|
@@ -788,7 +347,8 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
788
|
347
|
#region 上传文件
|
|
789
|
348
|
string filepath = "";
|
|
790
|
349
|
string datepath = DateTime.Now.ToString("yyyyMMddHHMMss");
|
|
791
|
|
- string aLastName = _upFile.FileName.Substring(_upFile.FileName.LastIndexOf(".") + 1, (_upFile.FileName.Length - _upFile.FileName.LastIndexOf(".") - 1)); //扩展名
|
|
|
350
|
+ string aLastName = Path.GetExtension(_upFile.FileName);
|
|
|
351
|
+ string oriname = Path.GetFileNameWithoutExtension(_upFile.FileName);
|
|
792
|
352
|
if (aLastName != "xls" && aLastName != "xlsx")
|
|
793
|
353
|
{
|
|
794
|
354
|
return Error("文件类型错误,请选择Excel文件");
|
|
|
@@ -802,156 +362,87 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
802
|
362
|
string PhysicalPath = Server.MapPath(filepath);
|
|
803
|
363
|
_upFile.SaveAs(PhysicalPath);
|
|
804
|
364
|
#endregion
|
|
805
|
|
- DataTable dt = new DataTable();
|
|
806
|
|
- #region 读取excel中内容
|
|
807
|
|
- IWorkbook workbook = null;
|
|
808
|
|
-
|
|
809
|
|
- using (FileStream file = new FileStream(PhysicalPath, FileMode.Open, FileAccess.Read))
|
|
810
|
|
- {
|
|
811
|
|
- if (aLastName == "xlsx") // 2007版本
|
|
812
|
|
- {
|
|
813
|
|
- workbook = new XSSFWorkbook(file);
|
|
814
|
|
- }
|
|
815
|
|
- else if (aLastName == "xls") // 2003版本
|
|
816
|
|
- {
|
|
817
|
|
- workbook = new HSSFWorkbook(file);
|
|
818
|
|
- }
|
|
819
|
|
- }
|
|
820
|
|
- ISheet sheet = workbook.GetSheetAt(0);
|
|
821
|
|
-
|
|
822
|
|
- System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
|
|
823
|
|
- //获取sheet的第一行
|
|
824
|
|
- IRow headerRow = sheet.GetRow(headrow);
|
|
825
|
|
- int cellCount = headerRow.LastCellNum;
|
|
826
|
|
- if (cellCount < 1)
|
|
827
|
|
- return Error("文件标题没有数据");
|
|
828
|
|
- for (int j = 0; j < cellCount; j++)
|
|
829
|
|
- {
|
|
830
|
|
- ICell cell = headerRow.GetCell(j);
|
|
831
|
|
- dt.Columns.Add(cell.ToString());
|
|
832
|
|
- }
|
|
|
365
|
+ #region 添加附件日志
|
|
|
366
|
+ Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
|
|
|
367
|
+ model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
|
|
|
368
|
+ model_T_Sys_Accessories.F_FileName = newpath;//附件名称
|
|
|
369
|
+ model_T_Sys_Accessories.F_FileType = aLastName;//附件类型
|
|
|
370
|
+ model_T_Sys_Accessories.F_FileUrl = filepath;//附件地址
|
|
|
371
|
+ model_T_Sys_Accessories.F_UserCode = usercode;//上传人
|
|
|
372
|
+ model_T_Sys_Accessories.F_OriName = oriname;
|
|
|
373
|
+ int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
|
|
833
|
374
|
#endregion
|
|
834
|
|
- int count = 0;
|
|
835
|
|
- for (int i = (sheet.FirstRowNum + headrow + 1); i <= sheet.LastRowNum; i++)
|
|
|
375
|
+ NPOIHelper np = new NPOIHelper();
|
|
|
376
|
+ DataTable dt = np.ExcelToTable(_upFile, headrow);
|
|
|
377
|
+ string msg = string.Empty;
|
|
|
378
|
+ if (dt == null || dt.Rows.Count == 0)
|
|
|
379
|
+ return Error("文件没有数据");
|
|
|
380
|
+ else
|
|
836
|
381
|
{
|
|
837
|
|
- #region 数据入库
|
|
838
|
|
- IRow row = sheet.GetRow(i);
|
|
839
|
|
- DataRow dataRow = dt.NewRow();
|
|
840
|
|
-
|
|
841
|
|
- for (int j = row.FirstCellNum; j < cellCount; j++)
|
|
842
|
|
- {
|
|
843
|
|
- if (row.GetCell(j) != null)
|
|
844
|
|
- dataRow[j] = row.GetCell(j).ToString();
|
|
845
|
|
- }
|
|
846
|
|
- dt.Rows.Add(dataRow);
|
|
847
|
|
- if (dt.Rows.Count < 1)
|
|
848
|
|
- return Error("文件内容没有数据");
|
|
849
|
|
-
|
|
850
|
|
- var cusmodel = new Model.T_Cus_CustomerBaseNew();
|
|
851
|
|
- var conmodel = new Model.T_Cus_ContactPersonNew();
|
|
852
|
|
- #region 信息对应
|
|
853
|
|
- //报税会计 做账会计 编号 客服 公司名称 负责人电话 交接日期
|
|
854
|
|
- if ((dataRow["编号"] == null || dataRow["编号"].ToString() == "")
|
|
855
|
|
- || (dataRow["公司名称"] == null || dataRow["公司名称"].ToString() == ""))
|
|
856
|
|
- { continue; }
|
|
857
|
|
- cusmodel.F_CustomerCode = dataRow["编号"].ToString();
|
|
858
|
|
- cusmodel.F_CompanyName = dataRow["公司名称"].ToString();
|
|
859
|
|
- //判断编号唯一
|
|
860
|
|
- if (getunique(0, cusmodel.F_CustomerCode, cusmodel.F_CompanyName))
|
|
861
|
|
- continue;
|
|
862
|
|
- #region 处理关键字
|
|
863
|
|
- var keyword = cusmodel.F_CompanyName;
|
|
864
|
|
- var keyconfig = Configs.GetValue("keystring");
|
|
865
|
|
- var keystring = keyconfig.Split(',');
|
|
866
|
|
- foreach (var item in keystring)
|
|
867
|
|
- {
|
|
868
|
|
- if (cusmodel.F_CompanyName.Contains(item))
|
|
869
|
|
- keyword = keyword.Replace(item, "");
|
|
870
|
|
- }
|
|
871
|
|
- cusmodel.F_KeyWords = keyword;
|
|
872
|
|
- #endregion
|
|
873
|
|
- cusmodel.F_BeRelatedAcc = dataRow["报税会计"].ToString();
|
|
874
|
|
- cusmodel.F_BeMakeAcc = dataRow["做账会计"].ToString();
|
|
875
|
|
- cusmodel.F_HandoverDate = dataRow["交接日期"].ToString();
|
|
876
|
|
- cusmodel.F_CusService = dataRow["客服"].ToString();
|
|
877
|
|
- cusmodel.F_CompanyAddress= dataRow["公司地址"].ToString();
|
|
878
|
|
- cusmodel.F_RegisteredAddress = dataRow["注册地址"].ToString();
|
|
879
|
|
- cusmodel.F_Address = dataRow["地址"].ToString();
|
|
880
|
|
- cusmodel.F_Address1 = dataRow["地址1"].ToString();
|
|
881
|
|
- cusmodel.F_Address2 = dataRow["地址2"].ToString();
|
|
882
|
|
- cusmodel.F_Address3 = dataRow["地址3"].ToString();
|
|
883
|
|
- cusmodel.F_Address4 = dataRow["地址4"].ToString();
|
|
884
|
|
- cusmodel.F_WxPassword = "123456";
|
|
885
|
|
- cusmodel.F_CreateBy = usercode;
|
|
886
|
|
- cusmodel.F_CreatedOn = DateTime.Now;
|
|
887
|
|
- cusmodel.F_DeleteFlag = 0;
|
|
888
|
|
- #endregion
|
|
889
|
|
- int n = cusbll.Add(cusmodel);
|
|
890
|
|
-
|
|
891
|
|
- if (n > 0)
|
|
|
382
|
+ Model.T_Cus_CustomerBaseNew dModel = new Model.T_Cus_CustomerBaseNew();
|
|
|
383
|
+ dModel.F_CreateBy = usercode;
|
|
|
384
|
+ dModel.F_IsDelete = 0;
|
|
|
385
|
+ dModel.F_FileId = fid;
|
|
|
386
|
+ foreach (DataRow dr in dt.Rows)
|
|
892
|
387
|
{
|
|
893
|
|
- #region 添加联系人
|
|
894
|
|
- conmodel.F_CustomerId = n;
|
|
895
|
|
- conmodel.F_CreateBy = usercode;
|
|
896
|
|
- conmodel.F_CreateOn = DateTime.Now;
|
|
897
|
|
- conmodel.F_DeleteFlag = 0;
|
|
898
|
|
- conmodel.F_IsMain = true;
|
|
899
|
|
- if ((dataRow["负责人电话"] != null && dataRow["负责人电话"].ToString() != "")
|
|
900
|
|
- || (dataRow["负责人姓名"] != null && dataRow["负责人姓名"].ToString() != ""))
|
|
|
388
|
+ #region 数据入库
|
|
|
389
|
+ headrow = headrow + 1;
|
|
|
390
|
+
|
|
|
391
|
+ if (dr["客户编号"].ToString() != "" && valcode(dr["客户编号"].ToString()))
|
|
901
|
392
|
{
|
|
902
|
|
- if (dataRow["负责人电话"] != null && dataRow["负责人电话"].ToString() != "")
|
|
903
|
|
- conmodel.F_Telephone = dataRow["负责人电话"].ToString();
|
|
904
|
|
- if (dataRow["负责人姓名"] != null && dataRow["负责人姓名"].ToString() != "")
|
|
905
|
|
- conmodel.F_Name = dataRow["负责人姓名"].ToString();
|
|
906
|
|
- conbll.Add(conmodel);
|
|
907
|
|
- }
|
|
908
|
|
- for (int nn = 0; nn <= 10; nn++)
|
|
909
|
|
- {
|
|
910
|
|
- if ((dataRow["负责人电话" + nn.ToString()] != null && dataRow["负责人电话" + nn.ToString()].ToString() != "")
|
|
911
|
|
- || (dataRow["负责人姓名" + nn.ToString()] != null && dataRow["负责人姓名" + nn.ToString()].ToString() != ""))
|
|
|
393
|
+ dModel.F_CustomerCode = dr["客户编号"].ToString();
|
|
|
394
|
+ #region
|
|
|
395
|
+ #endregion
|
|
|
396
|
+ dModel.F_CreateOn = DateTime.Now;
|
|
|
397
|
+ var res = cusbll.Add(dModel);
|
|
|
398
|
+ if (res > 0)
|
|
912
|
399
|
{
|
|
913
|
|
- if (dataRow["负责人电话" + nn.ToString()] != null && dataRow["负责人电话" + nn.ToString()].ToString() != "")
|
|
914
|
|
- conmodel.F_Telephone = dataRow["负责人电话" + nn.ToString()].ToString();
|
|
915
|
|
- if (dataRow["负责人姓名" + nn.ToString()] != null && dataRow["负责人姓名" + nn.ToString()].ToString() != "")
|
|
916
|
|
- conmodel.F_Name = dataRow["负责人姓名" + nn.ToString()].ToString();
|
|
917
|
|
- conbll.Add(conmodel);
|
|
|
400
|
+ addoptlog(usercode, ip, EnumOpt.import.ToString(), res.ToString(), "导入成功,导入的文件为:" + newpath + ",当前为第" + headrow + "行");
|
|
918
|
401
|
}
|
|
919
|
|
- }
|
|
|
402
|
+ else
|
|
|
403
|
+ {
|
|
920
|
404
|
|
|
|
405
|
+ msg = msg + "第" + headrow + "行,导入失败<br>";
|
|
|
406
|
+ }
|
|
|
407
|
+ }
|
|
|
408
|
+ else
|
|
|
409
|
+ msg = msg + "第" + headrow + "行,物料编号为空或格式不正确,未导入<br>";
|
|
921
|
410
|
#endregion
|
|
922
|
|
- #region 添加财税情况
|
|
923
|
|
- var finmodel = new Model.T_Cus_CustomerFinance();
|
|
924
|
|
- finmodel.F_CustomerId = n;
|
|
925
|
|
- finbll.Add(finmodel);
|
|
926
|
|
- #endregion
|
|
927
|
|
- count++;
|
|
928
|
|
- }
|
|
929
|
|
- #endregion
|
|
930
|
|
- }
|
|
931
|
|
- if (dt == null || dt.Rows.Count == 0)
|
|
932
|
|
- return Error("文件没有数据");
|
|
933
|
|
- else
|
|
934
|
|
- {
|
|
935
|
|
- var jstr = DataTableToJson(dt);
|
|
936
|
|
- if (count > 0)
|
|
937
|
|
- {
|
|
938
|
|
- return Success("导入成功 " + count + "条信息", jstr);
|
|
939
|
411
|
}
|
|
|
412
|
+ if (string.IsNullOrEmpty(msg))
|
|
|
413
|
+ return Success("导入成功 " );
|
|
940
|
414
|
else
|
|
941
|
|
- {
|
|
942
|
|
- return Success("导入成功 " + count + "条信息", jstr);
|
|
943
|
|
- }
|
|
|
415
|
+ return Error(msg);
|
|
944
|
416
|
}
|
|
945
|
417
|
}
|
|
946
|
418
|
return Error("数据源上传失败");
|
|
947
|
419
|
}
|
|
948
|
420
|
return Error("用户登录失败,请重新登录");
|
|
949
|
421
|
}
|
|
950
|
|
- public string DataTableToJson(DataTable dt)
|
|
|
422
|
+ #endregion
|
|
|
423
|
+ #region 私有方法
|
|
|
424
|
+ /// <summary>
|
|
|
425
|
+ /// 验证物料编码为10位纯数字
|
|
|
426
|
+ /// </summary>
|
|
|
427
|
+ private bool valcode(string code)
|
|
|
428
|
+ {
|
|
|
429
|
+ var res = false;
|
|
|
430
|
+ //11位数字
|
|
|
431
|
+ if (code.Length == 11 && Regex.IsMatch(code, @"^\d{10}$"))
|
|
|
432
|
+ res = true;
|
|
|
433
|
+ return res;
|
|
|
434
|
+ }
|
|
|
435
|
+ /// <summary>
|
|
|
436
|
+ /// 操作日志
|
|
|
437
|
+ /// </summary>
|
|
|
438
|
+ /// <param name="usercode">操作人工号</param>
|
|
|
439
|
+ /// <param name="ip">操作人IP</param>
|
|
|
440
|
+ /// <param name="optcode">操作编号</param>
|
|
|
441
|
+ /// <param name="optid">操作id</param>
|
|
|
442
|
+ /// <param name="des">操作描述</param>
|
|
|
443
|
+ private void addoptlog(string usercode, string ip, string optcode, string optid, string des)
|
|
951
|
444
|
{
|
|
952
|
|
- string JsonString = string.Empty;
|
|
953
|
|
- JsonString = JsonConvert.SerializeObject(dt);
|
|
954
|
|
- return JsonString;
|
|
|
445
|
+ new BLL.T_Sys_OperateLogs().AddOptLog("客户管理", usercode, ip, des, optcode, "T_Cus_CustomerBaseNew", optid);
|
|
955
|
446
|
}
|
|
956
|
447
|
#endregion
|
|
957
|
448
|
}
|