|
|
@@ -19,6 +19,8 @@ use common\models\Region;
|
|
|
use common\models\ShopGoods;
|
|
|
use common\models\User;
|
|
|
use common\models\UserNetwork;
|
|
|
+use common\models\RemainPv;
|
|
|
+use common\models\FlowRemainPv;
|
|
|
use yii\base\Exception;
|
|
|
|
|
|
/**
|
|
|
@@ -57,6 +59,7 @@ class OrderForm extends Model
|
|
|
private $_standardAmount;
|
|
|
private $_decAmountStandard;
|
|
|
private $_exchangeRate;
|
|
|
+ private $_remainPv;
|
|
|
|
|
|
/**
|
|
|
* @var Order
|
|
|
@@ -415,6 +418,20 @@ class OrderForm extends Model
|
|
|
return $this->_model;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * BV分期
|
|
|
+ *
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private function _pvSplit($oPv){
|
|
|
+ $currentPv = $oPv % 30 + 30;
|
|
|
+ $remainPv = $oPv - $currentPv;
|
|
|
+ return [
|
|
|
+ 'current' => $currentPv,
|
|
|
+ 'remain' => $remainPv
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 复销
|
|
|
* @throws Exception
|
|
|
@@ -429,6 +446,7 @@ class OrderForm extends Model
|
|
|
$totalPv = 0;
|
|
|
$totalAmountStandard = 0;
|
|
|
$goodsType = ShopGoods::GOODS_TYPE;
|
|
|
+ $this->_remainPv = 0;
|
|
|
$exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
|
|
|
foreach ($this->goodsNum as $k => $v) {
|
|
|
if ($v) {
|
|
|
@@ -447,7 +465,12 @@ class OrderForm extends Model
|
|
|
}
|
|
|
$totalAmount += $realPrice * intval($v);
|
|
|
$totalPv += $realPv * intval($v);
|
|
|
-
|
|
|
+ if($goods['PV_SPLIT']==1){//当商品为PV分期时
|
|
|
+ $pvSplit = $this->_pvSplit($realPv);
|
|
|
+ $realPv = $pvSplit['current'];
|
|
|
+ $remainPv = $pvSplit['remain'];
|
|
|
+ $this->_remainPv += $remainPv * intval($v);
|
|
|
+ }
|
|
|
$totalAmountStandard += $realPriceStandard * intval($v);
|
|
|
// if($this->payType=='cash') {
|
|
|
// $discount = $goodsType[$goods['TYPE']]['discount'];
|
|
|
@@ -480,6 +503,7 @@ class OrderForm extends Model
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
+ print_r($this->_remainPv);
|
|
|
}
|
|
|
$this->_decAmount = $totalAmount;
|
|
|
$this->_decPv = $totalPv;
|
|
|
@@ -683,6 +707,19 @@ class OrderForm extends Model
|
|
|
Balance::changeUserBonus(\Yii::$app->user->id,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE,'REMARK' => '会员复销积分兑换']);
|
|
|
}
|
|
|
|
|
|
+ if($this->_remainPv>0) {
|
|
|
+ $flowRemainPvModel = new FlowRemainPv();
|
|
|
+ $flowRemainPvModel->ID = $this->_generateSn();
|
|
|
+ $flowRemainPvModel->USER_ID = $userId;
|
|
|
+ $flowRemainPvModel->REMAIN_PV_FLOW = $this->_remainPv;
|
|
|
+ $flowRemainPvModel->UPDATED_AT = Date::nowTime();
|
|
|
+ $flowRemainPvModel->ORDER_SN = 'OS'.$ordNo;
|
|
|
+ }
|
|
|
+ if(!$flowRemainPvModel->save()){
|
|
|
+ $this->addErrors($flowRemainPvModel->getErrors());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
return $orderModel;
|
|
|
}
|
|
|
|