merchant_order.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <?php
  2. use task\manager;
  3. require_once(BASE_HELPER_PATH . '/task/task_helper.php');
  4. class merchant_orderControl extends mbMerchantControl
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. public function listOp()
  11. {
  12. $model_vr_order = Model('refill_order');
  13. $cond['mchid'] = $this->mchid();
  14. $cond['inner_status'] = 0;
  15. if (!empty($_GET['card_type'])) {
  16. if(in_array($_GET['card_type'] , ['1' , '2' , '4' , '5' , '6'])) {
  17. $cond['refill_order.card_type'] = $_GET['card_type'];
  18. }
  19. if($_GET['card_type'] == 'oil') {
  20. $cond['refill_order.card_type'] = ['in' , ['1' , '2']];
  21. }
  22. if($_GET['card_type'] == 'phone') {
  23. $cond['refill_order.card_type'] = ['in' , ['4' , '5' , '6']];
  24. }
  25. }
  26. if (!empty($_GET['card_no'])) {
  27. $cond['refill_order.card_no'] = $_GET['card_no'];
  28. }
  29. if (!empty($_GET['refill_amount'])) {
  30. $cond['refill_order.refill_amount'] = $_GET['refill_amount'];
  31. }
  32. if (!empty($_GET['mch_order'])) {
  33. $cond['refill_order.mch_order'] = $_GET['mch_order'];
  34. }
  35. if (!empty($_GET['order_sn'])) {
  36. $cond['refill_order.order_sn'] = $_GET['order_sn'];
  37. }
  38. if (!empty($_GET['quality'])) {
  39. $cond['refill_order.quality'] = $_GET['quality'];
  40. }
  41. $cur_time = time();
  42. $end_date = strtotime(date('Y-m-d',$cur_time));
  43. $add_end = $end_date + 86400 * 5;
  44. $start = intval($_GET['start_time']);
  45. $end = intval($_GET['end_time']);
  46. if($start <= 0) {
  47. $start = $cur_time - 86400 * 2;
  48. }
  49. if($end <= 0) {
  50. $end = $cur_time;
  51. }
  52. $cond['refill_order.order_time'] = [['egt', $start], ['lt', $end], 'and'];
  53. $cond['vr_order.add_time'] = [['egt', $start], ['elt', $add_end], 'and'];
  54. if (in_array($_GET['order_state'], ['0', '30', '40']))
  55. {
  56. $cond['vr_order.order_state'] = $_GET['order_state'];
  57. }
  58. if ($_GET['stat']) {
  59. $stat = $this->orderStatsHour($cond);
  60. return self::outsuccess($stat);
  61. }
  62. $fields = 'refill_order.*,vr_order.order_state';
  63. $total = $this->getTotal($start, $end);
  64. $order_list = $model_vr_order->getMerchantOrderList($cond, $this->page, $total, $fields, 'refill_order.order_time desc');
  65. $order_list = $this->merchant_order_format($order_list);
  66. $result['data'] = $order_list;
  67. $result['total'] = $model_vr_order->gettotalpage();
  68. return self::outsuccess($result);
  69. }
  70. private function getTotal($start,$end)
  71. {
  72. $model_detail = Model('refill_detail');
  73. $cond['order_time'] = [['egt', $start], ['lt', $end], 'and'];
  74. $cond['mchid'] = $this->mchid();
  75. $items= $model_detail->field('count(*) as ncount')->where($cond)->select();
  76. foreach($items as $item) {
  77. $count = intval($item['ncount']);
  78. return $count;
  79. }
  80. return 0;
  81. }
  82. private function orderStatsHour($cond)
  83. {
  84. $stats = Model('')->table('refill_order,vr_order')->join('inner')
  85. ->on('refill_order.order_id=vr_order.order_id')
  86. ->field("FROM_UNIXTIME(order_time,'%d-%H') as hour, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(mch_amount) as mch_amounts, order_state")
  87. ->where($cond)->group('hour, order_state')->select();
  88. $cond['refill_order.channel_name'] = '';
  89. $excp_stats = Model('')->table('refill_order,vr_order')->join('inner')
  90. ->on('refill_order.order_id=vr_order.order_id')
  91. ->field("FROM_UNIXTIME(order_time,'%d-%H') as hour, count(*) as order_count")
  92. ->where($cond)->group('hour')->select();
  93. $data = [];
  94. $except = [];
  95. $result = [];
  96. $all = [
  97. 'success_count' => 0, 'success_amounts' => 0, 'cancel_count' => 0, 'except_count' => 0
  98. ];
  99. if(!empty($excp_stats)) {
  100. foreach ($excp_stats as $value) {
  101. $except[$value['hour']] = $value['order_count'];
  102. }
  103. }
  104. if(!empty($stats)) {
  105. foreach ($stats as $stat) {
  106. $hour = $stat['hour'];
  107. if ($stat['order_state'] == ORDER_STATE_SUCCESS) {
  108. $data[$hour]['success_count'] = $stat['order_count'];
  109. $data[$hour]['success_amounts'] = $stat['refill_amounts'];
  110. } elseif ($stat['order_state'] == ORDER_STATE_CANCEL) {
  111. $data[$hour]['cancel_count'] = $stat['order_count'];
  112. }
  113. if (array_key_exists($hour, $except)) {
  114. $data[$hour]['except_count'] = $except[$hour];
  115. }
  116. }
  117. foreach ($data as $hour => $val) {
  118. $success_count = $val['success_count'] ?? 0;
  119. $success_amounts = $val['success_amounts'] ?? 0;
  120. $cancel_count = $val['cancel_count'] ?? 0;
  121. $except_count = $val['except_count'] ?? 0;
  122. $result[] = [$hour, $success_count, $success_amounts, $cancel_count, $except_count];
  123. $all['success_count'] += $success_count;
  124. $all['success_amounts'] += ncPriceFormat($success_amounts);
  125. $all['cancel_count'] += ncPriceFormat($cancel_count);
  126. $all['except_count'] += ncPriceFormat($except_count);
  127. }
  128. $result[] = ['总计', $all['success_count'], $all['success_amounts'], $all['cancel_count'], $all['except_count']];
  129. }
  130. return $result;
  131. }
  132. public function OrderStatsOp()
  133. {
  134. if(empty($_GET['time_type']) || empty($_GET['start_time']) || empty($_GET['end_time'])) {
  135. return self::outerr(errcode::ErrInputParam, "参数错误.");
  136. }
  137. $cond['inner_status'] = 0;
  138. $time_type = $_GET['time_type'];
  139. $start = $_GET['start_time'];
  140. $end = $_GET['end_time'];
  141. $start_date = strtotime(date('Y-m-d',$start));
  142. $end_date = strtotime(date('Y-m-d',$end));
  143. if ($time_type == 'order_time') {
  144. $add_end = $end_date + 86400 * 5;
  145. $cond['refill_order.order_time'] = [['egt', $start], ['lt', $end], 'and'];
  146. $cond['vr_order.add_time'] = [['egt', $start], ['elt', $add_end], 'and'];
  147. } elseif ($time_type == 'notify_time') {
  148. $add_begin = $start_date - 86400 * 5;
  149. $cond['refill_order.order_time'] = [['egt', $add_begin], ['lt', $end], 'and'];
  150. $cond['vr_order.add_time'] = [['egt', $add_begin], ['elt', $end], 'and'];
  151. $cond['refill_order.notify_time'] = [['egt', $start], ['elt', $end], 'and'];
  152. } else {
  153. return self::outerr(errcode::ErrInputParam, "筛选日期类型错误.");
  154. }
  155. $cond['mchid'] = $this->mchid();
  156. $stats = Model('')->table('refill_order,vr_order')->join('inner')
  157. ->on('refill_order.order_id=vr_order.order_id')
  158. ->field('count(*) as order_count ,sum(refill_amount) as refill_amounts, sum(mch_amount) as mch_amounts, order_state')
  159. ->where($cond)->group('order_state')->select();
  160. $result['count'] = $result['sendCount'] = $result['errorCount'] = $result['successCount'] = $result['refill_amounts'] = $result['mch_amounts'] = 0;
  161. foreach ($stats as $stat) {
  162. $result['count'] += $stat['order_count'];
  163. if($stat['order_state'] == ORDER_STATE_SEND) {
  164. $result['sendCount'] = $stat['order_count'];
  165. }
  166. if($stat['order_state'] == ORDER_STATE_CANCEL) {
  167. $result['errorCount'] = $stat['order_count'];
  168. }
  169. if($stat['order_state'] == ORDER_STATE_SUCCESS) {
  170. $result['successCount'] = $stat['order_count'];
  171. $result['mch_amounts'] = $stat['mch_amounts'];
  172. $result['refill_amounts'] = $stat['refill_amounts'];
  173. }
  174. }
  175. return self::outsuccess($result);
  176. }
  177. public function interceptOp()
  178. {
  179. $mchid = $this->mchid();
  180. $mch_order = $_GET['order_sn'];
  181. if(empty($mch_order)) {
  182. return self::outerr(205,"客户订单号为空.");
  183. }
  184. $mod_refill = Model('refill_order');
  185. $order = $mod_refill->get_detail($mchid,$mch_order);
  186. if(empty($order)) {
  187. return self::outerr(205,"该订单号不存在.");
  188. }
  189. $order_state = $order['order_state'];
  190. if($order_state === ORDER_STATE_HANDLED) {
  191. return self::outerr(206,"该订单已经完成.");
  192. }
  193. $order_state = refill\util::query_queue_order($mchid,$mch_order);
  194. if ($order_state == ORDER_STATE_TIMEOUT || $order_state == ORDER_STATE_HANDLED) {
  195. Log::record("intercept timeout order mchid=$mchid mch_order=$mch_order order_state=$order_state" ,Log::DEBUG);
  196. return self::outerr(206,"该订单已经完成.");
  197. }
  198. refill\util::set_cancel_order($mchid,$mch_order);
  199. return self::outsuccess([]);
  200. }
  201. private function merchant_order_format($orders)
  202. {
  203. $data = [];
  204. foreach ($orders as $order) {
  205. if($order['notify_time'] > 0)
  206. {
  207. $order['diff_time_text'] = $this->elapse_time($order['notify_time'] - $order['order_time']);
  208. $order['diff_time'] = $order['notify_time'] - $order['order_time'];
  209. }
  210. else
  211. {
  212. $order['diff_time_text'] = $this->elapse_time(time() - $order['order_time']);
  213. $order['diff_time'] = time() - $order['order_time'];
  214. }
  215. if (isset($order['order_time'])) {
  216. $order['order_time'] = date('Y-m-d H:i:s', $order['order_time']);
  217. }
  218. if (isset($order['notify_time'])) {
  219. $order['notify_time'] = date('Y-m-d H:i:s', $order['notify_time']);
  220. }
  221. if($order['is_retrying'] == 1) {
  222. $order['order_state'] = ORDER_STATE_SEND;
  223. }
  224. if ($order['order_state'] == ORDER_STATE_NEW || $order['order_state'] == ORDER_STATE_PAY) {
  225. $order['order_state'] = ORDER_STATE_SEND;
  226. }
  227. $order['order_state_text'] = $this->_orderState($order['order_state']);
  228. $order['card_type_name'] = $this->scard_type($order['card_type']);
  229. $data[] = $order;
  230. }
  231. return $data;
  232. }
  233. /**
  234. * 取得订单状态文字输出形式
  235. *
  236. * @param int $order_state 订单数组
  237. * @return string
  238. */
  239. private function _orderState($order_state)
  240. {
  241. switch ($order_state) {
  242. case ORDER_STATE_CANCEL:
  243. $text = '已取消';
  244. break;
  245. case ORDER_STATE_NEW:
  246. $text = '新订单';
  247. break;
  248. case ORDER_STATE_SEND:
  249. $text = '充值中';
  250. break;
  251. case ORDER_STATE_PAY:
  252. $text = '支付成功';
  253. break;
  254. case ORDER_STATE_SUCCESS:
  255. $text = '充值成功';
  256. break;
  257. case 'retrying':
  258. $text = '重试中';
  259. break;
  260. default:
  261. $text = '未知状态';
  262. }
  263. return $text;
  264. }
  265. private function scard_type(int $card_type)
  266. {
  267. if ($card_type == mtopcard\PetroChinaCard) { //中石油
  268. return '中石油';
  269. } elseif ($card_type == mtopcard\SinopecCard) { //中石化
  270. return '中石化';
  271. } elseif ($card_type == mtopcard\ChinaMobileCard) { //中国移动
  272. return '中国移动';
  273. } elseif ($card_type == mtopcard\ChinaUnicomCard) { //中国联通
  274. return '中国联通';
  275. } elseif ($card_type == mtopcard\ChinaTelecomCard) { //中国电信
  276. return '中国电信';
  277. } elseif ($card_type == mtopcard\ThirdRefillCard) { //中国电信
  278. return '增值业务';
  279. } else {
  280. return 'unknown';
  281. }
  282. }
  283. private function elapse_time($seconds)
  284. {
  285. $minutes = intval($seconds / 60);
  286. $second = intval($seconds % 60);
  287. if($minutes >= 60) {
  288. $minute = $minutes % 60;
  289. $hours = intval($minutes / 60);
  290. $result = "{$minute}:{$second}";
  291. }
  292. else {
  293. if($minutes > 0){
  294. $result = "{$minutes}:{$second}";
  295. }else{
  296. $result = "{$second}";
  297. }
  298. }
  299. if(isset($hours))
  300. {
  301. $result = "{$hours}:" . $result;
  302. }
  303. return $result;
  304. }
  305. public function OrderExportOp()
  306. {
  307. $cond['mchid'] = $this->mchid();
  308. $cond['inner_status'] = 0;
  309. $fSingle = false;
  310. if (!empty($_GET['card_type'])) {
  311. if(in_array($_GET['card_type'] , ['1' , '2' , '4' , '5' , '6'])) {
  312. $cond['refill_order.card_type'] = $_GET['card_type'];
  313. }
  314. if($_GET['card_type'] == 'oil') {
  315. $cond['refill_order.card_type'] = ['in' , ['1' , '2']];
  316. }
  317. if($_GET['card_type'] == 'phone') {
  318. $cond['refill_order.card_type'] = ['in' , ['4' , '5' , '6']];
  319. }
  320. }
  321. if (!empty($_GET['card_no'])) {
  322. $fSingle = true;
  323. $cond['refill_order.card_no'] = $_GET['card_no'];
  324. }
  325. if (!empty($_GET['refill_amount'])) {
  326. $cond['refill_order.refill_amount'] = $_GET['refill_amount'];
  327. }
  328. if (!empty($_GET['mch_order'])) {
  329. $fSingle = true;
  330. $cond['refill_order.mch_order'] = $_GET['mch_order'];
  331. }
  332. if (!empty($_GET['order_sn'])) {
  333. $fSingle = true;
  334. $cond['refill_order.order_sn'] = $_GET['order_sn'];
  335. }
  336. if (!empty($_GET['quality'])) {
  337. $cond['refill_order.quality'] = $_GET['quality'];
  338. }
  339. $cur_time = time();
  340. $end_date = strtotime(date('Y-m-d',$cur_time));
  341. $add_end = $end_date + 86400 * 5;
  342. if($fSingle)
  343. {
  344. $start = intval($_GET['start_time']);
  345. $end = intval($_GET['end_time']);
  346. if($start <= 0) {
  347. $start = $cur_time - 3600;
  348. }
  349. if($end <= 0) {
  350. $end = $cur_time;
  351. }
  352. }
  353. else{
  354. $start = $cur_time - 3600;
  355. $end = $cur_time;
  356. }
  357. $cond['refill_order.order_time'] = [['egt', $start], ['lt', $end], 'and'];
  358. $cond['vr_order.add_time'] = [['egt', $start], ['elt', $add_end], 'and'];
  359. if (in_array($_GET['order_state'], array('0', '30', '40'))) {
  360. $cond['vr_order.order_state'] = $_GET['order_state'];
  361. if($_GET['order_state'] == 30 && $_GET['time'] == 1){
  362. $cond['refill_order.order_time'] = ['lt', (time() - 3600)];
  363. }
  364. }
  365. $order_list = $this->getAllOrders($cond);
  366. $order_list = $this->merchant_order_format($order_list);
  367. $result = $this->export_order_exec($order_list);
  368. return self::outsuccess($result);
  369. }
  370. private function getAllOrders($condition): array
  371. {
  372. $len = 1000;
  373. $i = 0;
  374. $orders = [];
  375. while (true)
  376. {
  377. $start = $i * $len;
  378. $items = Model('')->table('refill_order,vr_order')
  379. ->field('refill_order.*,vr_order.order_state')
  380. ->join('inner')
  381. ->on('refill_order.order_id=vr_order.order_id')
  382. ->where($condition)
  383. ->order('refill_order.order_time desc')
  384. ->limit("{$start},{$len}")
  385. ->select();
  386. $orders = array_merge($orders,$items);
  387. if (empty($items) || count($items) < $len) {
  388. break;
  389. }
  390. $i++;
  391. }
  392. return $orders;
  393. }
  394. private function export_order_exec($order_list)
  395. {
  396. $card_type = ['1'=>'中石油' , '2' =>'中石化' , '4' => '移动' , '5' => '联通' , '6' => '电信'];
  397. $datas = [];
  398. if(defined('COMPANY_NAME') && COMPANY_NAME === 'LZKJ_COMPANY') {
  399. $title = [
  400. ['value' => '代理商账号'],
  401. ['value' => '商品名称'],
  402. ['value' => '交易账号'],
  403. ['value' => '交易金额'],
  404. ['value' => '交易面值'],
  405. ['value' => '交易日期'],
  406. ['value' => '交易状态'],
  407. ['value' => '处理时间'],
  408. ['value' => '第三方流水']
  409. ];
  410. foreach ($order_list as $order) {
  411. $data = [];
  412. $official_sn = $order['official_sn'];
  413. $notify_time = $order['$notify_time'];
  414. if(empty($order['official_sn'])) {
  415. $official_sn = '';
  416. }
  417. if(empty($order['$notify_time'])) {
  418. $notify_time = '';
  419. }
  420. $data[] = ['value' => $order['mchid']];
  421. $data[] = ['value' => "{$card_type[$order['card_type']]}{$order['refill_amount']}元"];
  422. $data[] = ['value' => $order['card_no']];
  423. $data[] = ['value' => $order['mch_amount']];
  424. $data[] = ['value' => $order['refill_amount']];
  425. $data[] = ['value' => $order['order_time']];
  426. $data[] = ['value' => $order['order_state_text']];
  427. $data[] = ['value' => $notify_time];
  428. $data[] = ['value' => $official_sn];
  429. $datas[] = $data;
  430. }
  431. }
  432. else
  433. {
  434. $title = [
  435. ['value' => '商户号'],
  436. ['value' => '客户订单号'],
  437. ['value' => '平台单号'],
  438. ['value' => '面额'],
  439. ['value' => '充值卡号'],
  440. ['value' => '充值卡类型'],
  441. ['value' => '下单日期'],
  442. ['value' => '完成日期'],
  443. ['value' => '官方流水号'],
  444. ['value' => '订单状态'],
  445. ['value' => '扣款金额']
  446. ];
  447. foreach ($order_list as $order) {
  448. $data = [];
  449. $data[] = ['value'=>$order['mchid']];
  450. $data[] = ['value'=>$order['mch_order']];
  451. $data[] = ['value'=>$order['order_sn']];
  452. $data[] = ['value'=>$order['refill_amount']];
  453. $data[] = ['value'=>$order['card_no']];
  454. $data[] = ['value'=>$order['card_type_name']];
  455. $data[] = ['value'=>$order['order_time']];
  456. $data[] = ['value'=>$order['notify_time']];
  457. $data[] = ['value'=>$order['official_sn']];
  458. $data[] = ['value'=>$order['order_state_text']];
  459. $data[] = ['value'=>$order['mch_amount']];
  460. $datas[] = $data;
  461. }
  462. }
  463. return ['title' => $title , 'data' => $datas];
  464. }
  465. private function checkSend($start, $end)
  466. {
  467. $order_state_send = ORDER_STATE_SEND;
  468. $order_state_queue = ORDER_STATE_QUEUE;
  469. $cond['order_state'] = ['in',"{$order_state_send},{$order_state_queue}"];
  470. $cond['order_time'] = [['egt', $start], ['lt', $end], 'and'];
  471. $cond['mchid'] = $this->mchid();
  472. return Model('refill_detail')->where($cond)->select();
  473. }
  474. private function is_timestamp($timestamp) {
  475. $timestamp = intval($timestamp);
  476. if(strtotime(date('Y-m-d H:i:s',$timestamp)) === $timestamp) {
  477. return $timestamp;
  478. } else return false;
  479. }
  480. public function create_taskOp()
  481. {
  482. if(empty($_GET['time_type']) || empty($_GET['start_time']) || empty($_GET['end_time'])) {
  483. return self::outerr(errcode::ErrInputParam, "参数错误.");
  484. }
  485. if(!$this->is_timestamp($_GET['start_time']) || !$this->is_timestamp($_GET['end_time'])) {
  486. return self::outerr(errcode::ErrInputParam, "时间戳类型错误.");
  487. }
  488. $task_title_create = function ($start, $end, $time_type){
  489. $start = date('Y-m-d H:i:s', $start);
  490. $end = date('Y-m-d H:i:s', $end);
  491. if ($time_type === 'order_time') {
  492. $task_title = "订单导出: 下单时间 {$start} - {$end}";
  493. } else {
  494. $task_title = "订单导出: 回调时间 {$start} - {$end}";
  495. }
  496. return $task_title;
  497. };
  498. $time_type = $_GET['time_type'];
  499. $start = $_GET['start_time'];
  500. $end = $_GET['end_time'];
  501. if (!empty($this->checkSend($start, $end))) {
  502. return self::outerr(errcode::ErrInputParam, "还有正在充值中的订单,请稍后再试.");
  503. }
  504. $start_date = strtotime(date('Y-m-d',$start));
  505. $end_date = strtotime(date('Y-m-d',$end));
  506. $today = strtotime(date('Y-m-d',time()));
  507. $tomorrow = $today + 86400;
  508. if ($time_type === 'order_time')
  509. {
  510. $add_end = $end_date + 86400 * 5;
  511. if($add_end > $tomorrow) {
  512. $add_end = $tomorrow;
  513. }
  514. $scope = ['order_time' => [$start, $end], 'add_time' => [$start, $add_end]];
  515. } elseif ($time_type === 'notify_time') {
  516. $add_begin = $start_date - 86400 * 5;
  517. $scope = ['order_time' => [$add_begin, $end], 'add_time' => [$add_begin, $end], 'notify_time' => [$start, $end]];
  518. } else {
  519. return self::outerr(errcode::ErrInputParam, "筛选日期类型错误.");
  520. }
  521. $normal_cond['inner_status'] = 0;
  522. $normal_cond['order_state'] = ORDER_STATE_SUCCESS;
  523. $normal_cond['mchid'] = $this->mchid();
  524. $task_title = $task_title_create($start, $end, $time_type);
  525. $cond = ['normal' => $normal_cond, 'time_scope' => $scope, 'export_type' => 'merchant'];
  526. $manager = new manager();
  527. $task = $manager->add_task('refill_order_export',$cond,1,-1, $task_title, $this->mchid());
  528. $file_path = '';
  529. if ($task->completed() && $task->success()) {
  530. $file_name = $task->result();
  531. $file_path = UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . $file_name;
  532. }
  533. return self::outsuccess(['file_path' => $file_path]);
  534. }
  535. public function task_listOp()
  536. {
  537. $model = Model('task');
  538. $condition['is_show'] = 1;
  539. $condition['mchid'] = $this->mchid();
  540. $task_list = $model->getList($condition, $this->page, '*', 'add_time desc', 20);
  541. foreach ($task_list as $key => $value)
  542. {
  543. if($value['state'] == 3 && !empty($value['result']))
  544. {
  545. $task_list[$key]['file_path'] = UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . unserialize($value['result']);
  546. }else{
  547. $task_list[$key]['file_path'] = '';
  548. }
  549. }
  550. $result['data'] = $task_list;
  551. $result['total'] = $model->gettotalpage();
  552. return self::outsuccess($result);
  553. }
  554. }