加上会员等级扣费
This commit is contained in:
parent
17d0440ef5
commit
a648821407
@ -4,6 +4,7 @@ namespace app\api\logic\order;
|
|||||||
|
|
||||||
use app\common\enum\OrderEnum;
|
use app\common\enum\OrderEnum;
|
||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\enum\UserShipEnum;
|
||||||
use app\common\enum\YesNoEnum;
|
use app\common\enum\YesNoEnum;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\logic\CapitalFlowLogic;
|
use app\common\logic\CapitalFlowLogic;
|
||||||
@ -19,6 +20,7 @@ use app\common\model\system_store\SystemStore;
|
|||||||
use app\common\model\system_store\SystemStoreStaff;
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
|
use app\common\model\user\UserShip;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
use taoser\exception\ValidateException;
|
use taoser\exception\ValidateException;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
@ -72,11 +74,44 @@ class OrderLogic extends BaseLogic
|
|||||||
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||||
self::$total = bcadd(self::$total, $cart_select[$k]['total'], 2);
|
self::$total = bcadd(self::$total, $cart_select[$k]['total'], 2);
|
||||||
}
|
}
|
||||||
|
//TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级
|
||||||
|
$pay_price = self::$total;
|
||||||
|
$check = StoreOrder::where('uid',\request()->userId)->count();
|
||||||
|
if(empty($check)){
|
||||||
|
$discountRate = '0.99';
|
||||||
|
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
|
||||||
|
}else{
|
||||||
|
$userVip = User::where('id',\request()->userId)->value('user_ship');
|
||||||
|
if($userVip){
|
||||||
|
switch ($userVip){
|
||||||
|
case UserShipEnum::VIP1:
|
||||||
|
$discountRate = UserShip::where('id',UserShipEnum::VIP1)->value('discount');
|
||||||
|
break;
|
||||||
|
case UserShipEnum::VIP2:
|
||||||
|
$discountRate = UserShip::where('id',UserShipEnum::VIP2)->value('discount');
|
||||||
|
break;
|
||||||
|
case UserShipEnum::VIP3:
|
||||||
|
$discountRate = UserShip::where('id',UserShipEnum::VIP3)->value('discount');
|
||||||
|
break;
|
||||||
|
case UserShipEnum::VIP4:
|
||||||
|
$discountRate = UserShip::where('id',UserShipEnum::VIP4)->value('discount');
|
||||||
|
break;
|
||||||
|
case UserShipEnum::VIP5:
|
||||||
|
$discountRate = UserShip::where('id',UserShipEnum::VIP5)->value('discount');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$discountRate = 1;
|
||||||
|
}
|
||||||
|
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$order = [
|
$order = [
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
'order_id' => getNewOrderId('PF'),
|
'order_id' => getNewOrderId('PF'),
|
||||||
'total_price' => self::$total,//总价
|
'total_price' => self::$total,//总价
|
||||||
'pay_price' => self::$total,//后期可能有降价抵扣
|
'pay_price' => $pay_price,//后期可能有降价抵扣
|
||||||
'total_num' => count($cart_select),//总数
|
'total_num' => count($cart_select),//总数
|
||||||
'pay_type' => $params['pay_type'] ?? 0,
|
'pay_type' => $params['pay_type'] ?? 0,
|
||||||
'cart_id' => implode(',', $cartId),
|
'cart_id' => implode(',', $cartId),
|
||||||
|
16
app/common/enum/UserShipEnum.php
Normal file
16
app/common/enum/UserShipEnum.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\enum;
|
||||||
|
|
||||||
|
class UserShipEnum
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 会员等级
|
||||||
|
*/
|
||||||
|
const VIP1 = 1;
|
||||||
|
const VIP2 = 7;
|
||||||
|
const VIP3 = 8;
|
||||||
|
const VIP4 = 9;
|
||||||
|
const VIP5 = 10;
|
||||||
|
|
||||||
|
}
|
13
app/common/model/user/UserShip.php
Normal file
13
app/common/model/user/UserShip.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\user;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
class UserShip extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'user_ship';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user