CustomerVisitsLog.Class.php 3.1 KB

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