LakalaAccountController.php 4.5 KB

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