TestOrder.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/1/13
  6. * Time: 下午11:46
  7. */
  8. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  9. require_once (BASE_ROOT_PATH . '/fooder.php');
  10. require_once (BASE_ROOT_PATH . '/helper/util_helper.php');
  11. class TestOrder extends PHPUnit_Framework_TestCase
  12. {
  13. public static function setUpBeforeClass()
  14. {
  15. Base::run_util();
  16. }
  17. public static function tearDownAfterClass()
  18. {
  19. }
  20. public function testCancelOms()
  21. {
  22. $oms = Logic('delivery');
  23. $oms->cancel_oms('9000000002010310');
  24. }
  25. public static function testSuccess()
  26. {
  27. $model_order = Model('order');
  28. $logic_order = Logic('order');
  29. $condition = array();
  30. $condition['order_state'] = ORDER_STATE_SEND;
  31. $condition['lock_state'] = 0;
  32. //$condition['delay_time'] = array('lt',time() - ORDER_AUTO_RECEIVE_DAY * 86400);
  33. $condition['order_id'] = 6370;
  34. //分批,每批处理100个订单,最多处理5W个订单
  35. $order_list = $model_order->getOrderList($condition, '', '*', 'delay_time asc', 100);
  36. foreach ($order_list as $order_info) {
  37. $result = $logic_order->changeOrderStateReceive($order_info,'system','系统','超期未收货系统自动完成订单');
  38. }
  39. }
  40. public function testSend()
  41. {
  42. $order_sn = '9000000001035202';
  43. $status = 1;
  44. $consign_time = '2017-01-15 18:07:05.0';
  45. $logistics_no = '3322415835338';
  46. $logistics_company = '申通快递';
  47. $express = Model('express')->field('id')->where(array('e_name' => $logistics_company))->select();
  48. if (empty($express) || count($express) == 0) {
  49. echo 'FAIL';
  50. return;
  51. }
  52. $express_id = $express[0]['id'];
  53. $time = strtotime($consign_time);
  54. }
  55. public function testInitOrder()
  56. {
  57. $mod_member = Model('member');
  58. $i = 0;
  59. while (true)
  60. {
  61. $start = $i * 1000;
  62. $items = Model()->table('member')->field('member_id')->order('member_id asc')->limit("{$start},1000")->select();
  63. if(empty($items)) {
  64. return;
  65. }
  66. $i++;
  67. foreach ($items as $item)
  68. {
  69. $member_id = intval($item['member_id']);
  70. if($member_id <= 0) continue;
  71. $result = $this->stat_order($member_id);
  72. if($result == false) continue;
  73. $order_num = intval($result['order_num']);
  74. $lasted_time = intval($result['lastest_time']);
  75. $mod_member->editMember(['member_id' => $member_id],['order_num' => $order_num,'lastest_order' => $lasted_time]);
  76. }
  77. }
  78. }
  79. private function stat_order($member_id)
  80. {
  81. $items = Model()->table('order')
  82. ->field('count(*) as order_num,max(payment_time) lastest_time')
  83. ->where(['buyer_id' => $member_id,'order_state' => array('in',[20,30,40])])
  84. ->select();
  85. if(empty($items)) {
  86. return false;
  87. }
  88. else
  89. {
  90. if($items[0]['order_num'] == 0){
  91. return false;
  92. } else {
  93. return $items[0];
  94. }
  95. }
  96. }
  97. public function testMemberOrder()
  98. {
  99. $mod_member = Model('member');
  100. $this->mStartm = strtotime(date('Y-m-d',time()));
  101. $this->mEndtm = $this->mStartm + 86400 - 1;
  102. $cond['payment_time'] = ['between',"{$this->mStartm},{$this->mEndtm}"];
  103. $cond['order_state'] = array('in',[20,30,40]);
  104. $i = 0;
  105. while (true)
  106. {
  107. $start = $i * 1000;
  108. $items = Model()->table('order')->field('buyer_id,payment_time')->where($cond)->order('payment_time asc')->limit("{$start},1000")->select();
  109. if(empty($items)) {
  110. return;
  111. }
  112. $i++;
  113. foreach ($items as $item)
  114. {
  115. $member_id = intval($item['buyer_id']);
  116. if($member_id <= 0) continue;
  117. $payment_time = intval($item['payment_time']);
  118. if($payment_time <= 0) continue;
  119. $mod_member->editMember(['member_id' => $member_id],['order_num' => array('exp', 'order_num+1'),'lastest_order' => $payment_time]);
  120. }
  121. }
  122. }
  123. public function testStatCall()
  124. {
  125. $x = 'a:4:{s:8:"function";a:16:{s:10:"app_update";a:2:{s:13:"check_version";a:1:{s:5:"count";i:7;}s:4:"area";a:1:{s:5:"count";i:7;}}s:6:"config";a:1:{s:11:"getconfigex";a:1:{s:5:"count";i:9;}}s:11:"member_info";a:2:{s:3:"get";a:1:{s:5:"count";i:7;}s:4:"edit";a:1:{s:5:"count";i:1;}}s:7:"special";a:1:{s:5:"index";a:1:{s:5:"count";i:10;}}s:5:"index";a:2:{s:6:"splash";a:1:{s:5:"count";i:8;}s:4:"tabs";a:1:{s:5:"count";i:8;}}s:5:"login";a:1:{s:6:"status";a:1:{s:5:"count";i:8;}}s:12:"member_order";a:1:{s:15:"orderCountState";a:1:{s:5:"count";i:5;}}s:12:"member_bonus";a:1:{s:5:"topup";a:1:{s:5:"count";i:16;}}s:13:"member_logout";a:1:{s:5:"index";a:1:{s:5:"count";i:2;}}s:14:"member_address";a:1:{s:12:"address_list";a:1:{s:5:"count";i:1;}}s:7:"bonusex";a:1:{s:4:"open";a:1:{s:5:"count";i:2;}}s:6:"search";a:3:{s:13:"suggest_words";a:1:{s:5:"count";i:4;}s:5:"index";a:1:{s:5:"count";i:7;}s:7:"history";a:1:{s:5:"count";i:1;}}s:12:"goods_common";a:1:{s:5:"index";a:1:{s:5:"count";i:2;}}s:5:"fcode";a:2:{s:5:"index";a:1:{s:5:"count";i:4;}s:4:"open";a:1:{s:5:"count";i:4;}}s:5:"mshop";a:1:{s:7:"signurl";a:1:{s:5:"count";i:3;}}s:4:"cart";a:2:{s:5:"addex";a:1:{s:5:"count";i:1;}s:10:"rate_money";a:1:{s:5:"count";i:1;}}}s:5:"other";a:3:{s:10:"goods_4919";a:1:{s:5:"count";i:1;}s:10:"goods_6212";a:1:{s:5:"count";i:1;}s:11:"special_466";a:1:{s:5:"count";i:1;}}s:9:"app_count";i:107;s:9:"wap_count";i:11;}';
  126. $y = unserialize($x);
  127. $x = json_encode($y);
  128. $x = json_decode($x,true);
  129. }
  130. public function testBonusRate()
  131. {
  132. $data = 'a:2:{i:50;d:5.1799999999999997;i:30;d:17.59;}';
  133. $x = unserialize($data);
  134. }
  135. public function testRefund()
  136. {
  137. //SELECT * FROM lrlz_order WHERE add_time > UNIX_TIMESTAMP(DATE ('2017-09-28 00:00:00')) AND order_state = 0;
  138. $items = Model()->query('SELECT * FROM lrlz_order WHERE pd_amount=0 AND LENGTH(bonus_rate) > 0 AND add_time > UNIX_TIMESTAMP(DATE (\'2017-09-01 00:00:00\')) AND order_state = 0');
  139. foreach ($items as $item) {
  140. $order_sn = $item['order_sn'];
  141. $member_id = intval($item['buyer_id']);
  142. account_helper::order_cancel($order_sn,$member_id,true);
  143. }
  144. }
  145. }