|
|
|
@ -27,6 +27,9 @@ use think\db\exception\DataNotFoundException; |
|
|
|
|
use think\db\exception\DbException; |
|
|
|
|
use think\db\exception\ModelNotFoundException; |
|
|
|
|
use app\store\model\goods\GoodsPrice as GoodsPriceModel; |
|
|
|
|
use app\api\model\PreSale; |
|
|
|
|
use app\api\model\PreSaleMessage; |
|
|
|
|
use app\api\model\PreSaleLog; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商品模型 |
|
|
|
@ -116,6 +119,27 @@ class Goods extends GoodsModel |
|
|
|
|
return $this->setGoodsListDataFromApi($list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function presale() |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(true); |
|
|
|
|
|
|
|
|
|
$info = PreSaleLog::where([ |
|
|
|
|
'user_id' => $userId, |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'goods_id' => $_POST['goods_id'], |
|
|
|
|
])->find(); |
|
|
|
|
|
|
|
|
|
if (!$info) { |
|
|
|
|
PreSaleLog::insert([ |
|
|
|
|
'user_id' => $userId, |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'goods_id' => $_POST['goods_id'], |
|
|
|
|
'ctime' => date('Y-m-d H:i:s') |
|
|
|
|
]); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function browseLog() |
|
|
|
|
{ |
|
|
|
@ -159,6 +183,31 @@ class Goods extends GoodsModel |
|
|
|
|
return $info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function presaleList() |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(true); |
|
|
|
|
$info = PreSaleLog::alias('a') |
|
|
|
|
->join('presale b', 'a.pre_id = b.id') |
|
|
|
|
->join('goods c', 'c.goods_id = a.goods_id') |
|
|
|
|
->where([ |
|
|
|
|
'a.store_id' => request()->header()['storeid'], |
|
|
|
|
'a.user_id' => $userId, |
|
|
|
|
])->field('c.goods_name,c.goods_price_min,a.id,b.p_time')->paginate(15); |
|
|
|
|
|
|
|
|
|
return $info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function canlpresale() |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(true); |
|
|
|
|
$info = PreSaleLog::where([ |
|
|
|
|
'id' => $_POST['id'], |
|
|
|
|
'user_id' => $userId |
|
|
|
|
])->delete(); |
|
|
|
|
|
|
|
|
|
return $info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取商品详情 (详细数据用于页面展示) |
|
|
|
|
* @param int $goodsId 商品ID |
|
|
|
|