alias('d') ->leftJoin(['s' => Sender::tableName()], 'd.id=s.delivery_id') ->where(['d.is_delete' => 0]); if (get_supplier_id()) { $query->andWhere(['d.supplier_id' => get_supplier_id(), 'type' => 1]); } else { $query->andWhere(['d.store_id' => get_store_id(), 'type' => 0]); } $list = $query->select(['d.*', 's.company', 's.name', 's.tel', 's.mobile', 's.post_code', 's.province', 's.city', 's.exp_area', 's.address', 's.company']) ->orderBy(['d.id' => SORT_DESC]) ->asArray()->all(); foreach ($list as &$val) { $val['express_name'] = Express::findOne($val['express_id'])->name; } return $list; } /** * 获取面单详情 * @return array|\yii\db\ActiveRecord[] */ public static function getEdit($id) { $query = Delivery::find()->alias('d') ->leftJoin(['s' => Sender::tableName()], 'd.id=s.delivery_id') ->where(['d.is_delete' => 0, 'd.id' => $id]) ->select(['d.*', 's.company', 's.name', 's.tel', 's.mobile', 's.post_code', 's.province', 's.city', 's.exp_area', 's.address', 's.company']); if (get_supplier_id()) { $query->andWhere(['d.supplier_id' => get_supplier_id()]); } else { $query->andWhere(['d.store_id' => get_store_id()]); } return $query->asArray()->one(); } }