MarketCustomerResourcesController.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using Microsoft.AspNetCore.Mvc;
  2. using OASystem.API.OAMethodLib;
  3. using OASystem.Domain.Dtos.CRM;
  4. using OASystem.Domain.Entities.Customer;
  5. using OASystem.Infrastructure.Repositories.CRM;
  6. using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
  7. namespace OASystem.API.Controllers
  8. {
  9. /// <summary>
  10. /// 市场客户资料
  11. /// </summary>
  12. [Route("api/[controller]/[action]")]
  13. public class MarketCustomerResourcesController : ControllerBase
  14. {
  15. private readonly NewClientDataRepository _clientDataRepository;
  16. /// <summary>
  17. /// 初始化
  18. /// </summary>
  19. public MarketCustomerResourcesController(NewClientDataRepository clientDataRepository)
  20. {
  21. this._clientDataRepository = clientDataRepository;
  22. }
  23. /// <summary>
  24. /// 客户资料数据
  25. /// 基础数据
  26. /// </summary>
  27. /// <returns></returns>
  28. [HttpPost]
  29. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  30. public async Task<IActionResult> MarketCustomerInit(PortDtoBase dto)
  31. {
  32. JsonView jw = new JsonView();
  33. try
  34. {
  35. Result resultData = await _clientDataRepository._Init(dto.PortType);
  36. if (resultData.Code == 0)
  37. {
  38. jw = JsonView(true, "查询成功!", resultData.Data);
  39. }
  40. else
  41. {
  42. jw = JsonView(false, resultData.Msg);
  43. }
  44. }
  45. catch (Exception)
  46. {
  47. jw = JsonView(false, "程序错误!");
  48. }
  49. return Ok(jw);
  50. }
  51. /// <summary>
  52. /// 查询客户资料数据
  53. /// </summary>
  54. /// <returns></returns>
  55. [HttpPost]
  56. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  57. public async Task<IActionResult> QueryNewClientData(NewClientDataQueryDto dto)
  58. {
  59. JsonView jw = new JsonView();
  60. try
  61. {
  62. Result resultData = await _clientDataRepository.QueryNewClientData(dto);
  63. if (resultData.Code == 0)
  64. {
  65. #region 客户资料表操作记录
  66. await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.NoOperation, dto.OperationUserId, 0, "");
  67. #endregion
  68. jw = JsonView(true, "查询成功!", resultData.Data);
  69. }
  70. else
  71. {
  72. jw = JsonView(false, resultData.Msg);
  73. }
  74. }
  75. catch (Exception)
  76. {
  77. jw = JsonView(false, "程序错误!");
  78. }
  79. return Ok(jw);
  80. }
  81. /// <summary>
  82. /// 客户资料数据
  83. /// Details
  84. /// </summary>
  85. /// <returns></returns>
  86. [HttpPost]
  87. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  88. public async Task<IActionResult> PostNewClientDataDetails(NewClientDataDetailsDto dto)
  89. {
  90. JsonView jw = new JsonView();
  91. try
  92. {
  93. Result resultData = await _clientDataRepository._Details(dto.PortType, dto.Id);
  94. if (resultData.Code == 0)
  95. {
  96. #region 客户资料表操作记录
  97. await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.Details, dto.UserId, dto.Id, "");
  98. #endregion
  99. jw = JsonView(true, "查询成功!", resultData.Data);
  100. }
  101. else
  102. {
  103. jw = JsonView(false, resultData.Msg);
  104. }
  105. }
  106. catch (Exception)
  107. {
  108. jw = JsonView(false, "程序错误!");
  109. }
  110. return Ok(jw);
  111. }
  112. /// <summary>
  113. /// 客户资料操作(Status:1.新增,2.修改)
  114. /// </summary>
  115. /// <param name="dto"></param>
  116. /// <returns></returns>
  117. [HttpPost]
  118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  119. public async Task<IActionResult> NewClientOp(NewClientOpDto dto)
  120. {
  121. try
  122. {
  123. Domain.Result result = await _clientDataRepository.NewClientOp(dto);
  124. if (result.Code != 0)
  125. {
  126. return Ok(JsonView(false, result.Msg));
  127. }
  128. #region 客户资料操作记录
  129. OperationEnum operationEnum = OperationEnum.NoOperation;
  130. if (dto.Status == 1)
  131. {
  132. operationEnum = OperationEnum.Add;
  133. dto.Id = Convert.ToInt32(result.Data);
  134. }
  135. else if (dto.Status == 2) operationEnum = OperationEnum.Edit;
  136. await GeneralMethod.NewClientOperationRecord(dto.PortType, operationEnum, dto.CreateUserId, dto.Id, "");
  137. #endregion
  138. return Ok(JsonView(true, result.Msg + "Id:" + dto.Id));
  139. }
  140. catch (Exception ex)
  141. {
  142. return Ok(JsonView(false, "程序错误!Msg:" + ex.Message));
  143. }
  144. }
  145. /// <summary>
  146. /// 新客户资料操作(删除)
  147. /// </summary>
  148. /// <param name="dto"></param>
  149. /// <returns></returns>
  150. [HttpPost]
  151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  152. public async Task<IActionResult> NewClientDel(DelBaseDto dto)
  153. {
  154. var res = await _clientDataRepository.DelNewClientData(dto);
  155. if (res.Code != 0)
  156. {
  157. return Ok(JsonView(false, "删除失败"));
  158. }
  159. #region 客户资料表操作记录
  160. await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.Del, dto.DeleteUserId, dto.Id, "");
  161. #endregion
  162. return Ok(JsonView(true, "删除成功!"));
  163. }
  164. /// <summary>
  165. /// 获取下拉列表数据和单条数据信息
  166. /// </summary>
  167. /// <param name="dto"></param>
  168. /// <returns></returns>
  169. [HttpPost]
  170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  171. public async Task<IActionResult> QuerySelectAndSingleData(QuerySingleDto dto)
  172. {
  173. JsonView jw = new JsonView();
  174. var result = await _clientDataRepository.QuerySelectAndSingleData(dto);
  175. if (result.Code == 0)
  176. {
  177. #region 客户资料表操作记录
  178. await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.Details, dto.UserId, dto.Id, "");
  179. #endregion
  180. jw = JsonView(true, result.Msg, result.Data);
  181. }
  182. else
  183. {
  184. jw = JsonView(false, result.Msg);
  185. }
  186. return Ok(jw);
  187. }
  188. /// <summary>
  189. /// 获取现有负责人
  190. /// </summary>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> QueryUserSelect()
  195. {
  196. try
  197. {
  198. Result resTable = _clientDataRepository.QueryUserSelect();
  199. return Ok(JsonView(true, resTable.Msg, resTable.Data));
  200. }
  201. catch (Exception)
  202. {
  203. return Ok(JsonView(false, "程序错误!"));
  204. }
  205. }
  206. /// <summary>
  207. /// 获取出团数据
  208. /// </summary>
  209. /// <returns></returns>
  210. [HttpPost]
  211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  212. public async Task<IActionResult> QueryNumberGroups()
  213. {
  214. var result = await _clientDataRepository.QueryNumberGroups();
  215. if (result.Code != 0)
  216. {
  217. return Ok(JsonView(false, result.Msg));
  218. }
  219. return Ok(JsonView(true, result.Msg, result.Data));
  220. }
  221. /// <summary>
  222. /// 新客户资料操作
  223. /// 批量分配
  224. /// </summary>
  225. /// <param name="dto"></param>
  226. /// <returns></returns>
  227. [HttpPost]
  228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  229. public async Task<IActionResult> PostBatchAssignment(BatchAssignmentDto dto)
  230. {
  231. var res = await _clientDataRepository._BatchAssignment(dto);
  232. if (res.Code != 0)
  233. {
  234. return Ok(JsonView(false, "操作失败!"));
  235. }
  236. return Ok(JsonView(true, "操作成功!"));
  237. }
  238. }
  239. }