diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 286a6a82..af7bbc41 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -208,7 +208,7 @@ class Goods extends BaseModel // 执行查询 $list = $query ->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) ->order($sort) ->paginate($listRows); diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index 03d3c89c..4f097e1e 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -204,12 +204,24 @@ class Goods extends Controller $params['store_id'] = $this->storeId; $perSize = 10000; $params['page'] = 1; - $params['channels'] = ['zy']; + //$params['channels'] = ['zy']; + // echo "
"; + // print_r($params); + //exit(); $data = $model->getAdminListExport($params, $perSize)->toArray(); // echo ""; // print_r($data['data']); + // exit(); if ($data['data']) { 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(); $value['category_id'] = $cates ? implode(",", array_column($cates, "category_id")) : ""; } diff --git a/app/store/model/goods/Import.php b/app/store/model/goods/Import.php index 15ef06a6..e5927c1a 100644 --- a/app/store/model/goods/Import.php +++ b/app/store/model/goods/Import.php @@ -231,28 +231,48 @@ class Import extends ImportModel self::$storeId = $form['store_id'] ?? 0; foreach ($execlData as $key => $value) { + $upData = [ 'goods_name'=> $value['B'], 'cmmdty_model'=> $value['C'], 'goods_source'=> $value['D'], - 'goods_no'=> $value['E'], + //'goods_no'=> $value['E'], 'delivery_time'=> $value['G'], 'is_check'=> $value['H'], 'delivery_id'=> $value['I'], 'status'=> $value['J'], - 'cost_price_min'=> $value['K'], - 'goods_price_min'=> $value['L'], - 'goods_price_max'=> $value['L'], - 'line_price_min'=> $value['L'], - 'line_price_max'=> $value['L'], + // 'cost_price_min'=> $value['K'], + // 'goods_price_min'=> $value['L'], + // 'goods_price_max'=> $value['L'], + // 'line_price_min'=> $value['L'], + // 'line_price_max'=> $value['L'], 'stock_total'=> $value['M'], '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 ""; // print_r(explode(",", $value['F'])); // exit(); 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'])); } return true;