CashController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace hd\controllers;
  3. use biz\sj\classes\CashClass;
  4. use common\components\dict;
  5. use common\components\util;
  6. use Yii;
  7. class CashController extends BaseController
  8. {
  9. //客户列表 ssh 2019.11.30
  10. public function actionList()
  11. {
  12. $where = ['mainId' => $this->mainId];
  13. $list = CashClass::getCashList($where);
  14. util::success($list);
  15. }
  16. //申请提现 ssh 2021.3.14
  17. public function actionApply()
  18. {
  19. if (getenv('YII_ENV') == 'production') {
  20. util::fail('系统自动提现,无需人为操作');
  21. } else {
  22. //这里需要测试,所以打开来
  23. //util::fail('系统自动提现,无需人为操作');
  24. }
  25. $get = Yii::$app->request->get();
  26. $get['shopAdminId'] = $this->shopAdminId;
  27. $shopAdmin = $this->shopAdmin;
  28. if (isset($shopAdmin['super']) == false || $shopAdmin['super'] != 1) {
  29. util::fail('超管才能申请提现');
  30. }
  31. $get['shopAdminName'] = $shopAdmin->name ?? '';
  32. $get['shopId'] = $this->shopId;
  33. $get['sjId'] = $this->sjId;
  34. $get['ptStyle'] = dict::getDict('ptStyle', 'hd');
  35. $connection = Yii::$app->db;
  36. $transaction = $connection->beginTransaction();
  37. try {
  38. CashClass::addApply($get);
  39. $transaction->commit();
  40. util::success('提交成功,等待审核');
  41. } catch (\Exception $exception) {
  42. $transaction->rollBack();
  43. Yii::info("提现申请报错:" . $exception->getMessage());
  44. util::fail('申请失败');
  45. }
  46. }
  47. }