From c10936ab9eed8eba42d0cba0b606186fc6ac9381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 18 Oct 2022 13:26:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/model/ShopOrder.php | 17 +++++++++++++++++ app/data/model/ShopOrderItem.php | 10 +++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/data/model/ShopOrder.php b/app/data/model/ShopOrder.php index e2f348d0b..1bbbfae63 100644 --- a/app/data/model/ShopOrder.php +++ b/app/data/model/ShopOrder.php @@ -3,6 +3,7 @@ namespace app\data\model; use think\admin\Model; +use think\model\relation\HasMany; /** * 商城订单主模型 @@ -11,5 +12,21 @@ use think\admin\Model; */ class ShopOrder extends Model { + /** + * 关联订单商品 + * @return \think\model\relation\HasMany + */ + public function items(): HasMany + { + return $this->hasMany('order_no', 'order_no')->where(['deleted' => 0]); + } + /** + * 关联物码数据 + * @return \think\model\relation\HasMany + */ + public function sends(): HasMany + { + return $this->hasMany('order_no', 'order_no')->where(['deleted' => 0]); + } } \ No newline at end of file diff --git a/app/data/model/ShopOrderItem.php b/app/data/model/ShopOrderItem.php index d36115b37..38571b088 100644 --- a/app/data/model/ShopOrderItem.php +++ b/app/data/model/ShopOrderItem.php @@ -3,6 +3,7 @@ namespace app\data\model; use think\admin\Model; +use think\model\relation\HasOne; /** * 商城订单详情模型 @@ -11,5 +12,12 @@ use think\admin\Model; */ class ShopOrderItem extends Model { - + /** + * 关联商品数据 + * @return \think\model\relation\HasOne + */ + public function goods(): HasOne + { + return $this->hasOne(ShopGoods::class, 'code', 'goods_code'); + } } \ No newline at end of file