lqmac 6 months ago
parent 3cf25d8c3f
commit b090f55ce4
  1. 2
      app/common/model/Goods.php
  2. 14
      app/store/controller/Goods.php
  3. 34
      app/store/model/goods/Import.php

@ -208,7 +208,7 @@ class Goods extends BaseModel
// 执行查询 // 执行查询
$list = $query $list = $query
->alias($this->name) ->alias($this->name)
->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other']) ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other','channel'])
->where('is_delete', '=', 0) ->where('is_delete', '=', 0)
->order($sort) ->order($sort)
->paginate($listRows); ->paginate($listRows);

@ -204,12 +204,24 @@ class Goods extends Controller
$params['store_id'] = $this->storeId; $params['store_id'] = $this->storeId;
$perSize = 10000; $perSize = 10000;
$params['page'] = 1; $params['page'] = 1;
$params['channels'] = ['zy']; //$params['channels'] = ['zy'];
// echo "<pre>";
// print_r($params);
//exit();
$data = $model->getAdminListExport($params, $perSize)->toArray(); $data = $model->getAdminListExport($params, $perSize)->toArray();
// echo "<pre>"; // echo "<pre>";
// print_r($data['data']); // print_r($data['data']);
// exit();
if ($data['data']) { if ($data['data']) {
foreach ($data['data'] as &$value) { foreach ($data['data'] as &$value) {
if (!in_array($value['channel'], ['zy'])) {
$value['goods_price_min'] = self::$show_content;
$value['goods_price_max'] = self::$show_content;
$value['line_price_max'] = self::$show_content;
$value['line_price_min'] = self::$show_content;
$value['cost_price_min'] = self::$show_content;
$value['goods_no'] = self::$show_content;
}
$cates = GoodsCategoryRel::where('goods_id', $value['goods_id'])->select()->toArray(); $cates = GoodsCategoryRel::where('goods_id', $value['goods_id'])->select()->toArray();
$value['category_id'] = $cates ? implode(",", array_column($cates, "category_id")) : ""; $value['category_id'] = $cates ? implode(",", array_column($cates, "category_id")) : "";
} }

@ -231,28 +231,48 @@ class Import extends ImportModel
self::$storeId = $form['store_id'] ?? 0; self::$storeId = $form['store_id'] ?? 0;
foreach ($execlData as $key => $value) { foreach ($execlData as $key => $value) {
$upData = [ $upData = [
'goods_name'=> $value['B'], 'goods_name'=> $value['B'],
'cmmdty_model'=> $value['C'], 'cmmdty_model'=> $value['C'],
'goods_source'=> $value['D'], 'goods_source'=> $value['D'],
'goods_no'=> $value['E'], //'goods_no'=> $value['E'],
'delivery_time'=> $value['G'], 'delivery_time'=> $value['G'],
'is_check'=> $value['H'], 'is_check'=> $value['H'],
'delivery_id'=> $value['I'], 'delivery_id'=> $value['I'],
'status'=> $value['J'], 'status'=> $value['J'],
'cost_price_min'=> $value['K'], // 'cost_price_min'=> $value['K'],
'goods_price_min'=> $value['L'], // 'goods_price_min'=> $value['L'],
'goods_price_max'=> $value['L'], // 'goods_price_max'=> $value['L'],
'line_price_min'=> $value['L'], // 'line_price_min'=> $value['L'],
'line_price_max'=> $value['L'], // 'line_price_max'=> $value['L'],
'stock_total'=> $value['M'], 'stock_total'=> $value['M'],
'remark'=> $value['N'], 'remark'=> $value['N'],
]; ];
$goods = GoodsModel::where('goods_id', $value['A'])->find();
if (!$goods) {
continue;
}
//自营数据才能更新价格
if (in_array($goods['channel'], ['zy'])) {
$upData['goods_no'] = $value['E'];
$upData['cost_price_min'] = $value['K'];
$upData['goods_price_min' ]= $value['L'];
$upData['goods_price_max'] = $value['L'];
$upData['line_price_min'] = $value['L'];
$upData['line_price_max'] = $value['L'];
$profit = (float)$upData['goods_price_min'] - (float)$upData['cost_price_min'];
$profit_rate = (float)$upData['goods_price_min'] > 0 ? bcmul(bcdiv((string)$profit, (string)$upData['goods_price_min'], 2), (string)100, 2) : 0.00;
$upData['profit'] = $profit;
$upData['profit_rate'] = $profit_rate;
GoodsSkuModel::where('goods_id', $value['A'])->update(['cost_price' => $value['K'], 'goods_price' => $value['L']]);
}
// echo "<pre>"; // echo "<pre>";
// print_r(explode(",", $value['F'])); // print_r(explode(",", $value['F']));
// exit(); // exit();
GoodsModel::where('goods_id', $value['A'])->update($upData); GoodsModel::where('goods_id', $value['A'])->update($upData);
GoodsSkuModel::where('goods_id', $value['A'])->update(['cost_price' => $value['K'], 'goods_price' => $value['L']]);
GoodsCategoryRelModel::updates((int)$value['A'], explode(",", $value['F'])); GoodsCategoryRelModel::updates((int)$value['A'], explode(",", $value['F']));
} }
return true; return true;

Loading…
Cancel
Save