CustomDebtChangeController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\custom\classes\CustomClass;
  4. use bizGhs\custom\classes\CustomDebtChangeClass;
  5. use common\components\dateUtil;
  6. use common\components\dict;
  7. use common\components\util;
  8. use Yii;
  9. class CustomDebtChangeController extends BaseController
  10. {
  11. public $guestAccess = [];
  12. //欠款变动明细
  13. public function actionList()
  14. {
  15. $get = Yii::$app->request->get();
  16. $export = $get['export'] ?? 0;
  17. $where = [];
  18. $shopId = $this->shopId;
  19. $where['shopId'] = $shopId;
  20. $customId = $get['customId'] ?? 0;
  21. if (!empty($customId)) {
  22. $where['customId'] = $customId;
  23. }
  24. $searchTime = $get['searchTime'] ?? '';
  25. if (!empty($searchTime)) {
  26. $startTime = $get['startTime'] ?? '';
  27. $endTime = $get['endTime'] ?? '';
  28. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  29. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  30. } else {
  31. if ($export == 1) {
  32. util::fail('请选择时间');
  33. }
  34. }
  35. if ($export == 1) {
  36. ini_set('memory_limit', '2045M');
  37. set_time_limit(0);
  38. if (isset($where['addTime']) == false) {
  39. util::fail('请选时间段');
  40. }
  41. $start = $where['addTime'][1][0];
  42. $end = $where['addTime'][1][1];
  43. $monthTime = bcmul(31, 86400);
  44. $startArea = strtotime($start);
  45. $endArea = strtotime($end);
  46. $diff = bcsub($endArea, $startArea);
  47. if ($diff > $monthTime) {
  48. util::fail('最长可导出一个月');
  49. }
  50. }
  51. $respond = CustomDebtChangeClass::getChangeList($where);
  52. if ($export == 1) {
  53. CustomDebtChangeClass::exportData($respond, $this->mainId);
  54. }
  55. util::success($respond);
  56. }
  57. }