|
|
@@ -98,7 +98,7 @@ class PledgeLogic
|
|
|
}
|
|
|
|
|
|
//解除质抵押订单
|
|
|
- public static function setPledgeRemove(int $pledge_id, string $product_id, int $user_id)
|
|
|
+ public static function setPledgeRemove(int $pledge_id, string $order_id, int $user_id)
|
|
|
{
|
|
|
$model = Loader::model('UserPledge');
|
|
|
$time = time();
|
|
|
@@ -111,19 +111,18 @@ 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);
|
|
|
+ //修改状态
|
|
|
+ $orderId = explode(',', $order_id);
|
|
|
+ $detail = array_column(json_decode($rows->details, true), 'id');
|
|
|
+ $diff = array_diff($detail, $orderId);
|
|
|
$num = $rows->num;
|
|
|
if(empty($diff)) {
|
|
|
$rows->status = $model::Remove;
|
|
|
}else{
|
|
|
- $rows->product_id = implode(',', $diff);
|
|
|
$rows->num = count($diff);
|
|
|
- $num = $count;
|
|
|
+ $num = count($orderId);
|
|
|
}
|
|
|
+
|
|
|
$day = 86400;
|
|
|
$total = 0; //当前累计收益
|
|
|
$reta = bcdiv($rows->day_num, $day, 6); //天数
|
|
|
@@ -132,8 +131,7 @@ class PledgeLogic
|
|
|
$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);
|
|
|
+ Loader::model('ProductOrder')::where('user_id', $user_id)->whereIn('id', $orderId)->setField('status', ProductOrder::Paid);
|
|
|
|
|
|
//更新领取状态
|
|
|
$rows->last_time = $time;
|