pifa
zengyyh 6 months ago
commit f4b05cb260
  1. 77
      app/admin/controller/Store.php
  2. 2
      app/api/controller/Dealer.php
  3. 17
      app/api/controller/Invite.php
  4. 52
      app/api/controller/Region copy.php
  5. 4
      app/common/model/Goods.php

@ -372,8 +372,11 @@ class Store extends Controller
* @param int $storeId [description]
* @return [type] [description]
*/
public function deleteGoods(int $storeId): Json
public function deleteGoods(): Json
{
$params = $this->postData();
$storeId = $params['storeId'] ?? 0;
$type = $params['type'] ?? 0;
ini_set('memory_limit', '1024M');
set_time_limit(0);
$model = StoreModel::detail($storeId);
@ -382,36 +385,52 @@ class Store extends Controller
}
//删除分类
Category::where('store_id', $storeId)->delete();
// GoodsSku::where('store_id', $storeId)->delete();
// GoodsImage::where('store_id', $storeId)->delete();
// GoodsSpecRel::where('store_id', $storeId)->delete();
// GoodsModel::where('store_id', $storeId)->delete();
$page = 1;
while (TRUE) {
//echo $page.PHP_EOL;
$goods_list = GoodsModel::where('store_id', $storeId)
->where('channel','<>', 'zy')
->field('goods_id')
->order("goods_id desc")
->page($page)
->limit(2000)
->select();
if ($goods_list->isEmpty()) {
break;
if ($type == "cate") {
Category::where('store_id', $storeId)->delete();
return $this->renderSuccess();
}
if ($type == "goods") {
$page = 1;
while (TRUE) {
//echo $page.PHP_EOL;
$goods_list = GoodsModel::where('store_id', $storeId)
->where('channel','<>', 'zy')
->field('goods_id')
->order("goods_id desc")
->page($page)
->limit(2000)
->select();
if ($goods_list->isEmpty()) {
break;
}
$goods_ids = array_column($goods_list->toArray(), "goods_id");
// 分批每次导入20条
// $limit = 200;
// // 根据商品总数量计算需要的队列任务数量
// $jobCount = \count($goods_ids) / $limit;
// // 逐次发布队列任务
// for ($i = 0; $i < $jobCount; $i++) {
// $data = array_slice($goods_ids, $i * $limit, $limit);
// GoodsRealDeleteJob::dispatch([
// 'list' => $data,
// ]);
// }
//删除商品sku
GoodsSku::whereIn('goods_id', $goods_ids)->delete();
//删除商品图片
GoodsImage::whereIn('goods_id', $goods_ids)->delete();
//删除商品规格
GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete();
$page++;
}
$goods_ids = array_column($goods_list->toArray(), "goods_id");
//删除商品sku
GoodsSku::whereIn('goods_id', $goods_ids)->delete();
//删除商品图片
GoodsImage::whereIn('goods_id', $goods_ids)->delete();
//删除商品规格
GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete();
$page++;
//删除商品
GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->delete();
}
//删除商品
GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->delete();
return $this->renderSuccess();
}

@ -63,7 +63,7 @@ class Dealer extends Controller
{
$dealer = $this->dealer;
if (!$dealer) {
return $this->renderError('您没有购买分销会员');
return $this->renderError('您还没有成为服务商');
}
$dealer = $dealer->toArray();
$dealer['update_time'] = date("Y-m-d", strtotime($dealer['update_time']));

@ -15,6 +15,7 @@ use app\common\model\UploadFile;
use app\common\model\dealer\Setting;
use app\store\model\User;
use app\store\model\user\GradeLog;
use app\store\model\dealer\User;
class Invite extends Controller
{
@ -103,6 +104,7 @@ class Invite extends Controller
$data['adoption_num'] = $adoption_num."/".$invite_num;
$data['invite_num'] = 0;
$data['refuse_num'] = 0;
$data['invite_num'] = 0;
$model = new InviteLog();
$storeId = $this->storeId;
$user_ids = $model->inviteeUserIds();
@ -183,6 +185,21 @@ class Invite extends Controller
'create_time' => time(),
];
GradeLog::create($gradeLog);
if (!DealerUserModel::isDealerUser($this->user['user_id'])) {
// 新增分销商用户
$model = new UserModel();
$mobile = $model->where(['user_id' => $this->user['user_id']])->value('mobile');
DealerUserModel::add($this->user['user_id'], [
'real_name' => $mobile,
'mobile' => $mobile,
'store_id' => $storeId,
]);
} else {
//更新分销用户
DealerUserModel::update(['is_delete' => 0], ['user_id' => $this->user['user_id']]);
}
return $this->renderSuccess('升级成功');
}

@ -1,52 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\controller;
use app\api\model\Region as RegionModel;
use think\response\Json;
/**
* 地区管理
* Class Region
* @package app\api\controller
*/
class Region extends Controller
{
/**
* 获取所有地区
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function all(): Json
{
$list = RegionModel::getCacheAll();
return $this->renderSuccess(compact('list'));
}
/**
* 获取所有地区(树状)
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function tree(): Json
{
$model = new RegionModel();
$list = $model->getNewTreeList();
//$list = array_values($list);
return $this->renderSuccess(compact('list'));
}
}

@ -27,6 +27,8 @@ use think\model\relation\HasOne;
use think\Paginator;
use app\store\model\GoodsImage as GoodsImageModel;
use app\store\model\UploadFile as UploadFileModel;
use think\facade\Log;
/**
* 商品模型
* Class Goods
@ -330,7 +332,7 @@ class Goods extends BaseModel
}
$str = trim($str, "or ");
//筛选的分类不在当前筛选条件里面就无需带上过滤条件
if (in_array($param['categoryId'], $categorys)) {
if (!$param['categoryId'] || in_array($param['categoryId'], $categorys)) {
// 执行查询
$list = $query->with(['images.file'])
->alias($this->name)

Loading…
Cancel
Save