|
|
@@ -23,7 +23,8 @@ class CurrenciesConversionsForm extends Model
|
|
|
|
|
|
public $from_currency_id;
|
|
|
public $to_currency_id;
|
|
|
- public $rate;
|
|
|
+ public $product_rate;
|
|
|
+ public $bonuses_rate;
|
|
|
public $synchronize;
|
|
|
|
|
|
private $period;
|
|
|
@@ -43,7 +44,7 @@ class CurrenciesConversionsForm extends Model
|
|
|
public function rules()
|
|
|
{
|
|
|
return [
|
|
|
- [['from_currency_id', 'to_currency_id', 'rate'], 'required'],
|
|
|
+ [['from_currency_id', 'to_currency_id', 'product_rate', 'bonuses_rate'], 'required'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -52,7 +53,8 @@ class CurrenciesConversionsForm extends Model
|
|
|
return [
|
|
|
'from_currency_id' => 'From Currency Name', // 源汇率
|
|
|
'to_currency_id' => 'To Currency Name', // 目标汇率
|
|
|
- 'rate' => 'Rate', // 汇率
|
|
|
+ 'product_rate' => 'Product Rate', // 商品汇率
|
|
|
+ 'bonuses_rate' => 'Bonuses_rate Rate', // 奖金汇率
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -64,7 +66,7 @@ class CurrenciesConversionsForm extends Model
|
|
|
{
|
|
|
$parentScenarios = parent::scenarios();
|
|
|
$customScenarios = [
|
|
|
- 'setCurrenciesConversions' => ['from_currency_id', 'to_currency_id', 'rate'],
|
|
|
+ 'setCurrenciesConversions' => ['from_currency_id', 'to_currency_id', 'product_rate', 'bonuses_rate'],
|
|
|
];
|
|
|
|
|
|
return array_merge($parentScenarios, $customScenarios);
|
|
|
@@ -94,16 +96,17 @@ class CurrenciesConversionsForm extends Model
|
|
|
$model->PERIOD_NUM = $this->period->getNowPeriodNum();
|
|
|
$model->FROM_CURRENCY_ID = $this->from_currency_id;
|
|
|
$model->TO_CURRENCY_ID = $this->to_currency_id;
|
|
|
- $model->RATE = $this->rate;
|
|
|
+ $model->PRODUCT_RATE = $this->product_rate;
|
|
|
+ $model->BONUSES_RATE = $this->bonuses_rate;
|
|
|
$model->ACTIVE = StatusEnum::ACTIVE;
|
|
|
$model->CREATED_AT = Date::nowTime();
|
|
|
- $model->CREATED_BY = $this->goodsNo;
|
|
|
+ $model->CREATED_BY = \Yii::$app->user->id;;
|
|
|
if (!$model->save()) {
|
|
|
throw new Exception(Form::formatErrorsForApi($model->getErrors()));
|
|
|
}
|
|
|
|
|
|
- // 选择商品汇率同步,并且美元汇率变化时,更新商品属性
|
|
|
- if ($postData['synchronize'] && (($this->from_currency_id == 104) || ($this->to_currency_id == 104))) {
|
|
|
+ // 选择商品汇率同步,更新商品属性
|
|
|
+ if ($postData['synchronize']) {
|
|
|
// 异步属性商品价格
|
|
|
$taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('config/update-exchange-rate', $model->ID);
|
|
|
if($taskKey === false){
|