Kaynağa Gözat

993832011-09312

Zory 3 saat önce
ebeveyn
işleme
d8ce16c9ae

+ 11 - 3
app/controller/api/Goods.php

@@ -31,13 +31,21 @@ class Goods extends Base
     {
         try {
             $param = $this->_valid([
-                "goods.require" => trans("empty.require"),
-                "spm.default"   => "",
+                "goods.require"     => trans("empty.require"),
+                "spm.default"       => "",
+                "option.default"    => ""
             ],$request->method());
             if (!is_array($param)) return error($param);
+            echo getDateFull()."===>商品详情\n";
+            echo json_encode($param)."\n";
             $data = $this->model->where("product_id",$param['goods'])->with(['poi' => function ($query) {
                 $query->field("poi_id,poi_name,poi_address,longitude,latitude,service_mobile,start_at,end_at");
-            },'skuSpecs'])->findOrEmpty();
+            },'skuSpecs'])->append(['otherImg'])->withAttr(['otherImg' => function ($qu,$resp) {
+                $img = json_decode($resp['image_list'],true);
+                return array_map(function ($v) {
+                    return $v['url'];
+                }, $img);
+            }])->findOrEmpty();
             if ($data->isEmpty()) return errorTrans("empty.data");
             return $this->encode("success",$data->toArray());
         } catch (\Throwable $th) {

+ 4 - 1
app/controller/api/Order.php

@@ -127,9 +127,12 @@ class Order extends Base
     {
         try {
             $param = $this->_valid([
-                "order.require"     => trans("empty.require")
+                "order.require"     => trans("empty.require"),
+                "option.default"    => ""
             ],$request->method());
             if (!is_array($param)) return error($param);
+            echo getDateFull()."===>订单详情\n";
+            echo json_encode($param)."\n";
             $order = $this->model->where("out_order_no",$param['order'])->with(['product','poi'])->findOrEmpty();
             if ($order->isEmpty()) return errorTrans("empty.data");
             $order['end_time'] = timeDiff(strtotime("+30 minutes",strtotime($order['create_at'])),time());

+ 25 - 0
app/controller/merchant/Plan.php

@@ -120,5 +120,30 @@ class Plan extends Base
         }
     }
 
+    #[GetMapping('detail')]
+    public function detailPlan(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"         => trans("empty.require"),
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $plan = $this->model->where("id",$param['id'])->with(['goods' => function ($query) {
+                $query->with(['goods' => function($subQue){
+                    $subQue->field("goods_id,product_name,image_list,product_id,price,line_price,limit_use_rule,use_num_per_consume,status");
+                }]);
+            },'star' => function ($query) {
+                $query->with(['star' => function($subQue){
+                    $subQue->field("unique_id,avatar_url,show_nickname,fans_count,fans_tag_list,local_fans_count,talent_item_level_display,talent_live_level_display,content_level_display,credit_score_display,city_name,rank_display,status");
+                }]);
+            }])->findOrEmpty();
+            if ($plan->isEmpty()) return errorTrans("empty.data");
+            if ($plan['poi_id'] <> $request->user['store_id']) return errorTrans("empty.data");
+            return successTrans("success.data",$plan->toArray());
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
 
 }

+ 20 - 0
app/controller/notify/Life.php

@@ -3,7 +3,9 @@
 namespace app\controller\notify;
 
 use app\extra\basic\Base;
+use app\extra\dyMini\PlanLive;
 use LinFly\Annotation\Attributes\Route\Controller;
+use LinFly\Annotation\Attributes\Route\GetMapping;
 use LinFly\Annotation\Attributes\Route\PostMapping;
 use support\Request;
 use support\Response;
@@ -17,6 +19,24 @@ class Life extends Base
 {
 
 
+    #[GetMapping("test")]
+    public function test2data(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "order.require"     => trans("empty.require"),
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $data = (new PlanLive)->config([
+                "appid"     => sConf("wechat.mini_appid"),
+                "secret"    => sConf("wechat.mini_secret"),
+            ])->token()->planOrder($param['order']);
+            return success('success',$data);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
     #[PostMapping("spi")]
     public function getLifeSpi(Request $request): Response
     {

+ 1 - 4
app/extra/dyLife/BasicLife.php

@@ -57,13 +57,9 @@ class BasicLife
     public function getAccessToken()
     {
         try {
-            echo $this->getPrefix()."\n";
             $accessToken = Cache::get($this->getPrefix());
             if (!empty($accessToken)) return $accessToken;
-            echo "Token:{$accessToken}\n";
-            print_r($this->config);
             $result = (new Token)->config($this->config)->getAccessToken();
-            print_r($result);
             if (empty($result)) return "获取Token失败";
             Cache::set($this->getPrefix(),$result['access_token'],$result['expires_in']);
             return $result['access_token'];
@@ -90,6 +86,7 @@ class BasicLife
     public function curlPostApi(string $url = "", array $data = [], string $field = "data"): array
     {
         $result = Http::asJson()->withHeaders($this->header)->post($this->gateway.$url,$data)->array();
+        print_r($result);
         if (isset($result['err_no']) && $result['err_no'] <> 0) return ['msg' => $result['err_msg']];
         if(!empty($result[$field]))
         {

+ 13 - 0
app/extra/dyMini/PlanLive.php

@@ -26,4 +26,17 @@ class PlanLive extends BasicLife
         return $this->curlPostApi("api/match/v2/poi/save_live_oriented_plan/",$param);
     }
 
+    /**
+     * 查下是否为cps订单
+     * @param string $order
+     * @return array
+     */
+    public function planOrder(string $order = ""): array
+    {
+        $param = [
+            "order_id"           => $order,
+        ];
+        return $this->curlPostApi("api/apps/trade/v2/order/query_cps/",$param);
+    }
+
 }

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

@@ -3,14 +3,15 @@
 namespace app\model\saas;
 
 use app\extra\basic\Model;
+use think\model\relation\HasMany;
 
 
 /**
- * @property integer $id (主键)
- * @property mixed $poi_id 门店ID
- * @property string $plan_name 
- * @property string $merchant_phone 
- * @property integer $status 
+ * @property integer $id (主键)
+ * @property mixed $poi_id 门店ID
+ * @property string $plan_name 
+ * @property string $merchant_phone 
+ * @property integer $status 
  * @property mixed $create_at
  */
 class SaasLivePlan extends Model
@@ -43,5 +44,14 @@ class SaasLivePlan extends Model
      */
     public bool $timestamps = false;
 
+    public function goods(): HasMany
+    {
+        return $this->hasMany(SaasLivePlanGoods::class,'plan_id','plan_id');
+    }
+
+    public function star(): HasMany
+    {
+        return $this->hasMany(SaasLivePlanStar::class,'plan_id','plan_id');
+    }
 
 }

+ 7 - 2
app/model/saas/SaasLivePlanGoods.php

@@ -3,11 +3,12 @@
 namespace app\model\saas;
 
 use app\extra\basic\Model;
+use think\model\relation\HasOne;
 
 
 /**
- * @property integer $id (主键)
- * @property mixed $plan_id 
+ * @property integer $id (主键)
+ * @property mixed $plan_id 
  * @property mixed $goods_id
  */
 class SaasLivePlanGoods extends Model
@@ -40,5 +41,9 @@ class SaasLivePlanGoods extends Model
      */
     public bool $timestamps = false;
 
+    public function goods(): HasOne
+    {
+        return $this->hasOne(SaasGoods::class,'goods_id','goods_id');
+    }
 
 }

+ 7 - 2
app/model/saas/SaasLivePlanStar.php

@@ -3,11 +3,12 @@
 namespace app\model\saas;
 
 use app\extra\basic\Model;
+use think\model\relation\HasOne;
 
 
 /**
- * @property integer $id (主键)
- * @property mixed $plan_id 
+ * @property integer $id (主键)
+ * @property mixed $plan_id 
  * @property string $unique_id 抖音号
  */
 class SaasLivePlanStar extends Model
@@ -40,5 +41,9 @@ class SaasLivePlanStar extends Model
      */
     public bool $timestamps = false;
 
+    public function star(): HasOne
+    {
+        return $this->hasOne(SaasStar::class,'unique_id','unique_id');
+    }
 
 }