where('role_id', $roleId) ->where('channel', 'huifu') ->find(); $now = time(); if ($existing) { $existing->receiver_type = 'HUIFU_ID'; $existing->receiver_account = $row['huifu_id']; $existing->receiver_name = $name; $existing->status = 'normal'; $existing->updatetime = $now; $existing->save(); return $existing; } return Receiver::create([ 'role_type' => $row['role_type'], 'role_id' => $roleId, 'channel' => 'huifu', 'receiver_type' => 'HUIFU_ID', 'receiver_account' => $row['huifu_id'], 'receiver_name' => $name, 'relation_type' => 'USER', 'wx_status' => 0, 'status' => 'normal', 'createtime' => $now, 'updatetime' => $now, ]); } public static function bindOnboardId($roleType, $roleRefId, $onboardId) { if ($roleType === 'promoter') { Db::name('shopro_commission_agent')->where('user_id', $roleRefId)->update(['huifu_onboard_id' => $onboardId]); return; } if ($roleType === 'regional_agent') { Db::name('shopro_regional_agent')->where('id', $roleRefId)->update(['huifu_onboard_id' => $onboardId]); } } }