|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
namespace app\api\lists\property;
|
|
|
|
|
|
+use think\facade\Db;
|
|
|
use app\api\lists\BaseApiDataLists;
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
use app\common\model\property\PropertyHead;
|
|
|
@@ -28,16 +29,20 @@ class PropertyGroupOrderLists extends BaseApiDataLists implements ListsSearchInt
|
|
|
public function queryWhere()
|
|
|
{
|
|
|
// 指定用户
|
|
|
- $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
|
|
|
+ $propertyHeadId = (int)PropertyHead::where('user_id',$this->userId)->value('id');
|
|
|
$where[] = ['b.property_head_id', '=', $propertyHeadId];
|
|
|
|
|
|
if (isset($this->params['status'])) {
|
|
|
if ($this->params['status'] == 0) {
|
|
|
- $where[] = ['a.status', '=', 0];
|
|
|
- } elseif ($this->params['status'] == 1) {
|
|
|
+ //待完成
|
|
|
$where[] = ['a.status', '=', 1];
|
|
|
+ $where[] = ['c.service_status', 'exp', Db::Raw('IS NULL OR c.service_status <> 3')];
|
|
|
+ } elseif ($this->params['status'] == 1) {
|
|
|
+ //工单已完成
|
|
|
+ $where[] = ['c.service_status', '=', 3];
|
|
|
} else {
|
|
|
- $where[] = ['a.status', '>', 1];
|
|
|
+ //已退款
|
|
|
+ $where[] = ['a.status', 'in', [2,3]];
|
|
|
}
|
|
|
}
|
|
|
if (isset($this->params['start_time']) && !empty($this->params['start_time'])) {
|
|
|
@@ -55,14 +60,27 @@ class PropertyGroupOrderLists extends BaseApiDataLists implements ListsSearchInt
|
|
|
public function lists(): array
|
|
|
{
|
|
|
$lists = GroupUserOrder::alias('a')
|
|
|
- ->leftJoin('group_order b','a.group_order_id=b.id')
|
|
|
- ->leftJoin('group_activity c','a.group_activity_id=c.id')
|
|
|
- ->field('a.id,a.sn,a.group_activity_id,a.status,a.order_amount,a.paid_amount,a.pay_status,a.refund_status,a.create_time,b.goods_id,b.num,b.origin_price,b.end_time,c.title,c.image')
|
|
|
+ ->leftJoin('group_order b','a.group_order_id=b.id')
|
|
|
+ ->leftJoin('group_service_work c','a.id=c.group_user_order_id')
|
|
|
+ ->field('a.id,a.status,a.order_amount,a.mobile,a.area,a.address,a.create_time,a.num,c.service_status')
|
|
|
->where($this->queryWhere())
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
->order('a.create_time', 'desc')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
+ foreach($lists as &$item) {
|
|
|
+ if ($item['status'] == 0) {
|
|
|
+ $item['status_txt'] = '未支付';
|
|
|
+ } else if ($item['status'] == 2 || $item['status'] == 3) {
|
|
|
+ $item['status_txt'] = '已退款';
|
|
|
+ } else if ($item['status'] == 4) {
|
|
|
+ $item['status_txt'] = '已取消';
|
|
|
+ } else if ($item['service_status'] == 3) {
|
|
|
+ $item['status_txt'] = '已完成';
|
|
|
+ } else {
|
|
|
+ $item['status_txt'] = '待完成';
|
|
|
+ }
|
|
|
+ }
|
|
|
return $lists;
|
|
|
}
|
|
|
|
|
|
@@ -74,7 +92,7 @@ class PropertyGroupOrderLists extends BaseApiDataLists implements ListsSearchInt
|
|
|
{
|
|
|
return GroupUserOrder::alias('a')
|
|
|
->leftJoin('group_order b','a.group_order_id=b.id')
|
|
|
- ->leftJoin('group_activity c','a.group_activity_id=c.id')
|
|
|
+ ->leftJoin('group_service_work c','a.id=c.group_user_order_id')
|
|
|
->where($this->queryWhere())
|
|
|
->count();
|
|
|
}
|