lqmac 7 months ago
parent 0fc84ef58c
commit 88d431f54f
  1. 16
      app/admin/controller/Store.php
  2. 9
      app/admin/model/Store.php
  3. 10
      app/api/service/Goods.php
  4. 10
      app/command/SyncCategory.php
  5. 8
      app/store/controller/Presale.php

@ -106,7 +106,21 @@ class Store extends Controller
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* 更新商城信息
* @return Json
*/
public function edit(int $storeId): Json
{
$params = $this->postForm();
// 商城详情
$model = StoreModel::detail($storeId);
// 更新记录
if (!$model->edit($params)) {
return $this->renderError($model->getError() ?: '更新失败');
}
return $this->renderSuccess('更新成功');
}
/**
* 移入回收站
* @param int $storeId

@ -82,6 +82,15 @@ class Store extends StoreModel
return $status;
});
}
/**
* 更新记录
* @param array $data
* @return bool
*/
public function edit(array $data): bool
{
return $this->save($data) !== false;
}
/**
* 新增一个多商户角色,不能删除
* [addMerchantRoleAndMenu description]

@ -413,19 +413,25 @@ class Goods extends GoodsService
'goods_sales' => $goods['goods_sales'],
'remaizhishu' => $goods['remaizhishu'],
];
$currtime = time();
if (UserService::isLogin()) {
$catService = new \app\store\model\GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods['goods_id']])->column('category_id');
//价格判断
if (UserService::isstore()) {
$temp['goods_price_min'] = $goods['cost_price_min'];
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
$temp['goods_price_min_plus'] = $priceArr['membershipPrice'];
$temp['goods_price_min_dealer'] = $priceArr['distributionPrice'];
$temp['goods_price_min'] = $goods['goods_price_min_plus'];//$goods['cost_price_min'];//店长售价,展示为成本价
} elseif (UserService::isPlusMember()) {
$temp['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
} elseif (UserService::isDealerMember()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
$temp['goods_price_min'] = $priceArr['distributionPrice'];
}
if ($goods['sec_start_time'] && strtotime($goods['sec_start_time']) <= $currtime && (strtotime($goods['sec_start_time']) + 24 * 3600) >= $currtime) {
$temp['goods_price_min'] = $goods['seckill_price'];
}
}
$data[] = $temp;
}

@ -72,6 +72,7 @@ class SyncCategory extends Command
$upData = [
'name' => $value['name'],
'level' => $value['level'],
'sort' => $value['sort'],
'parent_id' => $p_category['category_id'] ?? 0,
];
if ($is_update_image) {
@ -119,6 +120,7 @@ class SyncCategory extends Command
$upData1 = [
'name' => $value1['name'],
'level' => $value1['level'],
'sort' => $value1['sort'],
'parent_id' => $p_category1['category_id'] ?? 0,
];
if ($is_update_image) {
@ -155,7 +157,6 @@ class SyncCategory extends Command
if ($value2['status'] != 1) {
continue;
}
$category2 = CategoryModel::where('original_category_id', $value2['category_id'])->where('store_id', $new_store_id)->find();
if ($category2) {
//更新分类
@ -164,6 +165,7 @@ class SyncCategory extends Command
$upData2 = [
'name' => $value2['name'],
'level' => $value2['level'],
'sort' => $value2['sort'],
'parent_id' => $p_category2['category_id'] ?? 0,
];
if ($is_update_image) {
@ -209,6 +211,7 @@ class SyncCategory extends Command
$upData3 = [
'name' => $value3['name'],
'level' => $value3['level'],
'sort' => $value3['sort'],
'parent_id' => $p_category3['category_id'] ?? 0,
];
if ($is_update_image) {
@ -246,14 +249,15 @@ class SyncCategory extends Command
continue;
}
$category4 = CategoryModel::where('original_category_id', $value4['category_id'])->find();
$category4 = CategoryModel::where('original_category_id', $value4['category_id'])->where('store_id', $new_store_id)->find();
if ($category4) {
//更新分类
//父类id
$p_category4 = CategoryModel::where('original_category_id', $value4['parent_id'])->find();
$p_category4 = CategoryModel::where('original_category_id', $value4['parent_id'])->where('store_id', $new_store_id)->find();
$upData4 = [
'name' => $value4['name'],
'level' => $value4['level'],
'sort' => $value4['sort'],
'parent_id' => $p_category4['category_id'] ?? 0,
];
if ($is_update_image) {

@ -20,10 +20,14 @@ class Presale extends Controller
{
// 店员列表
$model = new PreSaleModel;
$goodsModel = new \app\common\model\Goods();
$goodsModel = new \app\store\model\Goods();
$list = $model->where('store_id', $this->storeId)->paginate(15);
foreach ($list as &$row) {
$row['goods_list'] = $goodsModel->whereIn('goods_id', explode(',', $row['goods_list']))->select()->toArray();
if ($row['goods_list']) {
$goods_list = $goodsModel->getListByIds(explode(',', $row['goods_list']));
$row['goods_list'] = json_decode($goods_list, true);
}
}
return $this->renderSuccess(compact('list'));
}

Loading…
Cancel
Save