| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models;
- use app\models\Delivery;
- use app\models\Express;
- use app\models\Sender;
- use yii\base\Model;
- class ExpressListForm extends Model
- {
- /**
- * 获取面单列表
- * @return array|\yii\db\ActiveRecord[]
- */
- public static function getList()
- {
- $query = Delivery::find()->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();
- }
- }
|