lszyh
lqmac 8 months ago
parent 978de26bfa
commit 49b402b823
  1. 5
      app/admin/controller/Goods.php
  2. 11
      app/api/controller/Upload.php
  3. 35
      app/api/model/Goods.php
  4. 7
      app/api/service/Goods.php
  5. 5
      app/api/service/Upload.php
  6. 9
      app/job/service/goods/AdminImport.php
  7. 8
      app/job/service/goods/Collector.php
  8. 3
      app/job/service/goods/GoodsUpdateImport.php
  9. 2
      app/store/model/goods/Import.php

@ -326,7 +326,7 @@ class Goods extends Controller
$model = new GoodsModel;
$params = $this->request->param();
$params['store_id'] = 0;
$perSize = 10000;
$perSize = 100000;
$params['page'] = 1;
$platform = $this->getUserPlatform();
$params['channels'] = $platform ? array_column($platform->toArray(), "code") : [];
@ -344,6 +344,9 @@ class Goods extends Controller
['link_other'=>'京东的价拖链接'],
['goods_price_min'=>'前台价'],
['goods_no'=>'sku'],
['goods_source'=>'商品来源 (GC:工厂 CC:仓储 ZC:自采 填其中一项)'],
['delivery_time'=>'发货时效(0:24小时 1:48小时 2:72小时 3:7天内 4:15天内 5:30天内 6:45天内 填写其中一项)'],
['is_check'=>'是否审单(是填1 否填0)'],
];
downLoadExcel('导出数据-'.date('Y-m-d', time()),$titles,$data['data']);

@ -36,9 +36,17 @@ class Upload extends Controller
*/
public function image(bool $checkLogin = true): Json
{
$params = $this->request->param();
// echo "<pre>";
// print_r($params);
// print_r($_FILES);
// exit();
// if (isset($params['filename']) && $params['filename']) {
// $_FILES['file']['name'] = $params['filename'];
// }
// 执行文件上传
$service = new UploadService();
if (!$service->upload(FileTypeEnum::IMAGE, $checkLogin)) {
if (!$service->upload(FileTypeEnum::IMAGE, $checkLogin, ($params['filename'] ?? ""))) {
return $this->renderError('文件上传失败:' . $service->getError());
}
// 图片上传成功
@ -48,6 +56,7 @@ class Upload extends Controller
public function wxUpload(): Json
{
$checkLogin = $this->request->param('checkLogin');
// 执行文件上传
$service = new UploadService();
if (!$service->upload(FileTypeEnum::IMAGE, boolval($checkLogin))) {

@ -581,7 +581,11 @@ class Goods extends GoodsModel
$value->goods_sku_no = $goodsInfo['goods_no_other'];
}
}
//是否展示看同款按钮
$goodsInfo->is_show_ktk = 1;
if (in_array($goodsInfo['channel'], ['sn','sn1']) && !$goodsInfo['link_other']) {
$goodsInfo->is_show_ktk = 0;
}
// 判断商品是否存在
if (empty($goodsInfo) || $goodsInfo['is_delete']) {
throwError('很抱歉,商品信息不存在');
@ -623,6 +627,7 @@ class Goods extends GoodsModel
$catService = new GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id');
$currtime = time();
if ($goods->getAttr('skuInfo')) {
if (UserService::isPlusMember()) {
$goods['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds);
@ -631,7 +636,10 @@ class Goods extends GoodsModel
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds);
$goods['skuInfo']['goods_price'] = $priceArr['distributionPrice'];
}
//处理店长临时设置的秒杀价
if ($goods['skuInfo']['sec_start_time'] && strtotime($goods['skuInfo']['sec_start_time']) <= $currtime && (strtotime($goods['skuInfo']['sec_start_time']) + 24 * 3600) >= $currtime) {
$goods['skuInfo']['goods_price'] = $goods['skuInfo']['seckill_price'];
}
}
//(new static)->setGoodsMoney($goodsInfo);
return $goods['skuInfo'];
@ -680,7 +688,7 @@ class Goods extends GoodsModel
$goods['line_price_min'] = $goods['goods_price_min'];
return;
}
$currtime = time();
$catService = new GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id');
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价
@ -702,13 +710,18 @@ class Goods extends GoodsModel
//$goods['goods_price_min'] = $membershipPrice;
$goods['goods_price_min'] = $priceArr['distributionPrice'];
}
//处理店长临时设置的秒杀价
if ($goods['sec_start_time'] && strtotime($goods['sec_start_time']) <= $currtime && (strtotime($goods['sec_start_time']) + 24 * 3600) >= $currtime) {
$goods['goods_price_min'] = $goods['seckill_price'];
}
// if ($goods['discount'] == 10) {
// $goods['discount'] = 0.0;
// }
// 会员折扣价: 商品sku列表
if ($goods->getRelation('skuList') || $goods->getRelation('skuList1')) {
foreach ($goods['skuList'] as &$skuItem) {
//处理图片和库
$goods_image = GoodsImage::where('goods_id', $skuItem['goods_id'])->order("id asc")->find();
@ -728,13 +741,17 @@ class Goods extends GoodsModel
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds);
$skuItem['goods_price'] = $priceArr['distributionPrice'];
}
//处理店长临时设置的秒杀价
if ($skuItem['sec_start_time'] && strtotime($skuItem['sec_start_time']) <= $currtime && (strtotime($skuItem['sec_start_time']) + 24 * 3600) >= $currtime) {
$skuItem['goods_price'] = $skuItem['seckill_price'];
}
}
}
// 折扣价: 已选择的商品sku(用于购物车)
if ($goods->getAttr('skuInfo')) {
if (UserService::isPlusMember()) {
// $sku_price_plus = [];
@ -753,7 +770,10 @@ class Goods extends GoodsModel
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds);
$goods['skuInfo']['goods_price'] = $priceArr['distributionPrice'];
}
//处理店长临时设置的秒杀价
if ($goods['skuInfo']['sec_start_time'] && strtotime($goods['skuInfo']['sec_start_time']) <= $currtime && (strtotime($goods['skuInfo']['sec_start_time']) + 24 * 3600) >= $currtime) {
$goods['skuInfo']['goods_price'] = $goods['skuInfo']['seckill_price'];
}
}
}
@ -878,6 +898,7 @@ class Goods extends GoodsModel
'sec_hour' => $data['sec_hour'],
];
$skuData->save($up_data);
GoodsModel::where('goods_id', $data['goods_id'])->update($up_data);
}
// }
return true;

@ -158,7 +158,7 @@ class Goods extends GoodsService
// 数据来源:自动
$goodsList = $model->getList([
'status' => 10,
'categoryId' => $setting['params']['auto']['category'],
'categoryId' => is_array($setting['params']['auto']['category']) ? implode(',', $setting['params']['auto']['category']) : $setting['params']['auto']['category'],
'sortType' => $setting['params']['auto']['goodsSort'],
], 50);
// ], $setting['params']['auto']['showNum']);
@ -198,7 +198,7 @@ class Goods extends GoodsService
// 数据来源:自动
$goodsList = $model->getList([
'status' => 10,
'categoryId' => $setting['params']['auto']['category'],
'categoryId' => is_array($setting['params']['auto']['category']) ? implode(',', $setting['params']['auto']['category']) : $setting['params']['auto']['category'],
'sortType' => $setting['params']['auto']['goodsSort'],
'page' => $param['page'] ?? 1,
], 10);
@ -234,7 +234,7 @@ class Goods extends GoodsService
'status' => 1,
'is_paihang' => 1,
'store_id' => $storeid
])->order('category_id desc')->select()->toArray();
])->order('sort asc, category_id desc')->select()->toArray();
return $list;
}
@ -317,6 +317,7 @@ class Goods extends GoodsService
$file = UploadFile::whereIn('file_id', explode(',', $info['shop_image_id']))->select();
$info['imageList'] = helper::getArrayColumn($file, 'preview_url');
$info['service_num_for_me'] = 0;
$info['summary'] = mb_substr($info['summary'],0,32);
//当前用户门店自提订单数
$userId = UserService::getCurrentLoginUserId(false);
if ($userId) {

@ -53,7 +53,7 @@ class Upload extends BaseService
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function upload(int $fileType, bool $checkLogin = true): bool
public function upload(int $fileType, bool $checkLogin = true, $filename = ""): bool
{
$userId = $checkLogin && UserService::isLogin(true) ? UserService::getCurrentLoginUserId() : 0;
// 实例化上传驱动
@ -65,6 +65,9 @@ class Upload extends BaseService
}
// 文件信息
$fileInfo = $storage->getSaveFileInfo();
if ($filename) {
$fileInfo['file_name'] = $filename;
}
// 添加文件库记录
return $this->record($fileInfo, $fileType, $userId);
}

@ -95,7 +95,7 @@ class AdminImport extends BaseService
$service = new \app\job\service\goods\Collector();
foreach ($list as $item) {
//sku存在了就不抓取了
$info = GoodsModel::where('goods_no', $item['C'])->where('store_id', $storeId)->where('channel', $item['B'])->where('is_delete',0)->find();
$info = GoodsModel::where('goods_no', $item['C'])->where('store_id', $storeId)->where('channel', $item['A0'])->where('is_delete',0)->find();
if ($info) {
$this->successCount++;
continue;
@ -230,13 +230,16 @@ class AdminImport extends BaseService
// 整理商品数据
$data = [
'cmmdty_model' => $original["A"],
'channel' => $original["B"] ?? "zy",
'channel' => $original["A0"] ?? "zy",
'goods_source' => $original["B"] ?? "GC",
'delivery_time' => $original["K"] ?? 2,
'is_check' => $original["L"] ?? 0,
'goods_no' => $original["C"],
'goods_price' => $original["F"],
'cost_price' => $original["G"],
'stock_num' => $original["H"],
'remark' => $original["I"],
'delivery_id' => $original["K"],
//'delivery_id' => $original["K"],
//'link' => $original["D"],
'categoryIds' => $this->ids2array($original["E"]),
'imageStorage' => 20,//下载图片到本地

@ -223,9 +223,9 @@ class Collector extends BaseService
$original['goods_no'] = $form['goods_no'] ?? "";
$original['region'] = $form['region'] ?? "";
$original['region_text'] = $form['region_text'] ?? "";
$original['delivery_time'] = $form['delivery_time'] ?? "";
$original['delivery_time'] = $form['delivery_time'] ?? 2;
$original['is_check'] = $form['is_check'] ?? 0;
$original['goods_source'] = $form['goods_source'] ?? "";
$original['goods_source'] = $form['goods_source'] ?? "GC";
$original['data_type'] = 1;
$original['link'] = $url;
// echo "<pre>";
@ -331,6 +331,10 @@ class Collector extends BaseService
$data['content'] = $original['content'];
//重新计算利润和利润率
$data['goods_source'] = $form['goods_source'];
$data['cmmdty_model'] = $form['cmmdty_model'];
$data['delivery_time'] = $form['delivery_time'];
$data['is_check'] = $form['is_check'];
$data['goods_price_min'] = $original['goods_price'];
$data['goods_price_max'] = $original['goods_price'];
$data['line_price_min'] = $original['goods_price'];

@ -128,6 +128,9 @@ class GoodsUpdateImport extends BaseService
'stock_total' => $original['F'] ?? "",
'link_other' => $original['G'] ?? "",
'goods_price_min' => $original['H'] ?? "",
'goods_source' => $original['J'] ?? "GC",
'delivery_time' => $original['K'] ?? 2,
'is_check' => $original['L'] ?? 0,
];
return $data;

@ -89,7 +89,7 @@ class Import extends ImportModel
self::$merchantId = $form['merchant_id'] ?? 0;
self::$storeId = $form['store_id'] ?? 0;
foreach ($execlData as &$value) {
$value['B'] = $form['channel']??'zy';
$value['A0'] = $form['channel']??'zy';
}
// $obj = new \app\job\service\goods\AdminImport();
// $service = new \app\job\service\goods\Collector();

Loading…
Cancel
Save