CustomerMaintenanceController.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using Microsoft.AspNetCore.Mvc;
  2. using System.Threading.Tasks;
  3. using XYY.Common.Standard;
  4. using XYY.Core.Standard.Mvc;
  5. using XYY.Data.Standard.Order;
  6. using XYY.Service.Standard.Finance;
  7. namespace XYY.Api.Order.Controllers
  8. {
  9. [Route("api/[controller]/[action]")]
  10. [ApiController]
  11. public class CustomerMaintenanceController : ApiControllerBase
  12. {
  13. ICustomerMaintenanceMsgRepository customerMaintenanceMsgRepository;
  14. IDingDingBaseService dingDingBaseService;
  15. public CustomerMaintenanceController(IDingDingBaseService dingDingBaseService, ICustomerMaintenanceMsgRepository customerMaintenanceMsgRepository)
  16. {
  17. this.dingDingBaseService = dingDingBaseService;
  18. this.customerMaintenanceMsgRepository = customerMaintenanceMsgRepository;
  19. }
  20. public class Msg
  21. {
  22. public string Contact
  23. {
  24. get; set;
  25. }
  26. public string Phone
  27. {
  28. get; set;
  29. }
  30. public int Id { get; set; }
  31. }
  32. public async Task<IActionResult> PostMsg(Msg msg)
  33. {
  34. await customerMaintenanceMsgRepository.InsertAsync(new XYY.Model.Standard.Order.Customer_Maintenance_Msg
  35. {
  36. Contact = msg.Contact,
  37. IsHandle = false,
  38. Phone = msg.Phone
  39. });
  40. var ddModel = new
  41. {
  42. msgtype = "text",
  43. text =
  44. new
  45. {
  46. content = $"有新的客户咨询发货:客户联系人:{msg.Contact},客户联系方式:{msg.Phone}"
  47. }
  48. };
  49. var ddUserInfo = await dingDingBaseService.GetDingDingUserInfo(58);
  50. if (ddUserInfo != null)
  51. {
  52. await dingDingBaseService.SendMessage(ddUserInfo.UserId, ddModel);
  53. }
  54. return Ok();
  55. }
  56. public async Task<IActionResult> GetPageResult(QueryModel queryModel)
  57. {
  58. var pageresult = await customerMaintenanceMsgRepository.GetPageResult(queryModel);
  59. return Ok(pageresult);
  60. }
  61. public async Task<IActionResult> SetHandel(Msg msg)
  62. {
  63. await customerMaintenanceMsgRepository.SetHandle(new XYY.Model.Standard.Order.Customer_Maintenance_Msg { Id = msg.Id });
  64. return Ok();
  65. }
  66. }
  67. }