Browse Source

新增修改客户状态接口

yb 6 months ago
parent
commit
0b73a9c8f4
2 changed files with 45 additions and 0 deletions
  1. 42 0
      app/api/controller/custom/MarketCustom.php
  2. 3 0
      route/api.php

+ 42 - 0
app/api/controller/custom/MarketCustom.php

@@ -0,0 +1,42 @@
+<?php
+
+
+namespace app\api\controller\custom;
+
+
+use app\model\MarketCustomer;
+use support\Request;
+
+class MarketCustom
+{
+    public function updateStatus(Request $request)
+    {
+        $params = $request->post();
+        if (empty($params['mobile'])) {
+            return json_fail('手机号不能为空');
+        }
+        $mobile = $params['mobile'];
+        $where = [
+            ['mobile', '=', $mobile],
+            [function($query) {
+                $query->orWhere(function ($query){
+                    $diffNums = (60 * 60 * 24 * 30);
+                    $currentTime = time();
+                    $query->whereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0)")->where('current_status', '=', 1);
+                })->orWhereIn('current_status', [2,3,4]);
+            }],
+            ['check_status', '=', 2]
+        ];
+        $info = MarketCustomer::where($where)->first();
+        if (empty($info)) {
+            return json_fail('客户不存在');
+        }
+        $info->current_status = 3;
+        $result = $info->save();
+        if ($result) {
+            return json_success('修改成功');
+        } else {
+            return json_fail('修改失败');
+        }
+    }
+}

+ 3 - 0
route/api.php

@@ -3,6 +3,9 @@
 use Webman\Route;
 
 Route::group('/api',function (){
+    Route::group('/market_custom', function (){
+        Route::post('/update', [\app\api\controller\custom\MarketCustom::class,'updateStatus']);
+    });
     Route::group('/pay',function (){
         Route::post('/alipay',[\app\api\controller\pay\AlipayController::class,'index']);
         Route::post('/wxpay',[\app\api\controller\pay\WxpayController::class,'index']);