FinanceController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace backend\modules\admin\controllers;
  3. use backend\controllers\AdminController;
  4. use common\enums\PayTypeEnum;
  5. use common\enums\platform\PlatformEnum;
  6. use common\enums\StatusEnum;
  7. use common\models\addons\AddonsOrder;
  8. use common\models\backend\Admin;
  9. use common\models\common\PlatformSetting;
  10. use common\models\finance\PlatformFinanceLog;
  11. use common\models\mall\Mall;
  12. use common\models\platform\PlatformFinanceDay;
  13. use common\models\platform\PlatformOrder;
  14. use Yii;
  15. /**
  16. *
  17. * 商城控制器
  18. * @Author ltm
  19. * @DateTime 2021-08-13 15:29:41
  20. * @copyright: Copyright (c) 2020 广东七件事集团
  21. */
  22. class FinanceController extends AdminController
  23. {
  24. public function actionIndex($keyword = null, $is_recycle = 0)
  25. {
  26. $retuest = Yii::$app->request;
  27. if ($retuest->isAjax) {
  28. if ($retuest->isPost) {
  29. $post = Yii::$app->request->post();
  30. // 检查提交的参数
  31. $res = Yii::$app->services->validate->validate($post,[
  32. [['id','level'], 'integer'],
  33. [['out_trade_no','date_end','date_start'], 'safe'],
  34. [['limit'],'default','value' => '15'],
  35. ]);
  36. if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  37. $post = PlatformFinanceLog::exceptNullVal($post);
  38. if($post['date_start'] && $post['date_end']) $where[] = ['between', 'created_at', strtotime($post['date_start']),strtotime($post['date_end'])];
  39. if($post['out_trade_no']) $where[] = ['like', 'out_trade_no', $post['out_trade_no']];
  40. $where[] = ['>=','status',StatusEnum::DISABLED];
  41. $order = 'id desc';
  42. $params = array('where' => $where, 'order'=>$order, 'limit' => $post['limit']);
  43. $list = PlatformFinanceLog::listPage($params, false, true);
  44. $select = 'sum(add_money) as add_money,sum(sub_money) as sub_money';
  45. $statics = PlatformFinanceDay::getOne('',true,'','id desc',$select);
  46. $list['statistics'] = $statics;
  47. $list['change_type'] = PlatformEnum::getChangeTypeMap();
  48. $list['from_type'] = PlatformEnum::getFromTypeMap();
  49. $list['payment_type'] = PayTypeEnum::getMap();
  50. $this->success('获取成功', $list);
  51. }
  52. } else {
  53. return $this->render($this->action->id);
  54. }
  55. }
  56. }