فهرست منبع

Merge branch 'master' of e.coding.net:zdap/weixiu/weixiu_api into sale-m

liugc 1 سال پیش
والد
کامیت
3c4b1f808b

+ 10 - 0
app/adminapi/controller/property/PropertyHeadController.php

@@ -108,5 +108,15 @@ class PropertyHeadController extends BaseAdminController
         return $this->data($result);
     }
 
+    /**
+     * @notes 获取二维码
+     * @return \think\response\Json
+     */
+    public function getQrcode()
+    {
+        $params = (new PropertyHeadValidate())->goCheck('detail');
+        $result = PropertyHeadLogic::getWechatQrcode($params, $this->request->domain());
+        return $this->data(['qrcode'=>$result]);
+    }
 
 }

+ 31 - 0
app/adminapi/logic/property/PropertyHeadLogic.php

@@ -19,7 +19,10 @@ use app\adminapi\logic\user\UserLogic;
 use app\common\model\property\PropertyHead;
 use app\common\logic\BaseLogic;
 use app\common\model\user\User;
+use app\common\service\wechat\WeChatMnpService;
+use Exception;
 use think\facade\Db;
+use think\facade\Log;
 
 
 /**
@@ -158,4 +161,32 @@ class PropertyHeadLogic extends BaseLogic
     {
         return PropertyHead::where('id','>',0)->select()->toArray();
     }
+
+    /**
+     * @param $params
+     * @param $url
+     * @return string
+     */
+    public static function getWechatQrcode($params,$url)
+    {
+        try {
+            $mnp_page = 'pages/tabView/service';
+            $response = (new WeChatMnpService())->getUnlimitedQRCode(
+                'property_head_id='.$params['id'],
+                $mnp_page,
+                env('miniprogram.mini_env_version', 'release'),
+                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 $url.'/'.$file_name;
+        } catch (\Throwable $e) {
+            Log::info('getQRCode:'.$e->getMessage());
+            return '';
+        }
+    }
 }

+ 9 - 10
app/api/logic/PropertyOrderLogic.php

@@ -45,17 +45,16 @@ class PropertyOrderLogic extends BaseLogic
                throw new Exception('物业代理不存在');
             }
             $order = PropertyOrder::where(['property_user_id'=>$propertyUserId,'property_head_id'=>$params['property_head_id'],'order_status'=>0])->where('work_id','<>',0)->order('id desc')->findOrEmpty();
-            if(!empty($order)){
-
+            if(empty($order)){
+                PropertyOrder::create([
+                    'property_head_id' => $params['property_head_id'],
+                    'property_user_id' => $propertyUserId,
+                    'remark' => $params['remark']??'',
+                    'address' => $address??'',
+                    'order_status' => 0,
+                    'work_id' => 0,
+                ]);
             }
-            PropertyOrder::create([
-                'property_head_id' => $params['property_head_id'],
-                'property_user_id' => $propertyUserId,
-                'remark' => $params['remark']??'',
-                'address' => $address??'',
-                'order_status' => 0,
-                'work_id' => 0,
-            ]);
             Db::commit();
             return true;
         } catch (\Exception $e) {