From 92dea53e82d4aa80d652d2ae0e314ad49bfd9b6c Mon Sep 17 00:00:00 2001 From: wmc Date: Fri, 2 Feb 2024 17:17:22 +0800 Subject: [PATCH] 111 --- app/api/controller/Goods.php | 8 ++++++++ app/api/model/Goods.php | 12 ++++++++++-- app/api/model/PreSale.php | 31 +++++++++++++++++++++++++++++++ app/api/model/PreSaleLog.php | 31 +++++++++++++++++++++++++++++++ app/api/model/PreSaleMessage.php | 31 +++++++++++++++++++++++++++++++ app/command/test.php | 26 ++++++++++++++++++++++++-- app/common/model/Category.php | 5 +++++ 7 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 app/api/model/PreSale.php create mode 100644 app/api/model/PreSaleLog.php create mode 100644 app/api/model/PreSaleMessage.php diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 45f9d0b2..41d6ce8f 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -70,6 +70,14 @@ class Goods extends Controller return $this->renderSuccess($goodsInfo); } + public function presale() + { + $param = $this->request->param(); + $model = new GoodsModel; + $goodsInfo = $model->presale($param); + return $this->renderSuccess($goodsInfo); + } + public function browseDel() { $param = $this->request->param(); diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index b548ffa3..3b882253 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -198,7 +198,13 @@ class Goods extends GoodsModel 'is_delete' => 0 ])->column('goods_id'); foreach ($spe as $v) { - $skuList[] = $this->getSpecData($v)['skuList']->toArray()[0]; + $sku1 = $this->getSpecData($v)['skuList']->toArray()[0]; + +// foreach ($sku1['spec_value_ids'] as $k3 => &$v3) { +// $v3 = (int)$v3; +// } + + $skuList[] = $sku1; $specList[] = $this->getSpecData($v)['specList'][0]; } $newList = [ @@ -207,7 +213,9 @@ class Goods extends GoodsModel ]; $goodsInfo->specifications = $newList; } + $goodsInfo = $goodsInfo->toArray(); + //替换原规格数组 $goodsInfo['skuList2'] = $skuList; $goodsInfo['specList2'] = $specList; @@ -387,7 +395,7 @@ class Goods extends GoodsModel // 会员折扣价: 商品sku列表 if ($goods->getRelation('skuList')) { foreach ($goods['skuList'] as &$skuItem) { - $temp_price_plus = $temp_price_dealer = []; + $temp_price_plus = $temp_price_dealer = []; foreach ($catIds as $k => $v) { $temp_price_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $skuItem['goods_price']); $temp_price_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $skuItem['goods_price']); diff --git a/app/api/model/PreSale.php b/app/api/model/PreSale.php new file mode 100644 index 00000000..e95dfc0c --- /dev/null +++ b/app/api/model/PreSale.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + +use app\common\model\GoodsSpecRel as GoodsSpecRelModel; + +/** + * 商品规格关系模型 + * Class GoodsSpecRel + * @package app\api\model + */ +class PreSale extends GoodsSpecRelModel +{ + // 定义表名 + protected $name = 'presale'; + + // 定义主键 + protected $pk = 'id'; + + protected $updateTime = false; +} diff --git a/app/api/model/PreSaleLog.php b/app/api/model/PreSaleLog.php new file mode 100644 index 00000000..060d6a33 --- /dev/null +++ b/app/api/model/PreSaleLog.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + +use app\common\model\GoodsSpecRel as GoodsSpecRelModel; + +/** + * 商品规格关系模型 + * Class GoodsSpecRel + * @package app\api\model + */ +class PreSaleLog extends GoodsSpecRelModel +{ + // 定义表名 + protected $name = 'presale_log'; + + // 定义主键 + protected $pk = 'id'; + + protected $updateTime = false; +} diff --git a/app/api/model/PreSaleMessage.php b/app/api/model/PreSaleMessage.php new file mode 100644 index 00000000..6be5350f --- /dev/null +++ b/app/api/model/PreSaleMessage.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + +use app\common\model\GoodsSpecRel as GoodsSpecRelModel; + +/** + * 商品规格关系模型 + * Class GoodsSpecRel + * @package app\api\model + */ +class PreSaleMessage extends GoodsSpecRelModel +{ + // 定义表名 + protected $name = 'presale_message'; + + // 定义主键 + protected $pk = 'id'; + + protected $updateTime = false; +} diff --git a/app/command/test.php b/app/command/test.php index 9406e9d4..67eb236d 100644 --- a/app/command/test.php +++ b/app/command/test.php @@ -8,6 +8,8 @@ use think\console\Command; use think\console\Output; use think\console\Input; use think\facade\Db; +use app\api\model\{Goods as GoodsModel}; +use app\api\model\PreSale; // /www/server/php/74/bin/php /server/wwwroot/yanzong/think test class test extends Command @@ -16,12 +18,32 @@ class test extends Command { // 指令配置 $this->setName('test') - ->setDescription('测试demo'); + ->setDescription('预售到期自动上架'); } protected function execute(Input $input, Output $output) { - echo date('Y-m-d H:i:s') . '完成'; + $info = PreSale::where('status', 1) + ->where('p_time', '<=', date('Y-m-d H:i:s')) + ->where('is_change', '=', 0) + ->select(); + + foreach ($info as $v) { + //所有商品直接上架 + if (!empty($v['goods_list'])) { + $goodslist = explode(',', $v['goods_list']); + GoodsModel::where('store_id', $v['store_id']) + ->whereIn('goods_id', $goodslist) + ->update(['status' => 10]); + } + //更改预售状态 + PreSale::where('id', $v['id']) + ->update(['is_change' => 1]); + //预约的用户推送消息 + + } + + } diff --git a/app/common/model/Category.php b/app/common/model/Category.php index 861d47fa..150bd2e8 100644 --- a/app/common/model/Category.php +++ b/app/common/model/Category.php @@ -43,6 +43,7 @@ class Category extends BaseModel $model = "app\\common\\model\\goods\\GoodsPrice"; return $this->HasMany($model, 'cat_id', 'category_id'); } + /** * 分类详情 * @param int|array $where @@ -85,6 +86,10 @@ class Category extends BaseModel // 设置检索条件 $filter = []; $params['status'] > -1 && $filter[] = ['status', '=', $params['status']]; + if ($_GET['is_hot'] == 1) { + $filter[] = ['is_hot','=',1]; + } + // 查询列表数据 return $this->with(['image']) ->where($filter)