username@email.com
2021-11-30 8878b4d2c65329d454688d306e9d692c760bffe5
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using IServices;
using DTO;
using Newtonsoft.Json;
using zhengcaioa.Models;
using Microsoft.AspNetCore.Http;
using zhengcaioa.IService;
using System.IO;
using Microsoft.Extensions.Configuration;
using System.Transactions;
using CommonToolsCore;
using System.Text;
 
namespace zhengcaioa.Controllers.Expert
{
  
    public class ExpertController : Controller
    {
        private readonly ILogger<ExpertController> _logger;
        private readonly IExpertService _expertService;
        private readonly ILiaotianService _liaotianService;
        private readonly IProjectService _projectService;
        private readonly IUserService _userService;
        private readonly IFiSubjectService _ifiSubjectService;
        private readonly ICooperOrderService _cooperOrderService;
        private readonly IFiAccountService _fiAccountService;
        private readonly IFiAccountRecordService _iFiAccountRecordService;
        private readonly IAreaService _iAreaService;
        public ExpertController(ILogger<ExpertController> logger, IExpertService expertService, IProjectService projectService, ILiaotianService liaotianService, IUserService userService
            , IFiSubjectService ifiSubjectService, ICooperOrderService cooperOrderService, IFiAccountService fiAccountService, IFiAccountRecordService iFiAccountRecordService
            , IAreaService iAreaService)
        {
            _logger = logger;
            _expertService = expertService;
            _projectService = projectService;
            _liaotianService = liaotianService;
            _userService = userService;
            _ifiSubjectService = ifiSubjectService;
            _cooperOrderService = cooperOrderService;
            _fiAccountService = fiAccountService;
            _iFiAccountRecordService = iFiAccountRecordService;
            _iAreaService = iAreaService;
        }
        [CheckLogin]
        public IActionResult Index()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Search";
            actionEntity.PageIco = "fa fa-search";
            actionEntity.ActionName = "查询";
            actionlist.Add(actionEntity);
            ActionEntity actionEntity1 = new ActionEntity();
            actionEntity1.OpenType = 0;
            actionEntity1.ActionUrl = "";
            actionEntity1.ActionFun = "Add";
            actionEntity1.PageIco = "fa fa-plus";
            actionEntity1.ActionName = "新增";
            actionlist.Add(actionEntity1);
            ViewData["ActionInfo"] = actionlist;
 
            ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.level = _liaotianService.GetSYScode("experts", "level").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.Province = _projectService.Getsheng().Select(x => new { code = x.CodeId, label = x.Name }).ToList();
            //  ViewBag.City = _projectService.Getshi( ).Select(x => new { code = x.CodeId, label = x.Name }).ToList();
            ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            return View();
        }
 
        #region 查询
        [CheckLogin]
        public string GetList(ExpertDTOSearch search)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            search.ShenheStatus = "A";
            ViewData["curentuser"] = curentuser;
            return JsonConvert.SerializeObject(_expertService.SearchByPaging(search));
        }
        #endregion
 
 
 
        [CheckLogin]
        public IActionResult Indexziliao()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Search";
            actionEntity.PageIco = "fa fa-search";
            actionEntity.ActionName = "查询";
            actionlist.Add(actionEntity);
            ActionEntity actionEntity4 = new ActionEntity();
            actionEntity4.OpenType = 0;
            actionEntity4.ActionUrl = "";
            actionEntity4.ActionFun = "Duanxin";
            actionEntity4.PageIco = "";
            actionEntity4.ActionName = "群发短信";
            actionlist.Add(actionEntity4);
            ViewData["ActionInfo"] = actionlist;
 
            ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.level = _liaotianService.GetSYScode("experts", "level").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.Province = _projectService.Getsheng().Select(x => new { code = x.CodeId, label = x.Name }).ToList();
            //  ViewBag.City = _projectService.Getshi( ).Select(x => new { code = x.CodeId, label = x.Name }).ToList();
            ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
 
 
            ViewBag.users = _userService.GetList().Select(x => new { code = x.Id, label = x.UserName }).ToList();
            ViewBag.YearJiou = _liaotianService.GetSYScode("experts", "year_jiou").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.Createtime = DateTime.Now.ToString("yyyy-MM-dd");
            ViewBag.Createtimebe = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"); 
            return View();
        }
 
 
        #region 编辑
        [CheckLogin]
        public ActionResult Edit(string id = null, string Province = null, string City = null)
        {
 
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Save";
            actionEntity.PageIco = "glyphicon glyphicon-ok";
            actionEntity.ActionName = "保存";
            actionlist.Add(actionEntity);
 
            ViewData["ActionInfo"] = actionlist;
 
            ExpertDTO expertDTO = new ExpertDTO();
            if (!string.IsNullOrEmpty(id))
            {
                expertDTO = _expertService.Get(id);
            }
            else
            {
                if (string.IsNullOrEmpty(Province))
                {
                    expertDTO.Province = "510000";
                }
                else
                {
                    expertDTO.Province = Province;
                }
                if (string.IsNullOrEmpty(City))
                {
                    expertDTO.City = "510100";
                }
                else
                {
                    expertDTO.City = City;
                }
                expertDTO.ExpertType = "4";
                expertDTO.Level = "1";
                expertDTO.CertiNumber = "SC";
                expertDTO.InfoSource = "01";
                expertDTO.Sex = "1";
                expertDTO.YearJiou = "1";
            }
            // var sheng = _projectService.Getsheng();
 
 
            ViewBag.InfoSource = _liaotianService.GetSYScode("CooperatecustomCustomer", "khly");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.sex = _liaotianService.GetSYScode("plt_user", "sex");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.level = _liaotianService.GetSYScode("experts", "level");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
 
 
            ViewBag.Province = _projectService.Getsheng();//.Select(x => new { code = x.CodeId, label = x.Name }).ToList();             
            ViewBag.City = _projectService.Getshi(expertDTO.Province);//.Select(x => new { code = x.CodeId, label = x.Name }).ToList();
            ViewBag.YearJiou = _liaotianService.GetSYScode("experts", "year_jiou");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewData.Model = expertDTO;
            return View();
        }
 
 
 
        /// <summary>
        /// 图片上传
        /// </summary>
        /// <returns></returns>
        public string UploadImage()
        {
            var files = Request.Form.Files;
            if (files.Count == 0)
            {
                return "File does not exist!";
            }
            var file = files[0];
            string fileName = file.FileName;
            if (string.IsNullOrEmpty(fileName))//服务器是否存在该文件
            {
                return "File does not exist!";
            }
            // 获取上传的图片名称和扩展名称
            string fileFullName = Path.GetFileName(file.FileName);
            string fileExtName = Path.GetExtension(fileFullName);
 
 
            string imgPath = string.Format("{0}\\wwwroot\\{1}\\", Directory.GetCurrentDirectory(), "UploadFile");
 
            var newPath = fileFullName.Substring(0, fileFullName.IndexOf(fileExtName)) + System.DateTime.UtcNow.Ticks + fileExtName;
            var src = imgPath + newPath;
 
            // 如果目录不存在则要先创建
            if (!Directory.Exists(imgPath))
            {
                Directory.CreateDirectory(imgPath);
            }
            using (FileStream fs = System.IO.File.Create(src))
            {
                file.CopyTo(fs);
                fs.Flush();
            }
           // imgPath = string.Format("~/UploadFile/{0}", fileFullName);
            return newPath;
        }
 
        public string Get(string id = null)
        {
            ExpertDTO expertDTO = new ExpertDTO();
            if (!String.IsNullOrEmpty(id))
            {
                expertDTO = _expertService.Get(id);
            }
 
            return JsonConvert.SerializeObject(expertDTO);
        }
 
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="data">岗位实体类对象</param>
        /// <returns></returns>
        [HttpPost]
        [CheckLogin]
        public string Save(ExpertDTO data)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            data.ShenheStatus = "A";
            data.ReviewItem = data.ReviewItemSelect;
            data.RecStatus = "A";
            if (String.IsNullOrEmpty(data.Id))
            {
                data.Creater = curentuser.Id;
                data.Createtime = DateTime.Now;
            }
            data.Modifier = curentuser.Id;
            data.Modifytime = DateTime.Now;
 
            ResultEntity resultEntity = _expertService.save(data);
 
            return JsonConvert.SerializeObject(resultEntity);
        }
        #endregion
 
 
 
 
 
 
        /// <summary>
        /// 删除主信息
        /// </summary>
        /// <param name="info">实体</param>
        /// <returns></returns>
        /// 
        [CheckLogin]
        public string Nullify(string Id = "")
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            return JsonConvert.SerializeObject(_expertService.ModifyStatus(Id, curentuser.Id));
        }
 
 
        #region 推广记录
        /// <summary>
        /// 取得推广记录列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        [CheckLogin]
        public string GetPromoteList(ExpertPromoteDTOSearch search)
        {
            return JsonConvert.SerializeObject(_expertService.SearchExpPromote(search));
        }
 
        /// <summary>
        /// 查看推广记录
        /// </summary>
        /// <param name="experId"></param>
        /// <returns></returns>
        [CheckLogin]
        public IActionResult Promote(string experId)
        {
            // ViewData["curentuser"] = curentuser;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Search";
            actionEntity.PageIco = "fa fa-search";
            actionEntity.ActionName = "查询";
            actionlist.Add(actionEntity);
            ViewData["ActionInfo"] = actionlist;
            ViewData["experId"] = experId;
            ViewBag.users = _userService.GetList().Select(x => new { code = x.Id, label = x.UserSn }).ToList();
            return View();
        }
 
        /// <summary>
        /// 新增推广记录
        /// </summary>
        /// <param name="experId"></param>
        /// <returns></returns>
        [CheckLogin]
        public IActionResult EditPromote(string experId)
        {
            ViewData["experId"] = experId;
            return View();
        }
 
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="data">保存推广记录</param>
        /// <returns></returns>
        [HttpPost]
        [CheckLogin]
        public string SavePromte(ExpertPromoteDTO data)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            data.RecStatus = "A";
            if (String.IsNullOrEmpty(data.Id))
            {
                data.Creater = curentuser.Id;
                data.Createtime = DateTime.Now;
            }
            data.Modifier = curentuser.Id;
            data.Modifytime = DateTime.Now;
 
            ResultEntity resultEntity = _expertService.SaveExpPromote(data);
 
            return JsonConvert.SerializeObject(resultEntity);
        }
        #endregion
 
        #region 专家派工
        [CheckLogin]
        public IActionResult ExpertOrderDispatch()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Search";
            actionEntity.PageIco = "fa fa-search";
            actionEntity.ActionName = "查询";
            actionlist.Add(actionEntity);
            ViewData["ActionInfo"] = actionlist;
 
            ViewBag.OrderType = _liaotianService.GetSYScode("CooperVisit", "jtype").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.users = _userService.GetList().Where(x => x.IsYwjl == "A").Select(x => new { code = x.Id, label = x.UserName }).ToList();
 
            ViewBag.Khlx = _liaotianService.GetSYScode("CooperatecustomCustomer", "khlx").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
 
            ViewBag.HuifangStatus = _liaotianService.GetSYScode("CooperOrder", "huifang_status").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
 
            ViewBag.PingjiaStatus = _liaotianService.GetSYScode("CooperOrder", "pingjia_status").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.Expert = _expertService.GetList().Select(x => new { code = x.Id, label = x.Name }).ToList();
            return View();
        }
        [CheckLogin]
        public string GetOrderList(ExpertOrderDipatchDTOSearch search)
        {
            return JsonConvert.SerializeObject(_expertService.SearchOrderDispatch(search));
        }
        [CheckLogin]
        public IActionResult Dispatch(string orderid)
        {
 
            List<ExpertDTO> list = _expertService.GetList();
            ViewData["experts"] = list;
            ViewBag.OrderId = orderid;
            return View();
        }
        [CheckLogin]
        public string SaveDispatch(ExpertOrderDipatchDTO data)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            data.RecStatus = "A";
            if (String.IsNullOrEmpty(data.Id))
            {
                data.Creater = curentuser.Id;
                data.Createtime = DateTime.Now;
                data.sort = "D";
            }
            data.Modifier = curentuser.Id;
            data.Modifytime = DateTime.Now;
 
            ResultEntity resultEntity = _expertService.SaveDispatch(data);
 
            return JsonConvert.SerializeObject(resultEntity);
        }
        #endregion
 
 
 
        #region 专家费用结算
        [CheckLogin]
        public IActionResult ExpertFeiyong()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            List<ActionEntity> actionlist = new List<ActionEntity>();
            ActionEntity actionEntity = new ActionEntity();
            actionEntity.OpenType = 0;
            actionEntity.ActionUrl = "";
            actionEntity.ActionFun = "Search";
            actionEntity.PageIco = "fa fa-search";
            actionEntity.ActionName = "查询";
            actionlist.Add(actionEntity);
 
            ActionEntity actionEntity1 = new ActionEntity();
            actionEntity1.OpenType = 0;
            actionEntity1.ActionUrl = "";
            actionEntity1.ActionFun = "Jiesuan";
            actionEntity1.PageIco = "fa fa-plus-square";
            actionEntity1.ActionName = "结算";
            actionlist.Add(actionEntity1);
 
 
            ViewData["ActionInfo"] = actionlist;
 
          
            ViewBag.Expert = _expertService.GetList().Select(x => new { code = x.Id, label = x.Name }).ToList();
            ViewBag.shifou = _liaotianService.GetSYScode("system", "shifou").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            return View();
        }
 
        [CheckLogin]
        public string GetJiesuanList(ExpertOrderDipatchDTOSearch search)
        {
            return JsonConvert.SerializeObject(_expertService.SearchJiesuan(search));
        }
 
 
        public IActionResult EditJiesuan(string id)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            decimal Money = 0;
            FiOrderrecievemoneyDTO dto = new FiOrderrecievemoneyDTO();
            if (!String.IsNullOrEmpty(id))
            {
                string[] ids = id.Split(',');
                foreach(var iddd in ids)
                {
                   var expertOrderDipatchDTO =  _expertService.GetDispatch(iddd);
                    if(expertOrderDipatchDTO.sort != "A")
                    {
                        Money += expertOrderDipatchDTO.Money.Value;
                    }
                   
                   
                }
            }
            dto.PayTime = DateTime.Now;
            dto.Id = id;
 
            dto.Money = Money;
 
 
            ViewData.Model = dto;
 
            ViewBag.PayType = _liaotianService.GetSYScode("fi_account", "accounttype");
            ViewBag.accounttype = _liaotianService.GetSYScode("fi_account", "accounttype");
            ViewBag.FiSubject = _ifiSubjectService.GetList().Where(x => x.Subjecttype == "02").ToList();
 
 
 
 
 
            ViewData.Model = dto;
            return View();
        }
 
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="data">岗位实体类对象</param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public IActionResult SaveJiesuan(FiOrderrecievemoneyDTO data)
        {
            ResultEntity resultEntity = new ResultEntity();
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            using (TransactionScope scope = new TransactionScope())
            {
                string[] ids = data.Id.Split(',');
                foreach (var iddd in ids)
                {
                    var expertOrderDipatchDTO = _expertService.GetDispatch(iddd);
                    if(expertOrderDipatchDTO.sort == "A")
                    {
                        resultEntity.Result = false;
                        resultEntity.Message = "存在已经结算的订单";
                        return new JsonResult(resultEntity);
                    }
               
                    expertOrderDipatchDTO.sort = "A";
                    expertOrderDipatchDTO.Modifier = curentuser.Id;
                    expertOrderDipatchDTO.Modifytime = DateTime.Now;
                    resultEntity = _expertService.SaveDispatch(expertOrderDipatchDTO);
                    if (!resultEntity.Result)
                    {
                        return new JsonResult(resultEntity);
                    }
                    var expertDTO  =  _expertService.Get(expertOrderDipatchDTO.ExpertId);
                   var orderDTO = _cooperOrderService.Get(expertOrderDipatchDTO.OrderId);
                    //插入支出记录
                    FiAccountRecordDTO data1 = new FiAccountRecordDTO();
                    data1.RecStatus = "A";
                    data1.Creater = curentuser.Id;
                    data1.Createtime = data.PayTime;
                    data1.Modifier = curentuser.Id;
                    data1.Modifytime = data.PayTime;
                    data1.SubjectId = data.SubjectId;
                    data1.AccountId = data.AccountId;
                    data1.Money = expertOrderDipatchDTO.Money;
                    data1.PaymentUnit = expertDTO.Name;
                    data1.OperationalMatters = expertDTO.Name +"  " +orderDTO.OrderNo+ "结算费用" ;
 
 
 
                    FiAccountDTO firmAccount = _fiAccountService.Get(data1.AccountId);
 
 
                    data1.RecordTypeId = "2";//收入
                    data1.Department = "";
 
                    
                    firmAccount.AllExpenses = (firmAccount.AllExpenses ?? 0) + data1.Money;
                    firmAccount.Balance = (firmAccount.Balance ?? 0) - data1.Money;
 
 
 
                    data1.AccountMoney = firmAccount.Balance;
                    resultEntity = _iFiAccountRecordService.save(data1);
                    if (!resultEntity.Result)
                    {
                        return new JsonResult(resultEntity);
                    }
 
 
                    resultEntity = _fiAccountService.save(firmAccount);
                    if (!resultEntity.Result)
                    {
                        return new JsonResult(resultEntity);
                    }
 
                }
                scope.Complete();
            }
 
            return new JsonResult(resultEntity);
        }
 
 
 
 
 
        #endregion
 
 
 
 
        public IActionResult Duanxin(string id = null)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ViewData["baifangid"] = id;
 
 
 
            return View();
        }
 
 
 
        public IActionResult Fasong(string neirong, string baifangid)
        {
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = true;
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            List<ExpertDTO> result = new List<ExpertDTO>();
 
            if (baifangid != null)
            {
                result = _expertService.GetList(baifangid.Split(","));
            }
            else
            {
                resultEntity.Result = false;
                resultEntity.Message = "无联系人号码";
            }
            string customename = "";
            StringBuilder number = new StringBuilder(); ;
            if (result != null && result.Count > 0)
            {
                for (int i = 0; i < result.Count; i++)
                {
                    number.Append(string.IsNullOrEmpty(result[i].Phone1) ? result[i].Phone2 : result[i].Phone1);
                    customename += result[i].Name + ",";
                    if (i != result.Count - 1)
                    {
                        number.Append(",");
                    }
                }
            }
            else
            {
                resultEntity.Result = false;
                resultEntity.Message = "无联系电话";
            }
 
            string sss = SMSHelper.PushWToUserMES(number.ToString(), "您好,"+neirong+" 详情见:http://51zhengcai.com/"   );
            if (int.Parse(sss) <= 0)
            {
                resultEntity.Result = false;
                resultEntity.Message = "短信发送失败";
 
            }
 
            _logger.LogInformation(curentuser.UserName + "发送短信给专家" + customename);
            return new JsonResult(resultEntity);
        }
 
 
        /// <summary>
        /// 判断身份证是否重复
        /// </summary>
        /// <param name="shengid">省id</param>
        /// <returns></returns>
        /// 
        [CheckLogin]
        public string IdCardChongfu(string IdCard = "",string Id = "")
        {
            ResultEntity resultEntity = _expertService.IdCardChongfu(IdCard, Id);
 
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
 
        /// <summary>
        /// 判断专家证是否重复
        /// </summary>
        /// <param name="shengid">省id</param>
        /// <returns></returns>
        /// 
        [CheckLogin]
        public string CertiNumberChongfu(string CertiNumber = "", string Id = "")
        {
            ResultEntity resultEntity = _expertService.CertiNumberChongfu(CertiNumber, Id);
            if (resultEntity.Result)
            {
                //拆解专家证号
 
                var CertiNumber11 = CertiNumber.Replace("SC", "");
                var sysCodeDtls = _liaotianService.GetSYScode("experts", "City");
 
                var chengshis = sysCodeDtls.Where(x => CertiNumber11.StartsWith(x.CodeSn)).ToList();
                if (chengshis.Count > 0)
                {
                  var areaDTOs =  _iAreaService.GetList();
 
                    var chengshi = areaDTOs.Where(x => x.Name == chengshis[0].Comments).FirstOrDefault();
                    if (chengshi != null)
                    {
                        resultEntity.Message = chengshi.CodeId;
                        resultEntity.Remark = chengshi.ParentId;
                    }
 
                }
 
            }
 
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
 
        /// <summary>
        /// 判断电话是否重复
        /// </summary>
        /// <param name="shengid">省id</param>
        /// <returns></returns>
        /// 
        [CheckLogin]
        public string Phone1Chongfu(string Phone1 = "", string Id = "")
        {
            ResultEntity resultEntity = _expertService.Phone1Chongfu(Phone1, Id);
 
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
    }
}