ShopYeChangeController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\shop\classes\ShopYeChangeClass;
  4. use common\components\dict;
  5. use common\components\util;
  6. use common\components\dateUtil;
  7. use Yii;
  8. class ShopYeChangeController extends BaseController
  9. {
  10. public $guestAccess = [];
  11. public function actionList()
  12. {
  13. $get = Yii::$app->request->get();
  14. $status = $get['status'] ?? 0;
  15. $export = $get['export']??0;
  16. $where = [];
  17. $where['mainId'] = $this->mainId;
  18. if (!empty($status)) {
  19. $where['status'] = $status;
  20. }
  21. $tx = $get['tx'] ?? 0;
  22. if (!empty($tx)) {
  23. $where['tx'] = $tx;
  24. }
  25. $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : '';
  26. $startTime = $get['startTime'] ?? '';
  27. $endTime = $get['endTime'] ?? '';
  28. if (!empty($searchTime)) {
  29. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  30. $start = date("Y-m-d 00:00:00", strtotime($period['startTime']));
  31. $end = date("Y-m-d 23:59:59", strtotime($period['endTime']));
  32. $where['addTime'] = ['between', [$start, $end]];
  33. }
  34. $list = ShopYeChangeClass::getChangeList($where);
  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. ShopYeChangeClass::exportData($list, $this->mainId);
  51. }
  52. util::success($list);
  53. }
  54. }