Browse Source

add - 师傅端-商品收费标准API

liugc 1 năm trước cách đây
mục cha
commit
dc99433fe3

+ 6 - 2
app/common/model/goods_fee_standards/GoodsFeeStandards.php

@@ -16,7 +16,7 @@ namespace app\common\model\goods_fee_standards;
 
 
 use app\common\model\BaseModel;
-
+use app\common\model\dict\DictData;
 
 
 /**
@@ -29,6 +29,10 @@ class GoodsFeeStandards extends BaseModel
     
     protected $name = 'goods_fee_standards';
     
-
+    public function getTypeTextAttr($value, $data)
+    {
+        $fee_standard_type_data = DictData::where('type_value','fee_standard_type')->column('name','value');
+        return $fee_standard_type_data[$data['type']];
+    }
     
 }

+ 16 - 0
app/workerapi/controller/WorksController.php

@@ -8,10 +8,12 @@ use app\common\model\works\ReturnWork;
 use app\common\model\works\ServiceWork;
 use app\workerapi\lists\HistoryWorkLists;
 use app\workerapi\lists\ServiceAssignWorkLists;
+use app\workerapi\lists\GoodsFeeStandardsLists;
 use app\workerapi\lists\ServiceWorkLists;
 use app\workerapi\lists\ServiceWorkSparePartLists;
 use app\workerapi\lists\SparePartLists;
 use app\workerapi\validate\ServiceWorkValidate;
+use app\workerapi\validate\GoodsFeeStandardsValidate;
 
 /**
  * 工单系统
@@ -204,4 +206,18 @@ class WorksController extends BaseApiController
         ]);
         return $this->dataLists(new ServiceWorkSparePartLists());
     }
+
+    /**
+     * 工单收费标准列表
+     * @return \think\response\Json
+     */
+    public function serviceFeeStandards()
+    {
+        // 查该订单的配件
+        (new GoodsFeeStandardsValidate())->get()->goCheck('standards', [
+            'user_id' => $this->userId
+        ]);
+        return $this->dataLists(new GoodsFeeStandardsLists());
+    }
+
 }

+ 81 - 0
app/workerapi/lists/GoodsFeeStandardsLists.php

@@ -0,0 +1,81 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\lists\ListsSearchInterface;
+use app\common\model\goods_fee_standards\GoodsFeeStandards;
+use app\common\model\recharge\RechargeOrder;
+
+/**
+ * GoodsFeeStandards列表
+ * Class GoodsFeeStandardsLists
+ * @package app\workerapi\lists
+ */
+class GoodsFeeStandardsLists extends BaseWorkerDataLists implements ListsSearchInterface
+{
+
+    /**
+     * 设置搜索条件
+     * @return array[]
+     * @author liuguanci
+     * @date 2024/7/11 下午1:46
+     */
+    public function setSearch(): array
+    {
+        if($this->params['work_id']??0){
+            $rechargeOrder = RechargeOrder::with(['orderGoods'])->where('work_id',$this->params['work_id'])->where('payment_type','IN',[0,1])->find()->toArray();
+            $this->params['goods_id'] =  $rechargeOrder['orderGoods'][0]['goods_id']??0;
+        }
+        return [
+            '=' => ['goods_id'],
+        ];
+    }
+    /*
+     * 查询条件
+     * @return array
+     * @author liuguanci
+     * @date 2024/7/11 下午1:46
+     */
+    public function queryWhere(){
+        $where = [];
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/14 15:08
+     */
+    public function lists(): array
+    {
+        $data = GoodsFeeStandards::where($this->queryWhere())->where($this->searchWhere)
+                ->field(['*'])
+                ->append(['type_text'])
+                ->select()->toArray();
+        return array_values(array_reduce($data, function ($carry, $item) {
+            $type = $item['type'];
+            if (!isset($carry[$type])) {
+                $carry[$type] = [
+                    'type' => $type,
+                    'type_text'=>$item['type_text'],
+                    'type_data'=>[],
+                ];
+            }
+            $carry[$type]['type_data'][] = $item;
+            return $carry;
+        }, []));
+    }
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/14 15:08
+     */
+    public function count(): int
+    {
+        return GoodsFeeStandards::where($this->queryWhere())->where($this->searchWhere)->count();
+    }
+
+}

+ 41 - 0
app/workerapi/validate/GoodsFeeStandardsValidate.php

@@ -0,0 +1,41 @@
+<?php
+namespace app\workerapi\validate;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * GoodsFeeStandards验证器
+ * Class GoodsFeeStandardsValidate
+ * @package app\workerapi\validate\works
+ */
+class GoodsFeeStandardsValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'work_id' => 'require'
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'work_id' => '工单ID'
+    ];
+
+    /**
+     * 报价获取列表
+     * @return GoodsFeeStandardsValidate
+     */
+    public function sceneStandards()
+    {
+        return $this->only(['work_id']);
+    }
+}