|
|
@@ -172,6 +172,8 @@ class PledgeOrderService extends BaseService
|
|
|
$tradeStatus = isset($userInfo['trade_status'])? intval($userInfo['trade_status']) : 0;
|
|
|
$userStatus = isset($userInfo['status'])? intval($userInfo['status']) : 0;
|
|
|
$parentIds = isset($userInfo['parent_ids'])? trim($userInfo['parent_ids']) : '';
|
|
|
+ $settleStatus = isset($userInfo['settle_status'])? intval($userInfo['settle_status']) : 0;
|
|
|
+ $settleStatus = $settleStatus==2? 2 : 1; // 1-正常结算,2-不结算动态和个人业绩
|
|
|
if($userId<=0 || $userUsdt<=0 || $userStatus != 1){
|
|
|
$this->error = lang(4101,['uid'=>$userId,'usdt'=>$userUsdt,'status'=>$userStatus]);
|
|
|
return false;
|
|
|
@@ -258,6 +260,7 @@ class PledgeOrderService extends BaseService
|
|
|
'round'=> $round,
|
|
|
'expired_at'=> $expiredAt,
|
|
|
'settle_at'=> $settleAt,
|
|
|
+ 'settle_status'=> $settleStatus, // 1-正常结算,2-不结算动态和个人业绩
|
|
|
'create_time'=>time(),
|
|
|
'remark'=> '自动质押',
|
|
|
'status'=>1,
|
|
|
@@ -273,12 +276,15 @@ class PledgeOrderService extends BaseService
|
|
|
// 扣除余额和手续费
|
|
|
$updateData = [
|
|
|
'usdt'=> DB::raw("usdt - {$pledgeUsdt}"),
|
|
|
- 'performance'=>DB::raw("performance + {$pledgeUsdt}"),
|
|
|
'upgrade_at'=>date('Y-m-d H:i:s',time() + 2*86400),
|
|
|
'pledge_count'=>DB::raw("pledge_count + 1"),
|
|
|
'sbt'=>DB::raw("sbt - {$sbtFee}"),
|
|
|
'update_time'=>time()
|
|
|
];
|
|
|
+ // 正常结算业绩
|
|
|
+ if($settleStatus==1){
|
|
|
+ $updateData['performance'] = DB::raw("performance + {$pledgeUsdt}");
|
|
|
+ }
|
|
|
if(!MemberModel::where(['id'=> $userId])->update($updateData)){
|
|
|
DB::rollBack();
|
|
|
$this->error = lang(4107,['uid'=> $userId,'round'=>$round,'money'=> $pledgeUsdt]);
|
|
|
@@ -443,6 +449,8 @@ class PledgeOrderService extends BaseService
|
|
|
$pledgeUserId = isset($orderInfo['user_id'])? $orderInfo['user_id'] : 0;
|
|
|
$pledgeUsdt = isset($orderInfo['money'])? floatval($orderInfo['money']) : 0;
|
|
|
$pledgeRound = isset($orderInfo['round'])? intval($orderInfo['round']) : 0;
|
|
|
+ $settleStatus = isset($orderInfo['settle_status'])? intval($orderInfo['settle_status']) : 0;
|
|
|
+ $settleStatus = $settleStatus==2? 2 : 1; // 结算动态收益状态:1-正常,2-不结算动态
|
|
|
if($expiredAt>date('Y-m-d H:i:s') || $status != 1 || $pledgeRound<=0){
|
|
|
$this->error = lang(4312,['uid'=>$userId,'order_no'=>$orderNo]);
|
|
|
return false;
|
|
|
@@ -480,10 +488,13 @@ class PledgeOrderService extends BaseService
|
|
|
// 返还本金
|
|
|
$updateData = [
|
|
|
'usdt'=>DB::raw("usdt + {$pledgeUsdt}"),
|
|
|
- 'performance'=>max(0,($performance - $pledgeUsdt)),
|
|
|
'pledge_count'=>max(0,($pledgeCount - 1)),
|
|
|
'update_time'=>time()
|
|
|
];
|
|
|
+ // 正常结算业绩
|
|
|
+ if($settleStatus == 1){
|
|
|
+ $updateData['performance'] = max(0,($performance - $pledgeUsdt));
|
|
|
+ }
|
|
|
if(!MemberModel::where(['id'=>$pledgeUserId])->update($updateData)){
|
|
|
DB::rollBack();
|
|
|
$this->error = lang(4315,['uid'=>$userId,'order_no'=>$orderNo]);
|
|
|
@@ -540,7 +551,7 @@ class PledgeOrderService extends BaseService
|
|
|
|
|
|
// 订单信息
|
|
|
$orderInfo = $this->model::where(['id'=> $orderId,'mark'=>1])
|
|
|
- ->select(['id','user_id','order_no','money','round','bonus_rate','sbt_price','profit','profit_usdt','settle_at','status'])
|
|
|
+ ->select(['id','user_id','order_no','money','round','bonus_rate','sbt_price','profit','profit_usdt','settle_at','settle_status','status'])
|
|
|
->first();
|
|
|
$orderInfo = $orderInfo? $orderInfo->toArray() : [];
|
|
|
if(empty($orderInfo)){
|
|
|
@@ -556,6 +567,8 @@ class PledgeOrderService extends BaseService
|
|
|
$profit = isset($orderInfo['profit'])? floatval($orderInfo['profit']) : 0; // 总收益
|
|
|
$profitUsdt = isset($orderInfo['profit_usdt'])? floatval($orderInfo['profit_usdt']) : 0; // USDT收益
|
|
|
$pledgeRound = isset($orderInfo['round'])? intval($orderInfo['round']) : 0;
|
|
|
+ $settleStatus = isset($orderInfo['settle_status'])? intval($orderInfo['settle_status']) : 0;
|
|
|
+ $settleStatus = $settleStatus==2? 2 : 1; // 结算动态收益状态:1-正常,2-不结算动态
|
|
|
if($settleAt>date('Y-m-d H:i:s') || $status != 2 || $pledgeRound<=0){
|
|
|
$this->error = lang(4412,['uid'=>$userId,'order_no'=>$orderNo]);
|
|
|
return false;
|
|
|
@@ -658,19 +671,22 @@ class PledgeOrderService extends BaseService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // TODO 推荐奖结算
|
|
|
- if(!FinanceService::make()->settleShareAward($userId, $parentIds, $orderInfo)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = FinanceService::make()->getError();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ // TODO 是否结算动态收益
|
|
|
+ if($settleStatus==1){
|
|
|
+ // TODO 推荐奖结算
|
|
|
+ if(!FinanceService::make()->settleShareAward($userId, $parentIds, $orderInfo)){
|
|
|
+ DB::rollBack();
|
|
|
+ $this->error = FinanceService::make()->getError();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- // TODO 管理奖和平级奖结算
|
|
|
- if(!FinanceService::make()->settleManageAndLevelAward($userId, $parentIds, $orderInfo)){
|
|
|
- DB::rollBack();
|
|
|
- $this->error = FinanceService::make()->getError();
|
|
|
- return false;
|
|
|
+ // TODO 管理奖和平级奖结算
|
|
|
+ if(!FinanceService::make()->settleManageAndLevelAward($userId, $parentIds, $orderInfo)){
|
|
|
+ DB::rollBack();
|
|
|
+ $this->error = FinanceService::make()->getError();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
DB::commit();
|