|
@@ -29,4 +29,62 @@ class StoreExchangeOrder extends BaseModel
|
|
|
*/
|
|
*/
|
|
|
protected $name = 'store_exchange_order';
|
|
protected $name = 'store_exchange_order';
|
|
|
use ModelTrait;
|
|
use ModelTrait;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static function getUserOrderSearchList($uid, $type, $page, $limit, $search)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($search) {
|
|
|
|
|
+ $order = self::searchUserOrder($uid, $search) ?: [];
|
|
|
|
|
+ $list = $order == false ? [] : [$order];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $list = self::getUserOrderList($uid, $type, $page, $limit);
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($list as $k => $order) {
|
|
|
|
|
+ $list[$k]['order'] = StoreOrder::get($order['oid']);
|
|
|
|
|
+ $list[$k]['cart_info'] = StoreOrderCartInfo::where('oid', $order['oid'])
|
|
|
|
|
+ ->where('cart_id', $order['cart_id'])
|
|
|
|
|
+ ->value('cart_info');
|
|
|
|
|
+ if (is_string($list[$k]['cart_info'])) $list[$k]['cart_info'] = json_decode($list[$k]['cart_info'], true);
|
|
|
|
|
+ }
|
|
|
|
|
+ return $list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static function searchUserOrder($uid, $order_id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $order = self::where('uid|gift_uid', $uid)->where('order_id', $order_id)->where('is_del', 0)
|
|
|
|
|
+ ->order('add_time DESC')->select();
|
|
|
|
|
+ if (!$order)
|
|
|
|
|
+ return false;
|
|
|
|
|
+ else
|
|
|
|
|
+ return $order;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static function getUserOrderList($uid, $status = '', $page = 0, $limit = 8)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($page) $list = self::statusByWhere($status, $uid)->where('is_del', 0)->where('uid|gift_uid', $uid)
|
|
|
|
|
+ ->order('add_time DESC')->page((int)$page, (int)$limit)->select()->toArray();
|
|
|
|
|
+ else $list = self::statusByWhere($status, $uid)->where('is_del', 0)->where('uid|gift_uid', $uid)
|
|
|
|
|
+ ->order('add_time DESC')->page((int)$page, (int)$limit)->select()->toArray();
|
|
|
|
|
+ return $list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static function statusByWhere($status, $uid = 0, $model = null)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($model == null) $model = new self;
|
|
|
|
|
+ if ('' === $status)
|
|
|
|
|
+ return $model;
|
|
|
|
|
+ else if ($status == 0)//待使用
|
|
|
|
|
+ return $model->where('status', 0)->where('refund_status', 0);
|
|
|
|
|
+ else if ($status == 1)//已使用
|
|
|
|
|
+ return $model->where('status', 1)->where('refund_status', 0);
|
|
|
|
|
+ else if ($status == -1)//退款中
|
|
|
|
|
+ return $model->where('refund_status', 1);
|
|
|
|
|
+ else if ($status == -2)//已退款
|
|
|
|
|
+ return $model->where('refund_status', 2);
|
|
|
|
|
+ else if ($status == -3)//退款
|
|
|
|
|
+ return $model->where('refund_status', 'IN', '1,2');
|
|
|
|
|
+ else
|
|
|
|
|
+ return $model;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|