Explorar o código

刷新商品增加日志

kevin_zhangl %!s(int64=3) %!d(string=hai) anos
pai
achega
197df969d1
Modificáronse 1 ficheiros con 11 adicións e 3 borrados
  1. 11 3
      common/models/forms/ShopGoodsForm.php

+ 11 - 3
common/models/forms/ShopGoodsForm.php

@@ -315,20 +315,28 @@ class ShopGoodsForm extends Model
         $goods = ShopGoods::findAll(['STATUS' => 1]);
 
         $transaction = \Yii::$app->db->beginTransaction();
-        try{
+        try {
             foreach ($goods as $good) {
+                $content = [
+                    'id'                => $good->ID,
+                    'exchangeRate'      => $exchangeRate,
+                    'priceStandard'     => $good->SELL_PRICE_STANDARD,
+                    'originSellPrice'   => $good->SELL_PRICE,
+                    'modernSellPrice'   => $good->SELL_PRICE_STANDARD * $exchangeRate,
+                ];
+
                 $good->SELL_PRICE = $good->SELL_PRICE_STANDARD * $exchangeRate;
                 $good->UPDATED_AT = Date::nowTime();
                 if (!$good->save()) {
                     throw new Exception(Form::formatErrorsForApi($good->getErrors()));
                 }
 
-                $item = json_encode($good->toArray());
+                $item = json_encode($content);
                 echo "商品 {$item} 更新成功!" . PHP_EOL;
             }
 
             $transaction->commit();
-        } catch (Exception $e){
+        } catch (Exception $e) {
             $transaction->rollBack();
             $this->addError('update', $e->getMessage());
             return false;