pull/1/head
wmc 1 year ago
parent bf5b154cb9
commit 92dea53e82
  1. 8
      app/api/controller/Goods.php
  2. 12
      app/api/model/Goods.php
  3. 31
      app/api/model/PreSale.php
  4. 31
      app/api/model/PreSaleLog.php
  5. 31
      app/api/model/PreSaleMessage.php
  6. 26
      app/command/test.php
  7. 5
      app/common/model/Category.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();

@ -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']);

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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;
}

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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;
}

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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;
}

@ -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]);
//预约的用户推送消息
}
}

@ -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)

Loading…
Cancel
Save