|
|
@ -295,7 +295,7 @@ class UserService extends BaseHomeService |
|
|
|
} |
|
|
|
|
|
|
|
// 用户购买VIP |
|
|
|
public function purchaseVip($userId) |
|
|
|
public function purchaseVip($userId, $param) |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (empty($userId) || empty($param['vip_type']) ) { |
|
|
@ -312,23 +312,23 @@ class UserService extends BaseHomeService |
|
|
|
} |
|
|
|
// 购买vip所需的货币类型检测 [产品确定使用美股支付 USD] |
|
|
|
if (empty($vipPurchaseCfg['stock_id'])) { |
|
|
|
return $this->toData('500', lang('data_configuration_error')); |
|
|
|
return $this->toData('501', lang('data_configuration_error')); |
|
|
|
} |
|
|
|
$stockId = $vipPurchaseCfg['stock_id']; |
|
|
|
// vip类型配置检测 |
|
|
|
if (!isset($vipPurchaseCfg[$param['vip_type']])) { |
|
|
|
return $this->toData('500', lang('data_configuration_error')); |
|
|
|
return $this->toData('502', lang('data_configuration_error')); |
|
|
|
} |
|
|
|
$tagVipConfig = $vipPurchaseCfg[$param['vip_type']]; |
|
|
|
// vip价格检测 |
|
|
|
if (!isset($vipPurchaseCfg['vip_price']) || $vipPurchaseCfg['vip_price'] <= 0) { |
|
|
|
return $this->toData('500', lang('data_configuration_error')); |
|
|
|
if (!isset($tagVipConfig['vip_price']) || $tagVipConfig['vip_price'] <= 0) { |
|
|
|
return $this->toData('503', lang('data_configuration_error')); |
|
|
|
} |
|
|
|
// vip有效天数检测 |
|
|
|
if (!isset($vipPurchaseCfg['vip_day']) || $vipPurchaseCfg['vip_day'] <= 0) { |
|
|
|
return $this->toData('500', lang('data_configuration_error')); |
|
|
|
if (!isset($tagVipConfig['vip_day']) || $tagVipConfig['vip_day'] <= 0) { |
|
|
|
return $this->toData('504', lang('data_configuration_error')); |
|
|
|
} |
|
|
|
// 查询用户美股余额是否足够 【产品确定用美股余额支付】 |
|
|
|
// 查询用户余额是否足够 |
|
|
|
$userMoney = UserStockJpModel::where(['user_id'=>$userId,'stock_id'=> $stockId])->find(); |
|
|
|
if (empty($userMoney)) { |
|
|
|
return $this->toData('500', lang('user_usd_balance_is_insufficient')); |
|
|
|