| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <?php
- namespace addons\AvoidTax\backend\controllers;
- use addons\AvoidTax\common\service\AccountService;
- use addons\AvoidTax\common\service\AlipayService;
- use Yii;
- /**
- * 记账本
- *
- * Class AccountController
- * @package addons\AvoidTax\backend\controllers
- */
- class AccountController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * @var AccountService
- */
- protected $service;
- /**
- * 初始化
- *
- * @return void
- */
- public function init()
- {
- parent::init();
- $this->service = new AccountService(['mall_id' => $this->mall_id]);
- }
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- if ($this->request->isAjax) {
- $list = $this->service->getAccountList(
- $this->request->getBodyParams()
- );
- return $this->success('ok', $list);
- }
- return $this->render('index');
- }
- /**
- * 是否新签约
- *
- * @return mixed
- */
- public function actionIsSign()
- {
- $type = $this->request->get('type');
- $is_new_sign = $this->service->getIsNewSign($type);
- return $this->success('ok', compact('is_new_sign'));
- }
- /**
- * 跳转签约 (税务方签约)
- *
- * @return void
- */
- public function actionSign()
- {
- $type = $this->request->get('type');
- $html = $this->service->sign($type);
- echo $html;
- }
- /**
- * 添加签约 不跳转
- *
- * @return mixed
- */
- public function actionAddSign()
- {
- $type = $this->request->get('type');
- $model = $this->service->sign($type);
- if ($model) $this->service->query($model->id);
- return $this->success();
- }
- /**
- * 签约查询
- *
- * @return void
- */
- public function actionQuery()
- {
- if ($this->request->isAjax) {
- $id = $this->request->getQueryParam('id');
- return $this->service->query($id) ? $this->success('查询成功') : $this->error($this->service->error);
- }
- }
- /**
- * 记帐本查询
- *
- * @return void
- */
- public function actionQueryBook()
- {
- if ($this->request->isAjax) {
- $id = $this->request->getQueryParam('id');
- return ($data = $this->service->queryBook($id)) ? $this->success('ok', $data) : $this->error($this->service->error);
- }
- }
- /**
- * 设为默认值
- *
- * @return void
- */
- public function actionSetDefault()
- {
- if ($this->request->isAjax) {
- $id = $this->request->getQueryParam('id');
- $type = $this->request->get('type');
- return $this->service->setDefault($id, $type)
- ? $this->success('ok')
- : $this->error($this->service->error);
- }
- }
- /**
- * 记账本充值
- *
- * @return void
- */
- public function actionRecharge()
- {
- $id = $this->request->get('id');
- $amount = $this->request->get('amount');
- $html = $this->service->recharge($id, $amount);
- echo $html;
- }
- /**
- * 记账本资金逆流
- *
- * @return void
- */
- public function actionAnarrhea()
- {
- if ($this->request->isAjax) {
- $id = $this->request->get('id');
- return $this->service->anarrhea($id)
- ? $this->success('ok')
- : $this->error($this->service->getError());
- }
- }
- /**
- * 删除记账本
- *
- * @return void
- */
- public function actionDel()
- {
- if ($this->request->isAjax) {
- $id = $this->request->get('id');
- return $this->service->deleteNotSign($id)
- ? $this->success('ok')
- : $this->error($this->service->getError());
- }
- }
- /**
- * 退回
- *
- * @return void
- */
- public function actionRefund()
- {
- if ($this->request->isAjax) {
- $id = $this->request->get('id');
- return $this->service->refund($id)
- ? $this->success('ok')
- : $this->error($this->service->getError());
- }
- }
- /**
- * 服务商版本记账本退回
- *
- * @param integer $id
- * @return string
- */
- public function actionReturn(int $id)
- {
- $data = $this->request->post();
- $validate = Yii::$app->services->validate->validate($data, [
- [['amount', 'account_name', 'account_number'], 'required'],
- ]);
- if ($validate === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- return $this->service->refundToAccount($id, $data)
- ? $this->success('ok')
- : $this->error($this->service->getError());
- }
- /**
- * 过流水相关
- *
- * @return mixed
- */
- public function actionPaymentFlow()
- {
- return $this->success('ok', $this->service->getPaymentFlow());
- }
- }
|