|
@@ -1,5 +1,9 @@
|
|
|
<?php
|
|
|
+
|
|
|
+use task\manager;
|
|
|
+
|
|
|
require_once(BASE_ROOT_PATH . '/mobile/control/merchantweb.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/task/task_helper.php');
|
|
|
|
|
|
class merchant_orderControl extends mbMerchantControl
|
|
|
{
|
|
@@ -76,7 +80,7 @@ class merchant_orderControl extends mbMerchantControl
|
|
|
}
|
|
|
|
|
|
$fields = 'refill_order.*,vr_order.order_state';
|
|
|
- $order_list = $model_vr_order->getMerchantOrderList($cond, $this->page, 0, $fields, 'refill_order.order_time desc');
|
|
|
+ $order_list = $model_vr_order->getMerchantOrderList($cond, $this->page, 5000, $fields, 'refill_order.order_time desc');
|
|
|
$order_list = $this->merchant_order_format($order_list);
|
|
|
$result['data'] = $order_list;
|
|
|
$result['total'] = $model_vr_order->gettotalpage();
|
|
@@ -413,4 +417,104 @@ class merchant_orderControl extends mbMerchantControl
|
|
|
|
|
|
return ['title' => $title , 'data' => $datas];
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ private function checkSend($start, $end)
|
|
|
+ {
|
|
|
+ $order_state_send = ORDER_STATE_SEND;
|
|
|
+ $order_state_queue = ORDER_STATE_QUEUE;
|
|
|
+ $cond['order_state'] = ['in',"{$order_state_send},{$order_state_queue}"];
|
|
|
+ $cond['order_time'] = [['egt', $start], ['lt', $end], 'and'];
|
|
|
+ return Model('refill_detail')->where($cond)->select();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function is_timestamp($timestamp) {
|
|
|
+ $timestamp = intval($timestamp);
|
|
|
+ if(strtotime(date('Y-m-d H:i:s',$timestamp)) === $timestamp) {
|
|
|
+ return $timestamp;
|
|
|
+ } else return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function create_taskOp()
|
|
|
+ {
|
|
|
+ if(empty($_GET['time_type']) || empty($_GET['start_time']) || empty($_GET['end_time'])) {
|
|
|
+ return self::outerr(errcode::ErrInputParam, "参数错误.");
|
|
|
+ }
|
|
|
+ if(!$this->is_timestamp($_GET['start_time']) || !$this->is_timestamp($_GET['end_time'])) {
|
|
|
+ return self::outerr(errcode::ErrInputParam, "时间戳类型错误.");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $task_title_create = function ($start, $end, $time_type){
|
|
|
+ $start = date('Y-m-d H:i:s', $start);
|
|
|
+ $end = date('Y-m-d H:i:s', $end);
|
|
|
+ if ($time_type === 'order_time') {
|
|
|
+ $task_title = "订单导出: 下单时间 {$start} - {$end}";
|
|
|
+ } else {
|
|
|
+ $task_title = "订单导出: 回调时间 {$start} - {$end}";
|
|
|
+ }
|
|
|
+ return $task_title;
|
|
|
+ };
|
|
|
+
|
|
|
+ $time_type = $_GET['time_type'];
|
|
|
+ $start = $_GET['start_time'];
|
|
|
+ $end = $_GET['end_time'];
|
|
|
+ if (!empty($this->checkSend($start, $end))) {
|
|
|
+ return self::outerr(errcode::ErrInputParam, "还有正在充值中的订单,请稍后再试.");
|
|
|
+ }
|
|
|
+
|
|
|
+ $start_date = strtotime(date('Y-m-d',$start));
|
|
|
+ $end_date = strtotime(date('Y-m-d',$end));
|
|
|
+ $today = strtotime(date('Y-m-d',time()));
|
|
|
+ $tomorrow = $today + 86400;
|
|
|
+
|
|
|
+ if ($time_type === 'order_time')
|
|
|
+ {
|
|
|
+ $add_end = $end_date + 86400 * 5;
|
|
|
+ if($add_end > $tomorrow) {
|
|
|
+ $add_end = $tomorrow;
|
|
|
+ }
|
|
|
+ $scope = ['order_time' => [$start, $end], 'add_time' => [$start, $add_end]];
|
|
|
+ } elseif ($time_type === 'notify_time') {
|
|
|
+ $add_begin = $start_date - 86400 * 5;
|
|
|
+ $scope = ['order_time' => [$add_begin, $end], 'add_time' => [$add_begin, $end], 'notify_time' => [$start, $end]];
|
|
|
+ } else {
|
|
|
+ return self::outerr(errcode::ErrInputParam, "筛选日期类型错误.");
|
|
|
+ }
|
|
|
+ $normal_cond['inner_status'] = 0;
|
|
|
+ $normal_cond['order_state'] = ORDER_STATE_SUCCESS;
|
|
|
+ $normal_cond['mchid'] = $this->mchid();
|
|
|
+
|
|
|
+ $task_title = $task_title_create($start, $end, $time_type);
|
|
|
+ $cond = ['normal' => $normal_cond, 'time_scope' => $scope, 'export_type' => 'merchant'];
|
|
|
+
|
|
|
+ $manager = new manager();
|
|
|
+ $task = $manager->add_task('refill_order_export',$cond,1,-1, $task_title, $this->mchid());
|
|
|
+ $file_path = '';
|
|
|
+ if ($task->completed() && $task->success()) {
|
|
|
+ $file_name = $task->result();
|
|
|
+ $file_path = UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . $file_name;
|
|
|
+ }
|
|
|
+ return self::outsuccess(['file_path' => $file_path]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function task_listOp()
|
|
|
+ {
|
|
|
+ $model = Model('task');
|
|
|
+ $condition['is_show'] = 1;
|
|
|
+ $condition['mchid'] = $this->mchid();
|
|
|
+ $task_list = $model->getList($condition, $this->page, '*', 'add_time desc', 20);
|
|
|
+
|
|
|
+ foreach ($task_list as $key => $value)
|
|
|
+ {
|
|
|
+ if($value['state'] == 3 && !empty($value['result']))
|
|
|
+ {
|
|
|
+ $task_list[$key]['file_path'] = UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . unserialize($value['result']);
|
|
|
+ }else{
|
|
|
+ $task_list[$key]['file_path'] = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result['data'] = $task_list;
|
|
|
+ $result['total'] = $model->gettotalpage();
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+}
|