|
|
@@ -2,16 +2,19 @@
|
|
|
namespace app\api\lists\property;
|
|
|
|
|
|
use app\api\lists\BaseApiDataLists;
|
|
|
+use app\common\lists\ListsExtendInterface;
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
use app\common\model\property\PropertyCommission;
|
|
|
use app\common\model\property\PropertyHead;
|
|
|
use app\common\model\property\PropertyOrder;
|
|
|
use app\common\model\property\PropertySurplusLog;
|
|
|
+use app\common\model\works\ServiceWork;
|
|
|
+use DateTime;
|
|
|
|
|
|
/**
|
|
|
* 订单列表
|
|
|
*/
|
|
|
-class PropertyOrderLists extends BaseApiDataLists implements ListsSearchInterface
|
|
|
+class PropertyOrderLists extends BaseApiDataLists implements ListsSearchInterface,ListsExtendInterface
|
|
|
{
|
|
|
|
|
|
public function setSearch(): array
|
|
|
@@ -53,4 +56,27 @@ class PropertyOrderLists extends BaseApiDataLists implements ListsSearchInterfac
|
|
|
{
|
|
|
return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->count();
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @notes 返回扩展数据
|
|
|
+ * @return array|int
|
|
|
+ */
|
|
|
+ public function extend(): array
|
|
|
+ {
|
|
|
+ $workIds = PropertyOrder::where('order_status',3)->where($this->queryWhere())->column('work_id');
|
|
|
+ if(empty($workIds)){
|
|
|
+ return ['month_amount' => 0,'month_num' => 0];
|
|
|
+ }
|
|
|
+ $startDateTime = strtotime(date('Y-m-01'));
|
|
|
+ if(isset($this->params['start_month']) && $this->params['start_month']){
|
|
|
+ $startDateTime = strtotime($this->params['start_month']);
|
|
|
+ }
|
|
|
+ $endDateTime = strtotime('+1 month', strtotime($startDateTime))-1;
|
|
|
+ $serviceWork = ServiceWork::where([['id','in',$workIds],['work_pay_status','=',2],['approval','=',1]])
|
|
|
+ ->where('user_id',$this->userId)
|
|
|
+ ->where('create_time','BETWEEN',[$startDateTime,$endDateTime]);
|
|
|
+ return [
|
|
|
+ 'month_amount' =>$serviceWork->sum('work_amount'),
|
|
|
+ 'month_num' => $serviceWork->count('id')
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|