LakalaAccountController.php 4.0 KB

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