ExpendController.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\expend\classes\ExpendClass;
  4. use common\components\dict;
  5. use common\components\util;
  6. use Yii;
  7. class ExpendController extends BaseController
  8. {
  9. public function actionList()
  10. {
  11. $where = [];
  12. $where['mainId'] = $this->mainId;
  13. $list = ExpendClass::getExpendList($where);
  14. util::success($list);
  15. }
  16. //新增支出 ssh 20220710
  17. public function actionAddExpend()
  18. {
  19. $post = Yii::$app->request->post();
  20. $type = $post['type'] ?? dict::getDict('expendType', 'hs');
  21. $amount = $post['amount'] ?? 0;
  22. if (is_numeric($amount) == false || $amount <= 0) {
  23. util::fail('请输入正确的金额');
  24. }
  25. $remark = $post['remark'] ?? '';
  26. $staffName = $this->shopAdmin->name ?? '';
  27. $data = ['type' => $type, 'amount' => $amount, 'remark' => $remark, 'mainId' => $this->mainId, 'staffId' => $this->shopAdminId, 'staffName' => $staffName];
  28. ExpendClass::add($data);
  29. util::complete();
  30. }
  31. }