|
@@ -311,6 +311,9 @@ class StoreOrder extends BaseModel
|
|
|
$cartIds = [];
|
|
$cartIds = [];
|
|
|
$totalNum = 0;
|
|
$totalNum = 0;
|
|
|
$gainIntegral = 0;
|
|
$gainIntegral = 0;
|
|
|
|
|
+ $use_max_integral=0;
|
|
|
|
|
+ $one_integral = 0;
|
|
|
|
|
+ $two_integral = 0;
|
|
|
foreach ($cartInfo as $cart){
|
|
foreach ($cartInfo as $cart){
|
|
|
if (!$test && !self::checkProductStock($uid, $cart['product_id'], $cart['cart_num'], $cart['product_attr_unique'], $cart['combination_id'], $cart['seckill_id'], $cart['bargain_id'])) {
|
|
if (!$test && !self::checkProductStock($uid, $cart['product_id'], $cart['cart_num'], $cart['product_attr_unique'], $cart['combination_id'], $cart['seckill_id'], $cart['bargain_id'])) {
|
|
|
return false;
|
|
return false;
|
|
@@ -322,6 +325,18 @@ class StoreOrder extends BaseModel
|
|
|
if (!$combinationId) $combinationId = $cart['combination_id'];
|
|
if (!$combinationId) $combinationId = $cart['combination_id'];
|
|
|
$cartInfoGainIntegral = isset($cart['productInfo']['give_integral']) ? bcmul($cart['cart_num'], $cart['productInfo']['give_integral'], 2) : 0;
|
|
$cartInfoGainIntegral = isset($cart['productInfo']['give_integral']) ? bcmul($cart['cart_num'], $cart['productInfo']['give_integral'], 2) : 0;
|
|
|
$gainIntegral = bcadd($gainIntegral, $cartInfoGainIntegral, 2);
|
|
$gainIntegral = bcadd($gainIntegral, $cartInfoGainIntegral, 2);
|
|
|
|
|
+ if(isset($cart['productInfo']['max_integral']) && $cart['productInfo']['max_integral']>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ $use_max_integral+=intval($cart['productInfo']['max_integral'])*intval($cart['cart_num']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(isset($cart['productInfo']['one_integral']) && $cart['productInfo']['one_integral']>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ $one_integral+=intval($cart['productInfo']['one_integral'])*intval($cart['cart_num']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(isset($cart['productInfo']['two_integral']) && $cart['productInfo']['two_integral']>0)
|
|
|
|
|
+ {
|
|
|
|
|
+ $two_integral+=intval($cart['productInfo']['two_integral'])*intval($cart['cart_num']);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
$deduction = $seckill_id || $bargain_id || $combinationId;
|
|
$deduction = $seckill_id || $bargain_id || $combinationId;
|
|
|
if ($deduction) {
|
|
if ($deduction) {
|
|
@@ -375,19 +390,14 @@ class StoreOrder extends BaseModel
|
|
|
//积分抵扣
|
|
//积分抵扣
|
|
|
$res2 = true;
|
|
$res2 = true;
|
|
|
$SurplusIntegral = 0;
|
|
$SurplusIntegral = 0;
|
|
|
- if ($useIntegral && $userInfo['integral'] > 0) {
|
|
|
|
|
|
|
+ if ($useIntegral && $userInfo['integral'] > 0 && $use_max_integral>0) {
|
|
|
$deductionPrice = (float)bcmul($userInfo['integral'], $other['integralRatio'], 2);
|
|
$deductionPrice = (float)bcmul($userInfo['integral'], $other['integralRatio'], 2);
|
|
|
|
|
+ if($deductionPrice>$use_max_integral) $deductionPrice = $use_max_integral;
|
|
|
if ($deductionPrice < $payPrice) {
|
|
if ($deductionPrice < $payPrice) {
|
|
|
$payPrice = bcsub($payPrice, $deductionPrice, 2);
|
|
$payPrice = bcsub($payPrice, $deductionPrice, 2);
|
|
|
- $usedIntegral = $userInfo['integral'];
|
|
|
|
|
|
|
+ $usedIntegral = $userInfo['integral']>$use_max_integral?$use_max_integral:$userInfo['integral'];
|
|
|
$SurplusIntegral = 0;
|
|
$SurplusIntegral = 0;
|
|
|
- $res2 = false !== User::edit(['integral' => 0], $userInfo['uid'], 'uid');
|
|
|
|
|
- } else {
|
|
|
|
|
- $deductionPrice = $payPrice;
|
|
|
|
|
- $usedIntegral = (float)bcdiv($payPrice, $other['integralRatio'], 2);
|
|
|
|
|
- $SurplusIntegral = bcsub($userInfo['integral'], $usedIntegral, 2);
|
|
|
|
|
$res2 = false !== User::bcDec($userInfo['uid'], 'integral', $usedIntegral, 'uid');
|
|
$res2 = false !== User::bcDec($userInfo['uid'], 'integral', $usedIntegral, 'uid');
|
|
|
- $payPrice = 0;
|
|
|
|
|
}
|
|
}
|
|
|
$res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $userInfo['integral'], '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
|
|
$res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $userInfo['integral'], '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
|
|
|
} else {
|
|
} else {
|
|
@@ -438,6 +448,9 @@ class StoreOrder extends BaseModel
|
|
|
'shipping_type' => $shipping_type,
|
|
'shipping_type' => $shipping_type,
|
|
|
'code' => input('post.code',''),
|
|
'code' => input('post.code',''),
|
|
|
'can_up_level' => input('can_up_level',0),
|
|
'can_up_level' => input('can_up_level',0),
|
|
|
|
|
+ 'is_integral' => input('is_integral',0),
|
|
|
|
|
+ 'two_integral' =>$two_integral,
|
|
|
|
|
+ 'one_integral' =>$one_integral,
|
|
|
];
|
|
];
|
|
|
if ($shipping_type === 2) {
|
|
if ($shipping_type === 2) {
|
|
|
$orderInfo['verify_code'] = self::getStoreCode();
|
|
$orderInfo['verify_code'] = self::getStoreCode();
|
|
@@ -470,7 +483,7 @@ class StoreOrder extends BaseModel
|
|
|
return self::setErrorInfo('生成订单时SQL执行错误错误原因:' . $e->getMessage());
|
|
return self::setErrorInfo('生成订单时SQL执行错误错误原因:' . $e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
self::rollbackTrans();
|
|
self::rollbackTrans();
|
|
|
- return self::setErrorInfo('生成订单时系统错误错误原因:' . $e->getMessage());
|
|
|
|
|
|
|
+ return self::setErrorInfo('生成订单时系统错误错误原因:' . $e->getFile().'--'.$e->getLine().'--'.$e->getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2111,9 +2124,11 @@ class StoreOrder extends BaseModel
|
|
|
if($levelinfo &&$levelinfo['one']>0)
|
|
if($levelinfo &&$levelinfo['one']>0)
|
|
|
{
|
|
{
|
|
|
$brokerage = bcmul($order['total_price'],bcdiv($levelinfo['one'],100,3),2);
|
|
$brokerage = bcmul($order['total_price'],bcdiv($levelinfo['one'],100,3),2);
|
|
|
- User::where('uid', $oneuser['uid'])->inc('brokerage_price', $brokerage)->update();
|
|
|
|
|
|
|
+ User::where('uid', $oneuser['uid'])->inc('brokerage_price', $brokerage)->inc('integral',$order['one_integral'])->update();
|
|
|
$str = sprintf("推荐%s用户,订单金额%2.f,获得推荐奖:%.2f", $user['nickname'],$order['total_price'], $brokerage);
|
|
$str = sprintf("推荐%s用户,订单金额%2.f,获得推荐奖:%.2f", $user['nickname'],$order['total_price'], $brokerage);
|
|
|
UserBill::income('直推奖', $oneuser['uid'], 'now_money', 'brokerage_price',$brokerage , $order['id'], bcadd($oneuser['brokerage_price'], $brokerage, 2), $str, 1);
|
|
UserBill::income('直推奖', $oneuser['uid'], 'now_money', 'brokerage_price',$brokerage , $order['id'], bcadd($oneuser['brokerage_price'], $brokerage, 2), $str, 1);
|
|
|
|
|
+ $str = sprintf("推荐%s用户,获得推荐积分:%.2f", $user['nickname'], $order['one_integral']);
|
|
|
|
|
+ UserBill::income('直推积分', $oneuser['uid'], 'integral', 'one',$order['one_integral'] , $order['id'], bcadd($oneuser['integral'], $order['one_integral'], 2), $str, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if($twouser)
|
|
if($twouser)
|
|
@@ -2122,9 +2137,11 @@ class StoreOrder extends BaseModel
|
|
|
if($levelinfo && $levelinfo['two']>0)
|
|
if($levelinfo && $levelinfo['two']>0)
|
|
|
{
|
|
{
|
|
|
$brokerage = bcmul($order['total_price'],bcdiv($levelinfo['two'],100,3),2);
|
|
$brokerage = bcmul($order['total_price'],bcdiv($levelinfo['two'],100,3),2);
|
|
|
- User::where('uid', $twouser['uid'])->inc('brokerage_price', $brokerage)->update();
|
|
|
|
|
|
|
+ User::where('uid', $twouser['uid'])->inc('brokerage_price', $brokerage)->inc('integral',$order['two_integral'])->update();
|
|
|
$str = sprintf("推荐%s用户,订单金额%2.f,获得推荐奖:%.2f", $user['nickname'],$order['total_price'], $brokerage);
|
|
$str = sprintf("推荐%s用户,订单金额%2.f,获得推荐奖:%.2f", $user['nickname'],$order['total_price'], $brokerage);
|
|
|
UserBill::income('间推奖', $twouser['uid'], 'now_money', 'brokerage_price',$brokerage , $order['id'], bcadd($twouser['brokerage_price'], $brokerage, 2), $str, 1);
|
|
UserBill::income('间推奖', $twouser['uid'], 'now_money', 'brokerage_price',$brokerage , $order['id'], bcadd($twouser['brokerage_price'], $brokerage, 2), $str, 1);
|
|
|
|
|
+ $str = sprintf("间推%s用户,获得间推奖:%.2f", $user['nickname'], $order['two_integral']);
|
|
|
|
|
+ UserBill::income('间推积分', $oneuser['uid'], 'integral', 'two',$order['two_integral'] , $order['id'], bcadd($oneuser['integral'], $order['two_integral'], 2), $str, 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
User::where('uid',$user['uid'])->inc('monetary',$order['total_price'])->update();
|
|
User::where('uid',$user['uid'])->inc('monetary',$order['total_price'])->update();
|
|
@@ -2133,7 +2150,7 @@ class StoreOrder extends BaseModel
|
|
|
return true;
|
|
return true;
|
|
|
}catch (Exception $e)
|
|
}catch (Exception $e)
|
|
|
{
|
|
{
|
|
|
- return StoreOrderCartInfo::setErrorInfo($e->getMessage());
|
|
|
|
|
|
|
+ return StoreOrderCartInfo::setErrorInfo($e->getLine().'--'.$e->getMessage(),true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|