lqmac 6 months ago
parent a2b22afafc
commit f32e982a13
  1. 64
      app/admin/controller/Goods.php
  2. 11
      app/api/controller/Category.php
  3. 3
      app/api/service/Goods.php
  4. 8
      app/command/SyncStoreBasicData.php
  5. 6
      app/common/library/wxserver/Server.php
  6. 6
      app/common/library/wxserver/Wholesaler.php
  7. 47
      app/common/model/Goods.php
  8. 49
      app/job/controller/goods/GoodsDelete.php
  9. 49
      app/job/controller/goods/GoodsOffline.php
  10. 49
      app/job/controller/goods/GoodsOnline.php
  11. 9
      app/job/service/goods/AdminImport.php
  12. 10
      app/job/service/goods/Collector.php
  13. 10
      app/job/service/goods/GoodsAddPrice.php
  14. 49
      app/job/service/goods/GoodsDelete.php
  15. 52
      app/job/service/goods/GoodsOffline.php
  16. 50
      app/job/service/goods/GoodsOnline.php
  17. 10
      app/job/service/goods/GoodsStoreImport.php
  18. 10
      app/job/service/goods/GoodsUpdateImport.php

@ -20,6 +20,9 @@ use app\store\model\GoodsCategoryRel;
use app\store\model\GoodsSku;
use app\store\model\goods\Import as ImportModel;
use app\job\controller\goods\GoodsAddPrice as GoodsAddPriceJob;
use app\job\controller\goods\GoodsOffline as GoodsOfflineJob;
use app\job\controller\goods\GoodsOnline as GoodsOnlineJob;
use app\job\controller\goods\GoodsDelete as GoodsDeleteJob;
/**
* 商品管理控制器
@ -48,7 +51,7 @@ class Goods extends Controller
$params['store_id'] = 0;
//$params['role'] = $this->admin['user']['role'];
$platform = $this->getUserPlatform();
$params['channels'] = $platform ? array_column($platform->toArray(), "code") : [];
$params['channels'] = $this->admin['user']['role'] == 0 ? [] :($platform ? array_column($platform->toArray(), "code") : []);
$list= $model->getAdminList($params, $pageSize);
return $this->renderSuccess(compact('list'));
}
@ -175,11 +178,13 @@ class Goods extends Controller
// 'is_sale' => $goods_sku->is_sale,
'update_time' => time(),
];
if ($goods_sku->is_pool == 0 || $goods_sku->is_sale == 0) {
if ($goods_sku->is_pool != 1 || $goods_sku->is_sale == 0) {
$goods_data['status'] = 20;
$goods_data['is_jd_remove'] = 1;
}
if ($goods_sku->is_pool == 1 && $goods_sku->is_sale == 1) {
$goods_data['status'] = 10;
$goods_data['is_jd_remove'] = 0;
}
GoodsModel::where('origin_goods_id', $goodsId)->update($goods_data);
$goods_sku_data = [
@ -207,20 +212,57 @@ class Goods extends Controller
if (!$model->setIsPool($goodsIds, $is_pool)) {
return $this->renderError($model->getError() ?: '操作失败');
}
// 分批每次导入20条
$limit = 20;
// 根据商品总数量计算需要的队列任务数量
$jobCount = \count($goodsIds) / $limit;
// 逐次发布队列任务
for ($i = 0; $i < $jobCount; $i++) {
$data = array_slice($goodsIds, $i * $limit, $limit);
if ($is_pool == 2) {
GoodsOfflineJob::dispatch([
'list' => $data,
]);
} elseif ($is_pool == 1) {
GoodsOnlineJob::dispatch([
'list' => $data,
]);
}
}
return $this->renderSuccess('操作成功');
}
/**
* 修改商品状态(上下架)
* 修改商品状态(在售、停售)
* @param array $goodsIds 商品id集
* @param bool $state 为true表示上架
* @return Json
*/
public function sale(array $goodsIds, int $is_sale): Json
{
$model = new GoodsModel;
if (!$model->setIsSale($goodsIds, $is_sale)) {
return $this->renderError($model->getError() ?: '操作失败');
}
// 分批每次导入20条
$limit = 20;
// 根据商品总数量计算需要的队列任务数量
$jobCount = \count($goodsIds) / $limit;
// 逐次发布队列任务
for ($i = 0; $i < $jobCount; $i++) {
$data = array_slice($goodsIds, $i * $limit, $limit);
if ($is_sale == 0) {
GoodsOfflineJob::dispatch([
'list' => $data,
]);
} elseif ($is_sale == 1) {
GoodsOnlineJob::dispatch([
'list' => $data,
]);
}
}
return $this->renderSuccess('操作成功');
}
/**
@ -238,7 +280,7 @@ class Goods extends Controller
return $this->renderSuccess('操作成功');
}
/**
* 修改商品状态(上下架)
* 商品归类
* @param array $goodsIds 商品id集
* @param bool $state 为true表示上架
* @return Json
@ -263,8 +305,20 @@ class Goods extends Controller
{
$model = new GoodsModel;
if (!$model->setDelete($goodsIds)) {
return $this->renderError($model->getError() ?: '删除失败');
}
// 分批每次导入20条
$limit = 20;
// 根据商品总数量计算需要的队列任务数量
$jobCount = \count($goodsIds) / $limit;
// 逐次发布队列任务
for ($i = 0; $i < $jobCount; $i++) {
$data = array_slice($goodsIds, $i * $limit, $limit);
GoodsDeleteJob::dispatch([
'list' => $data,
]);
}
return $this->renderSuccess('删除成功');
}
public function export(){
@ -372,7 +426,7 @@ class Goods extends Controller
return $this->renderSuccess('没有需要加价的商品');
}
// 分批每次导入20条
$limit = 50;
$limit = 20;
// 根据商品总数量计算需要的队列任务数量
$jobCount = \count($goodsList) / $limit;
// 逐次发布队列任务

@ -46,9 +46,16 @@ class Category extends Controller
public function childrenList(): Json
{
$param = $this->request->param();
$cache_key = "childrenList".json_encode($param).$this->storeId;
if(Cache::has($cache_key)) {
$list = Cache::get($cache_key);
return $this->renderSuccess(compact('list'));
}
$model = new CategoryModel;
$list = $model->getChildrenList($this->request->param());
$list = $model->getChildrenList($param);
Cache::set($cache_key, $list, 86400);
return $this->renderSuccess(compact('list'));
}

@ -160,7 +160,8 @@ class Goods extends GoodsService
'status' => 10,
'categoryId' => $setting['params']['auto']['category'],
'sortType' => $setting['params']['auto']['goodsSort'],
], $setting['params']['auto']['showNum']);
], 50);
// ], $setting['params']['auto']['showNum']);
$goodsList = $goodsList ? $goodsList->toArray()['data'] : [];
}
//if (empty($goodsList) && $goodsList->isEmpty()) {

@ -26,7 +26,7 @@ use app\store\model\Setting;
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think test
class SyncStoreBasicData extends Command
{
const DEFAULT_STORE_ID = 10045;
const DEFAULT_STORE_ID = 10048;
protected function configure()
{
@ -45,7 +45,6 @@ class SyncStoreBasicData extends Command
protected function execute(Input $input, Output $output)
{
exit();
$store_id = $input->getArgument("store_id");
$isSyncMaintenanceData = $input->getArgument("isSyncMaintenanceData");
$isSyncHelpData = $input->getArgument("isSyncHelpData");
@ -115,13 +114,14 @@ class SyncStoreBasicData extends Command
$expressList = Express::where('store_id',self::DEFAULT_STORE_ID)->select()->toArray();
if ($expressList) {
foreach ($expressList as &$express) {
$info = Express::where('store_id', $store['store_id'])->where('original_id', $express['express_id'])->find();
$info = Express::where('store_id', $store['store_id'])->where('kuaidi100_code', $express['kuaidi100_code'])->where('kdniao_code', $express['kdniao_code'])->find();
if ($info) {
echo $express['express_id']."物流公司已存在".PHP_EOL;
$ret = Express::where('store_id', $store['store_id'])->where('original_id', $express['express_id'])->update([
$ret = Express::where('store_id', $store['store_id'])->where('express_id', $info['express_id'])->update([
'express_name' => $express['express_name'],
'kuaidi100_code' => $express['kuaidi100_code'],
'kdniao_code' => $express['kdniao_code'],
'original_id' => $express['express_id'],
]);
var_dump($ret);
continue;

@ -514,9 +514,9 @@ class Server
if ($token) {
$url = "https://api.weixin.qq.com/wxa/modify_domain_directly?access_token=$token";
$data['action'] = 'set';
$data['requestdomain'] = [$domain, 'https://apis.map.gg.com'];
$data['uploaddomain'] = $domain;
$data['downloaddomain'] = $domain;
$data['requestdomain'] = [$domain, 'https://apis.map.gg.com','https://qiniu.shop.royaum.com.cn'];
$data['uploaddomain'] = [$domain,'https://qiniu.shop.royaum.com.cn'];
$data['downloaddomain'] = [$domain,'https://qiniu.shop.royaum.com.cn'];
$result = $this->curlPost($url, json_encode($data));
$result = json_decode($result, true);
if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') {

@ -508,9 +508,9 @@ class Wholesaler
if ($token) {
$url = "https://api.weixin.qq.com/wxa/modify_domain_directly?access_token=$token";
$data['action'] = 'set';
$data['requestdomain'] = [$domain, 'https://apis.map.gg.com'];
$data['uploaddomain'] = $domain;
$data['downloaddomain'] = $domain;
$data['requestdomain'] = [$domain, 'https://apis.map.gg.com','https://qiniu.shop.royaum.com.cn'];
$data['uploaddomain'] = [$domain,'https://qiniu.shop.royaum.com.cn'];
$data['downloaddomain'] = [$domain,'https://qiniu.shop.royaum.com.cn'];
$result = $this->curlPost($url, json_encode($data));
Db::table('yoshop_wx_server')->insertGetId(['content' => "设置域名信息", 'created_at' => date('Y-m-d H:i:s')]);
Db::table('yoshop_wx_server')->insertGetId(['content' => $result, 'created_at' => date('Y-m-d H:i:s')]);

@ -347,8 +347,10 @@ class Goods extends BaseModel
if (isset($param['fliter_condition']) && $param['fliter_condition']) {
$fliter_condition = json_decode($param['fliter_condition'], true);
$categorys = [];
$str = "";
foreach ($fliter_condition as $value) {
$categorys = array_merge($categorys, $value['category']);
$strConditon = "(";
$strConditon .= "goods_category_rel.category_id in (".implode(",", $value['category']).")";
$strConditon .= " and goods.profit >= ".$value['profit'];
@ -356,15 +358,28 @@ class Goods extends BaseModel
$str .= $strConditon;
}
$str = trim($str, "or ");
// 执行查询
$list = $query->with(['images.file'])
->alias($this->name)
->field($field)
->where('is_delete', '=', 0)
->where($str)
->group("goods.goods_id")
->order($sort)
->paginate($listRows);
//筛选的分类不在当前筛选条件里面就无需带上过滤条件
if (in_array($param['categoryId'], $categorys)) {
// 执行查询
$list = $query->with(['images.file'])
->alias($this->name)
->field($field)
->where('is_delete', '=', 0)
->where($str)
->group("goods.goods_id")
->order($sort)
->paginate($listRows);
} else {
// 执行查询
$list = $query->with(['images.file'])
->alias($this->name)
->field($field)
->where('is_delete', '=', 0)
->group("goods.goods_id")
->order($sort)
->paginate($listRows);
}
} else {
// 执行查询
$list = $query->with(['images.file'])
@ -467,7 +482,7 @@ class Goods extends BaseModel
// 商品状态
$params['status'] > 0 && $filter[] = ['status', '=', (int)$params['status']];
$a = 1;
//$a = 1;
// 商品分类
if ($params['categoryId'] > 0 || (isset($params['fliter_condition']) && $params['fliter_condition'])) {
// 关联商品与分类关系记录表
@ -638,17 +653,7 @@ class Goods extends BaseModel
if (in_array($goodsInfo['channel'], ['sn','sn1']) && $goodsInfo['link_other']) {
$goodsInfo['link'] = $goodsInfo['link_other'];
}
// //商品价格判断
// if (UserService::isLogin()) {
// if (UserService::isStore()) {//店主
// $goodsInfo['goods_price_min_plus'] = 0;
// $goodsInfo['goods_price_min_dealer'] = 0;
// } elseif (UserService::isDealerMember()) { //分销商
// $goodsInfo['goods_price_min_dealer'] = 0;
// } elseif (UserService::isPlusMember()) {//升级会员
// $goodsInfo['goods_price_min_plus'] = 0;
// }
// }
// 回调函数
is_callable($callback) && call_user_func($callback, $goodsInfo);
return $goodsInfo;

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\job\controller\goods;
use app\job\service\goods\GoodsDelete as GoodsDeleteService;
use cores\BaseJob;
use cores\traits\QueueTrait;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 队列任务:商品批量导入
* Class Import
* @package app\job\controller
*/
class GoodsDelete extends BaseJob
{
use QueueTrait;
/**
* 消费队列任务:商品导入
* @param array $data 参数 [index队列顺序;totalCount商品总数量;list商品列表;storeId商城ID]
* @return bool 返回结果
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function handle(array $data): bool
{
$time = date('H:i:s');
echo "\n ---- GoodsDelete ---- {$time} ---- \n";
$service = new GoodsDeleteService;
return $service->batch($data['list']);
}
}

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\job\controller\goods;
use app\job\service\goods\GoodsOffline as GoodsOfflineService;
use cores\BaseJob;
use cores\traits\QueueTrait;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 队列任务:商品批量导入
* Class Import
* @package app\job\controller
*/
class GoodsOffline extends BaseJob
{
use QueueTrait;
/**
* 消费队列任务:商品导入
* @param array $data 参数 [index队列顺序;totalCount商品总数量;list商品列表;storeId商城ID]
* @return bool 返回结果
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function handle(array $data): bool
{
$time = date('H:i:s');
echo "\n ---- GoodsOffline ---- {$time} ---- \n";
$service = new GoodsOfflineService;
return $service->batch($data['list']);
}
}

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\job\controller\goods;
use app\job\service\goods\GoodsOnline as GoodsOnlineService;
use cores\BaseJob;
use cores\traits\QueueTrait;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 队列任务:商品批量导入
* Class Import
* @package app\job\controller
*/
class GoodsOnline extends BaseJob
{
use QueueTrait;
/**
* 消费队列任务:商品导入
* @param array $data 参数 [index队列顺序;totalCount商品总数量;list商品列表;storeId商城ID]
* @return bool 返回结果
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function handle(array $data): bool
{
$time = date('H:i:s');
echo "\n ---- GoodsOnline ---- {$time} ---- \n";
$service = new GoodsOnlineService;
return $service->batch($data['list']);
}
}

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

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

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

@ -0,0 +1,49 @@
<?php
declare (strict_types=1);
namespace app\job\service\goods;
use app\common\library\helper;
use app\common\service\BaseService;
use app\common\model\Goods as GoodsModel;
use app\common\model\GoodsSku;
use app\store\model\GoodsCategoryRel;
use cores\exception\BaseException;
use think\facade\Log;
use app\common\model\Channel;
use app\common\model\Region;
/**
* 服务类:商品批量导入
* Class Import
* @package app\job\service\goods
*/
class GoodsDelete extends BaseService
{
/**
* 批量导入商品
* @param array $list
* @param int $recordId
* @param int $storeId
* @return bool
* @throws BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function batch(array $goodsIds): bool
{
$goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
->where('is_delete',1)
->field(['goods_id','is_sale','is_pool'])
->select();
if ($goods_list->isEmpty()) {
return true;
}
$goodsIds = array_column($goods_list->toArray(), "goods_id");
GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
return true;
}
}

@ -0,0 +1,52 @@
<?php
declare (strict_types=1);
namespace app\job\service\goods;
use app\common\library\helper;
use app\common\service\BaseService;
use app\common\model\Goods as GoodsModel;
use app\common\model\GoodsSku;
use app\store\model\GoodsCategoryRel;
use cores\exception\BaseException;
use think\facade\Log;
use app\common\model\Channel;
use app\common\model\Region;
/**
* 服务类:商品批量导入
* Class Import
* @package app\job\service\goods
*/
class GoodsOffline extends BaseService
{
/**
* 批量导入商品
* @param array $list
* @param int $recordId
* @param int $storeId
* @return bool
* @throws BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function batch(array $goodsIds): bool
{
$goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
->where('is_delete',0)
->where(function($query){
$query->where('is_pool',2)->whereOr('is_sale',0);
})
->field(['goods_id','is_sale','is_pool'])
->select();
if ($goods_list->isEmpty()) {
return true;
}
$goodsIds = array_column($goods_list->toArray(), "goods_id");
GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 20, 'is_jd_remove' => 1, 'update_time' => time()]);
return true;
}
}

@ -0,0 +1,50 @@
<?php
declare (strict_types=1);
namespace app\job\service\goods;
use app\common\library\helper;
use app\common\service\BaseService;
use app\common\model\Goods as GoodsModel;
use app\common\model\GoodsSku;
use app\store\model\GoodsCategoryRel;
use cores\exception\BaseException;
use think\facade\Log;
use app\common\model\Channel;
use app\common\model\Region;
/**
* 服务类:商品批量导入
* Class Import
* @package app\job\service\goods
*/
class GoodsOnline extends BaseService
{
/**
* 批量导入商品
* @param array $list
* @param int $recordId
* @param int $storeId
* @return bool
* @throws BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function batch(array $goodsIds): bool
{
$goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
->where('is_delete',0)
->where('is_sale',1)
->where('is_pool',1)
->field(['goods_id','is_sale','is_pool'])
->select();
if ($goods_list->isEmpty()) {
return true;
}
$goodsIds = array_column($goods_list->toArray(), "goods_id");
GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 10, 'is_jd_remove' => 0, 'update_time' => time()]);
return true;
}
}

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

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

Loading…
Cancel
Save