2026-03-21 02:55:24 +08:00
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
2026-03-29 11:22:52 +08:00
|
|
|
// | Author: ScottPan Team
|
2026-03-21 02:55:24 +08:00
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace app\dao\order;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use app\dao\BaseDao;
|
|
|
|
|
use app\model\order\StoreOrder;
|
|
|
|
|
use app\model\order\StoreOrderCartInfo;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Class StoreOrderStoreOrderCartInfoDao
|
|
|
|
|
* @package app\dao\order
|
|
|
|
|
*/
|
|
|
|
|
class StoreOrderStoreOrderCartInfoDao extends BaseDao
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
protected string $alias = 'a';
|
|
|
|
|
|
|
|
|
|
protected string $joinAlis = 'c';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置主表模型
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
protected function setModel(): string
|
|
|
|
|
{
|
|
|
|
|
return StoreOrder::class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置链表模型
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
protected function setJoinModel(): string
|
|
|
|
|
{
|
|
|
|
|
return StoreOrderCartInfo::class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置模型
|
|
|
|
|
* @return \crmeb\basic\BaseModel
|
|
|
|
|
*/
|
|
|
|
|
public function getModel()
|
|
|
|
|
{
|
|
|
|
|
$name = app()->make($this->setJoinModel())->getName();
|
|
|
|
|
return parent::getModel()->alias($this->alias)->join($name . ' ' . $this->joinAlis, $this->alias . '.id =' . $this->joinAlis . '.oid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户购买过的商品id
|
|
|
|
|
* @param array $where
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getUserCartProductIds(array $where)
|
|
|
|
|
{
|
|
|
|
|
return $this->getModel()->when(isset($where['uid']), function ($query) use ($where) {
|
|
|
|
|
$query->where($this->alias . '.uid', $where['uid']);
|
|
|
|
|
})->column($this->joinAlis . '.product_id');
|
|
|
|
|
}
|
|
|
|
|
}
|