37 lines
1004 B
PHP
37 lines
1004 B
PHP
<?php
|
|
|
|
namespace app\jinyou\model;
|
|
|
|
use fastphp\base\Model;
|
|
|
|
class UserPrice extends Model
|
|
{
|
|
protected $table = 'product_user_price';
|
|
|
|
|
|
public function get_user_price($user_id,$discount,$package_info){
|
|
$price = 100000;
|
|
|
|
//根据用户价格
|
|
if ($discount != 0) {
|
|
if ($discount == -1) {
|
|
$price = $this->getOne(['UserId' => $user_id,'PackageId' => $package_info['Id']])['UserPrice'];
|
|
} else {
|
|
$scheme_model = new PriceScheme;
|
|
$discount = $scheme_model->getone(['Id' => $discount])['discount'];
|
|
$price = $package_info['LinePrice'] * $discount / 100;
|
|
}
|
|
//判读最低价
|
|
if ($price < $package_info['MinPrice']) {
|
|
$price = $package_info['MinPrice'];
|
|
}
|
|
if ($price < $package_info['Price']) {
|
|
$package_info['Price'] = $price;
|
|
}
|
|
}
|
|
|
|
return $package_info['Price'];
|
|
}
|
|
|
|
}
|