|
|
@@ -81,7 +81,6 @@ class OrderService extends BaseService
|
|
|
$query->where('a.status', $status)->where('a.refund_status', 0);
|
|
|
}
|
|
|
})->select(['a.*'])
|
|
|
-// ->orderBy('a.status', 'asc')
|
|
|
->orderBy('a.id', 'desc')
|
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
$list = $list ? $list->toArray() : [];
|
|
|
@@ -120,8 +119,9 @@ class OrderService extends BaseService
|
|
|
*/
|
|
|
public function getQuery($params)
|
|
|
{
|
|
|
- $where = ['a.mark' => 1];
|
|
|
- return $this->model->from('orders as a')->with(['orderGoods', 'store'])
|
|
|
+ $where = ['a.is_hide'=>0,'a.mark' => 1];
|
|
|
+ return $this->model->from('orders as a')
|
|
|
+ ->with(['orderGoods', 'store'])
|
|
|
->leftJoin('member as b', 'b.id', '=', 'a.user_id')
|
|
|
->where($where)
|
|
|
->where(function ($query) use ($params) {
|
|
|
@@ -499,7 +499,6 @@ class OrderService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 商品数据
|
|
|
RedisService::set($cacheLockKey, ['order_id' => $orderId, 'user_id' => $userId], rand(3, 5));
|
|
|
|
|
|
// 用户信息
|
|
|
@@ -565,6 +564,62 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 订单删除隐藏
|
|
|
+ * @param $userId
|
|
|
+ * @param $orderId
|
|
|
+ * @return array|false
|
|
|
+ */
|
|
|
+ public function hide($userId, $orderId)
|
|
|
+ {
|
|
|
+ if ($orderId <= 0) {
|
|
|
+ $this->error = '请选择订单';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 缓存锁
|
|
|
+ $cacheLockKey = "caches:orders:hide_lock:{$userId}_{$orderId}";
|
|
|
+ if (RedisService::get($cacheLockKey)) {
|
|
|
+ $this->error = '订单删除中~';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ RedisService::set($cacheLockKey, ['order_id' => $orderId, 'user_id' => $userId], rand(3, 5));
|
|
|
+
|
|
|
+ // 用户信息
|
|
|
+ $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1])
|
|
|
+ ->select(['id', 'openid', 'mobile', 'nickname', 'realname', 'balance', 'status'])
|
|
|
+ ->first();
|
|
|
+ $status = isset($userInfo['status']) ? $userInfo['status'] : 0;
|
|
|
+ if (empty($userInfo) || $status != 1) {
|
|
|
+ $this->error = 1045;
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单信息
|
|
|
+ $info = $this->model->where(['id' => $orderId, 'mark' => 1])
|
|
|
+ ->select(['id', 'order_no', 'pay_total', 'status'])
|
|
|
+ ->first();
|
|
|
+ $orderNo = isset($info['order_no']) ? $info['order_no'] : '';
|
|
|
+ $status = isset($info['status']) ? $info['status'] : 0;
|
|
|
+ if (empty($info) || empty($orderNo)) {
|
|
|
+ $this->error = '订单信息不存在';
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($status != 4) {
|
|
|
+ $this->error = '订单未完成';
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->error = '删除订单成功';
|
|
|
+ $this->model->where(['id' => $orderId])->update(['is_hide' => 1, 'update_time' => time()]);
|
|
|
+ return ['id' => $orderId];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 订单完成
|
|
|
* @param $userId 订单用户ID
|
|
|
* @param $id 订单ID
|