services->events->dispatch($event, $order, $event->listeners); exit; $data = []; (new \addons\AgentBase\common\listeners\order\OrderPayRewardListener())->handleSync($data); // $ids = [798155,797417,784601,756116,580755]; $ids = [380140,380141,380142,380143,380144]; $mall_id = 26; $supply_id = 20; $api = ApiService::getConnect($mall_id, $supply_id); // id转Int $ids = array_map(function ($v) { return (int) $v; }, $ids); // 商品详情 $result = $api->getGoodsInfo($ids); $list = current($result); if(!empty($list)){ $getIds = array_column($list, 'id'); $pull_ids = array_diff($ids, $getIds); }else{ $pull_ids = $ids; } if(!empty($list)){ foreach ($list as $detail) { if(!empty($detail)){ // 商品存在 if ($detail['is_display'] == 0) { // 商品存在且下架 $pull_ids[] = $detail['id']; } } } } if($pull_ids){ var_dump($pull_ids); return; // 商城商品下架 StorageService::mallGoodsPull($pull_ids); // 执行商品下架 GoodsModel::GoodsPullByMiddleIds($pull_ids); } } public function actionFf() { $batchSize = 100; // 每次处理100条 $executionsPerMinute = 10; // 每分钟执行10次 $totalMinutes = 10; // 总运行时间(分钟),按需调整 // 获取所有商城 $supplysList = SupplysModel::find()->where(['mall_id' => 26])->asArray()->all(); // 外层循环:控制总运行时间(分钟) for ($minute = 0; $minute < $totalMinutes; $minute++) { $minuteStartTime = time(); // 内层循环:每分钟执行10次 for ($execution = 0; $execution < $executionsPerMinute; $execution++) { $executionStartTime = microtime(true); // 遍历每个商城 foreach ($supplysList as $mall) { // 计算当前分页偏移量 $offset = ($minute * $executionsPerMinute + $execution) * $batchSize; // 查询当前批次的100条数据 $data = StorageModel::find()->where(['mall_id' => $mall['mall_id']])->orderBy('id ASC')->offset($offset)->limit($batchSize)->asArray()->all(); if (empty($data)) { continue; // 该商城无更多数据 } // 处理当前批次(保持你的原有逻辑) $this->processBatch($mall, $data); } // 确保每次执行间隔6秒(控制每分钟10次) $executionTime = microtime(true) - $executionStartTime; $sleepTime = max(0, 6 - $executionTime); usleep($sleepTime * 1000000); // 微秒级等待 } // 确保每分钟刚好60秒 $elapsed = time() - $minuteStartTime; if ($elapsed < 60) { sleep(60 - $elapsed); } } } private function processBatch($mall, $data) { $ids = array_column($data, 'middle_goods_id'); // id转Int $ids = array_map(function ($v) { return (int) $v; }, $ids); $api = ApiService::getConnect($mall['mall_id'], $mall['id']); // 调用API获取商品详情 $result = $api->getGoodsInfo($ids); if(!empty($result)){ $list = current($result); if(!empty($list)){ $getIds = array_column($list, 'id'); $pull_ids = array_diff($ids, $getIds); } }else{ $pull_ids = $ids; } if (!empty($list)) { foreach ($list as $detail) { if(!empty($detail)){ // 商品存在 if ($detail['is_display'] == 0) { // 商品存在且下架 $pull_ids[] = $detail['id']; } } } } if($pull_ids){ var_dump($pull_ids); return; // 商城商品下架 StorageService::mallGoodsPull($pull_ids); // 执行商品下架 GoodsModel::GoodsPullByMiddleIds($pull_ids); } } public function actionDd(){ $order_sn = Order::find()->where(['mall_id' => 16])->andWhere(['status' => 1])->andWhere(['order_status' => 1])->asArray()->all(); foreach($order_sn as $v){ var_dump($v['order_no']); $params = [ "data" => [ "message_code" => 0, "order_sn" => $v['order_no'], "message_type" => "order.delivery", "member_sign" => "6ead81e2e999b24fcb6faf47e6cf2273", "message_id" => "selfb3JkZXJzMjAyNTAzMzEwODI5MjkxMDgzNzhvcmRlci5kZWxpdmVyeTE3NDM0MTczMzE=" ], "method" => "order_delivery", "supplys_id" => "11" ]; \addons\QiJuhe\common\service\NoticeHandleService::handle($params); } } public function actionBb(){ $params = [ "data" => [ "message_code" => 0, "order_sn" => "s20250329212945270941", "message_type" => "order.delivery", "member_sign" => "6ead81e2e999b24fcb6faf47e6cf2273", "message_id" => "selfb3JkZXJzMjAyNTAzMzEwODI5MjkxMDgzNzhvcmRlci5kZWxpdmVyeTE3NDM0MTczMzE=" ], "method" => "order_delivery", "supplys_id" => "11" ]; \addons\QiJuhe\common\service\NoticeHandleService::handle($params); } public function actionAgentCommission() { $json = '{"data":{"id":843,"mch_id":0,"mall_id":5,"user_id":3,"order_no":"s202111171513073911817606","out_trade_no":"","mobile":"17781115894","province":2,"city":3,"area":4,"address":"ssaasdsai","region_name":"北京市 北京市 东城区 东四街道","zip":"","receiver_name":"bing","remark":"","seller_remark":"","shipping_type":1,"shipping_money":"0.00","refund_money":"0.00","pay_money":"1200.00","goods_price":"1200.00","original_goods_price":"1200.00","ip":"","coupon_id":0,"coupon_money":"0.00","score":0,"score_money":"0.00","order_status":1,"pay_status":1,"shipping_status":0,"review_status":0,"is_feedback":0,"payment_type":5,"marketing_id":0,"marketing_type":"0","invoice_id":null,"status":1,"is_comment":0,"is_recycle":0,"is_virtual":0,"is_new_user":0,"pay_time":1637133317,"shipping_time":0,"sign_time":0,"consign_time":0,"finish_time":0,"close_time":0,"created_at":1637133187,"updated_at":1637133317,"operator_id":"","operator_name":""}}'; $data = json_decode($json, true); $listener = new OrderPayRewardListener(); $listener->handleSync($data['data']); } public function actionIndex() { $event = new OrderPaidEvent(1); $order['id'] = 1964; \Yii::$app->services->events->dispatch($event, $order, $event->listeners); } public function actionFixOrderUnread(){ ini_set ("memory_limit","-1"); $mall_list = Mall::getEnableMallList(true); foreach ($mall_list as $mall) { $where = ['mall_id' => $mall['id']]; foreach (User::find()->where($where)->each(500) as $user_info){ OrderUnreadMsg::updateData($user_info['mall_id'],$user_info['id']); } } echo 'success'; } public function actionG(){ $mall_id = 1; $user_list = User::lists([ 'where' => [['mall_id' => $mall_id], ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]], 'select' => 'id' ]); foreach($user_list as $user){ $res = UserInviteCode::setData([ 'mall_id' => $mall_id, 'user_id' => $user['id'], ]); if($res === false){ \Yii::error('err://id:'.$user['id'].'//msg:'.UserInviteCode::getStaticError()); } } } public function actionQ() { $order = Order::getOne([['id' => 12016]], true, ['detail']); // 触发条件升级 $cond_upgrade = new ConditionUpgrade(); $cond_upgrade->execute(ServicePointAppointmentEnums::ADDONS_NAME, (new ServicePointUser()), (new ServicePointLevel()), $order); } public function actionLinggong() { $data = [ 'mall_id' => '959', 'id' => 1550, 'settlementInfoId' => '557bde439951b7e035d93010042bfbef', ]; $res = (new \addons\Linggong\common\service\WithdrawService())->handlePay($data); print_r($res);exit; } public function actionTest() { $data = [ 'id' => 71884, ]; $res = (new \common\listeners\user\UserUpgradeListener())->handleSync($data); print_r($res);exit; } }