|
|
@@ -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;
|