Parcourir la source

Merge branch 'dev_wf' of wugg/phpstock into version1.5

wufeng il y a 2 ans
Parent
commit
383d2d505a

+ 13 - 3
app/youzan/controller/Index.php

@@ -4,6 +4,7 @@ namespace app\youzan\controller;
 
 use app\admin\controller\Base;
 use app\youzan\logic\Cat;
+use app\youzan\logic\Tag;
 use app\youzan\logic\Goodup;
 use think\facade\Validate;
 
@@ -23,10 +24,20 @@ class Index extends Base
 
     }
 
+    //获取有赞的标签列表
+    public function getYzTagList()
+    {
+
+        $rs = Tag::getYzTagList();
+
+        return app_show(0, '请求成功', $rs);
+
+    }
+
     //审核并将商品推送到有赞平台
     public function checkExamstatus()
     {
-        $param = $this->request->only(['platform_youzan_id', 'exam_status', 'reject_reason', 'yz_cat_id', 'is_support_barter', 'good_ladder_id', 'final_price', 'token', 'start_sale_num', ''], 'post', 'trim');
+        $param = $this->request->only(['platform_youzan_id', 'exam_status', 'reject_reason', 'yz_cat_id', 'is_support_barter', 'good_ladder_id', 'final_price', 'token', 'start_sale_num', 'tags' => []], 'post', 'trim');
 
         $val = Validate::rule([
             'platform_youzan_id|商品上线记录ID' => 'require|number|gt:0',
@@ -68,7 +79,7 @@ class Index extends Base
     //商品下线
     public function youzanOffline()
     {
-        $param = $this->request->only(['platform_youzan_id', 'token','offline_reason_id','offline_remark'=>''], 'post', 'trim');
+        $param = $this->request->only(['platform_youzan_id', 'token', 'offline_reason_id', 'offline_remark' => ''], 'post', 'trim');
 
         $val = Validate::rule([
             'platform_youzan_id|有赞商品上线记录id' => 'require|number|gt:0',
@@ -91,7 +102,6 @@ class Index extends Base
 
     }
 
-
     //有赞下线商品详情
     public function youzanOfflineDetail()
     {

+ 2 - 2
app/youzan/logic/Cat.php

@@ -4,10 +4,9 @@ namespace app\youzan\logic;
 
 use app\youzan\model\YzCat;
 use think\facade\Cache;
-use think\facade\Db;
 
 
-//分类处理层
+//有赞 分类处理层
 class Cat
 {
 
@@ -36,4 +35,5 @@ class Cat
 
         return $rs;
     }
+
 }

+ 21 - 17
app/youzan/logic/Goodup.php

@@ -177,6 +177,7 @@ class Goodup
                 'post_fee' => $post_fee,
                 'desc' => $rs->good_remark,//商品描述
                 'good_ladder_id' => $data['good_ladder_id'],
+                'tags' => implode(',', $data['tags']),
             ]);
 
             //调有赞项目的接口,从有赞平台下线该商品
@@ -202,6 +203,7 @@ class Goodup
                 'sell_point' => '',//商品卖点信息
                 'yz_cat_id' => $data['yz_cat_id'],//有赞类目id
                 'start_sale_num' => $data['start_sale_num'],//商品起售数,默认为1
+                'tags' => $data['tags'],//标签id,多个以,分割
             ];
             $host = config('app.yz_domain');
             $response = curl_request($host . 'api/yz_goodup', $curl_data);
@@ -401,7 +403,7 @@ class Goodup
                 ->findOrEmpty();
 
             if ($rs->isEmpty()) throw new Exception('该记录不存在');
-            if ($rs->exam_status != $db::$exam_status_6) throw new Exception('该商品尚未上线');
+            if ($rs->exam_status == $db::$exam_status_8) throw new Exception('该商品已下线,无法重复下线');
 
             $userinfo = GetUserInfo($data['token']);
 
@@ -411,19 +413,22 @@ class Goodup
                 'nickname' => isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '',
             ];
 
-            //调有赞项目的接口,从有赞平台下线该商品
-            $host = config('app.yz_domain');
-            $response = curl_request($host . 'api/yz_goodup_offline', $curl_data);
+            if ($rs->exam_status == $db::$exam_status_6) {
+                //已上线的要调用有赞接口下线
+                //调有赞项目的接口,从有赞平台下线该商品
+                $host = config('app.yz_domain');
+                $response = curl_request($host . 'api/yz_goodup_offline', $curl_data);
 
-            $response = json_decode($response, true);
+                $response = json_decode($response, true);
 
-            if ($response['code'] != 0) throw new Exception($response['message']);
+                if ($response['code'] != 0) throw new Exception($response['message']);
+            }
 
             $db::where('id', $platform_youzan_id)
                 ->update([
                     'exam_status' => $db::$exam_status_8,
-                    'offline_reason_id'=>$data['offline_reason_id'],
-                    'offline_remark'=>$data['offline_remark'],
+                    'offline_reason_id' => $data['offline_reason_id'],
+                    'offline_remark' => $data['offline_remark'],
                     'updaterid' => isset($userinfo['data']['id']) ? $userinfo['data']['id'] : 0,
                     'updater' => isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : '',
                     'updatetime' => date('Y-m-d H:i:s')
@@ -440,7 +445,6 @@ class Goodup
 
     }
 
-
     //有赞下线商品列表
     public static function youzanOfflineList(array $data = [])
     {
@@ -450,13 +454,13 @@ class Goodup
 
         $count = Db::name('platform_youzan')
             ->alias('pyz')
-            ->leftJoin('good g','g.spuCode=pyz.spuCode')
+            ->leftJoin('good g', 'g.spuCode=pyz.spuCode')
             ->where($where)
             ->count('pyz.id');
 
-        $list = PlatformYouzan::field('pyz.id,pyz.id platform_youzan_id,pyz.spuCode,g.good_name,pyz.creater,pyz.updatetime')
+        $list = PlatformYouzan::field('pyz.id,pyz.id platform_youzan_id,pyz.spuCode,g.good_name,pyz.updater,pyz.updatetime')
             ->alias('pyz')
-            ->leftJoin('good g','g.spuCode=pyz.spuCode')
+            ->leftJoin('good g', 'g.spuCode=pyz.spuCode')
             ->where($where)
             ->order('pyz.addtime', 'desc')
             ->page($data['page'], $data['size'])
@@ -467,15 +471,15 @@ class Goodup
 
     }
 
-    //有赞下线商品列表
+    //有赞下线商品详情
     public static function youzanOfflineDetail(int $platform_youzan_id = 0)
     {
         $info = PlatformYouzan::where('pyz.id', $platform_youzan_id)
-            ->field('pyz.*,g.good_name,r.result_desc,p.platform_name')
+            ->field('pyz.*,g.good_name,r.result,p.platform_name')
             ->alias('pyz')
-            ->leftJoin('good g','g.spuCode=pyz.spuCode')
-            ->leftJoin('result_info r','r.id=pyz.offline_reason_id')
-            ->leftJoin('platform p','p.id=pyz.platform_id')
+            ->leftJoin('good g', 'g.spuCode=pyz.spuCode')
+            ->leftJoin('result_info r', 'r.result_code=pyz.offline_reason_id')
+            ->leftJoin('platform p', 'p.id=pyz.platform_id')
             ->findOrEmpty();
 
         return app_show(0, "获取成功", $info);

+ 1 - 0
app/youzan/route/app.php

@@ -4,6 +4,7 @@ use think\facade\Route;
 
 route::rule('push', 'youzan/Push/GetPush');
 route::rule('yz_cat_list', 'youzan/Index/getYzCatList');//有赞类目列表
+route::rule('yz_tag_list', 'youzan/Index/getYzTagList');//有赞标签列表
 route::rule('yz_check_exam_status', 'youzan/Index/checkExamstatus');//审核并将商品推送到有赞平台
 route::rule('yz_goodup_info', 'youzan/Index/getYzGoodupInfo');//商品上线详情
 route::rule('yz_goodup_again', 'youzan/Index/goodupOnlineAgain');//商品再次上线