lqmac 10 months ago
parent 1d0acf4eb3
commit cdc3f533f8
  1. 6
      app/admin/controller/Goods.php
  2. 9
      app/store/model/Goods.php
  3. BIN
      public/admin/static/template/batch-admin-goods.xlsx
  4. BIN
      public/store/static/template/batch-goods.xlsx

@ -127,9 +127,9 @@ class Goods extends Controller
{ {
// 商品详情 // 商品详情
$model = GoodsModel::detail($goodsId); $model = GoodsModel::detail($goodsId);
echo "<pre>"; // echo "<pre>";
print_r($this->postForm()); // print_r($this->postForm());
exit(); // exit();
// 更新记录 // 更新记录
if ($model->edit($this->postForm(), $model)) { if ($model->edit($this->postForm(), $model)) {
return $this->renderSuccess('更新成功'); return $this->renderSuccess('更新成功');

@ -279,6 +279,10 @@ class Goods extends GoodsModel
$data['line_price_min'] = $data['line_price_max'] = $data['goods_price']; $data['line_price_min'] = $data['line_price_max'] = $data['goods_price'];
$data['stock_total'] = $data['stock_num']; $data['stock_total'] = $data['stock_num'];
$data['cost_price_min'] = $data['cost_price']??0; $data['cost_price_min'] = $data['cost_price']??0;
$profit = (float)$data['goods_price_min'] - (float)$data['cost_price_min'];
$profit_rate = (float)$data['goods_price_min'] > 0 ? bcmul((string)($profit / (float)$data['goods_price_min']) , "100", 2) : 0.00;
$data['profit'] = $profit;
$data['profit_rate'] = $profit_rate;
} }
// 规格和sku数据处理 // 规格和sku数据处理
if ($data['spec_type'] == GoodsSpecTypeEnum::MULTI) { if ($data['spec_type'] == GoodsSpecTypeEnum::MULTI) {
@ -301,10 +305,7 @@ class Goods extends GoodsModel
$aloneGradeEquity[$gradeId] = $value; $aloneGradeEquity[$gradeId] = $value;
} }
} }
$profit = (float)$data['goods_price_min'] - (float)$data['cost_price_min'];
$profit_rate = (float)$data['goods_price_min'] > 0 ? bcmul((string)($profit / (float)$data['goods_price_min']) , "100", 2) : 0.00;
$data['profit'] = $profit;
$data['profit_rate'] = $profit_rate;
$data['alone_grade_equity'] = $aloneGradeEquity; $data['alone_grade_equity'] = $aloneGradeEquity;
return $data; return $data;
} }

Loading…
Cancel
Save