|
|
@@ -539,7 +539,7 @@ class OrderForm extends Model
|
|
|
'PRICE' => $goodsNature['SELL_PRICE'],
|
|
|
'PV' => $currentPv, // $goods['PRICE_PV'],
|
|
|
'REAL_PRICE' => $realPrice,
|
|
|
- 'REAL_PV' => $realPv,
|
|
|
+ 'REAL_PV' => $this->payType == 'prp' ? 0 : $realPv,
|
|
|
'REMAIN_PV' => $remainPv,
|
|
|
'POINT' => $goods['POINT'],
|
|
|
'BUY_NUMS' => intval($v),
|
|
|
@@ -691,19 +691,7 @@ class OrderForm extends Model
|
|
|
if ($payAmount > Balance::getBalanceExchangePoints($loginUserId)) {
|
|
|
return ['code' => 500, 'message' => Yii::t('app', 'exchangePointDoesNotAdequate')];
|
|
|
}
|
|
|
- } else if ($payType == 'tourism_points') {
|
|
|
- if ($payAmount > Balance::getBalanceTourism($loginUserId)) {
|
|
|
- return ['code' => 500, 'message' => Yii::t('app', 'travelPointDoesNotAdequate')];
|
|
|
- }
|
|
|
- } else if ($payType == 'garage_points') {
|
|
|
- if ($payAmount > Balance::getBalanceGarage($loginUserId)) {
|
|
|
- return ['code' => 500, 'message' => Yii::t('app', 'carFundPointDoesNotAdequate')];
|
|
|
- }
|
|
|
-// } else{
|
|
|
-// if ($payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
|
|
|
-// return ['code' => 500, 'message' => '复消积分不足,无法购买商品'];
|
|
|
-// }
|
|
|
- } else if ($payType == 'user_performance') {
|
|
|
+ } else if ($payType == 'prp') {
|
|
|
if ($payAmount > UserPerformance::getAmounts($loginUserId)) {
|
|
|
return ['code' => 500, 'message' => Yii::t('app', 'userPerformanceDoesNotAdequate')];
|
|
|
}
|
|
|
@@ -753,8 +741,8 @@ class OrderForm extends Model
|
|
|
$orderModel->ORDER_AMOUNT = $this->_decAmount;
|
|
|
$orderModel->PV = $_hasPV;
|
|
|
$orderModel->PAY_AMOUNT = $this->_payAmount;
|
|
|
- $orderModel->PAY_PV = $_hasRealPV; // 兑换积分不能算业绩
|
|
|
- $orderModel->REMAIN_PV = $this->_remainPv;
|
|
|
+ $orderModel->PAY_PV = $this->payType == 'prp' ? 0 : $_hasRealPV; // 兑换积分不能算业绩
|
|
|
+ $orderModel->REMAIN_PV = $this->payType == 'prp' ? 0 : $this->_remainPv;
|
|
|
$orderModel->PAY_AT = Date::nowTime();
|
|
|
$orderModel->PAY_TYPE = $this->payType;
|
|
|
$orderModel->PERIOD_NUM = $nowPeriodNum;
|
|
|
@@ -811,14 +799,8 @@ class OrderForm extends Model
|
|
|
Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_payAmount), ['REMARK' => 'Members reselling balance payment', 'ORDER_SN' => $orderModel->SN]); // 会员复销余额支付
|
|
|
} else if ($this->payType=='exchange') {
|
|
|
Balance::changeUserBonus(\Yii::$app->user->id,'exchange_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::EXCHANGE_POINTS_EXCHANGE,'REMARK' => '会员兑换积分兑换', 'ORDER_SN' => $orderModel->SN]);
|
|
|
- } else if ($this->payType == 'tourism_points') {
|
|
|
- Balance::changeUserBonus(\Yii::$app->user->id, 'tourism_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::TOURISM_POINTS_EXCHANGE,'REMARK' => '会员旅游换积分兑换', 'ORDER_SN' => $orderModel->SN]);
|
|
|
- } else if ($this->payType == 'garage_points') {
|
|
|
- Balance::changeUserBonus(\Yii::$app->user->id, 'garage_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::GARAGE_POINTS_EXCHANGE,'REMARK' => '会员名车积分兑换', 'ORDER_SN' => $orderModel->SN]);
|
|
|
- } else if ($this->payType == 'villa_points') {
|
|
|
- Balance::changeUserBonus(\Yii::$app->user->id, 'villa_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::VILLA_POINTS_EXCHANGE,'REMARK' => '会员房奖积分兑换', 'ORDER_SN' => $orderModel->SN]);
|
|
|
- } else if ($this->payType == 'reconsume_points') {
|
|
|
- Balance::changeUserBonus(\Yii::$app->user->id,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE,'REMARK' => '会员复销积分兑换', 'ORDER_SN' => $orderModel->SN]);
|
|
|
+ } else if ($this->payType == 'prp') {
|
|
|
+ UserPerformance::changeUserPerformance(\Yii::$app->user->id, $this->_payAmount, $orderModel->SN);
|
|
|
}
|
|
|
|
|
|
return $orderModel;
|
|
|
@@ -885,13 +867,13 @@ class OrderForm extends Model
|
|
|
$pvSplit = $this->_pvSplit($realPv);
|
|
|
$currentPv = $pvSplit['current'];
|
|
|
$remainPv = $pvSplit['remain'];
|
|
|
- $totalPv += $currentPv * intval($v);
|
|
|
- $totalRealPv += $realPv * intval($v);
|
|
|
+ $totalPv += $this->payType == 'prp' ? 0 : $currentPv * intval($v);
|
|
|
+ $totalRealPv += $this->payType == 'prp' ? 0 : $realPv * intval($v);
|
|
|
$this->_remainPv += $remainPv * intval($v);
|
|
|
}else{
|
|
|
$currentPv = $goods['PRICE_PV'];
|
|
|
- $totalPv += $realPv * intval($v);
|
|
|
- $totalRealPv += $realPv * intval($v);
|
|
|
+ $totalPv += $this->payType == 'prp' ? 0 : $realPv * intval($v);
|
|
|
+ $totalRealPv += $this->payType == 'prp' ? 0 : $realPv * intval($v);
|
|
|
$remainPv = 0;
|
|
|
$this->_remainPv += 0;
|
|
|
}
|
|
|
@@ -962,8 +944,8 @@ class OrderForm extends Model
|
|
|
$freeShipping = $freeTemplate['free_shipping'] ?? 0;
|
|
|
|
|
|
$this->_decAmount = $totalAmount;
|
|
|
- $this->_decPv = $totalPv;
|
|
|
- $this->_realPv = $totalRealPv;
|
|
|
+ $this->_decPv = $this->payType == 'prp' ? 0 : $totalPv;
|
|
|
+ $this->_realPv = $this->payType == 'prp' ? 0 : $totalRealPv;
|
|
|
$this->_freight = ($totalAmount >= $freeShipping) ? 0 : $freight;
|
|
|
|
|
|
$this->_payAmount = $this->_decAmount + $this->_freight;
|
|
|
@@ -987,12 +969,18 @@ class OrderForm extends Model
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //看现金余额是否充足
|
|
|
- $decCash = Cash::getAvailableBalance($loginUserId);
|
|
|
+ if ($this->payType == 'prp') {
|
|
|
+ //看余额是否充足
|
|
|
+ $decCash = UserPerformance::getAmounts($loginUserId);
|
|
|
+ } else {
|
|
|
+ //看现金余额是否充足
|
|
|
+ $decCash = Cash::getAvailableBalance($loginUserId);
|
|
|
+ }
|
|
|
+
|
|
|
// 转换后的余额
|
|
|
$localCash = Tool::convertAmount($decCash, $decUserCurrencyRate, $currencyRate);
|
|
|
if ($localCash < $this->_decAmount){
|
|
|
- throw new Exception(Yii::t('app', 'applicantCashShort'), 400);
|
|
|
+ throw new Exception(Yii::t('app', 'applicantPrpShort'), 400);
|
|
|
}
|
|
|
|
|
|
foreach ($this->goodsNum as $k => $v){
|
|
|
@@ -1079,9 +1067,9 @@ class OrderForm extends Model
|
|
|
$orderModel->USER_ID = $userId;
|
|
|
$orderModel->USER_NAME = $this->userName;
|
|
|
$orderModel->ORDER_AMOUNT = $this->_decAmount;
|
|
|
- $orderModel->PV = $this->_decPv;
|
|
|
+ $orderModel->PV = $this->payType == 'prp' ? 0 : $this->_decPv;
|
|
|
$orderModel->PAY_AMOUNT = $this->_payAmount;
|
|
|
- $orderModel->PAY_PV = $this->_decPv;
|
|
|
+ $orderModel->PAY_PV = $this->payType == 'prp' ? 0 : $this->_decPv;
|
|
|
$orderModel->PAY_AT = Date::nowTime();
|
|
|
$orderModel->PAY_TYPE = $this->payType;
|
|
|
$orderModel->PERIOD_NUM = $nowPeriodNum;
|
|
|
@@ -1118,7 +1106,9 @@ class OrderForm extends Model
|
|
|
//扣除会员余额/积分
|
|
|
if($this->payType=='cash') {
|
|
|
Cash::changeUserCash($loginUserId, 'CASH', -abs($this->_payAmount), ['REMARK' => Yii::t('app', 'membersResellingBalancePayment')]);
|
|
|
- }else{
|
|
|
+ } else if ($this->payType == 'prp') {
|
|
|
+ UserPerformance::changeUserPerformance($loginUserId, $this->_payAmount, $orderModel->SN);
|
|
|
+ } else{
|
|
|
Balance::changeUserBonus($loginUserId,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE, 'REMARK' => Yii::t('app', 'membersExchangePointPayment')]);
|
|
|
}
|
|
|
return $orderModel;
|