pifa
zengyyh 6 months ago
commit f4b05cb260
  1. 79
      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,46 +372,65 @@ class Store extends Controller
* @param int $storeId [description] * @param int $storeId [description]
* @return [type] [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'); ini_set('memory_limit', '1024M');
set_time_limit(0); set_time_limit(0);
$model = StoreModel::detail($storeId); $model = StoreModel::detail($storeId);
if (!$model || $storeId <= 0) { if (!$model || $storeId <= 0) {
return $this->renderError('商城不存在'); return $this->renderError('商城不存在');
} }
//删除分类 //删除分类
Category::where('store_id', $storeId)->delete(); if ($type == "cate") {
// GoodsSku::where('store_id', $storeId)->delete(); Category::where('store_id', $storeId)->delete();
// GoodsImage::where('store_id', $storeId)->delete(); return $this->renderSuccess();
// GoodsSpecRel::where('store_id', $storeId)->delete(); }
// GoodsModel::where('store_id', $storeId)->delete();
$page = 1; if ($type == "goods") {
while (TRUE) { $page = 1;
//echo $page.PHP_EOL; while (TRUE) {
$goods_list = GoodsModel::where('store_id', $storeId) //echo $page.PHP_EOL;
->where('channel','<>', 'zy') $goods_list = GoodsModel::where('store_id', $storeId)
->field('goods_id') ->where('channel','<>', 'zy')
->order("goods_id desc") ->field('goods_id')
->page($page) ->order("goods_id desc")
->limit(2000) ->page($page)
->select(); ->limit(2000)
if ($goods_list->isEmpty()) { ->select();
break; 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 GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->delete();
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();
return $this->renderSuccess(); return $this->renderSuccess();
} }

@ -63,7 +63,7 @@ class Dealer extends Controller
{ {
$dealer = $this->dealer; $dealer = $this->dealer;
if (!$dealer) { if (!$dealer) {
return $this->renderError('您没有购买分销会员'); return $this->renderError('您还没有成为服务商');
} }
$dealer = $dealer->toArray(); $dealer = $dealer->toArray();
$dealer['update_time'] = date("Y-m-d", strtotime($dealer['update_time'])); $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\common\model\dealer\Setting;
use app\store\model\User; use app\store\model\User;
use app\store\model\user\GradeLog; use app\store\model\user\GradeLog;
use app\store\model\dealer\User;
class Invite extends Controller class Invite extends Controller
{ {
@ -103,6 +104,7 @@ class Invite extends Controller
$data['adoption_num'] = $adoption_num."/".$invite_num; $data['adoption_num'] = $adoption_num."/".$invite_num;
$data['invite_num'] = 0; $data['invite_num'] = 0;
$data['refuse_num'] = 0; $data['refuse_num'] = 0;
$data['invite_num'] = 0;
$model = new InviteLog(); $model = new InviteLog();
$storeId = $this->storeId; $storeId = $this->storeId;
$user_ids = $model->inviteeUserIds(); $user_ids = $model->inviteeUserIds();
@ -183,6 +185,21 @@ class Invite extends Controller
'create_time' => time(), 'create_time' => time(),
]; ];
GradeLog::create($gradeLog); 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('升级成功'); 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 think\Paginator;
use app\store\model\GoodsImage as GoodsImageModel; use app\store\model\GoodsImage as GoodsImageModel;
use app\store\model\UploadFile as UploadFileModel; use app\store\model\UploadFile as UploadFileModel;
use think\facade\Log;
/** /**
* 商品模型 * 商品模型
* Class Goods * Class Goods
@ -330,7 +332,7 @@ class Goods extends BaseModel
} }
$str = trim($str, "or "); $str = trim($str, "or ");
//筛选的分类不在当前筛选条件里面就无需带上过滤条件 //筛选的分类不在当前筛选条件里面就无需带上过滤条件
if (in_array($param['categoryId'], $categorys)) { if (!$param['categoryId'] || in_array($param['categoryId'], $categorys)) {
// 执行查询 // 执行查询
$list = $query->with(['images.file']) $list = $query->with(['images.file'])
->alias($this->name) ->alias($this->name)

Loading…
Cancel
Save