浏览代码

0731-0118

Zory 5 天之前
父节点
当前提交
37d465106a

+ 51 - 0
app/controller/admin/VerifyLog.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\service\saas\GoodsService;
+use app\service\saas\VerifyService;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Attributes\Route\Controller;
+use LinFly\Annotation\Attributes\Route\GetMapping;
+use LinFly\Annotation\Attributes\Route\Middleware;
+use support\Request;
+use support\Response;
+
+/**
+ * 核销记录
+ */
+#[Controller("/api/verify"),Middleware(AuthMiddleware::class)]
+class VerifyLog extends Base
+{
+
+    #[Inject]
+    protected VerifyService $service;
+
+    #[GetMapping('list')]
+    public function getVerifyLog(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $productType = (new GoodsService)->productType();
+            $data = $this->service->setModel()->getList($param,['orders' => function($query) use ($productType) {
+                $query->field("order_sn,product_id,img")->with(['product' => function($query) use($productType){
+                    $query->field("product_id,product_name,product_type")->append(['types'])->withAttr(['types' => function($data,$next) use($productType){
+                        $productTypeArr = [];
+                        foreach ($productType as $val) {
+                            $productTypeArr[$val['key']] = $val['name'];
+                        }
+                        return $productTypeArr[$next['product_type']]??'';
+                    }]);
+                }]);
+            },'poi' => function($query){
+                $query->field("poi_id,poi_name,poi_address,nick_name");
+            }]);
+            return successTrans(100010,pageFormat($data),200);
+        }  catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 0 - 2
app/controller/api/Notify.php

@@ -37,8 +37,6 @@ class Notify extends Base
                 "secret"    => sConf("wechat.secret"),
                 "account"   => sConf("wechat.shop_id"),
             ])->token()->getOrderData($order['order_sn']);
-            echo getDateFull()."===订单详情\n";
-            print_r($orderData);
             if (isset($orderData['orders'][0]['anchor_id'])) {
                 $order->douyin_uid = $orderData['orders'][0]['anchor_id'];
             }

+ 12 - 2
app/controller/api/Solution.php

@@ -11,6 +11,7 @@ use app\model\saas\SaasGoods;
 use app\model\saas\SaasGoodsSku;
 use app\model\saas\SaasOrder;
 use app\model\saas\SaasOrderItem;
+use app\model\saas\SaasOrderVerify;
 use LinFly\Annotation\Attributes\Route\Controller;
 use LinFly\Annotation\Attributes\Route\GetMapping;
 use LinFly\Annotation\Attributes\Route\RequestMapping;
@@ -164,8 +165,17 @@ class Solution extends Base
     public function setTest()
     {
         try {
-            $data = (new Relation)->config($this->getDyConfig())->token()->createOrderFirst(['1865253598118939']);
-            return success("ok",$data);
+//            $data = (new Relation)->config($this->getDyConfig())->token()->createOrderFirst(['1865253598118939']);
+            $data = (new SaasOrderVerify)->where("status",0)->with(['orders'])->select();
+            if ($data->isEmpty()) return error("err");
+            $upData = array_map(function ($val) {
+                return [
+                    "id" => $val['id'],
+                    "money" => $val['orders']['price'] / $val['orders']['number']
+                ];
+            }, $data->toArray());
+            (new SaasOrderVerify)->saveAll($upData);
+            return success("ok",$upData);
         } catch (\Throwable $throwable) {
             return error($throwable->getMessage());
         }

+ 50 - 0
app/controller/merchant/VerifyLog.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace app\controller\merchant;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\service\saas\GoodsService;
+use app\service\saas\VerifyService;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Attributes\Route\Controller;
+use LinFly\Annotation\Attributes\Route\GetMapping;
+use LinFly\Annotation\Attributes\Route\Middleware;
+use support\Request;
+use support\Response;
+
+
+#[Controller("/api/merchant/verify"),Middleware(AuthMiddleware::class)]
+class VerifyLog extends Base
+{
+
+    #[Inject]
+    protected VerifyService $service;
+
+    #[GetMapping('list')]
+    public function getVerifyLog(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $param['poi_id'] = $request->user['store_id'];
+            $productType = (new GoodsService)->productType();
+            $data = $this->service->setModel()->getList($param,['orders' => function($query) use ($productType) {
+                $query->field("order_sn,product_id,img")->with(['product' => function($query) use($productType){
+                    $query->field("product_id,product_name,product_type")->append(['types'])->withAttr(['types' => function($data,$next) use($productType){
+                        $productTypeArr = [];
+                        foreach ($productType as $val) {
+                            $productTypeArr[$val['key']] = $val['name'];
+                        }
+                        return $productTypeArr[$next['product_type']]??'';
+                    }]);
+                }]);
+            },'poi' => function($query){
+                $query->field("poi_id,poi_name,poi_address,nick_name");
+            }]);
+            return successTrans(100010,pageFormat($data),200);
+        }  catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 15 - 5
app/model/saas/SaasOrderVerify.php

@@ -3,14 +3,15 @@
 namespace app\model\saas;
 
 use app\extra\basic\Model;
+use think\model\relation\HasOne;
 
 
 /**
- * @property integer $id (主键)
- * @property mixed $order_sn 
- * @property mixed $certificate_id 
- * @property mixed $verify_id 
- * @property integer $status 0核销成功1撤销成功
+ * @property integer $id (主键)
+ * @property mixed $order_sn 
+ * @property mixed $certificate_id 
+ * @property mixed $verify_id 
+ * @property integer $status 0核销成功1撤销成功
  * @property mixed $create_at
  */
 class SaasOrderVerify extends Model
@@ -43,5 +44,14 @@ class SaasOrderVerify extends Model
      */
     public bool $timestamps = false;
 
+    public function orders(): HasOne
+    {
+        return $this->hasOne(SaasOrder::class,"order_sn","order_sn");
+    }
 
+
+    public function poi(): HasOne
+    {
+        return $this->hasOne(SaasStore::class,"poi_id","poi_id");
+    }
 }

+ 1 - 0
app/queue/redis/fast/OrderDone.php

@@ -103,6 +103,7 @@ class OrderDone implements Consumer
                 $doneData[$key] = [
                     "poi_id"            => $order['poi_id'],
                     "order_sn"          => $order['order_sn'],
+                    "money"             => $order['price'] / $order['number'],
                     "certificate_id"    => $v['certificate_id'],
                     "verify_id"         => $v['verify_id'],
                 ];

+ 40 - 0
app/service/saas/VerifyService.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\service\saas;
+
+use app\extra\basic\Service;
+use app\model\saas\SaasOrderVerify;
+
+class VerifyService extends Service
+{
+
+
+    /**
+     *
+     * @return $this
+     */
+    public function setModel()
+    {
+        $this->mode = (new SaasOrderVerify);
+        return $this;
+    }
+
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['poi_id']) && $filter[] = ["poi_id", '=', $param['poi_id']];
+        !empty($param['poi']) && $filter[] = ["poi_id", '=', $param['poi']];
+        !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
+        !empty($param['name']) && $filter[] = ["name", 'like', "%{$param['name']}%"];
+        !empty($param['order_sn']) && $filter[] = ["order_sn", 'like', "%{$param['order_sn']}%"];
+        return $filter;
+    }
+
+
+}