StoreFinanceController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace addons\Store\client\controllers;
  3. use addons\JoinPay\common\global_func\payment_logic\JoinPayFastPay;
  4. use addons\JoinPay\common\models\JoinPayUserBankcard;
  5. use addons\Store\common\models\Store;
  6. use addons\Store\common\models\StoreBank;
  7. use addons\Store\common\models\StoreCashierOrder;
  8. use addons\Store\common\models\StoreCommission;
  9. use addons\Store\common\models\StoreCommissionCheck;
  10. use addons\Store\common\models\StoreSettings;
  11. use addons\Store\common\models\StoreStatistics;
  12. use addons\Store\common\models\StoreWithdrawLog;
  13. use Cassandra\Date;
  14. use common\enums\AddonsEnum;
  15. use common\enums\ApiStatusEnum;
  16. use common\enums\StatusEnum;
  17. use common\enums\UserWalletEnum;
  18. use common\helpers\ArrayHelper;
  19. use common\helpers\BankCardHelper;
  20. use common\helpers\StringHelper;
  21. use common\models\common\UserBankCard;
  22. use common\models\mall\MallAddons;
  23. use common\models\user\User;
  24. use common\models\user\UserWithdrawLog;
  25. use services\common\UserWalletService;
  26. use addons\Store\common\enums\StoreEnum;
  27. use addons\Store\common\services\StoreFinanceService;
  28. use common\enums\DownloadEnum;
  29. use common\globals\GlobalInvoke;
  30. use common\enums\WithdrawWayEnum;
  31. use common\helpers\csv\CsvExportHelper;
  32. use common\models\common\PlatformSetting;
  33. use Exception;
  34. use Yii;
  35. use yii\helpers\Json;
  36. class StoreFinanceController extends BaseController
  37. {
  38. public function actionIndex()
  39. {
  40. $request = Yii::$app->request;
  41. if ($request->isAjax) {
  42. try {
  43. if ($request->isGet) {
  44. $get = $request->get();
  45. $res = Yii::$app->services->validate->validate($get, [
  46. [['page', 'limit'], 'integer'],
  47. [['keyword', 'goods_keyword', 'tabname'], 'string'],
  48. [['date'], 'safe'],
  49. ]);
  50. if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
  51. $get['store_id'] = $this->store_id;
  52. $list = (new StoreFinanceService(['mall_id' => $this->mall_id]))->getClientFinanceData($get);
  53. if ($get['tabname'] == 'order-detail') {
  54. $export_list = (new StoreFinanceService(['mall_id' => $this->mall_id]))->storeFinanceDetailFieldList();
  55. } else if ($get['tabname'] == 'cashier') {
  56. $export_list = (new StoreFinanceService(['mall_id' => $this->mall_id]))->cashierFinanceDetailFieldList();
  57. }
  58. $list['export_list'] = $export_list;
  59. return $this->success('获取成功', $list);
  60. }
  61. if ($request->isPost) {
  62. if (\Yii::$app->request->post('flag') == 'EXPORT') {
  63. $post = \Yii::$app->request->post();
  64. $post['mall_id'] = $this->mall_id;
  65. $post['store_id'] = $this->store_id;
  66. $filename = 'o2o门店财务明细-' . date('YmdHis') . '_' . rand(10000, 99999);
  67. $func_model = 'exportStoreFinanceData';
  68. if ($post['tabname'] == 'cashier') {
  69. $func_model = 'exportCashierFinanceData';
  70. }
  71. $res = CsvExportHelper::exportDownLoadCenter($this->mall_id, $filename, DownloadEnum::TYPE_STORE_FINANCE, StoreFinanceService::class, $func_model, $post, 0, $this->store_id);
  72. if ($res === false) return $this->error('加入导出任务失败' . CsvExportHelper::getStaticError());
  73. return $this->success('添加导出任务成功,任务完成后请在下载中心进行下载!');
  74. }
  75. }
  76. } catch (\Exception $e) {
  77. return $this->error($e->getMessage());
  78. }
  79. }
  80. return $this->render($this->action->id);
  81. }
  82. public function actionGetStoreStatics()
  83. {
  84. $request = Yii::$app->request;
  85. if ($request->isAjax && $request->isGet) {
  86. try {
  87. $get = $request->get();
  88. $res = Yii::$app->services->validate->validate($get, [
  89. [['store_id'], 'integer'],
  90. [['date'], 'safe'],
  91. ]);
  92. if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
  93. $get['store_id'] = $this->store_id;
  94. $info = (new StoreFinanceService(['mall_id' => $this->mall_id]))->getStoreStatics($get);
  95. return $this->success('获取成功', $info);
  96. } catch (\Exception $e) {
  97. return $this->error($e->getMessage());
  98. }
  99. }
  100. }
  101. }