From 864e2e5de1013c1f95463938518222f06f457253 Mon Sep 17 00:00:00 2001 From: zhanglingsheng Date: Wed, 27 Nov 2019 15:02:46 +0800 Subject: [PATCH] OA --- .../Controller/PromoteController.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 656cd78a7..12e050ae8 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -101,14 +101,13 @@ unset($_REQUEST['parent_id']); } // $promote = D(self::model_name)->field('id,account')->where(['oa_associated' => 0])->order('id DESC')->select(); //只获取之前未关联 - $promote = D(self::model_name)->field('id,account')->order('id DESC')->select(); //全部重新获取 + $promote = D(self::model_name)->field('id,account,oa_associated')->order('id DESC')->select(); //全部重新获取 $oa_data = array_column($oa_data, 'platform_account'); foreach($promote as $k => $v) { $v['account'] = trim($v['account']); - if(in_array($v['account'], $oa_data)) { - M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => 1]); - } else { - M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => 0]); + $oa_val = (in_array($v['account'], $oa_data)) ? 1: 0; + if($v['oa_associated'] != $oa_val){ + M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $oa_val]); } } @@ -135,11 +134,12 @@ unset($_REQUEST['parent_id']); $re_data = json_decode($re_data,true)['data']; foreach($list_data as $k => $v) { - if(array_key_exists($v['account'], $re_data)) - { - $list_data[$k]['oa_associated'] = $re_data[$v['account']]; - M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $re_data[$v['account']]]); + $oa_val = $re_data[trim($v['account'])]; + if($v['oa_associated'] != $oa_val){ + $list_data[$k]['oa_associated'] = $oa_val; + M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $oa_val]); } + } } }