新增服务配置和首页商品秒杀价格设置

wysf
ztt 11 months ago
parent 6fb6919685
commit a49007b620
  1. 13
      app/api/controller/StoreKeeper.php
  2. 33
      app/api/model/Goods.php
  3. 2
      app/api/service/Goods.php
  4. 10
      app/api/service/Store.php
  5. 6
      app/common/model/Category.php
  6. 8
      app/common/model/Goods.php
  7. 24
      app/common/model/store/StoreServerConfig.php
  8. 45
      app/store/controller/Server.php

@ -561,6 +561,19 @@ class StoreKeeper extends Controller
return $this->renderSuccess('编辑成功');
}
/**
* 店长修改秒杀价格
* @return Json
* @throws \Exception
*/
public function editGoodsSeckillPrice() {
$model = new \app\api\model\Goods();
if (!$model->editGoodsSeckillPrice($this->request->param())) {
return $this->renderError($model->getError() ?: '编辑失败');
}
return $this->renderSuccess('编辑成功');
}
public function delPrice(): Json
{
$model = new GoodsPriceModel;

@ -700,4 +700,37 @@ class Goods extends GoodsModel
}
return $detail->save($data) !== false;
}
public function editGoodsSeckillPrice($data) {
if (empty($data['seckill_price']) || empty($data['is_limit']) || empty($data['limit_times']) || empty($data['goods_id'])) {
$this->error = "请补全信息";
return false;
}
$detail = $this->where('goods_id', '=', $data['goods_id'])->find();
if (empty($detail)) {
$this->error = "异常数据";
return false;
}
if(empty($data['sku_id'])) {
$this->error = "请输入sku_id";
return false;
}
//批量修改秒杀价格
$sku_ids = explode(',', $data['sku_id']);
foreach ($sku_ids as $sku_id) {
$skuData = GoodsSkuModel::get(['id' => $sku_id,'goods_id' => $data['goods_id']]);
if ($skuData) {
$up_data = [
'seckill_price' => $data['seckill_price'],
'is_limit' => $data['is_limit'],
'limit_times' => $data['limit_times'],
'sec_start_time' => $data['sec_start_time'],
'sec_end_time' => $data['sec_end_time'],
];
$skuData->save($up_data);
}
}
return true;
}
}

@ -128,7 +128,7 @@ class Goods extends GoodsService
'is_delete' => 0,
'is_brand' => $_GET['is_brand'],
'is_new' => $_GET['is_new'],
'is_in_store' => $_GET['is_in_store'] ?? 0,//是否店内
'is_in_store' => $_GET['is_in_store'] ?? '',//是否店内
'store_id' => $storeid,
'categoryId' => (int)$_GET['categoryId'],
], 15);

@ -18,6 +18,7 @@ use app\api\service\Client as ClientService;
use app\api\service\Setting as SettingService;
use app\api\model\store\Module as StoreModuleModel;
use app\api\model\dealer\Setting as DealerSettingModel;
use app\common\model\store\StoreServerConfig;
use app\common\model\store\StoreSettle;
use app\common\service\BaseService;
use think\facade\Db;
@ -52,6 +53,8 @@ class Store extends BaseService
'clientData' => $this->getClientData(),
// 开启的功能模块
'modules' => $this->getModules(),
//商城服务配置
'storeServerConfig' => $this->getServerConfig()
];
}
@ -197,4 +200,11 @@ class Store extends BaseService
return $storeList;
}
public function getServerConfig() {
$model = new StoreServerConfig();
return $model->with('iconImage')->hidden(['iconImage'])
->order(['sort' => 'desc', 'create_time' => 'desc'])
->select();
}
}

@ -91,9 +91,9 @@ class Category extends BaseModel
$filter[] = ['is_hot', '=', $params['is_hot']];
}
//添加店内分类
// if (!empty($param['is_in_store']) && $param['is_in_store'] == 1) {
$filter[] = ['is_in_store', '=', $params['is_in_store'] ?? 0];
// }
if (isset($param['is_in_store']) && $param['is_in_store'] != '') {
$filter[] = ['is_in_store', '=', $params['is_in_store']];
}
// 查询列表数据
return $this->with(['image'])

@ -305,10 +305,10 @@ class Goods extends BaseModel
!empty($params['goodsNo']) && $filter[] = ['goods_no', 'like', "%{$params['goodsNo']}%"];
//wmc
if (!empty($param['is_brand'])) {
if (isset($param['is_brand']) && $param['is_brand'] != '') {
$filter[] = ['is_brand', '=', $param['is_brand']];
}
if (!empty($param['is_new'])) {
if (isset($param['is_new']) && $param['is_new'] != '') {
$filter[] = ['is_new', '=', $param['is_new']];
}
if (!empty($param['store_id']) && $a == 0) {
@ -320,7 +320,9 @@ class Goods extends BaseModel
$query->order('paihang asc');
}
//是否店内
$filter[] = ['is_in_store', '=', $params['is_in_store'] ?? 0];
if (isset($param['is_in_store']) && $param['is_in_store'] != '') {
$filter[] = ['is_in_store', '=', $params['is_in_store']];
}
// 实例化新查询对象
return $query->where($filter);

@ -0,0 +1,24 @@
<?php
namespace app\common\model\store;
use app\common\model\UploadFile;
use cores\BaseModel;
class StoreServerConfig extends BaseModel
{
// 定义表名
protected $name = 'store_server_config';
// 定义主键
protected $pk = 'id';
protected $dateFormat = 'Y-m-d H:i:s';
public function IconImage() {
return $this->hasOne(UploadFile::class, 'file_id', 'icon_image_id')
->bind(['icon_url' => 'preview_url']);
}
}

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace app\store\controller;
use app\common\enum\ServerEnum;
use app\common\model\store\StoreServerConfig;
use app\store\model\server\Server as ServerModel;
use app\store\model\ServerCategory;
use cores\exception\BaseException;
@ -292,4 +293,48 @@ class Server extends Controller
}
return $this->renderError('操作失败');
}
/**
* 服务配置
*/
public function configList() {
$model = new StoreServerConfig();
$list = $model->with(['iconImage'])->hidden(['iconImage'])->order(['sort'=>'desc','create_time'=>'desc'])->paginate(10);
return $this->renderSuccess(compact('list'));
}
/**
* 服务配置添加
*/
public function configAdd() {
$model = new StoreServerConfig();
if ($model->save(array_merge(['store_id' => $this->storeId], $this->postForm()))) {
return $this->renderSuccess('新增成功');
}
return $this->renderError('新增失败');
}
/**
* 服务配置编辑
*/
public function configEdit(int $id) {
$detail = StoreServerConfig::get($id);
if ($detail) {
if ($detail->save($this->postForm())) {
return $this->renderSuccess('编辑成功');
}
}
return $this->renderError('编辑失败');
}
/**
* 删除服务配置
*/
public function configDel(int $id) {
$detail = StoreServerConfig::get($id);
if($detail->delete()) {
return $this->renderSuccess('删除成功');
}
return $this->renderError('删除失败');
}
}

Loading…
Cancel
Save