|
|
@@ -60,7 +60,7 @@ class PledgeLogic
|
|
|
|
|
|
//扣除支付金额
|
|
|
$action = ($pay_type == Asset::TEAC)? LedgerTeacChangeModel::PledgeFee: LedgerTokenChangeModel::Pledge; //类型
|
|
|
- (new LedgerWalletModel())->changeWalletAccount($user_id, $pay_type, $price, $action, 0);
|
|
|
+ (new LedgerWalletModel())->changeWalletAccount($user_id, $pay_type, -$price, $action, 0);
|
|
|
|
|
|
//修改状态
|
|
|
return $model->whereIn('id', array_column($product, 'id'))->setField('status', $model::Freeze);
|
|
|
@@ -98,7 +98,7 @@ class PledgeLogic
|
|
|
}
|
|
|
|
|
|
//解除质抵押订单
|
|
|
- public static function setPledgeRemove(int $pledge_id, int $user_id)
|
|
|
+ public static function setPledgeRemove(int $pledge_id, string $product_id, int $user_id)
|
|
|
{
|
|
|
$model = Loader::model('UserPledge');
|
|
|
$time = time();
|
|
|
@@ -111,18 +111,31 @@ class PledgeLogic
|
|
|
->field('a.*,b.day_num')
|
|
|
->find();
|
|
|
if(empty($rows)) throw new Exception('暂无质押订单');
|
|
|
+ $productAll = explode(',', $rows->product_id);
|
|
|
+ $productId = explode(',', $product_id);
|
|
|
+ $count = count(array_intersect($productAll, $productId));
|
|
|
+ if(count($productId) != $count) throw new Exception('参数有误');
|
|
|
+ $diff = array_diff($productAll, $productId);
|
|
|
+ $num = $rows->num;
|
|
|
+ if(empty($diff)) {
|
|
|
+ $rows->status = $model::Remove;
|
|
|
+ }else{
|
|
|
+ $rows->product_id = implode(',', $diff);
|
|
|
+ $rows->num = count($diff);
|
|
|
+ $num = $count;
|
|
|
+ }
|
|
|
$day = 86400;
|
|
|
$total = 0; //当前累计收益
|
|
|
$reta = bcdiv($rows->day_num, $day, 6); //天数
|
|
|
$inter = ($rows->last_time == 0) ? $time - $rows->create_time: $time - $rows->last_time; //最后收取时间
|
|
|
- $total = bcmul($reta, $inter, 6) * $rows->num; //累计收益
|
|
|
+ $total = bcmul($reta, $inter, 6) * $num; //累计收益
|
|
|
$rows->total_self= bcadd($total, $rows->total_self, 6);
|
|
|
|
|
|
//修改状态
|
|
|
$detail =json_decode($rows->details, true);
|
|
|
Loader::model('ProductOrder')::where('user_id', $user_id)->whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid);
|
|
|
|
|
|
- $rows->status = $model::Remove;
|
|
|
+ //更新领取状态
|
|
|
$rows->last_time = $time;
|
|
|
return $rows->save();
|
|
|
}
|
|
|
@@ -171,7 +184,7 @@ class PledgeLogic
|
|
|
{
|
|
|
//扣除支付金额
|
|
|
$action = ($pay_type == Asset::TEAC)? LedgerTeacChangeModel::PledgeFee: LedgerTokenChangeModel::Pledge; //类型
|
|
|
- (new LedgerWalletModel())->changeWalletAccount($user_id, $pay_type, $pledge[$pay_type], $action, 0);
|
|
|
+ (new LedgerWalletModel())->changeWalletAccount($user_id, $pay_type, -$pledge[$pay_type], $action, 0);
|
|
|
|
|
|
$pledge->end_time = $pledge->end_time + config('pledge_end_time');
|
|
|
return $pledge->save();
|