invoice_mailer->compose(); $emailSendHandle->setTo($mail); $emailSendHandle->setTextBody('深圳下大雨了 delete'); $emailSendHandle->setSubject('深圳下大雨了 subject ....'); $result = $emailSendHandle->send(); echo $result ."\r\n"; } */ //$str = "2018-09-04 09:00:00"; //$result = DeviceSearch::splitText('[沧田中]税]x金典'); //print_r($result); //echo round('33.1',0); //echo Deduction::coverInt(0.9); //$returnArr = Deduction::randomUserTag(9, 4); //shuffle($returnArr); //print_r($returnArr); //echo sprintf('%d', 2.00); } public function actionBindPhone() { $numbers = PrivateNumber::getAllPrivateNumbers(); $result = PrivateNumber::bindNumber( '17724017057','17004894899'); //echo PrivateNumber::$postResponseStr; echo "\r\n"; echo $result; } public function actionBatchBindPhone() { $query = new Query(); $query->from("jwx_engineer"); $query->select("id, mobile"); $query->offset(0); $query->orderBy("id asc"); $query->limit(810); $engineers = $query->all(); $engineerLen = count($engineers); $pair = (int)$engineerLen /2; $st = time(); echo 'start:'.$st; echo "\r\n"; $redis = \yii::$app->redis; $count = 0; for($i = 0; $i < $pair; $i++) { $j = $pair + $i; $rKey = 'mobile_'.$engineers[$i]['mobile']."__". $engineers[$j]['mobile']; //$redis->del($rKey); $result = PrivateNumber::bindNumber($engineers[$i]['mobile'], $engineers[$j]['mobile']); //$redis->set($rKey,$result); $resultJson = json_decode($result); if ( '000000' == $resultJson->code) { $count++; } echo $rKey; echo $result ."\r\n"; } echo "pair:".$pair; echo "\r\n"; $et = time(); echo 'end:'.$et; echo "\r\n"; echo "t:".($et - $st); echo "\r\n"; echo "ok:".$count; echo "\r\n"; } public function actionBatchUnbindPhone() { $ids = [269,301,314,316,320,322,330,339,344,345,350,369,378,380]; $privateNumberRecordModel = PrivateNumberBindRecord::find(); $privateNumberRecordModel->where(['id' => $ids]); $privateNumberRecordModel->asArray(); $records = $privateNumberRecordModel->all(); $tt = time(); foreach($records as $record){ $recordModel = PrivateNumberBindRecord::findOne($record['id']); if($recordModel) { //$result = PrivateNumber::unbindNumber($record['subscription_id'], 2); //echo $result. "\r\n"; //$recordModel->status = 0; //$recordModel->is_main = 2; $recordModel->unbind_at = $tt; $recordModel->unbind_desc = '超时手动解绑'; $result2 = $recordModel->save(); echo "result:". $result2. '__'; echo $recordModel->subscription_id. "\r\n"; } } } public function actionAna() { $redis = \yii::$app->redis; $records = $redis->hgetall('mobile*'); print_r($records); } public function actionUnbindPhone() { $subscriptionId = '17150372466'; //8617150372466 17150372300 $result = PrivateNumber::unbindNumber($subscriptionId, 1); //echo PrivateNumber::$postResponseStr; echo "\r\n"; echo $result; } public function actionQueryPhone() { $numbers = PrivateNumber::getAllPrivateNumbers(); $result = PrivateNumber::queryOrderedNumber('17150372300'); echo $result; } public function actionQueryVoiceRecord() { $subscribeId = '66053756068216559371537933854093'; $st = PrivateNumber::coverTimeStampToPHP('2018-09-26T03:46:07Z'); $ed = PrivateNumber::coverTimeStampToPHP('2018-09-26T06:49:01Z'); $result = PrivateNumber::queryVoiceRecord('fa2b53fb-2a95-49e5-9a5d-9f2b403a8295', '2018-09-26 14:30:00','2018-09-26 14:50:00'); echo $result; } public function actionGetVoice() { $arr = ['66261453769654176011542769693114']; $privateModel = PrivateNumberVoice::find(); $privateModel->where(['call_identifier' => $arr]); $privateModel->asArray(); $voiceArr = $privateModel->all(); foreach($voiceArr as $k=>$v){ $call_id = $v['call_identifier']; echo $v['path']."\r\n"; $result = PrivateNumber::getRecordDownloadURL($call_id); $path = \yii::getAlias('@app/runtime') . "/empty/".$call_id.".wav"; $local_file = fopen($path, 'w'); if (false !== $local_file){ if (false !== fwrite($local_file, $result)) { fclose($local_file); $savePath = $v['path']; FileManager::add($path , $savePath); } } } } public function actionAddOssFile() { $file = '/s201812211218389859.pdf'; $path = \yii::getAlias('@app/runtime') . $file ; $ossSavePath = 'invoice/20181221/s201812211218389859.pdf'; FileManager::add($path , $ossSavePath); echo "end"; } public function actionTestCall() { //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::bindNumber('15622137119', '15999944931'); //{"Message":"OK","RequestId":"1EE31873-4053-44F5-B2B4-031ECC4671F7","Code":"OK","SecretBindDTO":{"Extension":"15999944931","SecretNo":"13143439849","SubsId":"974715743568877041"} //echo json_encode($result); echo "\r\n"; //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::unbindSubscription('974715743568877041', '13143439849'); //echo json_encode($result); //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::querySubscriptionDetail('134915943835832737', '17097534251'); //echo json_encode($result, JSON_UNESCAPED_UNICODE);echo "\r\n"; //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::queryRecordFileDownloadUrl("415c0511041a2151", date('Y-m-d H:i:s', 1543835908)); //echo json_encode($result, JSON_UNESCAPED_UNICODE);echo "\r\n"; //{"Message":"OK","RequestId":"7CFD87F7-1FA9-4EFE-BBCA-CCF4CB6F1FD4","DownloadUrl":"http:\/\/secret-axb-record-files.oss-cn-shanghai.aliyuncs.com\/134915943835832737_415c0511041a2151.mp3?Expires=1543843500&OSSAccessKeyId=LTAI27GqAW1VrcQA&Signature=eEATuKSQDIxUurnSuqghV09D3yE%3D","Code":"OK"} } public function actionDeduction() { $repairOrderModel = RepairOrder::findOne(['uuid' => '4ba0976b7a0d3d16ae1de634a6201134']); $activityModel = DeductionActivityRepository::getCurrentActivity(); $repairOrderDeduction = RepairOrderDeduction::findOne([ 'repair_order_id' => $repairOrderModel->id, 'activity_id' => $activityModel->id, ]); $expireTime = $activityModel->expired_time; $re = Deduction::canDeduction($repairOrderDeduction, $repairOrderModel, $expireTime); Deduction::setRiseVale($repairOrderModel, $expireTime); if (0 == $re->errCode) { echo $re->error."--1\r\n"; return ; } $saveData = ['userTagId' => rand(1,4)]; $clientUserId = 8; $addResult = Deduction::addDeductionAmount($activityModel, $repairOrderModel, $clientUserId, $saveData); echo $addResult->error."\r\n"; } /** * 初始化5元抵扣券 */ public function actionAddDe() { $repairOrderModel = RepairOrder::findOne(['uuid' => '4ba0976b7a0d3d16ae1de634a6201134']); $activityModel = DeductionActivityRepository::getCurrentActivity(); $result = Deduction::initOrderDeduction($repairOrderModel, $activityModel->uuid); if (1 == $result->errCode) { echo "add ok\r\n"; } else { echo $result->error."\r\n"; } Deduction::getActivityInfoByOrderUUId('4ba0976b7a0d3d16ae1de634a6201134s'); } public function actionGetFriends() { $result = Deduction::getRecords('9a4ba1dcae263f11893e707d733e3593', 4, 0); print_r($result); } public function actionDeductionPage() { $orderUUId = '';//$this->request->post('id'); $e = new \stdClass(); $e->success = true; $e->canClick = true; $e->selectedTagId = ''; $e->clickResult = 0; $batchInfo = Deduction::getBatchInfoByOrderUUId($orderUUId); $orderModel = $batchInfo['orderModel']; $repairOrderDeduction = $batchInfo['repairOrderDeduction']; $deductionActivity = $batchInfo['deductionActivity']; //$userId = $this->getUserId(); $clientUserId = 15;//$this->getClientUserId(); $expireTime = $deductionActivity->expired_time; $re = Deduction::canDeduction($repairOrderDeduction, $orderModel, $expireTime); if (0 == $re->errCode) { $e->canClick = false; $e->error = $re->error; } $checkResult = Deduction::hasClickDeduction($repairOrderDeduction, $orderModel, $clientUserId); if (0 == $checkResult->errCode) { $e->canClick = false; $e->selectedTagId = $checkResult->selectedTag; $e->clickResult = Deduction::coverInt($checkResult->clickResult); $e->error = $re->error; } if (isset($deductionActivity['share_img'])) { $deductionActivity['share_img'] = ImageManager::getUrl($deductionActivity['share_img']); } $e->shareTitle = isset($deductionActivity['share_title'])? $deductionActivity['share_title']: '帮我砍价'; $e->shareImg = $deductionActivity['share_img']; $e->userTagList = Deduction::randomUserTag(9, $e->selectedTagId); return $e; } public function actionSendMina() { $str = 'M,,'; $pattern = "/^[A-Z](,[A-Z])+?$/"; //$pattern = "/^[A-Z]$/"; $rs = preg_match($pattern, $str); print_r($rs); } public function actionPEngineer() { //echo Utils::hidePhoneNumber('15622137119'); } public function actionWebSocket() { $to_uid = "123"; // 推送的url地址,使用自己的服务器地址 $push_api_url = "http://192.168.0.106:20211/"; global $argv; $toId = isset($argv[2])?$argv[2]:''; $content = isset($argv[3])?$argv[3]:'test ing'; $newPost = []; $newPost['username'] = '张小小'; $newPost['message'] = $content; $post_data = array( "type" => "publish", "content" => json_encode($newPost), "to" => $toId, ); Http::post($push_api_url, $post_data); } public function actionSub() { $sTime = time(); echo "== start time 导入数据 == \r\n"; $startTime = strtotime('2019-01-01'); $endTime = strtotime(date('Y-m-d')); for ($i = 0 ;$startTime < $endTime ; $i++) { if ($i == 29) { break; } $startTime = $startTime + (24 * 3600); $isTime = time(); EngineerTask::archiveAchievement($startTime, false); $ieTime = time(); $sec = $ieTime - $isTime; echo "date:".date('Y-m-d', $startTime) .' cost time:'. $sec ."\r\n"; } } public function actionSt() { $orders = $this->getOrdersInfo(); $prefers = $this->getPreferList(); $round0 = 0; $firstRound = 0; $secondRound = 0; $thriRound = 0; $round4 = 0; $round5 = 0; $round6 = 0; $round7 = 0; $dispatchCount = 0; $onSiteCount = 0; $normalCount = 0; foreach ($orders as $k => $order) { $engineerIds = $prefers['user_id_'.$order['user_id']]; $dispatchRecordsModel = RepairOrderDispatchRecords::find(); $dispatchRecordsModel->where(['repair_order_id' => $order['id'] ]); $dispatchRecordsModel->asArray(); $findResult = $dispatchRecordsModel->all(); $dispatchCount = $dispatchCount + count($findResult); echo $order['id'].' ccccount:'.count($findResult)."----\r\n"; if (empty($findResult)) { $onSiteCount ++; } else { $normalCount++; } if (empty($findResult)) { continue; } $orderFlag = 0; foreach ($findResult as $kk => $vv) { if (0 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $round0++; $orderFlag = true; } if (1 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $firstRound++;$orderFlag = true; } if (2 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $secondRound++;$orderFlag = true; } if (3 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $thriRound++;$orderFlag = true; } if (4 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $round4++;$orderFlag = true; } if (5 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $round5++;$orderFlag = true; } if (6 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $round6++;$orderFlag = true; } if (7 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) { $round7++;$orderFlag = true; } } if (false == $orderFlag ) { echo "null:".$order['id']."\r\n"; } } echo "dispatchCount:".$dispatchCount."\r\n"; echo "onSiteCount:".$onSiteCount.' normalCount:'.$normalCount."\r\n"; echo $round0.'_'.$firstRound.'_'.$secondRound.'_'.$thriRound.'_'.$round4.'_'.$round5.'_'.$round6.'_'.$round7; } /** * 临时提交电子发票申请 * @return string */ public function actionCreateInvoice() { $orderModel = RepairOrder::findOne(['order_no' => '201904241505438057' ]); if (empty($orderModel)) { echo "open invoice fail: repair order is null "; return false; } // 只是开一单一票 $info = [ 'user_id' => $orderModel->user_id, 'type' => Invoice::HEAD_TYPE_COMPANY, 'head' => '深圳市星康科技有限公司', 'taxpayer_id_number' => '91440300319568546J', 'email' => 'perelmen@qq.com', 'remark' => '订单号:201904241505438057', 'register_address' => '', 'register_tel' => '', 'bank' => '', 'bank_account' => '', 'amount' => 329.20, 'selectOrders' => [$orderModel->uuid] ]; $result = \domain\trade\Invoice::createInvoice($info); echo json_encode($result); } /** * 直接开票,不要用记录到数据库里面,有些商品要开票,直接开票发送总局软件那里, * 先发邮件到自己邮箱再发pdf 给客户 */ public function actionInvoiceStraight() { $amount = 20; //开票金额 $sid = 'sg'.date('YmdHis').mt_rand(1000,9999); $customerInfo = array( 'ghdwsbh' => '', //公司纳税人识别码 'ghdwmc' => '许可', //抬头 'email' => 'perelmen@qq.com', 'ghdwdzdh' => '', //'购货单位地址、电话' 'ghdwyhzh' => '', //'购货单位开户行、银行帐号' 'bz' => 'A4纸1箱' //备注 ); $serviceInfo = InvoiceApi::getGoodsCode(InvoiceApi::A4_PAPER_INVOICE); $queryResult = InvoiceApi::makeOutAnInvoice($sid, $amount, $serviceInfo, $customerInfo); var_dump($queryResult); sleep(4); echo "query1:"; $queryResult = InvoiceApi::queryInvoice($sid); var_dump($queryResult); sleep(5); echo "query2:"; $queryResult = InvoiceApi::queryInvoice($sid); var_dump($queryResult); echo "end"; } public function actionExportD() { $postId = date('Ymd0001'); $query = new Query(); $query->select("repair_order.order_no,repair_order.repair_device_name as device, GROUP_CONCAT(device_fault.`name`) as faults, parent_device_cat.name as keyword, brand.chinese_name as brand"); $query->from("repair_order_repair_plans"); $query->leftJoin("repair_order","repair_order.id = repair_order_repair_plans.repair_order_id and repair_order.repair_device_type = 1"); $query->leftJoin("repair_order_detail","repair_order_detail.repair_order_id = repair_order_repair_plans.repair_order_id and repair_order_detail.pay_at > 0"); $query->leftJoin("repair_plan","repair_plan.id = repair_order_repair_plans.repair_plan_id"); $query->leftJoin("device_fault","device_fault.id = repair_plan.device_fault_id"); $query->leftJoin("engineer_profile","engineer_profile.engineer_id = repair_order.engineer_id"); $query->leftJoin("user_device","user_device.id = repair_order.repair_device_id"); $query->leftJoin("device","device.id = user_device.device_id"); $query->leftJoin("model","model.id = device.model_id"); $query->leftJoin("brand","brand.id = model.brand_id"); $query->leftJoin("device_cat","device_cat.id = device.device_cat_id"); $query->leftJoin("device_cat as parent_device_cat","parent_device_cat.id = device_cat.parent_id"); $query->where("repair_order.is_system_delete = 0 and repair_order.pay_price > 0 and repair_order.repair_device_type = 1"); $query->andWhere("repair_order.created_at > UNIX_TIMESTAMP('2019-01-01')"); //$query->limit(3); $query->groupBy("repair_order.order_no"); $items = $query->all(); $totalCount = count($items); $postItemsTmp = []; foreach($items as $k => $item) { unset($item['order_no']); $key = $item['device'].'_'.$item['faults'].'_'.$item['keyword'].'_'.$item['brand']; $postItemsTmp[$key] = $item; } $postItems = []; foreach($postItemsTmp as $k => $vv) { $vv['keyword'] = $vv['keyword'].'维修'; $postItems[] = $vv; } $dataStr = [ "items" => $postItems, "attribute" => [ "count" => $totalCount, "totalcount" => $totalCount, "id" => $postId, "seq" => 0] ]; $postDataStr = json_encode($dataStr, JSON_UNESCAPED_UNICODE); $postDataStr = str_replace('\/', '/', $postDataStr); $postData = [ "data" => $postDataStr, "lifespan" => 86400, "query" => "{\"type\":1000078}", "scene" => 1 ]; echo json_encode($postData, JSON_UNESCAPED_UNICODE); } public function actionTV() { $repairOrderModel = RepairOrder::find(); $repairOrderModel->alias('ro'); $repairOrderModel->select('count(*) as cc,GROUP_CONCAT(ro.created_at) as cr, ro.repair_device_id'); $repairOrderModel->leftJoin('repair_order_detail rod', 'rod.repair_order_id = ro.id'); $repairOrderModel->where('ro.repair_device_type = 1 and rod.pay_at >0 and ro.is_system_delete = 0'); $repairOrderModel->groupBy('ro.repair_device_id'); $repairOrderModel->having('cc >=2'); $repairOrderModel->asArray(); $repairOrderArr = $repairOrderModel->all(); //print_r($repairOrderArr); foreach($repairOrderArr as $k => $order) { $timeArr = explode(',', $order['cr']); sort($timeArr); $timeDuration = []; foreach($timeArr as $kk => $vv) { if (isset($timeArr[$kk + 1])) { $durationSecond = 0 - ($vv - $timeArr[$kk + 1]); if ($durationSecond<60) { $sDur = $durationSecond. '秒'; } elseif($durationSecond >= 60 && $durationSecond < 3600) { $sDur = (round($durationSecond /60, 1)). '分'; } elseif($durationSecond >= 3600 && $durationSecond < 86400){ $sDur = (round($durationSecond /3600, 1)). '时'; } elseif($durationSecond >= 86400 && $durationSecond < 604800) { $sDur = (round($durationSecond /(3600*24), 1)). '天'; } else { $sDur = (round($durationSecond /(3600*24*7), 1)). '周'; } $timeDuration[] = $sDur; } } $order['durations'] = implode(',', $timeDuration); $repairOrderArr[$k] = $order; //echo $order['cc'].'_'.$order['repair_device_id'].'_'.$order['durations']."\r\n"; } $arr = [19,39,40]; sort($arr); print_r($arr); } public function actionSetPostData() { $str = ''; $postPackageId = 'D'.date('Ymd').'0000001'; $postPackage = [ "lifespan" => 86400, "query" => "{\"type\":1000078}", "scene" => 1, "data" => "", ]; $packageAttribute = [ "count" => '', "totalcount" => 100, "id" => $postPackageId, "seq" => 0 ]; $index = 0; $keywords = ["打印机维修","复印机维修","电脑维修","Mac电脑维修","加碳粉","换墨盒","重装系统","上门维修打印机","上门维修电脑","上门维修复印机","电脑蓝屏","无法使用扫描","打印机无法开机","无法打印","打印效果差","打印卡纸","设备未共享","设备未安装","缺粉","打印颜色淡","打印不清晰","打印模糊","传真或扫描模糊","纸张进纸故障","无法上纸","换主板","换内存","色带用尽","键盘损坏","触摸板失灵","电池鼓包","电池不耐用","无法充电","风扇噪音大","屏幕外壳变形","设备无法开机","无法使用传真","墨水不足","屏幕按键失灵","外壳磨损变形","内屏损坏无显示","闪屏","花屏","碎屏","USB无法使用","上门安装电脑","黑屏","安装软件","安装驱动","无法上网","运行速度慢","忘记系统密码","无法登陆系统","无法连接投影仪","未知故障","复印效果差","无法发送邮件","无法共享打印机","无法打开文件","提示C盘空间不足","办公软件无法使用","无法使用拼音","浏览器无法播放视频","电脑中毒","键盘按键无反应","无法打开office文件","深圳修电脑","深圳修打印机","深圳修复印机","加墨水","福田修电脑","福田修打印机","福田修复印机","修佳能打印机","修惠普打印机","修京瓷打印机","修联想笔记本","修苹果笔记本","修爱普生打印机","喷墨打印机维修","换打印纸","维修三星打印机","针式打印机维修","激光打印机维修","喷墨打印机维修","黑白打印机维修","彩色复印维修","漏墨","复印机闪灯","复印无法联网"]; $pageList = []; foreach($keywords as $k => $v) { $pageList[] = ["keyword" => $v]; } $totalcount = count($keywords); $postRound = 0; //"attribute" => [ $packageAttribute['count'] = $totalcount; $packageAttribute['totalcount'] = $totalcount; $packageAttribute['seq'] = $postRound; $postPackage['data'] = json_encode(["items" => $pageList, "attribute" => $packageAttribute], JSON_UNESCAPED_UNICODE); $postPackage['data'] = str_replace('\/', '/', $postPackage['data']); $postWxStr = json_encode($postPackage, JSON_UNESCAPED_UNICODE); echo $postWxStr; echo "\r\n"; $minaWechat = MinaHelper::getWxPHPSDK(); $result = $minaWechat->setDynamicData($postWxStr); print_r($result); echo $minaWechat->errCode."\r\n"; echo $minaWechat->errMsg; echo "\r\n"; } /** * 贴码补贴发放 * @return bool */ public function actionPasteAward() { $bindDeviceApplyFind = BindDeviceApply::find(); $bindDeviceApplyFind->where("apply_at > UNIX_TIMESTAMP('2019-08-01') and apply_at <= UNIX_TIMESTAMP('2019-08-21') and status = 1 and id = 209227"); $applyArr = $bindDeviceApplyFind->all(); foreach ($applyArr as $k => $apply) { $engineerModel = Engineer::findOne(['id' => $apply->engineer_id]); $result = ApplyAwardRule::canReceivePasteAward($apply, $engineerModel); //AppLog::DEBUG('= engineerAddPasteAward =result:'.$result); if ($result) { $addR = ApplyAwardRule::addPasteAward($apply, strtotime('2019-08-10 00:00:54')); return $addR; } } } public function actionUserConfirmPrice() { $orderModel = RepairOrderRepository::findOne(['uuid' => '72c7fd2bb0003bcf8bd55caf3a90ab7b']); $userId = $orderModel->user_id; $success = PrivateOrderUserOp::confirmPrice($orderModel, $userId, 0, 0); echo 'end'; } public function actionClearLog() { $str = 'OKI 打印机'; $splitResult = DeviceSearch::splitText($str); print_r($splitResult); } }