Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

林海涛 1 rok pred
rodič
commit
30dfc235e5

+ 1 - 1
app/api/logic/GoodsLogic.php

@@ -41,7 +41,7 @@ class GoodsLogic extends BaseLogic
             $data = [];
             foreach ($goods as $key => $value) {
                 if($value['goods_payment_type'] == '2'){
-                    $coupon = ($value['service_total']-$value['service_fee'])>0?'秒杀减'.$value['service_total']-$value['service_fee']:'';
+                    $coupon = ($value['service_total']-$value['service_fee'])>0?'减'.$value['service_total']-$value['service_fee']:'';
                 }
                 $data[] = [
                     'id'=>$value['id'],

+ 10 - 0
app/common/service/wechat/WeChatMnpService.php

@@ -97,5 +97,15 @@ class WeChatMnpService
         ]);
     }
 
+    public function getUnlimitedQRCode($scene,$page,$env_version='release',$check_path=true)
+    {
+        return $this->app->getClient()->postJson('wxa/getwxacodeunlimit', [
+            'scene' => $scene,
+            'page'=>$page,
+            'env_version'=>$env_version,//trial小程序版本
+            'check_path'=>$check_path
+        ]);
+    }
+
 
 }

+ 16 - 2
app/workerapi/controller/GoodsCategoryController.php

@@ -2,6 +2,9 @@
 namespace app\workerapi\controller;
 
 use app\workerapi\lists\GoodsCategoryLists;
+use app\workerapi\logic\GoodsCategoryLogic;
+use app\workerapi\validate\GoodsCategoryValidate;
+use app\workerapi\validate\IssueWorkValidate;
 
 /**
  * 用户控制器
@@ -10,10 +13,21 @@ use app\workerapi\lists\GoodsCategoryLists;
  */
 class GoodsCategoryController extends BaseApiController
 {
-    public array $notNeedLogin = ['lists'];
-
     public function lists()
     {
         return $this->dataLists(new GoodsCategoryLists());
     }
+
+    public function getQrCode()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('qrcode', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = GoodsCategoryLogic::getQRCode($params);
+        if (false === $result) {
+            return $this->fail(GoodsCategoryLogic::getError());
+        }
+        return $this->success('生成二维码', ['qrcode'=>$this->request->domain().'/'.$result], 1, 1);
+    }
 }

+ 42 - 0
app/workerapi/logic/GoodsCategoryLogic.php

@@ -0,0 +1,42 @@
+<?php
+namespace app\workerapi\logic;
+
+use app\common\logic\BaseLogic;
+use app\common\service\wechat\WeChatConfigService;
+use app\common\service\wechat\WeChatMnpService;
+use EasyWeChat\MiniApp\Application;
+use think\facade\Db;
+
+/**
+ * 服务商品逻辑处理
+ * Class GoodsCategoryLogic
+ * @package app\workerapi\logic
+ */
+class GoodsCategoryLogic extends BaseLogic
+{
+    /**
+     * @return string|void
+     */
+    public static function getQRCode($params)
+    {
+        try {
+            $response = (new WeChatMnpService())->getUnlimitedQRCode(
+                'type=2&id='.$params['id'].'worker_number='.$params['user_info']['worker_number'],
+                "pages/good/good",
+                'trial',
+                false
+            );
+            $qrcode = $response->getContent();
+            if(!is_dir('./uploads/wx_qrcode/'.date('Ymd'))){
+                mkdir('./uploads/wx_qrcode/'.date('Ymd'));
+            }
+            $file_name = 'uploads/wx_qrcode/'.date('Ymd').'/'.time().rand(1000,9999).'.png';
+            file_put_contents($file_name, $qrcode);
+            return $file_name;
+        } catch (\Throwable $e) {
+            // 失败
+            echo $e->getMessage();
+        }
+    }
+
+}

+ 1 - 1
app/workerapi/logic/MasterWorkerLogic.php

@@ -86,7 +86,7 @@ class MasterWorkerLogic extends  BaseLogic
 
      public static function detail($userId): array
     {
-        $worker = MasterWorker::field('id,sn,avatar,real_avatar,real_name,nickname,account,mobile,sex,estimate_money,user_money,earnest_money,exp')
+        $worker = MasterWorker::field('id,sn,avatar,real_avatar,real_name,nickname,account,mobile,sex,estimate_money,user_money,earnest_money,exp,worker_number')
             ->findOrEmpty($userId)
             ->toArray();
 

+ 43 - 0
app/workerapi/validate/GoodsCategoryValidate.php

@@ -0,0 +1,43 @@
+<?php
+namespace app\workerapi\validate;
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * GoodsCategoryValidate
+ * Class GoodsCategoryValidate
+ * @package app\workerapi\validate\works
+ */
+class GoodsCategoryValidate extends BaseValidate
+{
+
+    /**
+     * 设置校验规则
+     * @var string[]
+     */
+    protected $rule = [
+        'id' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => '分类ID',
+    ];
+
+    /**
+     * @notes 详情场景
+     * @return IssueWorkValidate
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function sceneQrocde()
+    {
+        return $this->only(['id']);
+    }
+
+}