AccountController.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. namespace addons\AvoidTax\backend\controllers;
  3. use addons\AvoidTax\common\service\AccountService;
  4. use addons\AvoidTax\common\service\AlipayService;
  5. use Yii;
  6. /**
  7. * 记账本
  8. *
  9. * Class AccountController
  10. * @package addons\AvoidTax\backend\controllers
  11. */
  12. class AccountController extends BaseController
  13. {
  14. public $enableCsrfValidation = false;
  15. /**
  16. * @var AccountService
  17. */
  18. protected $service;
  19. /**
  20. * 初始化
  21. *
  22. * @return void
  23. */
  24. public function init()
  25. {
  26. parent::init();
  27. $this->service = new AccountService(['mall_id' => $this->mall_id]);
  28. }
  29. /**
  30. * 首页
  31. *
  32. * @return string
  33. */
  34. public function actionIndex()
  35. {
  36. if ($this->request->isAjax) {
  37. $list = $this->service->getAccountList(
  38. $this->request->getBodyParams()
  39. );
  40. return $this->success('ok', $list);
  41. }
  42. return $this->render('index');
  43. }
  44. /**
  45. * 是否新签约
  46. *
  47. * @return mixed
  48. */
  49. public function actionIsSign()
  50. {
  51. $type = $this->request->get('type');
  52. $is_new_sign = $this->service->getIsNewSign($type);
  53. return $this->success('ok', compact('is_new_sign'));
  54. }
  55. /**
  56. * 跳转签约 (税务方签约)
  57. *
  58. * @return void
  59. */
  60. public function actionSign()
  61. {
  62. $type = $this->request->get('type');
  63. $html = $this->service->sign($type);
  64. echo $html;
  65. }
  66. /**
  67. * 添加签约 不跳转
  68. *
  69. * @return mixed
  70. */
  71. public function actionAddSign()
  72. {
  73. $type = $this->request->get('type');
  74. $model = $this->service->sign($type);
  75. if ($model) $this->service->query($model->id);
  76. return $this->success();
  77. }
  78. /**
  79. * 签约查询
  80. *
  81. * @return void
  82. */
  83. public function actionQuery()
  84. {
  85. if ($this->request->isAjax) {
  86. $id = $this->request->getQueryParam('id');
  87. return $this->service->query($id) ? $this->success('查询成功') : $this->error($this->service->error);
  88. }
  89. }
  90. /**
  91. * 记帐本查询
  92. *
  93. * @return void
  94. */
  95. public function actionQueryBook()
  96. {
  97. if ($this->request->isAjax) {
  98. $id = $this->request->getQueryParam('id');
  99. return ($data = $this->service->queryBook($id)) ? $this->success('ok', $data) : $this->error($this->service->error);
  100. }
  101. }
  102. /**
  103. * 设为默认值
  104. *
  105. * @return void
  106. */
  107. public function actionSetDefault()
  108. {
  109. if ($this->request->isAjax) {
  110. $id = $this->request->getQueryParam('id');
  111. $type = $this->request->get('type');
  112. return $this->service->setDefault($id, $type)
  113. ? $this->success('ok')
  114. : $this->error($this->service->error);
  115. }
  116. }
  117. /**
  118. * 记账本充值
  119. *
  120. * @return void
  121. */
  122. public function actionRecharge()
  123. {
  124. $id = $this->request->get('id');
  125. $amount = $this->request->get('amount');
  126. $html = $this->service->recharge($id, $amount);
  127. echo $html;
  128. }
  129. /**
  130. * 记账本资金逆流
  131. *
  132. * @return void
  133. */
  134. public function actionAnarrhea()
  135. {
  136. if ($this->request->isAjax) {
  137. $id = $this->request->get('id');
  138. return $this->service->anarrhea($id)
  139. ? $this->success('ok')
  140. : $this->error($this->service->getError());
  141. }
  142. }
  143. /**
  144. * 删除记账本
  145. *
  146. * @return void
  147. */
  148. public function actionDel()
  149. {
  150. if ($this->request->isAjax) {
  151. $id = $this->request->get('id');
  152. return $this->service->deleteNotSign($id)
  153. ? $this->success('ok')
  154. : $this->error($this->service->getError());
  155. }
  156. }
  157. /**
  158. * 退回
  159. *
  160. * @return void
  161. */
  162. public function actionRefund()
  163. {
  164. if ($this->request->isAjax) {
  165. $id = $this->request->get('id');
  166. return $this->service->refund($id)
  167. ? $this->success('ok')
  168. : $this->error($this->service->getError());
  169. }
  170. }
  171. /**
  172. * 服务商版本记账本退回
  173. *
  174. * @param integer $id
  175. * @return string
  176. */
  177. public function actionReturn(int $id)
  178. {
  179. $data = $this->request->post();
  180. $validate = Yii::$app->services->validate->validate($data, [
  181. [['amount', 'account_name', 'account_number'], 'required'],
  182. ]);
  183. if ($validate === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  184. return $this->service->refundToAccount($id, $data)
  185. ? $this->success('ok')
  186. : $this->error($this->service->getError());
  187. }
  188. /**
  189. * 过流水相关
  190. *
  191. * @return mixed
  192. */
  193. public function actionPaymentFlow()
  194. {
  195. return $this->success('ok', $this->service->getPaymentFlow());
  196. }
  197. }