master
zhanglingsheng 5 years ago
parent 104451ab10
commit 864e2e5de1

@ -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')->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'); $oa_data = array_column($oa_data, 'platform_account');
foreach($promote as $k => $v) { foreach($promote as $k => $v) {
$v['account'] = trim($v['account']); $v['account'] = trim($v['account']);
if(in_array($v['account'], $oa_data)) { $oa_val = (in_array($v['account'], $oa_data)) ? 1: 0;
M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => 1]); if($v['oa_associated'] != $oa_val){
} else { M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $oa_val]);
M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => 0]);
} }
} }
@ -135,11 +134,12 @@ unset($_REQUEST['parent_id']);
$re_data = json_decode($re_data,true)['data']; $re_data = json_decode($re_data,true)['data'];
foreach($list_data as $k => $v) foreach($list_data as $k => $v)
{ {
if(array_key_exists($v['account'], $re_data)) $oa_val = $re_data[trim($v['account'])];
{ if($v['oa_associated'] != $oa_val){
$list_data[$k]['oa_associated'] = $re_data[$v['account']]; $list_data[$k]['oa_associated'] = $oa_val;
M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $re_data[$v['account']]]); M('promote','tab_')->where(['id' => $v['id']])->setField(['oa_associated' => $oa_val]);
} }
} }
} }
} }

Loading…
Cancel
Save