浏览代码

同步test

whitefang 1 年之前
父节点
当前提交
fa14967001

+ 1 - 1
app/adminapi/logic/master_worker/MasterWorkerLogic.php

@@ -153,7 +153,7 @@ class MasterWorkerLogic extends BaseLogic
     /**
      * 获取加盐密码
      * @param $params
-     * @return array|false|string
+     * @return false|string
      */
     public static function saltToPassword($params){
         try{

+ 12 - 1
app/api/controller/PropertyController.php

@@ -46,7 +46,18 @@ class PropertyController extends BaseApiController
         }
         return $this->success('申请成功,等待审核', [], 1, 1);
     }
-
+    /**
+     * 物业负责人资金账户信息
+     * @return \think\response\Json
+     */
+    public function assetAccount()
+    {
+        $params = [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ];
+        return $this->success('资金账户', PropertyCommissionLogic::assetAccount($params), 1, 1);
+    }
     /**
      * 下单列表
      * @return \think\response\Json

+ 8 - 1
app/api/lists/property/PropertyCommissionLists.php

@@ -6,6 +6,7 @@ use app\common\lists\ListsSearchInterface;
 use app\common\model\property\PropertyCommission;
 use app\common\model\property\PropertyHead;
 use app\common\model\property\PropertySurplusLog;
+use app\common\model\recharge\RechargeOrder;
 
 /**
  * 订单列表
@@ -28,13 +29,19 @@ class PropertyCommissionLists extends BaseApiDataLists implements ListsSearchInt
     }
     public function lists(): array
     {
-        $lists = PropertyCommission::where($this->searchWhere)
+        $lists = PropertyCommission::with(['propertyHead','propertyUser','propertyWork'])->where($this->searchWhere)
             ->where($this->queryWhere())
             ->limit($this->limitOffset, $this->limitLength)
             ->field(['id','property_head_id','property_user_id','property_order_id','work_id','create_time','update_time','order_amount','commission_amount'])
             ->order('create_time desc')
             ->select()
             ->toArray();
+        foreach ($lists as &$item){
+            $item['orderGoods'] = (RechargeOrder::with(['orderGoods'])->where([
+                ['work_id', '=', $item['work_id']],
+                ['payment_type', 'IN', [0,1]]
+            ])->find())['orderGoods'][0];
+        }
         return $lists;
     }
 

+ 1 - 1
app/api/lists/property/PropertyOrderLists.php

@@ -29,7 +29,7 @@ class PropertyOrderLists extends BaseApiDataLists implements ListsSearchInterfac
     }
     public function lists(): array
     {
-        $lists = PropertyOrder::where($this->searchWhere)
+        $lists = PropertyOrder::with(['propertyHead','propertyUser','propertyWork'])->where($this->searchWhere)
             ->where($this->queryWhere())
             ->limit($this->limitOffset, $this->limitLength)
             ->field(['id','property_head_id','property_user_id','remark','order_status','work_id','create_time','update_time'])

+ 21 - 2
app/api/lists/property/PropertySurplusLogLists.php

@@ -3,8 +3,11 @@ namespace app\api\lists\property;
 
 use app\api\lists\BaseApiDataLists;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyCommission;
 use app\common\model\property\PropertyHead;
 use app\common\model\property\PropertySurplusLog;
+use app\common\model\works\ServiceWork;
+use DateTime;
 
 /**
  * 订单列表
@@ -23,17 +26,33 @@ class PropertySurplusLogLists extends BaseApiDataLists implements ListsSearchInt
         // 指定用户
         $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
         $where[] = ['property_head_id', '=', $propertyHeadId];
+        isset($this->params['in_out']) && $this->params['in_out'] && $where[] = ['in_out', '=', $this->params['in_out']];
+        if(isset($this->params['start_time']) && $this->params['start_time']){
+            $startDateTime = $this->params['start_time'];
+            $date = new DateTime($startDateTime);
+            $date->modify('+1 month');
+            $startDateTime = strtotime($startDateTime);
+            $endDateTime = strtotime($date->format('Y-m'))-1;
+            $where[] = ['create_time', 'BETWEEN', [$startDateTime, $endDateTime]];
+        }
         return $where;
     }
     public function lists(): array
     {
-        $lists = PropertySurplusLog::where($this->searchWhere)
+        $lists = PropertySurplusLog::with(['propertyHead'])->where($this->searchWhere)
             ->where($this->queryWhere())
             ->limit($this->limitOffset, $this->limitLength)
-            ->field(['id','in_out','amount','status','remark','create_time','update_time','property_head_id'])
+            ->field(['id','in_out','property_commission_id','amount','status','remark','create_time','update_time','property_head_id'])
             ->order('create_time desc')
             ->select()
             ->toArray();
+        foreach ($lists as &$item){
+            if($item['property_commission_id']){
+                $work_id = PropertyCommission::where('id',$item['property_commission_id'])->value('work_id');
+                $item['work_title'] = ServiceWork::where('id',$work_id)->value('title');
+            }
+            $item['surplus_sn'] = date('YmdHis',strtotime($item['create_time']));
+        }
         return $lists;
     }
 

+ 14 - 1
app/api/logic/PropertyCommissionLogic.php

@@ -135,5 +135,18 @@ class PropertyCommissionLogic extends BaseLogic
             return false;
         }
     }
-
+    /**
+     * 物业负责人用户申请提现
+     * @param $params
+     * @return false|true
+     */
+    public static function assetAccount($params) : array
+    {
+        $propertyHeadInfo = PropertyHead::where('user_id',$params['user_id'])->findOrEmpty();
+        if($propertyHeadInfo->isEmpty()){
+            self::setError('物业负责人不存在');
+            return [];
+        }
+        return $propertyHeadInfo->toArray();
+    }
 }

+ 22 - 5
app/api/logic/ServiceOrderLogic.php

@@ -13,7 +13,9 @@ use app\common\model\goods\Goods;
 use app\common\model\master_worker\MasterWorker;
 use app\common\model\orders\RechargeOrder;
 use app\common\model\recharge\OrderGoods;
+use app\common\model\spare_part\SparePart;
 use app\common\model\works\ServiceWork;
+use app\common\model\works\ServiceWorkSpare;
 use app\workerapi\logic\ServiceWorkLogLogic;
 use think\Exception;
 use think\facade\Db;
@@ -311,7 +313,7 @@ class ServiceOrderLogic extends BaseLogic
             $order_info =  \app\common\model\recharge\RechargeOrder::with(['order_goods'=>function ($query) {
                 $query->visible(['goods_name','goods_image','goods_number','good_unit']);
             },'service_work'=>function ($query) {
-                $query->visible(['real_name','mobile','address','service_status','appointment_time','master_worker_id','work_images','finished_images','finished_time'])->append(['service_status_text','user_service_status','user_service_status_text']);
+                $query->visible(['real_name','mobile','address','service_status','appointment_time','master_worker_id','work_images','finished_images','finished_time','spare_total','service_work_spare_id'])->append(['service_status_text','user_service_status','user_service_status_text']);
             }])
                 ->visible(['id','sn','payment_type','order_total','order_amount','paid_amount','pay_status','create_time','title','work_id'])
                 ->where([
@@ -320,6 +322,9 @@ class ServiceOrderLogic extends BaseLogic
                     'sn'=>$params['sn']
                 ])->findOrEmpty()->toArray();
 
+            if(empty($order_info)){
+                throw new Exception('订单不存在');
+            }
 
             $order_info['master_worker'] = [
                 'avatar' => '',
@@ -329,9 +334,7 @@ class ServiceOrderLogic extends BaseLogic
                 'worker_exp'=>''
             ];
 
-            if(empty($order_info)){
-                throw new Exception('订单不存在');
-            }
+
 
             //查询总价
             $order_info['order_amount'] = \app\common\model\recharge\RechargeOrder::where(['order_type'=>0,'user_id'=>$params['user_id'],'work_id'=>$order_info['work_id']])->sum('order_amount');
@@ -364,6 +367,21 @@ class ServiceOrderLogic extends BaseLogic
             //汇总优惠卷额度
             $order_info['coupon_price'] = $coupon_price;
 
+            // 所有配件
+            $order_info['spare_parts'] = [];
+            if($order_info['service_work']['service_work_spare_id']){
+                $work_spare_parts = json_decode(ServiceWorkSpare::where('id',$order_info['service_work']['service_work_spare_id'])->value('spare_parts'),true);
+                $spare_parts = SparePart::where('id','in',array_column($work_spare_parts,'id'))
+                    ->field(['id', 'goods_category_id', 'spare_name', 'spare_image', 'spare_number', 'spare_unit','spare_status'])
+                    ->select()
+                    ->toArray();
+                $spare_parts = array_column($spare_parts,null,'id');
+                foreach (array_column($work_spare_parts,null,'id') as $k=>&$v){
+                    $spare_parts[$k] = array_merge($spare_parts[$k],$v);
+                }
+                $order_info['spare_parts'] = array_values($spare_parts)??[];
+            }
+
             return $order_info;
         }
         catch (\Exception $e) {
@@ -612,7 +630,6 @@ class ServiceOrderLogic extends BaseLogic
             array_walk($orderGoodsData, function (&$value, $key, $data) {
                 $value = array_merge($value, ['sn' => $data['sn']]);
             },$data);
-            dd($orderGoodsData);
             $orderGoodsModel = new OrderGoods();
             $orderGoodsModel->saveAll($orderGoodsData);
             Db::commit();

+ 6 - 2
app/common/model/property/PropertyCommission.php

@@ -16,7 +16,7 @@ namespace app\common\model\property;
 
 
 use app\common\model\BaseModel;
-
+use app\common\model\works\ServiceWork;
 
 
 /**
@@ -39,5 +39,9 @@ class PropertyCommission extends BaseModel
         return $this->hasOne(PropertyUser::class, 'id', 'property_user_id')
             ->field('id,householder_name,householder_mobile');
     }
-    
+    public function propertyWork()
+    {
+        return $this->hasOne(ServiceWork::class, 'id', 'work_id')
+            ->field('id,work_sn,real_name,mobile,address,user_confirm_status,service_fee,work_total,work_amount,worker_price,create_time');
+    }
 }

+ 7 - 1
app/common/model/property/PropertyOrder.php

@@ -16,7 +16,7 @@ namespace app\common\model\property;
 
 
 use app\common\model\BaseModel;
-
+use app\common\model\works\ServiceWork;
 
 
 /**
@@ -39,4 +39,10 @@ class PropertyOrder extends BaseModel
         return $this->hasOne(PropertyUser::class, 'id', 'property_user_id')
             ->field('id,householder_name,householder_mobile');
     }
+    public function propertyWork()
+    {
+        return $this->hasOne(ServiceWork::class, 'id', 'work_id')
+            ->field('id,real_name,mobile,address,create_time');
+    }
+
 }

+ 1 - 1
app/common/model/property/PropertySurplusLog.php

@@ -32,7 +32,7 @@ class PropertySurplusLog extends BaseModel
     public function propertyHead()
     {
         return $this->hasOne(PropertyHead::class, 'id', 'property_head_id')
-            ->field('id,property_name,village_name,head_name');
+            ->field('id,property_name,village_name,head_name,head_bank_card');
     }
     
 }