refill_order_manual.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <?php
  2. require_once(BASE_HELPER_PATH . '/refill/util.php');
  3. require_once(BASE_HELPER_PATH . '/algorithm.php');
  4. use refill\util;
  5. class refill_order_manualControl extends SystemControl
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. }
  11. public function indexOp()
  12. {
  13. $model_refill_order = Model('refill_order');
  14. $condition['inner_status'] = 0;
  15. $order_list = [];
  16. if (!empty($_GET['order_sn'])) {
  17. $condition['refill_order.order_sn'] = $_GET['order_sn'];
  18. $merchant_list = $this->merchants();
  19. $order_list = $model_refill_order->getMerchantOrderList($condition, 50,0, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc','',true);
  20. $order_list = $this->OrderDataFormat($order_list, $merchant_list);
  21. }
  22. Tpl::output('order_list', $order_list);
  23. Tpl::showpage('refill.order.manual.index');
  24. }
  25. public function notify_manual_merchantOp()
  26. {
  27. $order_id = $_GET['order_id'];
  28. $type = $_GET['type'];
  29. $mod_order = Model('vr_order');
  30. $order_info = $mod_order->getOrderInfo(['order_id' => $order_id]);
  31. $mod_refill = Model('refill_order');
  32. $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id,'inner_status' => 0,'is_retrying' => 0]);
  33. if(empty($refill_info) || empty($order_info)) {
  34. showMessage('订单不存在,或不符合条件', '');
  35. }
  36. $fetch_order_ids = $this->check_fetch_order($order_id);
  37. if (in_array($order_id, $fetch_order_ids)) {
  38. showMessage('此订单不可手动操作,请联系抢单人员操作!');
  39. }
  40. $logic_vr_order = Logic("vr_order");
  41. if ($type == 'success') {
  42. $logic_vr_order->changeOrderStateSuccess($order_id,true);
  43. } elseif ($type == 'cancel') {
  44. $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败", true, true);
  45. } else {
  46. showMessage('手动操作类型错误', 'index.php?act=refill_order&op=index');
  47. }
  48. $this->manual_record([$refill_info], $type, $order_id, '手动强制处理');
  49. if($refill_info['notify_time'] == 0) {
  50. $mod_refill->edit($order_id, ['notify_state' =>1, 'notify_time' => time()]);
  51. }
  52. util::pop_queue_order($refill_info['mchid'],$refill_info['mch_order']);
  53. QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]);
  54. showMessage('操作成功');
  55. }
  56. public function refill_order_batchOp()
  57. {
  58. $model_refill_order = Model('refill_order');
  59. $condition = [];
  60. $orders = [];
  61. $_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d 00:00:00");
  62. if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
  63. {
  64. $condition['vr_order.order_state'] = $_GET['order_state'];
  65. }
  66. if (!empty($_GET['mchid'])) {
  67. $condition['refill_order.mchid'] = $_GET['mchid'];
  68. }
  69. if (!empty($_GET['store_id'])) {
  70. $condition['vr_order.store_id'] = $_GET['store_id'];
  71. }
  72. //批量查询,二者都有,以卡号为主
  73. if(!empty($_GET['card_nos'])) {
  74. $card_nos = trim($_GET['card_nos'], ',');
  75. $condition['refill_order.card_no'] = ['in', $card_nos];
  76. } elseif (!empty($_GET['mch_orders'])) {
  77. $mch_orders = rtrim($_GET['mch_orders'], ',');
  78. $condition['refill_order.mch_order'] = ['in', $mch_orders];
  79. }
  80. if(!empty($_GET['order_sns'])) {
  81. $order_sns = trim($_GET['order_sns'], ',');
  82. $condition['refill_order.order_sn'] = ['in', $order_sns];
  83. }
  84. if (!empty($_GET['card_type'])) {
  85. if (in_array($_GET['card_type'], ['1', '2', '4', '5', '6', '7'])) {
  86. $condition['refill_order.card_type'] = intval($_GET['card_type']);
  87. }
  88. }
  89. $merchant_list = $this->merchants();
  90. $provider_list = $this->providers();
  91. if(!empty($condition)) {
  92. $condition['refill_order.inner_status'] = 0;
  93. $start_unixtime = intval(strtotime($_GET['query_start_time']));
  94. $end_unixtime = intval(strtotime($_GET['query_end_time']));
  95. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  96. $condition['refill_order.order_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  97. $condition['vr_order.add_time'] = [['egt', $start_unixtime],['lt', $end_unixtime], 'and'];
  98. } elseif ($start_unixtime > 0) {
  99. $condition['refill_order.order_time'] = ['egt', $start_unixtime];
  100. $condition['vr_order.add_time'] = ['egt', $start_unixtime];
  101. } elseif ($end_unixtime > 0) {
  102. $condition['refill_order.order_time'] = ['lt', $end_unixtime];
  103. } else {
  104. $start = strtotime(date('Y-m-d', time()));
  105. $condition['refill_order.order_time'] = ['egt', $start];
  106. $condition['vr_order.add_time'] = ['egt', $start];
  107. }
  108. $orders = $model_refill_order->getMerchantOrderList($condition, 400, 0,'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
  109. $orders = $this->OrderDataFormat($orders, $merchant_list);
  110. $order_ids = array_column($orders,'order_id');
  111. $order_ids = $this->unique_array($order_ids);
  112. $refill_buyback_model = Model('refill_buyback');
  113. $buybacks = $refill_buyback_model->getBuyBackList(['order_id' => ['in',$order_ids], 'manual_type' => 'buyback']);
  114. $buyback_ids = array_column($buybacks, 'order_id');
  115. $buyback_ids = $this->int_array($buyback_ids);
  116. $buyback_ids = $this->unique_array($buyback_ids);
  117. foreach ($orders as $key => $order)
  118. {
  119. if($order['order_state'] != ORDER_STATE_SUCCESS) {
  120. $order[$key]['buyback'] = false;
  121. continue;
  122. }
  123. $order_id = intval($order['order_id']);
  124. if(algorithm::binary_search($buyback_ids,$order_id)) {
  125. $orders[$key]['buyback'] = true;
  126. }else{
  127. $orders[$key]['buyback'] = false;
  128. }
  129. }
  130. }
  131. Tpl::output('merchant_list', $merchant_list);
  132. Tpl::output('provider_list', $provider_list);
  133. Tpl::output('order_list', $orders);
  134. Tpl::output('show_page', $model_refill_order->showpage());
  135. Tpl::showpage('refill.order.batch');
  136. }
  137. public function refill_order_batch_disposeOp()
  138. {
  139. $oid_reader = function ($sids) {
  140. $sids = explode(',',$sids);
  141. $ids = $this->int_array($sids);
  142. return $this->unique_array($ids);
  143. };
  144. $oper_type = $_GET['type'];
  145. $order_ids = $oid_reader($_GET['order_id']);
  146. $cond = [];
  147. $cond['refill_order.order_id'] = ['in',$order_ids];
  148. $cond['refill_order.inner_status'] = 0;
  149. $cond['refill_order.is_retrying'] = 0;
  150. if ($oper_type == 'success' || $oper_type == 'cancel') {
  151. $cond['vr_order.order_state'] = ORDER_STATE_SEND;
  152. } elseif ($oper_type == 'buyback') {
  153. $cond['vr_order.order_state'] = ORDER_STATE_SUCCESS;
  154. }
  155. $model_refill_order = Model('refill_order');
  156. $orders = $model_refill_order->getMerchantOrderList($cond,'',0,'refill_order.*,vr_order.order_state,vr_order.buyer_id,vr_order.store_id','refill_order.order_id desc',2000);
  157. if(empty($orders)) {
  158. showMessage('操作数据为空');
  159. }
  160. if($oper_type == 'notify')
  161. {
  162. foreach ($orders as $order)
  163. {
  164. if ($order['order_state'] == ORDER_STATE_SEND) {
  165. QueueClient::push("QueryRefillState", ['order_id' => $order['order_id']]);
  166. } else {
  167. QueueClient::push("NotifyMerchantComplete", ['order_id' => $order['order_id'], 'manual' => true]);
  168. }
  169. }
  170. }
  171. elseif (in_array($oper_type, ['success', 'cancel', 'buyback'])) {
  172. $this->manual_record($orders, $oper_type, $order_ids, $_GET['bz']);
  173. }
  174. else {
  175. showMessage('手动操作类型错误');
  176. }
  177. showMessage('操作成功');
  178. }
  179. private function manual_record($orders, $oper_type, $order_ids, $bz)
  180. {
  181. $admininfo = $this->getAdminInfo();
  182. $bz = empty($bz) ? '' : $bz;
  183. $buyback_ids = function ($order_ids, $oper_type) {
  184. $buybacks = Model('refill_buyback')->getBuyBackList(['order_id' => ['in', $order_ids], 'manual_type' => $oper_type]);
  185. $buyback_ids = array_column($buybacks, 'order_id');
  186. $buyback_ids = $this->int_array($buyback_ids);
  187. return $this->unique_array($buyback_ids);
  188. };
  189. $format_item = function ($order, $oper_type, $admininfo, $cur_time, $bz)
  190. {
  191. return ['order_id' => $order['order_id'],
  192. 'order_sn' => $order['order_sn'],
  193. 'order_time' => $order['order_time'],
  194. 'notify_time' => $order['notify_time'],
  195. 'manual_type' => $oper_type,
  196. 'admin_id' => $admininfo['id'],
  197. 'admin_name' => $admininfo['name'],
  198. 'act_time' => $cur_time,
  199. 'bz' => $bz];
  200. };
  201. if($oper_type == 'buyback')
  202. {
  203. $mchids = array_column($orders, 'mchid');
  204. $mchids = $this->unique_array($mchids);
  205. $merchant_list = $this->merchants(['mchid' => ['in', $mchids]]);
  206. foreach ($merchant_list as $merchant) {
  207. $merchants[$merchant['mchid']] = $merchant;
  208. }
  209. $store_ids = array_column($orders, 'store_id');
  210. $store_ids = $this->unique_array($store_ids);
  211. $provider_list = $this->providers(['refill_provider.store_id' => ['in', $store_ids]]);
  212. foreach ($provider_list as $provider) {
  213. $providers[$provider['store_id']] = $provider;
  214. }
  215. }
  216. $mod_buyback = Model('refill_buyback');
  217. $buyback_ids = $buyback_ids($order_ids, $oper_type);
  218. $fetch_order_ids = $this->check_fetch_order($order_ids);
  219. $fetch_order_ids = $this->unique_array($fetch_order_ids);
  220. $cur_time = time();
  221. if($oper_type == 'buyback')
  222. {
  223. foreach ($orders as $order)
  224. {
  225. $order_id = intval($order['order_id']);
  226. if (algorithm::binary_search($buyback_ids, $order_id)) continue;
  227. $mchid = $order['mchid'];
  228. $merchant_info = $merchants[$mchid];
  229. $buyer_id = $order['buyer_id'];
  230. $store_id = $order['store_id'];
  231. $provider_info = $providers[$store_id];
  232. $account_id = $provider_info['account_id'];
  233. if (empty($mchid) || empty($buyer_id) || empty($store_id) || empty($account_id)) {
  234. Log::record("refill order manual err order_id:{$order_id}, order_sn:{$order['order_sn']}");
  235. continue;
  236. }
  237. try
  238. {
  239. $trans = new trans_wapper($mod_buyback, __METHOD__);
  240. $item = $mod_buyback->getOrder(['order_id' => $order_id, 'manual_type' => $oper_type], '*', true, true);
  241. if(!empty($item)) {
  242. $trans->commit();
  243. continue;
  244. }
  245. $insert_item = $format_item($order, $oper_type, $admininfo, $cur_time, $bz);
  246. $ret = $mod_buyback->insert($insert_item);
  247. if($ret)
  248. {
  249. $merchant_bz = "机构:{$mchid},订单号:{$order['mch_order']},卡号:{$order['card_no']},返销退款:{$order['mch_amount']}";
  250. $this->ct_refill_evidence(['mch_amount' => $order['mch_amount'], 'bz' => $merchant_bz], $merchant_info, $cur_time, $admininfo);
  251. $this->credit_save_money($order['mch_amount'], 'add', $buyer_id, $merchant_bz);
  252. }
  253. if($ret)
  254. {
  255. $provider_bz = "通道:{$store_id},椰子单号:{$order['order_sn']},卡号:{$order['card_no']},返销退款:{$order['channel_amount']}";
  256. $this->ct_provider_amount(['channel_amount' => $order['channel_amount']], $provider_info, $cur_time, $admininfo);
  257. $this->credit_save_money($order['channel_amount'], 'add', $account_id, $provider_bz);
  258. }
  259. $trans->commit();
  260. }
  261. catch (Exception $e) {
  262. $trans->rollback();
  263. Log::record("manual_record err: {$e->getMessage()}", Log::ERR);
  264. }
  265. }
  266. }
  267. else
  268. {
  269. foreach ($orders as $order)
  270. {
  271. $order_id = intval($order['order_id']);
  272. if (algorithm::binary_search($buyback_ids, $order_id)) continue;
  273. if (algorithm::binary_search($fetch_order_ids, $order_id)) continue;
  274. if ($oper_type == 'success') {
  275. refill\util::manual_success($order_id);
  276. } elseif ($oper_type == 'cancel') {
  277. refill\util::manual_cancel($order_id);
  278. } else {
  279. continue;
  280. }
  281. if (empty($bz)) {
  282. $bz = "批量处理页面,手动处理,操作人:{$admininfo['name']}";
  283. }
  284. $insert_item = $format_item($order, $oper_type, $admininfo, $cur_time, $bz);
  285. $ins[] = $insert_item;
  286. }
  287. if(!empty($ins)) {
  288. $mod_buyback->insertAll($ins);
  289. }
  290. }
  291. }
  292. public function set_cancel_orderOp()
  293. {
  294. $mod = Model('refill_order');
  295. $condition = [];
  296. $order_list = [];
  297. $mch_orderData = [];
  298. if(!empty($_GET['mchid'])) {
  299. $condition['mchid'] = $_GET['mchid'];
  300. }
  301. if (!empty($_GET['mch_orders'])) {
  302. $mch_orders = rtrim($_GET['mch_orders'],',');
  303. $condition['mch_order'] = ['in', $mch_orders];
  304. }
  305. $merchant_list = $this->merchants();
  306. if(!empty($condition)) {
  307. $condition['inner_status'] = 0;
  308. $order_list = $mod->getMerchantOrderList($condition, 200, 0,'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
  309. $order_list = $this->OrderDataFormat($order_list, $merchant_list);
  310. if(empty($mch_orders)) {
  311. $mch_orderData = [];
  312. }else{
  313. $mch_orderData = explode(',',$mch_orders);
  314. }
  315. foreach ($order_list as $order_id => $order) {
  316. $mch_order = $order['mch_order'];
  317. if(in_array($mch_order, $mch_orderData)) {
  318. $key = array_search($mch_order, $mch_orderData);
  319. unset($mch_orderData[$key]);
  320. }
  321. $order_list[$order_id]['can_cancel'] = $this->can_cancel_order($order);
  322. }
  323. }
  324. Tpl::output('noexist_mch_order', $mch_orderData);
  325. Tpl::output('merchant_list', $merchant_list);
  326. Tpl::output('list', $order_list);
  327. Tpl::output('show_page', $mod->showpage());
  328. Tpl::showpage('set.cancel.order');
  329. }
  330. public function order_cancel_disposeOp()
  331. {
  332. $order_id = $_GET['order_id'];
  333. $condition['refill_order.order_id'] = ['in',$order_id];
  334. $order_list = Model('refill_order')->getMerchantOrderList($condition,1000,0,'refill_order.*,vr_order.order_state');
  335. foreach ($order_list as $order) {
  336. if($this->can_cancel_order($order)) {
  337. $mchid = $order['mchid'];
  338. $mch_order = $order['mch_order'];
  339. refill\util::set_cancel_order($mchid,$mch_order);
  340. $this->log("拦截订单,订单号:{$order['order_sn']},商家单号:{$mch_order},机构编码:{$mchid}", 1);
  341. }
  342. }
  343. showMessage('操作成功');
  344. }
  345. private function can_cancel_order($order): bool
  346. {
  347. if($order['order_state'] == ORDER_STATE_SUCCESS) {
  348. return false;
  349. }
  350. if($order['order_state'] == ORDER_STATE_CANCEL && $order['is_retrying'] == 0) {
  351. return false;
  352. }
  353. return true;
  354. }
  355. public function refill_buybackOp()
  356. {
  357. $model_refill_order = Model('refill_order');
  358. $_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d 00:00:00");
  359. if (!empty($_GET['mchid'])) {
  360. $condition['refill_order.mchid'] = $_GET['mchid'];
  361. }
  362. if (!empty($_GET['store_id'])) {
  363. $condition['vr_order.store_id'] = $_GET['store_id'];
  364. }
  365. if(!empty($_GET['card_nos'])) {
  366. $card_nos = trim($_GET['card_nos'], ',');
  367. $condition['refill_order.card_no'] = ['in', $card_nos];
  368. }
  369. if(!empty($_GET['order_sns'])) {
  370. $order_sns = trim($_GET['order_sns'], ',');
  371. $condition['refill_order.order_sn'] = ['in', $order_sns];
  372. }
  373. if(!empty($_GET['manual_type']))
  374. {
  375. $condition['manual_type'] = $_GET['manual_type'];
  376. }
  377. $start = intval(strtotime($_GET['query_start_time']));
  378. $end = intval(strtotime($_GET['query_end_time']));
  379. if ($end <= 0) {
  380. $end = time();
  381. }
  382. $condition['refill_buyback.act_time'] = [['egt', $start], ['lt', $end], 'and'];
  383. $condition['inner_status'] = 0;
  384. if(!empty($_GET['export']))
  385. {
  386. $this->Export($condition);
  387. return;
  388. }
  389. $merchant_list = $this->merchants();
  390. $order_list = $model_refill_order->getBuyBackList($condition, 200, 'refill_buyback.*,refill_order.*,vr_order.order_state', 'refill_buyback.act_time desc','',true);
  391. $order_list = $this->OrderDataFormat($order_list, $merchant_list);
  392. $provider_list = $this->providers();
  393. Tpl::output('provider_list', $provider_list);
  394. Tpl::output('merchant_list', $merchant_list);
  395. Tpl::output('order_list', $order_list);
  396. Tpl::output('show_page', $model_refill_order->showpage());
  397. Tpl::showpage('refill.buyback.order');
  398. }
  399. private function int_array($sids): array
  400. {
  401. $result = [];
  402. foreach ($sids as $sid) {
  403. $result[] = intval($sid);
  404. }
  405. return $result;
  406. }
  407. private function unique_array($ids): array
  408. {
  409. $ids = array_unique($ids);
  410. sort($ids);
  411. return $ids;
  412. }
  413. private function ct_provider_amount($params, $provider_info, $cur_time, $admininfo)
  414. {
  415. $input['provider_id'] = $provider_info['provider_id'];
  416. $input['memeber_id'] = $provider_info['account_id'];
  417. $input['amount'] = $params['channel_amount'];
  418. $input['operation'] = $admininfo['name'];
  419. $input['add_time'] = $cur_time;
  420. return Model('provider_amount')->addAmount($input);
  421. }
  422. private function ct_refill_evidence($params, $merchant_info, $cur_time, $admininfo)
  423. {
  424. $mem_info = Model('member')->getMemberInfo(['member_id' => $merchant_info['admin_id']], '*', true);
  425. $input['mchid'] = $merchant_info['mchid'];
  426. $input['mch_name'] = $merchant_info['name'];
  427. $input['member_id'] = $merchant_info['admin_id'];
  428. $input['amount'] = $params['mch_amount'];
  429. $input['bank_username'] = '椰子';
  430. $input['bank_name'] = '椰子退款';
  431. $input['bz'] = $params['bz'];
  432. $input['voucher_name'] = '/';
  433. $input['status'] = 2;
  434. $input['is_operation'] = 2;
  435. $input['add_time'] = $input['check_time'] = $cur_time;
  436. $input['after_available'] = ncPriceFormat($mem_info['available_predeposit'] + $params['mch_amount']);
  437. $input['admin_name'] = $admininfo['name'];
  438. $input['admin_id'] = $admininfo['id'];
  439. $input['add_type'] = 3;
  440. return Model('merchant')->addRefillEvidence($input);
  441. }
  442. private function Export($cond)
  443. {
  444. $result = Model('refill_order')->getAllBuyBackOrders($cond);
  445. $this->createExcel($result);
  446. }
  447. private function createExcel($data = [])
  448. {
  449. $merchant_list = $this->merchants();
  450. foreach ($merchant_list as $value) {
  451. $merchants[$value['mchid']] = $value;
  452. }
  453. Language::read('export');
  454. import('libraries.excel');
  455. $excel_obj = new Excel();
  456. $excel_data = [];
  457. //设置样式
  458. $excel_obj->setStyle(['id' => 's_title', 'Font' => ['FontName' => '宋体', 'Size' => '12', 'Bold' => '1']]);
  459. //header
  460. $excel_data[0][] = ['styleid' => 's_title', 'data' => '编号'];
  461. $excel_data[0][] = ['styleid' => 's_title', 'data' => '操作日期'];
  462. $excel_data[0][] = ['styleid' => 's_title', 'data' => '订单号'];
  463. $excel_data[0][] = ['styleid' => 's_title', 'data' => '机构编号'];
  464. $excel_data[0][] = ['styleid' => 's_title', 'data' => '机构名称'];
  465. $excel_data[0][] = ['styleid' => 's_title', 'data' => '充值卡号'];
  466. $excel_data[0][] = ['styleid' => 's_title', 'data' => '充值卡类型'];
  467. $excel_data[0][] = ['styleid' => 's_title', 'data' => '充值额度'];
  468. $excel_data[0][] = ['styleid' => 's_title', 'data' => '折扣后金额'];
  469. $excel_data[0][] = ['styleid' => 's_title', 'data' => '下单日期'];
  470. $excel_data[0][] = ['styleid' => 's_title', 'data' => '订单状态'];
  471. $excel_data[0][] = ['styleid' => 's_title', 'data' => '渠道单号'];
  472. $excel_data[0][] = ['styleid' => 's_title', 'data' => '渠道名称'];
  473. $excel_data[0][] = ['styleid' => 's_title', 'data' => '折后金额'];
  474. $excel_data[0][] = ['styleid' => 's_title', 'data' => '操作类型'];
  475. $excel_data[0][] = ['styleid' => 's_title', 'data' => '操作人'];
  476. $excel_data[0][] = ['styleid' => 's_title', 'data' => '备注'];
  477. //data
  478. foreach ((array)$data as $k => $v) {
  479. $tmp = [];
  480. $tmp[] = ['data' => $k+1];
  481. if (empty($v['act_time'])) {
  482. $tmp[] = ['data' => ''];
  483. } else {
  484. $tmp[] = ['data' => date('Y-m-d H:i:s', $v['act_time'])];
  485. }
  486. $tmp[] = ['data' => $v['order_sn']];
  487. $tmp[] = ['data' => $v['mchid']];
  488. $tmp[] = ['data' => $merchants[$v['mchid']]['company_name']];
  489. $tmp[] = ['data' => $v['card_no']];
  490. $tmp[] = ['data' => $this->scard_type($v['card_type'])];
  491. $tmp[] = ['data' => $v['refill_amount']];
  492. $tmp[] = ['data' => $v['mch_amount']];
  493. $tmp[] = ['data' => date('Y-m-d H:i:s', $v['order_time'])];
  494. $tmp[] = ['data' => orderState($v)];
  495. $tmp[] = ['data' => $v['ch_trade_no']];
  496. $tmp[] = ['data' => $v['channel_name']];
  497. $tmp[] = ['data' => $v['channel_amount']];
  498. $tmp[] = ['data' => $v['manual_type']];
  499. $tmp[] = ['data' => $v['admin_name']];
  500. $tmp[] = ['data' => $v['bz']];
  501. $excel_data[] = $tmp;
  502. }
  503. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  504. $excel_obj->addArray($excel_data);
  505. $excel_obj->addWorksheet($excel_obj->charset(L('exp_od_order'), CHARSET));
  506. $excel_obj->generateXML('返销导出' . date('Y-m-d-H', time()));
  507. }
  508. }