wang hou sheng 7 months ago
parent 5f6f550bf9
commit 8463a37e15
  1. 2
      app/api/controller/Goods.php
  2. 21
      app/api/model/Goods.php

@ -196,7 +196,7 @@ class Goods extends Controller
{
$param = $this->request->param();
$model = new GoodsModel;
$list = $model->presaleGoodss($param);
$list = $model->presaleGoods($param);
return $this->renderSuccess(compact('list'));
}

@ -24,6 +24,7 @@ use app\common\model\Goods as GoodsModel;
use app\common\model\GoodsCategoryRel as GoodsCategoryRelModel;
use app\common\model\GoodsImage as GoodsImageModel;
use app\common\model\UploadFile as UploadFileModel;
use app\store\model\GoodsCategoryRel;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -238,23 +239,25 @@ class Goods extends GoodsModel
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function presaleGoodss(array $param): array
public function presaleGoods(array $param): array
{
$list = [];
$cate_goods_id = [];
if (!empty($param['category_id'])) {
$cate_model = new \app\store\model\GoodsCategoryRel();
$cate_goods_id = $cate_model
->where(['category_id' => $param['category_id']])
->column('goods_id');
}
$model = new PreSale();
$info = $model->where(['is_change' => 0, 'status' => 1])->field('goods_list,p_time')->find();
if (!$info->isEmpty()) {
$info = $info->toArray();
$goods_ids = explode(',', $info['goods_list']);
if (!empty($param['category_id'])) {
$cate_model = new GoodsCategoryRel();
$cate_goods_id = $cate_model
->where(['category_id' => $param['category_id']])
->whereIn('goods_id', $goods_ids)
->column('distinct goods_id');
}
if ($cate_goods_id) {
$goods_ids = array_unique(array_values(array_intersect($cate_goods_id, $goods_ids)));
$goods_ids = $cate_goods_id;
}
$result = $this->getListByIds($goods_ids);
if (!$result->isEmpty()) {
@ -633,7 +636,7 @@ class Goods extends GoodsModel
return;
}
$catService = new \app\store\model\GoodsCategoryRel();
$catService = new GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id');
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价
$goods['discount'] = 0.0;

Loading…
Cancel
Save