123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <?php declare(strict_types=1);
- use PHPUnit\Framework\TestCase;
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/1/13
- * Time: 下午11:46
- */
- define('APP_ID','test');
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/global.php');
- require_once(BASE_CORE_PATH . '/lrlz.php');
- require_once (BASE_ROOT_PATH . '/fooder.php');
- require_once (BASE_ROOT_PATH . '/helper/util_helper.php');
- require_once (BASE_ROOT_PATH . '/helper/order_helper.php');
- class TestOrder extends TestCase
- {
- public static function setUpBeforeClass() : void
- {
- Base::run_util();
- }
- public static function tearDownAfterClass() : void
- {
- }
- public function testCancelOms()
- {
- $oms = Logic('delivery');
- $oms->cancel_order('9000000002963603');
- }
- public static function testSuccess()
- {
- $model_order = Model('order');
- $logic_order = Logic('order');
- $condition = array();
- $condition['order_state'] = ORDER_STATE_SEND;
- $condition['lock_state'] = 0;
- //$condition['delay_time'] = array('lt',time() - ORDER_AUTO_RECEIVE_DAY * 86400);
- $condition['order_id'] = 6591;
- //分批,每批处理100个订单,最多处理5W个订单
- $order_list = $model_order->getOrderList($condition, '', '*', 'delay_time asc', 100);
- foreach ($order_list as $order_info) {
- $result = $logic_order->changeOrderStateReceive($order_info,'system','系统','超期未收货系统自动完成订单');
- }
- }
- public function testSend()
- {
- $order_sn = '9000000001035202';
- $status = 1;
- $consign_time = '2017-01-15 18:07:05.0';
- $logistics_no = '3322415835338';
- $logistics_company = '申通快递';
- $express = Model('express')->field('id')->where(array('e_name' => $logistics_company))->select();
- if (empty($express) || count($express) == 0) {
- echo 'FAIL';
- return;
- }
- $express_id = $express[0]['id'];
- $time = strtotime($consign_time);
- }
- public function testInitOrder()
- {
- $mod_member = Model('member');
- $i = 0;
- while (true)
- {
- $start = $i * 1000;
- $items = Model()->table('member')->field('member_id')->order('member_id asc')->limit("{$start},1000")->select();
- if(empty($items)) {
- return;
- }
- $i++;
- foreach ($items as $item)
- {
- $member_id = intval($item['member_id']);
- if($member_id <= 0) continue;
- $result = $this->stat_order($member_id);
- if($result == false) continue;
- $order_num = intval($result['order_num']);
- $lasted_time = intval($result['lastest_time']);
- $mod_member->editMember(['member_id' => $member_id],['order_num' => $order_num,'lastest_order' => $lasted_time]);
- }
- }
- }
- private function stat_order($member_id)
- {
- $items = Model()->table('order')
- ->field('count(*) as order_num,max(payment_time) lastest_time')
- ->where(['buyer_id' => $member_id,'order_state' => ['in',[20,30,40]]])
- ->select();
- if(empty($items)) {
- return false;
- }
- elseif($items[0]['order_num'] == 0){
- return false;
- } else {
- return $items[0];
- }
- }
- public function testMemberOrder()
- {
- $mod_member = Model('member');
- $this->mStartm = strtotime(date('Y-m-d',time()));
- $this->mEndtm = $this->mStartm + 86400 - 1;
- $cond['payment_time'] = ['between',"{$this->mStartm},{$this->mEndtm}"];
- $cond['order_state'] = array('in',[20,30,40]);
- $i = 0;
- while (true)
- {
- $start = $i * 1000;
- $items = Model()->table('order')->field('buyer_id,payment_time')->where($cond)->order('payment_time asc')->limit("{$start},1000")->select();
- if(empty($items)) {
- return;
- }
- $i++;
- foreach ($items as $item)
- {
- $member_id = intval($item['buyer_id']);
- if($member_id <= 0) continue;
- $payment_time = intval($item['payment_time']);
- if($payment_time <= 0) continue;
- $mod_member->editMember(['member_id' => $member_id],['order_num' => ['exp', 'order_num+1'],'lastest_order' => $payment_time]);
- }
- }
- }
- public function testStatCall()
- {
- $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;}';
- $y = unserialize($x);
- $x = json_encode($y);
- $x = json_decode($x,true);
- }
- public function testBonusRate()
- {
- $data = 'a:2:{i:50;d:5.1799999999999997;i:30;d:17.59;}';
- $x = unserialize($data);
- }
- public function testRefund()
- {
- //SELECT * FROM lrlz_order WHERE add_time > UNIX_TIMESTAMP(DATE ('2017-09-28 00:00:00')) AND order_state = 0;
- $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');
- foreach ($items as $item) {
- $order_sn = $item['order_sn'];
- $member_id = intval($item['buyer_id']);
- account_helper::order_cancel($order_sn,$member_id,true);
- }
- }
- ////
- public function testVOrder()
- {
- $model_vr_order = Model('vr_order');
- $order_list = $model_vr_order->getOrderList(['order_id' => 1]);
- $page_count = $model_vr_order->gettotalpage();
- $helper = new vorder_helper($order_list);
- $result = $helper->format();
- }
- public function testUpdateVOrder()
- {
- $order_sn = '730652395243593640';
- $payer = new pay_helper($order_sn);
- $trade_no = '730510765598547589';
- $cb_info = $payer->update_order($trade_no,'wxpay');
- }
- public function testBonusAmount()
- {
- $mod_order = Model('order');
- $i = 0;
- while (true)
- {
- $start = $i * 1000;
- $items = $mod_order->table('order')->field('*')->order('order_id asc')->limit("{$start},1000")->select();
- if(empty($items)) {
- return;
- }
- $i++;
- foreach ($items as $item)
- {
- $order_id = intval($item['order_id']);
- $pd_amount = intval($item['pd_amount'] * 100 + 0.5);
- $bonus_rate = unserialize($item['bonus_rate']);
- $bonus_amount = unserialize($item['bonus_amount']);
- if($bonus_amount != false) continue;
- $data = [];
- if($bonus_rate != false)
- {
- $amount = 0;
- foreach ($bonus_rate as $rate => $money) {
- $amount += $money;
- }
- $data['bonus_amount'] = serialize(['user_bonus' => $amount]);
- }
- elseif($pd_amount > 0) {
- $data['bonus_amount'] = serialize(['user_bonus' => $pd_amount / 100]);
- }
- else {
- }
- $data['bonus_rate'] = '';
- $data['pd_amount'] = 0.00;
- $mod_order->editOrder($data,['order_id' => $order_id]);
- }
- }
- }
- public function testQueryOrder()
- {
- $delivery = Logic('delivery');
- $order_sn = '2000000004387603';
- $status = $delivery->query_order($order_sn);
- $time = $status->send_time();
- }
- public function testCancelOrder()
- {
- $delivery = Logic('delivery');
- $order_sn = '2000000004385101';
- $status = $delivery->cancel_order($order_sn);
- }
- }
|