|
|
@@ -41,16 +41,17 @@ class PledgeLogic
|
|
|
public static function setPledgeOrder(object $pledge, array $order_no, int $user_id)
|
|
|
{
|
|
|
$model = Loader::model('ProductOrder');
|
|
|
+ $count = count($order_no);
|
|
|
$product= $model::alias('a')
|
|
|
->join('product_list b', 'a.product_id = b.id', 'left')
|
|
|
->where('a.user_id', $user_id)
|
|
|
->where('a.status', $model::Paid)
|
|
|
- ->whereIn('a.order_no', $order_no)->field('b.id,b.zh_name,b.thum,a.order_no')->select();
|
|
|
+ ->whereIn('a.order_no', $order_no)->field('a.id,b.zh_name,b.thum,a.order_no')->limit($count)->select();
|
|
|
|
|
|
- if(empty($product) || count($product) < count($order_no)) throw new Exception('订单不存在');
|
|
|
+ if(empty($product) || count($product) < $count) throw new Exception('订单不存在');
|
|
|
$pledge_num = 1;
|
|
|
if($pledge->type_id == ProductPledges::Single){
|
|
|
- $pledge_num = count($order_no);
|
|
|
+ $pledge_num = $count;
|
|
|
}
|
|
|
|
|
|
//添加订单
|
|
|
@@ -61,7 +62,7 @@ class PledgeLogic
|
|
|
\think\Log::info('添加质抵押订单', ['pledge_id' => $pledge->id, 'order_no' => $order_no, 'user_id' => $user_id]);
|
|
|
|
|
|
//修改状态
|
|
|
- return $model->whereIn('order_no', $order_no)->where('status', $model::Paid)->limit(count($order_no))->setField('status', $model::Freeze);
|
|
|
+ return $model->whereIn('id', array_column($product, 'id'))->setField('status', $model::Freeze);
|
|
|
}
|
|
|
|
|
|
//获取质抵押订单列表
|
|
|
@@ -112,7 +113,7 @@ class PledgeLogic
|
|
|
\think\Log::info('解除质抵押订单', ['pledge_id' => $pledge_id, 'detail' => $rows->details, 'user_id' => $user_id]);
|
|
|
//修改状态
|
|
|
$detail =json_decode($rows->details, true);
|
|
|
- Loader::model('ProductOrder')::whereIn('order_no', array_column($detail, 'order_no'))->setField('status', ProductOrder::Paid);
|
|
|
+ Loader::model('ProductOrder')::whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid);
|
|
|
|
|
|
$rows->status = $model::Remove;
|
|
|
$rows->last_time = $time;
|