| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\jobs;
- use app\models\Lg;
- use app\utils\LgApi;
- use yii\base\BaseObject;
- use yii\queue\JobInterface;
- use app\models\Goods;
- use app\models\MdGoods;
- use app\models\Md;
- /**
- * 用于用户灵工进件后查询状态
- */
- class LgApplyJob extends BaseObject implements JobInterface
- {
- public int $id;
- public int $store_id;
- public int $retry;
- public function execute($queue)
- {
- if ($this->retry > 0) {
- $lg_success = Lg::find()->where(['id' => $this->id,'store_id'=>$this->store_id,'is_delete'=>0,'status'=>1])->one();
- if (!$lg_success){
- $queue_id = \queue_push(new LgApplyJob(['id'=>$this->id,'store_id'=>$this->store_id,'retry' => $this->retry--]), 60);
- }
- }
- try {
- /**
- * 查询待进件成功的记录
- */
- $lgApi = new LgApi($this->store_id);
- $lg = Lg::find()->where(['id' => $this->id,'store_id'=>$this->store_id,'is_delete'=>0])
- ->andWhere(['status'=>0])
- ->one();
- if ($lg){
- $post_data = [];
- $post_data['certCard'] = $lg['cert_card'];//身份证号
- $res = $lgApi->FlexibleQuery($post_data);
- //审核中
- if ($res[0]['status'] == 100 || $res[0]['status'] == 200){
- $lg->status = 0;
- $lg->updated_at = time();
- $lg->save();
- }
- //成功
- if ($res[0]['status'] == 300){
- $lg->status = 1;
- $lg->updated_at = time();
- $lg->save();
- }
- //失败
- if ($res[0]['status'] == 999){
- $lg->status = 2;
- $lg->updated_at = time();
- $lg->refuse_desc = $res['msg'];
- $lg->save();
- }
- }
- } catch(\Exception $e) {
- debug_log('--------auto-lg-apply-error---- '.$this->id.' ----auto-lg-apply-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- if (isset($queue_id) && !\Yii::$app->queue->isDone($queue_id)) {
- \Yii::$app->queue->remove($queue_id);
- }
- }
- }
|