field('card_no,using_times')->where(['card_no' => ['gt', $start], 'card_type' => 4])->limit("0,1000")->select(); if (empty($items)) { break; } foreach ($items as $item) { $card_no = $item['card_no']; $start = $card_no; $using_times = $item['using_times'] + 1; fputcsv($fcards, [$card_no,$using_times]); } } fclose($fcards); } public function testInit_reward() { $mod_member = Model('member'); $i = 0; while (true) { $start = $i * 1000; $items = $mod_member->field('member_id')->order('member_id asc')->limit("{$start},1000")->select(); if(empty($items)) { return; } $i++; foreach ($items as $item) { $user = intval($item['member_id']); if($user <= 0) continue; $val = $mod_member->field('count(*) inviter_count' )->where(['inviter_id' => $user])->select(); $invitees = intval($val[0]['inviter_count']); if($invitees <= 0) continue; $ret = $mod_member->editMember(['member_id' => $user],['invitees' => $invitees,'reward_amount' => $invitees * 30]); if($ret == false) { Log::record("update member_id = {$user} invitees and reward",Log::ERR); } } } } public function testLowestPrice() { Log::record(__METHOD__ . " start",Log::DEBUG); $mod_goods = Model('goods'); $path = BASE_DATA_PATH . '/mobile/lowest_price.txt'; $file = fopen($path,'r'); $i = 0; while (!feof($file)) { $line = fgets($file); $line = trim($line); $datas = explode("\t",$line); if(count($datas) == 3) { $goods_id = intval($datas[0]); $goods_price = intval($datas[1] * 100 + 0.5) / 100; $lowest_price = intval($datas[2] * 100 + 0.5) / 100; $result = $mod_goods->editGoods(['goods_marketprice' => $goods_price,'goods_price' => $goods_price,'goods_lowest_price' => $lowest_price],['goods_id' => $goods_id]); if($result == false) { Log::record("update goods_id = {$goods_id}",Log::ERR); } } else { Log::record("update err line ={$i}",Log::ERR); } $i++; } fclose($file); Log::record(__METHOD__ . " end",Log::DEBUG); } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestCommand::testQueryRefund)( .*)?$/" --test-suffix TestCommand.php /var/www/html/test public function testQueryRefund() { QueueClient::push("QueryRefund", ['order_id' => 8987841]); } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestCommand::testQueryAllRefund)( .*)?$/" --test-suffix TestCommand.php /var/www/html/test public function testQueryAllRefund() { $mod = Model(); $start = 0; $inter = 0; while (true) { $cond = ['inner_status' => 0, 'order_state' => ORDER_STATE_SUCCESS, 'vr_order.order_id' => ['gt', $start], 'store_id' => 33, 'order_time' => ['lt', strtotime("2023-05-24 18:00:00")] ]; $items = $mod->table('refill_order,vr_order') ->field('refill_order.order_id') ->where($cond) ->join('inner')->on('refill_order.order_id=vr_order.order_id') ->limit("0,100") ->select(); if(empty($items)) break; $inter += 1; foreach ($items as $item) { $order_id = intval($item['order_id']); $start = $order_id; QueueClient::async_push("QueryRefund", ['order_id' => $order_id],$inter); } } } }