member_id); $usercards->addCard(['card_type' => mcard\BothType, 'total_amount' => 10000, 'discount' => 0.05, 'package_type' => 'year']); } public function testDeduct() { $usercards = new mcard\user_mcards(36490); $amounts = [3000, 5000, 200, 100, 200, 2000, 1000]; foreach ($amounts as $amount) { if ($usercards->enough($amount)) { $usercards->deduct($amount); Log::record("Consume {$amount}."); } else { Log::record("Not enough money {$amount}."); } } } public function testAddTopCard() { $cards = new mtopcard\user_topcards($this->member_id); $cards->addCard('1000111100020445281', mtopcard\PetroChinaCard); $cards->addMoney(0, 1000); $cards->addMoney(0, 1000); $cards->addMoney(0, 1000); $ret = $cards->cards_format(); } public function testAddCardKeys() { $params = [ ['card_type' => mtopcard\OilCardPaper, 'amount' => 100], ['card_type' => mtopcard\OilCardPaper, 'amount' => 200], ['card_type' => mtopcard\OilCardPaper, 'amount' => 500], ['card_type' => mtopcard\OilCardPaper, 'amount' => 1000], ['card_type' => mtopcard\PhoneCardPaper, 'amount' => 100], ]; $car_no = '1900000000000000'; $count = 10; $mod_card = Model('card_key'); foreach ($params as $item) { for($i= 0; $i < $count; $i++) { $mod_card->addCard(['card_no' => $car_no,'card_key' => 'm8i094k4t8n8','card_type' => $item['card_type'],'amount' => $item['amount']]); $car_no += 1; } } } public function testAddCardKeysLocal() { $params = [ ['card_type' => mtopcard\OilCardPaper, 'amount' => 100], ['card_type' => mtopcard\OilCardPaper, 'amount' => 200], ['card_type' => mtopcard\PhoneCardPaper, 'amount' => 100], ['card_type' => mtopcard\PhoneCardPaper, 'amount' => 200] ]; $car_no = '1900000000000000'; $count = 10; $mod_card = Model('card_key'); foreach ($params as $item) { for($i= 0; $i < $count; $i++) { $mod_card->addCard(['card_no' => $car_no,'card_key' => 'm8i094k4t8n8','card_type' => $item['card_type'],'amount' => $item['amount']]); $car_no += 1; } } } public function testReserve() { $amount = 1000; $card = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard); mtopcard\cards_helper::assign(1,'xiongmao'); mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,1000,35268,'xxxyyyzzzkkkdj',mtopcard\PetroChinaCard); mtopcard\cards_helper::reuse(4); } public function testOnVrOrderSuccess() { $logic = Logic('queue'); $logic->OnVrOrderSuccess(['order_sn' => '920648515867397620']); } public function testOnVrOrderCancel() { $logic = Logic('queue'); $logic->OnVrOrderCancel(['order_sn' => '510649439049587625']); } public function testVOrderPaidSuccess() { $logic = Logic('queue'); $logic->OnVrOrderPaidSuccess(['order_sn' => '530649437595131625']); } //测试购买会员,成功支付,改变用户会员属性,修改状态. public function testPaidVOrderSuccess() { $order_sn = '530649437595131625'; $trade_no = '730510765598547599'; $payer = new pay_helper($order_sn); $payer->update_order($trade_no,'wxpay'); } public function testOnVrOrderComplete() { $order_sn = '260649436354923625'; $logic = Logic('queue'); $logic->OnVrOrderComplete(['order_sn' => $order_sn]); } //测试购买会员 public function testMcardOrderSucess() { $logic = Logic('queue'); $logic->OnMCardPaidSuccess(['order_sn' => '580648112029501620']); } public function testExtraInfo() { $order_sn = '920648515867397620'; $model_order = Model('vr_order'); $order = $model_order->getOrderInfo(['order_sn' => $order_sn]); vrorder_helper::extend_order_info($order); } public function testStrict() { } }