CustomerDemand.Class.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: kang
  5. * Date: 2021/3/8
  6. * Time: 16:29
  7. */
  8. namespace JinDouYun\Controller\Customer;
  9. use JinDouYun\Controller\Market\VipCard;
  10. use JinDouYun\Model\Customer\MCustomer;
  11. use Mall\Framework\Core\ErrorCode;
  12. use Mall\Framework\Core\StatusCode;
  13. use JinDouYun\Controller\BaseController;
  14. use JinDouYun\Model\Customer\MCustomerDemand;
  15. class CustomerDemand extends BaseController
  16. {
  17. private $objMCustomerDemand;
  18. public function __construct($isCheckAcl = true, $isMustLogin = true)
  19. {
  20. parent::__construct($isCheckAcl, $isMustLogin);
  21. $this->objMCustomerDemand = new MCustomerDemand($this->onlineEnterpriseId, $this->onlineUserId);
  22. }
  23. /**
  24. * 编辑客户需求提报管理公共字段处理方法
  25. *
  26. * @return array
  27. */
  28. public function commonFieldFilter()
  29. {
  30. $params = $this->request->getRawJson();
  31. if (empty($params)) {
  32. $this->sendOutput('参数为空', ErrorCode::$paramError);
  33. }
  34. $demandData = [
  35. 'enterpriseId' => $this->onlineEnterpriseId,
  36. 'customerId' => getArrayItem($params,'customerId'),
  37. 'demand' => getArrayItem($params,'demand'),
  38. ];
  39. $demandData['updateTime'] = time();
  40. foreach ($demandData as $key => $value) {
  41. if (empty($value) && $value !== 0) {
  42. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  43. }
  44. }
  45. return $demandData;
  46. }
  47. /**
  48. * 获取所有的客户需求提报
  49. */
  50. public function getAllCustomerdemand()
  51. {
  52. $params = $this->request->getRawJson();
  53. if (empty($params)) {
  54. $this->sendOutput('参数为空', ErrorCode::$paramError);
  55. }
  56. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  57. $params['limit'] = $pageParams['limit'];
  58. $params['offset'] = $pageParams['offset'];
  59. $returnData = $this->objMCustomerDemand->getAllCustomerdemand($params);
  60. if ($returnData->isSuccess()) {
  61. $returnData = $returnData->getData();
  62. $pageData = [
  63. 'pageIndex' => $params['page'],
  64. 'pageSize' => $params['pageSize'],
  65. 'pageTotal' => $returnData['total'],
  66. ];
  67. parent::sendOutput($returnData['data'], 0, $pageData);
  68. } else {
  69. parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
  70. }
  71. }
  72. /**
  73. * 获取指定的客户需求提报
  74. */
  75. public function getCustomerdemandInfo()
  76. {
  77. $customerdemandId = $this->request->param('request_id');
  78. if (!$customerdemandId) {
  79. $this->sendOutput('参数错误', ErrorCode::$paramError);
  80. }
  81. $result = $this->objMCustomerDemand->getCustomerdemandInfo($customerdemandId);
  82. if ($result->isSuccess()) {
  83. $this->sendOutput($result->getData());
  84. } else {
  85. $this->sendOutput($result->getData(), $result->getErrorCode());
  86. }
  87. }
  88. }