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