|
@@ -83,10 +83,6 @@ class TradeService extends BaseService
|
|
|
$where['a.is_appeal'] = $isAppeal;
|
|
$where['a.is_appeal'] = $isAppeal;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ($status > 0 && !$isAppeal) {
|
|
|
|
|
- $where['a.status'] = $status;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if ($goodsStatus > 0) {
|
|
if ($goodsStatus > 0) {
|
|
|
$where['g.status'] = $goodsStatus;
|
|
$where['g.status'] = $goodsStatus;
|
|
|
}
|
|
}
|
|
@@ -97,13 +93,14 @@ class TradeService extends BaseService
|
|
|
->leftJoin('shop as s', 's.id', '=', 'g.shop_id')
|
|
->leftJoin('shop as s', 's.id', '=', 'g.shop_id')
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->where('a.status', '>', 0)
|
|
->where('a.status', '>', 0)
|
|
|
- ->where(function ($query) use ($userId, $status) {
|
|
|
|
|
-// if($status == 0){
|
|
|
|
|
-// $query->whereNotIn('a.sell_uid',[$userId]);
|
|
|
|
|
-// }
|
|
|
|
|
-// else if($status == 2){
|
|
|
|
|
-// $query->whereNotIn('a.user_id',[$userId]);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ ->where(function ($query) use ($type, $status, $isAppeal) {
|
|
|
|
|
+ if($type == 1 && $status == 2){
|
|
|
|
|
+ $query->whereIn('a.status',[1,2,3])->orWhere(function($query) {
|
|
|
|
|
+ $query->where(['a.status'=>4])->where('a.is_sell','<=', 1);
|
|
|
|
|
+ });
|
|
|
|
|
+ }else if($status>0 && !$isAppeal){
|
|
|
|
|
+ $query->where(['a.status'=> $status]);
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
->where(function ($query) use ($params) {
|
|
->where(function ($query) use ($params) {
|
|
|
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
|
|
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
|
|
@@ -123,6 +120,7 @@ class TradeService extends BaseService
|
|
|
->where(function ($query) use ($type, $userId, $sellUid, $status) {
|
|
->where(function ($query) use ($type, $userId, $sellUid, $status) {
|
|
|
|
|
|
|
|
if ($type == 1) {
|
|
if ($type == 1) {
|
|
|
|
|
+ $query->whereIn('a.status',[1,2,3,4]);
|
|
|
if ($status == 0) {
|
|
if ($status == 0) {
|
|
|
$query->where(['a.user_id' => $userId, 'a.is_out' => 0]);
|
|
$query->where(['a.user_id' => $userId, 'a.is_out' => 0]);
|
|
|
$query->whereNotIn('a.sell_uid', [$userId]);
|
|
$query->whereNotIn('a.sell_uid', [$userId]);
|
|
@@ -132,6 +130,8 @@ class TradeService extends BaseService
|
|
|
} else {
|
|
} else {
|
|
|
$query->where(['a.user_id' => $userId, 'a.is_out' => 0]);
|
|
$query->where(['a.user_id' => $userId, 'a.is_out' => 0]);
|
|
|
}
|
|
}
|
|
|
|
|
+ } else if($type == 3){
|
|
|
|
|
+ $query->whereIn('a.status',[1,2,3,4]);
|
|
|
} else {
|
|
} else {
|
|
|
if ($userId) {
|
|
if ($userId) {
|
|
|
$query->where(['a.user_id' => $userId, 'a.is_out' => 0]);
|
|
$query->where(['a.user_id' => $userId, 'a.is_out' => 0]);
|
|
@@ -139,20 +139,13 @@ class TradeService extends BaseService
|
|
|
$query->where('a.sell_uid', '=', $sellUid);
|
|
$query->where('a.sell_uid', '=', $sellUid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /*if ($sellUid && $userId) {
|
|
|
|
|
- $query->where('a.user_id', $userId)->orWhere(function($query) use($sellUid){
|
|
|
|
|
- $query->where('a.sell_uid', $sellUid)->whereIn('a.status', [1,2]);
|
|
|
|
|
- });
|
|
|
|
|
- }else if($userId){
|
|
|
|
|
- $query->where('a.user_id', '=', $userId);
|
|
|
|
|
- }else if($sellUid){
|
|
|
|
|
- $query->where('a.sell_uid', '=', $sellUid);
|
|
|
|
|
- }*/
|
|
|
|
|
})
|
|
})
|
|
|
->select(['a.*', 'b.nickname', 'b.mobile as buy_mobile', 's.name as shop_name', 's.code as shop_code', 'c.nickname as sell_nickname', 'c.mobile as sell_mobile', 'g.goods_name', 'g.code', 'g.thumb']);
|
|
->select(['a.*', 'b.nickname', 'b.mobile as buy_mobile', 's.name as shop_name', 's.code as shop_code', 'c.nickname as sell_nickname', 'c.mobile as sell_mobile', 'g.goods_name', 'g.code', 'g.thumb']);
|
|
|
|
|
|
|
|
// 店长排序
|
|
// 店长排序
|
|
|
- if ($type == 3) {
|
|
|
|
|
|
|
+ if ($type == 1) {
|
|
|
|
|
+ $model = $model->orderBy('a.status', 'asc');
|
|
|
|
|
+ } else if ($type == 3) {
|
|
|
$model = $model->orderBy('a.status', 'asc')->orderBy('a.is_sell', 'asc');
|
|
$model = $model->orderBy('a.status', 'asc')->orderBy('a.is_sell', 'asc');
|
|
|
}
|
|
}
|
|
|
$model = $model->orderBy('s.id', 'asc')
|
|
$model = $model->orderBy('s.id', 'asc')
|
|
@@ -925,6 +918,13 @@ class TradeService extends BaseService
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 卖家收款账号
|
|
|
|
|
+// $bankInfo = MemberBankService::make()->getBindInfo($info['user_id']);
|
|
|
|
|
+// if (empty($bankInfo)) {
|
|
|
|
|
+// $this->error = 2060;
|
|
|
|
|
+// return false;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
if ($this->model->where(['id' => $id, 'mark' => 1])->update(['pay_time' => time(), 'pay_img' => $payImg, 'status' => 2, 'update_time' => time()])) {
|
|
if ($this->model->where(['id' => $id, 'mark' => 1])->update(['pay_time' => time(), 'pay_img' => $payImg, 'status' => 2, 'update_time' => time()])) {
|
|
|
$this->error = 2046;
|
|
$this->error = 2046;
|
|
|
return true;
|
|
return true;
|
|
@@ -1443,13 +1443,22 @@ class TradeService extends BaseService
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ($this->model->where(['id' => $id])->update(['status' => 5, 'update_time' => time()])) {
|
|
|
|
|
- $this->error = 2088;
|
|
|
|
|
- return true;
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ if (!$this->model->where(['id' => $id])->update(['status' => 5,'remark'=>'店长取消订单:'.date('Y-m-d H:i:s'), 'update_time' => time()])) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ $this->error = 2089;
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(!GoodsModel::where(['id'=> $info['goods_id'],'mark'=>1])->update(['status'=>1,'is_trade'=>2,'confirm_status'=>1,'remark'=>'店长取消订单'])){
|
|
|
|
|
+ DB::rollBack();
|
|
|
$this->error = 2089;
|
|
$this->error = 2089;
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ $this->error = 2088;
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1466,6 +1475,13 @@ class TradeService extends BaseService
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 取消订单
|
|
|
|
|
+ $this->model->where('create_time', '<', strtotime(date('Y-m-d')))
|
|
|
|
|
+ ->where('create_time', '<', time() - 7200)->where(['mark' => 1])
|
|
|
|
|
+ ->where('status','<',4)
|
|
|
|
|
+ ->update(['mark'=>0,'remark'=>'订单未付款取消']);
|
|
|
|
|
+
|
|
|
|
|
+ // 清除订单
|
|
|
$clearDay = strtotime(date('Y-m-d')) - $day * 86400;
|
|
$clearDay = strtotime(date('Y-m-d')) - $day * 86400;
|
|
|
$count = $this->model->where('create_time', '<', $clearDay)->count();
|
|
$count = $this->model->where('create_time', '<', $clearDay)->count();
|
|
|
if ($count <= 0) {
|
|
if ($count <= 0) {
|