retry > 0) { $cash_success = Cash::find()->where(['id'=>$this->id,'store_id' => $this->store_id,'status'=>1])->one(); if (!$cash_success){ $queue_id = \queue_push(new LgCashJob(['id'=>$this->id,'store_id'=>$this->store_id,'type'=>$this->type,'retry' => $this->retry--]), 60); } } try { /** * 查询待提现成功的记录 */ $lgApi = new LgApi($this->store_id); //如果是骑手 if ($this->type == 12){ $cash_info = LocalDeliveryCash::find()->where(['id'=>$this->id,'store_id' => $this->store_id,'status'=>6 ])->one(); if($cash_info){ $post_data = []; $post_data['outTradeNo'] = $cash_info['order_no'];//提现单号 $res = $lgApi->FlexiblePayQuery($post_data); //审核中 if ($res['status'] == 100 || $res['status'] == 200){ $cash_info->updated_at = time(); $cash_info->save(); } //成功 if ($res['status'] == 300){ $cash_info->status = 2; $cash_info->updated_at = time(); $cash_info->save(); } //失败 if ($res['status'] == 999){ $cash_info->status = 3; $cash_info->updated_at = time(); $cash_info->lg_refuse_desc = $res['msg']; if ($cash_info->save()){ $courier = LocalDeliveryCourier::findOne(['saas_user_id' => $cash_info['saas_user_id']]); //把提现的钱返还 $courier->updateCounters(['money' => $cash_info->price]); } } } } //如果是cash表 if (in_array($this->type,[0,2,3,7,8,9,17])){ $cash_info = Cash::find()->where(['id'=>$this->id,'store_id' => $this->store_id,'status'=>6 ])->one(); if($cash_info){ $post_data = []; $post_data['outTradeNo'] = $cash_info['order_no'];//提现单号 $res = $lgApi->FlexiblePayQuery($post_data); //审核中 if ($res['status'] == 100 || $res['status'] == 200){ $cash_info->updated_at = time(); $cash_info->save(); } //成功 if ($res['status'] == 300){ $cash_info->status = 2; $cash_info->updated_at = time(); $cash_info->save(); } //失败 if ($res['status'] == 999){ $cash_info->status = 3; $cash_info->updated_at = time(); $cash_info->lg_refuse_desc = $res['msg']; if ($cash_info->save()){ $user = User::findOne(['id' => $cash_info['user_id']]); //把提现的钱返还 if (in_array($cash_info->cash_type,[0,3,8])) {//分销,股东,2+1,区域分红 $user->updateCounters(['price' => $cash_info->price]); }elseif ($cash_info->cash_type == 2) {//门店 $md = Md::findOne($cash_info->md_id); $md->updateCounters(['cash_profit' => $cash_info->price]); }elseif ($cash_info->cash_type == 17) {//全域提现 $user->updateCounters(['global_money' => $cash_info->price]); }elseif ($cash_info->cash_type == Cash::IS_CASH_TYPE_BALANCE) {//充值 $saveLog = AccountLog::saveLog($cash_info->user_id, $cash_info->price, AccountLog::TYPE_BALANCE, AccountLog::LOG_TYPE_INCOME, 0, 0, "余额提现被驳回,单号:{$cash_info->order_no}"); if (!$saveLog) { debug_log('网络异常,账户保存失败'); } } elseif ($cash_info->cash_type == Cash::IS_CASH_TYPE_MCH) {//入驻商 $saveLog = \app\models\MchAccountLog::saveLog($cash_info->mch_id, $cash_info->user_id, $cash_info->price, AccountLog::LOG_TYPE_INCOME, 0, '', "提现被驳回,单号:{$cash_info->order_no}", 0, 0); if ($saveLog['code']) { debug_log($saveLog); } } } } } } } catch(\Exception $e) { debug_log('--------auto-lg-cash-error---- '.$this->id.' ----auto-lg-cash-error--------' . $e->getMessage() . $e->getFile() . $e->getLine()); } if (isset($queue_id) && !\Yii::$app->queue->isDone($queue_id)) { \Yii::$app->queue->remove($queue_id); } } }