ClerkController.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace api\modules\v1\controllers;
  3. use api\controllers\OnAuthController;
  4. use common\enums\ClerkEnum;
  5. use common\enums\StatusEnum;
  6. use common\globals\GlobalInvoke;
  7. use common\models\common\ClerkLog;
  8. use common\models\user\User;
  9. class ClerkController extends OnAuthController
  10. {
  11. public $enableCsrfValidation = false;
  12. public $modelClass = '';
  13. public function actionClerk()
  14. {
  15. try {
  16. $request = \Yii::$app->request;
  17. if ($request->isGet) {
  18. $params = $request->get();
  19. $params['method'] = 'get';
  20. $params['platform'] = $this->platform;
  21. $params['mall_id'] = $this->mall_id;
  22. $params['user_id'] = $this->user_id;
  23. $result = GlobalInvoke::exec(GlobalInvoke::INVOKE_CLERK, $this->mall_id, $params);
  24. if (empty($result)) return $this->error('获取数据失败');
  25. return $this->success('操作成功', $result);
  26. }
  27. if ($request->isPost) {
  28. $params = $request->post();
  29. $params['method'] = 'post';
  30. $params['platform'] = $this->platform;
  31. $params['mall_id'] = $this->mall_id;
  32. $params['user_id'] = $this->user_id;
  33. $result = GlobalInvoke::exec(GlobalInvoke::INVOKE_CLERK, $this->mall_id, $params);
  34. if (empty($result)) return $this->error('核销失败');
  35. return $this->success('操作成功', $result);
  36. }
  37. } catch (\Exception $e) {
  38. return $this->error($e->getMessage());
  39. }
  40. }
  41. public function actionClerkLog()
  42. {
  43. $params = \Yii::$app->request->get();
  44. $where[] = ['mall_id' => $this->mall_id];
  45. $where[] = ['user_id' => $this->user_id];
  46. $where[] = ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
  47. $params['where'] = $where;
  48. $params['order'] = 'id DESC';
  49. $params['select'] = 'id,mall_id,user_id,name,pic,mall_logo,mall_name,clerk_code,type,extra,created_at';
  50. $pageData = ClerkLog::getPageLists($params);
  51. return $this->success('操作成功', $pageData);
  52. }
  53. public function actionClerkLogDetail()
  54. {
  55. try {
  56. $params = \Yii::$app->request->get();
  57. $res = \Yii::$app->services->validate->validate($params, [
  58. [['clerk_log_id', 'type'], 'required'],
  59. ]);
  60. if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
  61. $params['platform'] = $this->platform;
  62. $params['mall_id'] = $this->mall_id;
  63. $params['user_id'] = $this->user_id;
  64. $result = GlobalInvoke::exec(GlobalInvoke::INVOKE_CLERK_DETAIL, $this->mall_id, $params);
  65. if (empty($result)) return $this->error('获取数据失败');
  66. return $this->success('操作成功', $result);
  67. } catch (\Exception $e) {
  68. return $this->error($e->getMessage());
  69. }
  70. }
  71. }