|
|
@@ -43,11 +43,7 @@ class PledgeLogic
|
|
|
public static function setPledgeOrder(object $pledge, array $order_no, int $user_id, int $count, string $pay_type, float $price)
|
|
|
{
|
|
|
$model = Loader::model('ProductOrder');
|
|
|
- $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('a.id,b.zh_name,b.thum,a.order_no')->limit($count)->select();
|
|
|
+ $product= self::getOrderProductList($user_id, $order_no, $count);
|
|
|
|
|
|
if(empty($product) || count($product) < $count) throw new Exception('订单不存在');
|
|
|
$pledge_num = 1;
|
|
|
@@ -144,8 +140,7 @@ class PledgeLogic
|
|
|
}
|
|
|
|
|
|
|
|
|
- //收取质抵押订单列表
|
|
|
- //(60*60*24)*(当前时间-最后一次收取时间)
|
|
|
+ //收取质抵押订单列表:(60*60*24)*(当前时间-最后一次收取时间)
|
|
|
public static function getPledgeCollect(int $user_id)
|
|
|
{
|
|
|
$model = Loader::model('UserPledge');
|
|
|
@@ -192,4 +187,32 @@ class PledgeLogic
|
|
|
return $pledge->save();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //添加用户存储产品
|
|
|
+ public static function setPledgeProductAdd(object $pledge, int $user_id, int $count, array $order_no)
|
|
|
+ {
|
|
|
+
|
|
|
+ $product = self::getOrderProductList($user_id, $order_no, $count);
|
|
|
+ if(empty($product) || count($product) < $count) throw new Exception('订单不存在');
|
|
|
+
|
|
|
+ //修改订单状态
|
|
|
+ Loader::model('ProductOrder')::where('user_id', $user_id)->whereIn('order_no', $order_no)->setField('status', ProductOrder::Paid);
|
|
|
+
|
|
|
+ //添加产品
|
|
|
+ $detail = json_decode($pledge->details, true);
|
|
|
+ $pledge->details = json_encode(array_merge($detail, $product), JSON_UNESCAPED_UNICODE);
|
|
|
+ $pledge->num = $pledge->num + $count ;
|
|
|
+ return $pledge->save();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取订单产品
|
|
|
+ private static function getOrderProductList(int $user_id, array $order_no, int $count)
|
|
|
+ {
|
|
|
+ return Loader::model('ProductOrder')::alias('a')
|
|
|
+ ->join('product_list b', 'a.product_id = b.id', 'left')
|
|
|
+ ->where('a.user_id', $user_id)
|
|
|
+ ->where('a.status', ProductOrder::Paid)
|
|
|
+ ->whereIn('a.order_no', $order_no)->field('a.id,b.zh_name,b.thum,a.order_no')->limit($count)->select();
|
|
|
+ }
|
|
|
}
|