UserInfoCustomerLogic.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using CZFW.Framework.Interface;
  2. using CZFW.Framework.Logic;
  3. using CZFW.Framework.Model.ViewModel;
  4. using CZKJ.GBRS2.Entity;
  5. using CZKJ.GBRS2.Interface;
  6. using System.Linq;
  7. using CZKJ.GBRS2.Model;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Text;
  11. namespace CZKJ.GBRS2.Logic
  12. {
  13. public class UserInfoCustomerLogic : LogicBase<CustomerInfoEntity>, IUserInfoCustomer
  14. {
  15. public ResultModel AddModel(Model.UserInfoModel model)
  16. {
  17. var entity = new CustomerInfoEntity();
  18. entity.User_id = model.User_id;
  19. entity.Type = model.Type;
  20. entity.Channel = model.Channel;
  21. entity.Job_number = model.Job_number;
  22. entity.Lock_flag = model.Lock_flag;
  23. entity.Email = model.Email;
  24. entity.Mobile = model.Mobile;
  25. entity.Nickname = model.Nickname;
  26. entity.Head_url = model.Head_url;
  27. entity.Wx_open_id = model.Wx_open_id;
  28. entity.Wx_union_id = model.Wx_union_id;
  29. entity.Core_customer_code = model.Core_customer_code;
  30. entity.Department = model.Props.Department;
  31. entity.On_job = model.Props.On_job;
  32. entity.Out_user_id = model.Props.Out_user_id;
  33. entity.Gender = model.Customer_info.Gender;
  34. entity.Id_type = model.Customer_info.Id_type;
  35. entity.Id_no = model.Customer_info.Id_no;
  36. entity.Name = model.Customer_info.Name;
  37. entity.Birthday = model.Customer_info.Birthday;
  38. entity.LastLoginTime = DateTime.Now;
  39. var result = AddEntity(entity);
  40. return result;
  41. }
  42. public CustomerInfoEntity GetCuser(string userId)
  43. {
  44. return Queryable.Where(x => x.User_id == userId).SingleOrDefault();
  45. }
  46. public TableModel<SlimCutomerInfo> GetCustomerList(int pageindex = 1, int pageSize = 20)
  47. {
  48. var res = new TableModel<SlimCutomerInfo>();
  49. var queryable = Queryable;
  50. var data = (from x in queryable
  51. select new SlimCutomerInfo
  52. {
  53. Id=x.Id,
  54. User_id = x.User_id,
  55. Mobile = x.Mobile,
  56. Nickname = x.Nickname,
  57. Name=x.Name,
  58. Gender=x.Gender,
  59. Birthday=x.Birthday,
  60. }).Skip(pageindex-1).Take(pageSize).ToList();
  61. res.SetData(data);
  62. res.TableHeads = PropertyHelper.Get(typeof(SlimCutomerInfo));
  63. return res;
  64. }
  65. /// <summary>
  66. /// 查看
  67. /// </summary>
  68. /// <param name="Id"></param>
  69. /// <returns></returns>
  70. public FormModel<CustomerInfoEntity> GetModel(int Id)
  71. {
  72. var queryable = Queryable;
  73. var data = queryable.Where(x => x.Id == Id).FirstOrDefault();
  74. var res = new FormModel<CustomerInfoEntity>(data);
  75. return res;
  76. }
  77. public TableModel<CustomerInfoEntity> GetUserInFo(string userId)
  78. {
  79. var res = new TableModel<CustomerInfoEntity>();
  80. var queryable = Queryable;
  81. if (!string.IsNullOrWhiteSpace(userId))
  82. {
  83. queryable = queryable.Where(x => x.User_id == userId);
  84. }
  85. var data = (from x in queryable
  86. select new CustomerInfoEntity
  87. {
  88. User_id = x.User_id,
  89. Type = x.Type,
  90. Channel = x.Channel,
  91. Job_number = x.Job_number,
  92. Lock_flag = x.Lock_flag,
  93. Email = x.Email,
  94. Mobile = x.Mobile,
  95. Nickname = x.Nickname,
  96. Head_url = x.Head_url,
  97. Wx_open_id = x.Wx_open_id,
  98. Wx_union_id = x.Wx_union_id,
  99. Core_customer_code = x.Core_customer_code,
  100. }).ToList();
  101. res.SetData(data);
  102. res.TableHeads = PropertyHelper.Get(typeof(CustomerInfoEntity));
  103. return res;
  104. }
  105. /// <summary>
  106. /// 明细
  107. /// </summary>
  108. /// <returns></returns>
  109. public TableModel<CustomerInfoEntity> GetUserInFoCustomer()
  110. {
  111. var res = new TableModel<CustomerInfoEntity>();
  112. var queryable = DbContext.Set<CustomerInfoEntity>();
  113. var data = queryable.OrderByDescending(x => x.SortOrder).ToList();
  114. res.SetData(data);
  115. res.TableHeads = PropertyHelper.Get(typeof(CustomerInfoEntity));
  116. return res;
  117. }
  118. }
  119. }