LakalaAccountController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\lakala\classes\AliyunOcrClass;
  4. use bizGhs\lakala\services\LakalaAccountService;
  5. use common\components\util;
  6. use ghs\models\lakala\AliyunOcrForm;
  7. use ghs\models\lakala\ApplicationIdForm;
  8. use ghs\models\lakala\CreateForm;
  9. use ghs\models\lakala\FormDataForm;
  10. use ghs\models\lakala\OcrResultForm;
  11. use ghs\models\lakala\OptionForm;
  12. use ghs\models\lakala\SetCurrentForm;
  13. use ghs\models\lakala\UploadFileForm;
  14. use Yii;
  15. class LakalaAccountController extends BaseController
  16. {
  17. public function actionList()
  18. {
  19. $list = LakalaAccountService::list($this->mainId, $this->shopId);
  20. util::success($list);
  21. }
  22. public function actionDetail()
  23. {
  24. $form = new ApplicationIdForm();
  25. $form->loadAndValidate();
  26. $detail = LakalaAccountService::detail((int)$form->id, $this->mainId, $this->shopId);
  27. util::success($detail);
  28. }
  29. public function actionCreate()
  30. {
  31. $form = new CreateForm();
  32. $data = Yii::$app->request->post();
  33. $form->load($data ?: ['type' => ''], '');
  34. $form->validateForm();
  35. util::success(LakalaAccountService::create(
  36. $this->mainId,
  37. $this->shopId,
  38. $this->shop,
  39. $form->type,
  40. (int)$form->accountId
  41. ));
  42. }
  43. public function actionSaveDraft()
  44. {
  45. $form = new FormDataForm();
  46. $form->loadAndValidate();
  47. util::success(LakalaAccountService::saveDraft(
  48. (int)$form->id,
  49. $this->mainId,
  50. $this->shopId,
  51. $form->getFormData(),
  52. (int)$form->currentStep
  53. ));
  54. }
  55. public function actionDeleteDraft()
  56. {
  57. $form = new ApplicationIdForm();
  58. $form->loadAndValidate();
  59. LakalaAccountService::deleteDraft((int)$form->id, $this->mainId, $this->shopId);
  60. util::complete();
  61. }
  62. public function actionUploadFile()
  63. {
  64. $form = new UploadFileForm();
  65. $form->loadAndValidate();
  66. util::success(LakalaAccountService::upload(
  67. (int)$form->id,
  68. $this->mainId,
  69. $this->shopId,
  70. $form->content,
  71. $form->imgType,
  72. (int)$form->isOcr
  73. ));
  74. }
  75. public function actionOcrResult()
  76. {
  77. $form = new OcrResultForm();
  78. $form->loadAndValidate();
  79. util::success(LakalaAccountService::ocr(
  80. (int)$form->id,
  81. $this->mainId,
  82. $this->shopId,
  83. $form->batchNo,
  84. $form->imgType
  85. ));
  86. }
  87. public function actionAliyunOcr()
  88. {
  89. $form = new AliyunOcrForm();
  90. $form->loadAndValidate();
  91. util::success(AliyunOcrClass::recognize(
  92. (int)$form->id,
  93. $this->mainId,
  94. $this->shopId,
  95. $form->imgType,
  96. $form->imageUrl
  97. ));
  98. }
  99. public function actionOption()
  100. {
  101. $form = new OptionForm();
  102. $form->loadAndValidate();
  103. $option = LakalaAccountService::option($form->type, $form->parentCode, $form->keyword);
  104. util::success($option);
  105. }
  106. public function actionApplyContract()
  107. {
  108. $form = new ApplicationIdForm();
  109. $form->loadAndValidate();
  110. $contract = LakalaAccountService::applyContract((int)$form->id, $this->mainId, $this->shopId);
  111. util::success($contract);
  112. }
  113. public function actionContractStatus()
  114. {
  115. $form = new ApplicationIdForm();
  116. $form->loadAndValidate();
  117. util::success(LakalaAccountService::contractStatus((int)$form->id, $this->mainId, $this->shopId));
  118. }
  119. public function actionSubmit()
  120. {
  121. $form = new FormDataForm();
  122. $form->loadAndValidate();
  123. $submit = LakalaAccountService::submitForPlatformAudit(
  124. (int)$form->id,
  125. $this->mainId,
  126. $this->shopId,
  127. $form->getFormData()
  128. );
  129. util::success($submit);
  130. }
  131. public function actionRefresh()
  132. {
  133. $form = new ApplicationIdForm();
  134. $form->loadAndValidate();
  135. $re = LakalaAccountService::refresh((int)$form->id, $this->mainId, $this->shopId);
  136. util::success($re);
  137. }
  138. public function actionSetCurrent()
  139. {
  140. $form = new SetCurrentForm();
  141. $form->loadAndValidate();
  142. LakalaAccountService::setCurrent((int)$form->accountId, $this->mainId, $this->shopId);
  143. util::complete('已设置为当前收款账户');
  144. }
  145. }